Skip to content

Commit 151f36c

Browse files
committed
fix: change container sync status icon
1 parent 7c4ef47 commit 151f36c

File tree

5 files changed

+56
-39
lines changed

5 files changed

+56
-39
lines changed

src/course-outline/section-card/SectionCard.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useIntl } from '@edx/frontend-platform/i18n';
66
import {
77
Bubble, Button, Icon, StandardModal, useToggle,
88
} from '@openedx/paragon';
9-
import { Newsstand } from '@openedx/paragon/icons';
9+
import { LinkOff, Newsstand } from '@openedx/paragon/icons';
1010
import { useSearchParams } from 'react-router-dom';
1111
import classNames from 'classnames';
1212

@@ -23,7 +23,7 @@ import { ContainerType } from '@src/generic/key-utils';
2323
import { ComponentPicker, SelectedComponent } from '@src/library-authoring';
2424
import { ContentType } from '@src/library-authoring/routes';
2525
import { COMPONENT_TYPES } from '@src/generic/block-type-utils/constants';
26-
import { XBlock } from '@src/data/types';
26+
import type { XBlock } from '@src/data/types';
2727
import messages from './messages';
2828

2929
interface SectionCardProps {
@@ -123,6 +123,7 @@ const SectionCard = ({
123123
highlights,
124124
actions: sectionActions,
125125
isHeaderVisible = true,
126+
upstreamInfo,
126127
} = section;
127128

128129
useEffect(() => {
@@ -219,14 +220,16 @@ const SectionCard = ({
219220
}
220221
}, [savingStatus]);
221222

223+
const upstreamRefOk = !upstreamInfo?.errorMessage;
224+
222225
const titleComponent = (
223226
<TitleButton
224227
title={displayName}
225228
isExpanded={isExpanded}
226229
onTitleClick={handleExpandContent}
227230
namePrefix={namePrefix}
228-
prefixIcon={!!section.upstreamInfo?.upstreamRef && (
229-
<Icon src={Newsstand} className="mr-1" />
231+
prefixIcon={!!upstreamInfo?.upstreamRef && (
232+
<Icon src={upstreamRefOk ? Newsstand : LinkOff} className="mr-1" />
230233
)}
231234
/>
232235
);

src/course-outline/subsection-card/SubsectionCard.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDispatch } from 'react-redux';
55
import { useSearchParams } from 'react-router-dom';
66
import { useIntl } from '@edx/frontend-platform/i18n';
77
import { Icon, StandardModal, useToggle } from '@openedx/paragon';
8-
import { Newsstand } from '@openedx/paragon/icons';
8+
import { LinkOff, Newsstand } from '@openedx/paragon/icons';
99
import classNames from 'classnames';
1010
import { isEmpty } from 'lodash';
1111

@@ -24,7 +24,7 @@ import { COMPONENT_TYPES } from '@src/generic/block-type-utils/constants';
2424
import { ContainerType } from '@src/generic/key-utils';
2525
import { ContentType } from '@src/library-authoring/routes';
2626
import OutlineAddChildButtons from '@src/course-outline/OutlineAddChildButtons';
27-
import { XBlock } from '@src/data/types';
27+
import type { XBlock } from '@src/data/types';
2828
import messages from './messages';
2929

3030
interface SubsectionCardProps {
@@ -105,6 +105,7 @@ const SubsectionCard = ({
105105
isHeaderVisible = true,
106106
enableCopyPasteUnits = false,
107107
proctoringExamConfigurationLink,
108+
upstreamInfo,
108109
} = subsection;
109110

110111
// re-create actions object for customizations
@@ -167,14 +168,16 @@ const SubsectionCard = ({
167168
const handleNewButtonClick = () => onNewUnitSubmit(id);
168169
const handlePasteButtonClick = () => onPasteClick(id, section.id);
169170

171+
const upstreamRefOk = !upstreamInfo?.errorMessage;
172+
170173
const titleComponent = (
171174
<TitleButton
172175
title={displayName}
173176
isExpanded={isExpanded}
174177
onTitleClick={handleExpandContent}
175178
namePrefix={namePrefix}
176-
prefixIcon={!!subsection.upstreamInfo?.upstreamRef && (
177-
<Icon src={Newsstand} className="mr-1" />
179+
prefixIcon={!!upstreamInfo?.upstreamRef && (
180+
<Icon src={upstreamRefOk ? Newsstand : LinkOff} className="mr-1" />
178181
)}
179182
/>
180183
);

src/course-outline/unit-card/UnitCard.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from 'react';
77
import { useDispatch } from 'react-redux';
88
import { Icon, useToggle } from '@openedx/paragon';
9-
import { Newsstand } from '@openedx/paragon/icons';
9+
import { LinkOff, Newsstand } from '@openedx/paragon/icons';
1010
import { isEmpty } from 'lodash';
1111
import { useSearchParams } from 'react-router-dom';
1212

@@ -22,7 +22,7 @@ import XBlockStatus from '@src/course-outline/xblock-status/XBlockStatus';
2222
import { getItemStatus, getItemStatusBorder, scrollToElement } from '@src/course-outline/utils';
2323
import { useClipboard } from '@src/generic/clipboard';
2424
import { PreviewLibraryXBlockChanges } from '@src/course-unit/preview-changes';
25-
import { XBlock } from '@src/data/types';
25+
import type { XBlock } from '@src/data/types';
2626

2727
interface UnitCardProps {
2828
unit: XBlock;
@@ -157,13 +157,15 @@ const UnitCard = ({
157157
dispatch(fetchCourseSectionQuery([section.id]));
158158
}, [dispatch, section]);
159159

160+
const upstreamRefOk = !upstreamInfo?.errorMessage;
161+
160162
const titleComponent = (
161163
<TitleLink
162164
title={displayName}
163165
titleLink={getTitleLink(id)}
164166
namePrefix={namePrefix}
165-
prefixIcon={!!unit.upstreamInfo?.upstreamRef && (
166-
<Icon src={Newsstand} size="sm" className="mr-1" />
167+
prefixIcon={!!upstreamInfo?.upstreamRef && (
168+
<Icon src={upstreamRefOk ? Newsstand : LinkOff} size="sm" className="mr-1" />
167169
)}
168170
/>
169171
);

src/course-unit/data/utils.js renamed to src/course-unit/data/utils.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { camelCaseObject } from '@edx/frontend-platform';
22

3+
import type { XBlock } from '@src/data/types';
4+
35
import { NOTIFICATION_MESSAGES } from '../../constants';
46
import { PUBLISH_TYPES } from '../constants';
57

@@ -27,35 +29,39 @@ export function normalizeCourseSectionVerticalData(metadata) {
2729

2830
/**
2931
* Get the notification message based on the publishing type and visibility.
30-
* @param {string} type - The publishing type.
31-
* @param {boolean} isVisible - The visibility status.
32-
* @param {boolean} isModalView - The modal view status.
33-
* @returns {string} The corresponding notification message.
32+
* @param type - The publishing type.
33+
* @param isVisible - The visibility status.
34+
* @param isModalView - The modal view status.
35+
* @returns The corresponding notification message.
3436
*/
35-
export const getNotificationMessage = (type, isVisible, isModalView) => {
36-
let notificationMessage;
37-
37+
export const getNotificationMessage = (type: string, isVisible: boolean, isModalView: boolean): string => {
3838
if (type === PUBLISH_TYPES.discardChanges) {
39-
notificationMessage = NOTIFICATION_MESSAGES.discardChanges;
40-
} else if (type === PUBLISH_TYPES.makePublic) {
41-
notificationMessage = NOTIFICATION_MESSAGES.publishing;
42-
} else if (type === PUBLISH_TYPES.republish && isModalView) {
43-
notificationMessage = NOTIFICATION_MESSAGES.saving;
44-
} else if (type === PUBLISH_TYPES.republish && !isVisible) {
45-
notificationMessage = NOTIFICATION_MESSAGES.makingVisibleToStudents;
46-
} else if (type === PUBLISH_TYPES.republish && isVisible) {
47-
notificationMessage = NOTIFICATION_MESSAGES.hidingFromStudents;
39+
return NOTIFICATION_MESSAGES.discardChanges;
40+
}
41+
if (type === PUBLISH_TYPES.makePublic) {
42+
return NOTIFICATION_MESSAGES.publishing;
43+
}
44+
if (type === PUBLISH_TYPES.republish && isModalView) {
45+
return NOTIFICATION_MESSAGES.saving;
46+
}
47+
if (type === PUBLISH_TYPES.republish && !isVisible) {
48+
return NOTIFICATION_MESSAGES.makingVisibleToStudents;
49+
}
50+
if (type === PUBLISH_TYPES.republish && isVisible) {
51+
return NOTIFICATION_MESSAGES.hidingFromStudents;
4852
}
4953

50-
return notificationMessage;
54+
// istanbul ignore next: should never hit this case
55+
return NOTIFICATION_MESSAGES.empty;
5156
};
5257

5358
/**
5459
* Updates the 'id' property of objects in the data structure using the 'blockId' value where present.
55-
* @param {Object} data - The original data structure to be updated.
56-
* @returns {Object} - The updated data structure with updated 'id' values.
60+
* @param data - The original data structure to be updated.
61+
* @returns The updated data structure with updated 'id' values.
5762
*/
58-
export const updateXBlockBlockIdToId = (data) => {
63+
export const updateXBlockBlockIdToId = (data: object): object => {
64+
// istanbul ignore if: should never hit this case
5965
if (typeof data !== 'object' || data === null) {
6066
return data;
6167
}
@@ -64,7 +70,7 @@ export const updateXBlockBlockIdToId = (data) => {
6470
return data.map(updateXBlockBlockIdToId);
6571
}
6672

67-
const updatedData = {};
73+
const updatedData: Record<string, any> = {};
6874

6975
Object.keys(data).forEach(key => {
7076
const value = data[key];
@@ -90,9 +96,11 @@ export const updateXBlockBlockIdToId = (data) => {
9096
*
9197
* Units sourced from libraries are read-only (temporary, for Teak).
9298
*
93-
* @param {object} unit - uses the 'upstreamInfo' object if found.
94-
* @returns {boolean} True if readOnly, False if editable.
99+
* @param unit - uses the 'upstreamInfo' object if found.
100+
* @returns True if readOnly, False if editable.
95101
*/
96-
export const isUnitReadOnly = ({ upstreamInfo }) => (
97-
upstreamInfo && upstreamInfo.upstreamRef && upstreamInfo.upstreamRef.startsWith('lct:')
102+
export const isUnitReadOnly = ({ upstreamInfo }: XBlock): boolean => (
103+
!!upstreamInfo
104+
&& !!upstreamInfo.upstreamRef
105+
&& upstreamInfo.upstreamRef.startsWith('lct:')
98106
);

src/data/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ export interface XBlockPrereqs {
4747
blockDisplayName: string;
4848
}
4949

50-
export interface UpstreeamInfo {
50+
export interface UpstreamInfo {
5151
readyToSync: boolean,
5252
upstreamRef: string,
5353
versionSynced: number,
54+
errorMessage: string | null,
5455
}
5556

5657
export interface XBlock {
@@ -106,5 +107,5 @@ export interface XBlock {
106107
prereqMinScore?: number;
107108
prereqMinCompletion?: number;
108109
discussionEnabled?: boolean;
109-
upstreamInfo?: UpstreeamInfo;
110+
upstreamInfo?: UpstreamInfo;
110111
}

0 commit comments

Comments
 (0)