Skip to content

Commit 41fc478

Browse files
authored
[Teak] style: Fixing nits about sync units [FC-0097] (#2320)
* Add a warning banner about units in the libraries sync page. * Update the message in the sync unit modal. * Stay visible the sync icon in the course outline. * Add a tooltip to the edit (in normal and disabled mode) and sync button.
1 parent 06497bf commit 41fc478

File tree

8 files changed

+61
-22
lines changed

8 files changed

+61
-22
lines changed

src/course-libraries/CourseLibraries.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('<CourseLibraries />', () => {
8282
expect(reviewTab).toHaveAttribute('aria-selected', 'true');
8383

8484
userEvent.click(allTab);
85-
const alert = await screen.findByRole('alert');
85+
const alert = (await screen.findAllByRole('alert'))[0];
8686
expect(await within(alert).findByText(
8787
'5 library components are out of sync. Review updates to accept or ignore changes',
8888
)).toBeInTheDocument();
@@ -105,7 +105,7 @@ describe('<CourseLibraries />', () => {
105105
userEvent.click(allTab);
106106
expect(allTab).toHaveAttribute('aria-selected', 'true');
107107

108-
const alert = await screen.findByRole('alert');
108+
const alert = (await screen.findAllByRole('alert'))[0];
109109
expect(await within(alert).findByText(
110110
'5 library components are out of sync. Review updates to accept or ignore changes',
111111
)).toBeInTheDocument();
@@ -133,7 +133,7 @@ describe('<CourseLibraries />', () => {
133133
expect(reviewTab).toHaveAttribute('aria-selected', 'true');
134134

135135
userEvent.click(allTab);
136-
const alert = await screen.findByRole('alert');
136+
const alert = (await screen.findAllByRole('alert'))[0];
137137
expect(await within(alert).findByText(
138138
'5 library components are out of sync. Review updates to accept or ignore changes',
139139
)).toBeInTheDocument();
@@ -156,7 +156,7 @@ describe('<CourseLibraries />', () => {
156156

157157
screen.logTestingPlaygroundURL();
158158

159-
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
159+
expect(screen.queryAllByRole('alert').length).toEqual(1);
160160
});
161161
});
162162

src/course-libraries/CourseLibraries.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
Tabs,
1818
} from '@openedx/paragon';
1919
import {
20-
Cached, CheckCircle, Launch, Loop,
20+
Cached, CheckCircle, Launch, Loop, Info,
2121
} from '@openedx/paragon/icons';
2222

2323
import sumBy from 'lodash/sumBy';
@@ -33,6 +33,7 @@ import { useStudioHome } from '../studio-home/hooks';
3333
import NewsstandIcon from '../generic/NewsstandIcon';
3434
import ReviewTabContent from './ReviewTabContent';
3535
import { OutOfSyncAlert } from './OutOfSyncAlert';
36+
import AlertMessage from '../generic/alert-message';
3637

3738
interface Props {
3839
courseId: string;
@@ -199,6 +200,12 @@ export const CourseLibraries: React.FC<Props> = ({ courseId }) => {
199200
showAlert={showReviewAlert && tabKey === CourseLibraryTabs.all}
200201
setShowAlert={setShowReviewAlert}
201202
/>
203+
{ /* TODO: Remove this alert after implement container in this page */}
204+
<AlertMessage
205+
title={intl.formatMessage(messages.unitsUpdatesWarning)}
206+
icon={Info}
207+
variant="info"
208+
/>
202209
<SubHeader
203210
title={intl.formatMessage(messages.headingTitle)}
204211
subtitle={intl.formatMessage(messages.headingSubtitle)}

src/course-libraries/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ const messages = defineMessages({
116116
defaultMessage: 'Something went wrong! Could not fetch results.',
117117
description: 'Generic error message displayed when fetching link data fails.',
118118
},
119+
unitsUpdatesWarning: {
120+
id: 'course-authoring.course-libraries.home-tab.warning.units',
121+
defaultMessage: 'Currently this page only tracks component updates. To check for unit updates, go to your Course Outline.',
122+
description: 'Warning message shown in library sync page about units updates.',
123+
},
119124
});
120125

121126
export default messages;

src/course-outline/card-header/CardHeader.jsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-check
22
import React, { useEffect, useRef, useState } from 'react';
33
import PropTypes from 'prop-types';
4+
import classNames from 'classnames';
45
import { getConfig } from '@edx/frontend-platform';
56
import { useIntl } from '@edx/frontend-platform/i18n';
67
import { useSearchParams } from 'react-router-dom';
@@ -10,6 +11,7 @@ import {
1011
Hyperlink,
1112
Icon,
1213
IconButton,
14+
IconButtonWithTooltip,
1315
useToggle,
1416
} from '@openedx/paragon';
1517
import {
@@ -133,19 +135,24 @@ const CardHeader = ({
133135
) : (
134136
<>
135137
{titleComponent}
136-
{readyToSync && (
137-
<IconButton
138-
className="item-card-button-icon"
139-
data-testid={`${namePrefix}-sync-button`}
140-
alt={intl.formatMessage(messages.readyToSyncButtonAlt)}
141-
iconAs={SyncIcon}
142-
onClick={onClickSync}
143-
/>
144-
)}
145-
<IconButton
146-
className="item-card-button-icon"
138+
<IconButtonWithTooltip
139+
className={classNames(
140+
'item-card-button-icon',
141+
{
142+
'item-card-button-icon-disabled': isDisabledEditField,
143+
},
144+
)}
147145
data-testid={`${namePrefix}-edit-button`}
148-
alt={intl.formatMessage(messages.altButtonEdit)}
146+
alt={intl.formatMessage(
147+
isDisabledEditField ? messages.cannotEditTooltip : messages.altButtonRename,
148+
)}
149+
tooltipContent={(
150+
<div>
151+
{intl.formatMessage(
152+
isDisabledEditField ? messages.cannotEditTooltip : messages.altButtonRename,
153+
)}
154+
</div>
155+
)}
149156
iconAs={EditIcon}
150157
onClick={onClickEdit}
151158
// @ts-ignore
@@ -161,6 +168,15 @@ const CardHeader = ({
161168
<TagCount count={contentTagCount} onClick={openManageTagsDrawer} />
162169
)}
163170
{extraActionsComponent}
171+
{readyToSync && (
172+
<IconButtonWithTooltip
173+
data-testid={`${namePrefix}-sync-button`}
174+
alt={intl.formatMessage(messages.readyToSyncButtonAlt)}
175+
iconAs={SyncIcon}
176+
tooltipContent={<div>{intl.formatMessage(messages.readyToSyncButtonAlt)}</div>}
177+
onClick={onClickSync}
178+
/>
179+
)}
164180
<Dropdown data-testid={`${namePrefix}-card-header__menu`} onClick={onClickMenuButton}>
165181
<Dropdown.Toggle
166182
className="item-card-header__menu"

src/course-outline/card-header/CardHeader.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
&:hover {
2626
.item-card-button-icon {
2727
opacity: 1;
28+
29+
&.item-card-button-icon-disabled {
30+
pointer-events: all;
31+
opacity: .5;
32+
cursor: default;
33+
}
2834
}
2935
}
3036
}

src/course-outline/card-header/messages.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ const messages = defineMessages({
2929
id: 'course-authoring.course-outline.card.status-badge.draft-unpublished-changes',
3030
defaultMessage: 'Draft (Unpublished changes)',
3131
},
32-
altButtonEdit: {
32+
altButtonRename: {
3333
id: 'course-authoring.course-outline.card.button.edit.alt',
34-
defaultMessage: 'Edit',
34+
defaultMessage: 'Rename',
3535
},
3636
menuPublish: {
3737
id: 'course-authoring.course-outline.card.menu.publish',
@@ -82,6 +82,11 @@ const messages = defineMessages({
8282
defaultMessage: 'Update available - click to sync',
8383
description: 'Alt text for the sync icon button.',
8484
},
85+
cannotEditTooltip: {
86+
id: 'course-authoring.course-outline.card.button.edit.disable.tooltip',
87+
defaultMessage: 'This object was added from a library, so it cannot be edited.',
88+
description: 'Tooltip text of button when the object was added from a library.',
89+
},
8590
});
8691

8792
export default messages;

src/course-outline/unit-card/UnitCard.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('<UnitCard />', () => {
176176

177177
// Should open compare preview modal
178178
expect(screen.getByRole('heading', { name: /preview changes: unit name/i })).toBeInTheDocument();
179-
expect(screen.getByText('Preview not available')).toBeInTheDocument();
179+
expect(screen.getByText('Preview not available for unit changes at this time')).toBeInTheDocument();
180180

181181
// Click on accept changes
182182
const acceptChangesButton = screen.getByText(/accept changes/i);
@@ -196,7 +196,7 @@ describe('<UnitCard />', () => {
196196

197197
// Should open compare preview modal
198198
expect(screen.getByRole('heading', { name: /preview changes: unit name/i })).toBeInTheDocument();
199-
expect(screen.getByText('Preview not available')).toBeInTheDocument();
199+
expect(screen.getByText('Preview not available for unit changes at this time')).toBeInTheDocument();
200200

201201
// Click on ignore changes
202202
const ignoreChangesButton = screen.getByRole('button', { name: /ignore changes/i });

src/library-authoring/component-comparison/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const messages = defineMessages({
1919
},
2020
previewNotAvailable: {
2121
id: 'course-authoring.library-authoring.component-comparison.preview-not-available',
22-
defaultMessage: 'Preview not available',
22+
defaultMessage: 'Preview not available for unit changes at this time',
2323
description: 'Message shown when preview is not available.',
2424
},
2525
});

0 commit comments

Comments
 (0)