Skip to content

Commit 2fb04d6

Browse files
authored
feat: add legacy library alert (#2412)
Adds an Alert to the Legacy Library Page to notify the user of the process of deprecating Legacy Libraries and a Button to open the Migrate Library interface.
1 parent f79b65c commit 2fb04d6

File tree

4 files changed

+112
-69
lines changed

4 files changed

+112
-69
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Alert, Button } from '@openedx/paragon';
2+
import { Warning } from '@openedx/paragon/icons';
3+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
4+
5+
import messages from '../messages';
6+
7+
export const MigrateLegacyLibrariesAlert = () => (
8+
<Alert variant="warning" icon={Warning}>
9+
<Alert.Heading>
10+
<FormattedMessage {...messages.alertTitle} />
11+
</Alert.Heading>
12+
<div className="row">
13+
<div className="col-8">
14+
<FormattedMessage {...messages.alertDescription} />
15+
</div>
16+
<div className="col-4 d-flex justify-content-center align-items-start">
17+
<Button>
18+
<FormattedMessage {...messages.alertReviewButton} />
19+
</Button>
20+
</div>
21+
</div>
22+
</Alert>
23+
);

src/studio-home/tabs-section/libraries-tab/index.jsx

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from 'react';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
3+
import { Icon, Row } from '@openedx/paragon';
4+
import { Error } from '@openedx/paragon/icons';
5+
6+
import AlertMessage from '@src/generic/alert-message';
7+
import { LoadingSpinner } from '@src/generic/Loading';
8+
import CardItem from '../../card-item';
9+
import { sortAlphabeticallyArray } from '../utils';
10+
import messages from '../messages';
11+
import { MigrateLegacyLibrariesAlert } from './MigrateLegacyLibrariesAlert';
12+
13+
interface LibrariesTabProps {
14+
libraries: {
15+
displayName: string;
16+
libraryKey: string;
17+
number: string;
18+
org: string;
19+
url: string;
20+
}[];
21+
isLoading: boolean;
22+
isFailed: boolean;
23+
}
24+
25+
const LibrariesTab = ({
26+
libraries,
27+
isLoading,
28+
isFailed,
29+
}: LibrariesTabProps) => {
30+
const intl = useIntl();
31+
if (isLoading) {
32+
return (
33+
<Row className="m-0 mt-4 justify-content-center">
34+
<LoadingSpinner />
35+
</Row>
36+
);
37+
}
38+
return (
39+
isFailed ? (
40+
<AlertMessage
41+
variant="danger"
42+
description={(
43+
<Row className="m-0 align-items-center">
44+
<Icon src={Error} className="text-danger-500 mr-1" />
45+
<span>{intl.formatMessage(messages.librariesTabErrorMessage)}</span>
46+
</Row>
47+
)}
48+
/>
49+
) : (
50+
<>
51+
<MigrateLegacyLibrariesAlert />
52+
<div className="courses-tab">
53+
{sortAlphabeticallyArray(libraries).map(({
54+
displayName, org, number, url,
55+
}) => (
56+
<CardItem
57+
key={`${org}+${number}`}
58+
isLibraries
59+
displayName={displayName}
60+
org={org}
61+
number={number}
62+
url={url}
63+
/>
64+
))}
65+
</div>
66+
</>
67+
)
68+
);
69+
};
70+
71+
export default LibrariesTab;

src/studio-home/tabs-section/messages.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ const messages = defineMessages({
8888
id: 'course-authoring.studio-home.libraries.tab.library.not.found.alert.message',
8989
defaultMessage: 'There are no libraries with the current filters.',
9090
},
91+
alertTitle: {
92+
id: 'studio-home.legacy-libraries.migrate-alert.title',
93+
defaultMessage: 'Migrate Legacy Libraries',
94+
description: 'Title for the alert message to migrate legacy libraries',
95+
},
96+
alertDescription: {
97+
id: 'studio-home.legacy-libraries.migrate-alert.description',
98+
defaultMessage: 'In a future release, legacy libraries will no longer be supported.'
99+
+ ' The new libraries experience allows you to author sections, subsections, units,'
100+
+ ' and components to reuse across your courses. Content from legacy libraries can be'
101+
+ ' migrated to the new experience.',
102+
description: 'Description for the alert message to migrate legacy libraries',
103+
},
104+
alertReviewButton: {
105+
id: 'studio-home.legacy-libraries.migrate-alert.review-button',
106+
defaultMessage: 'Review Legacy Libraries',
107+
description: 'Label for the button to review legacy libraries',
108+
},
91109
});
92110

93111
export default messages;

0 commit comments

Comments
 (0)