forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseImportHomePage.tsx
More file actions
96 lines (89 loc) · 2.92 KB
/
CourseImportHomePage.tsx
File metadata and controls
96 lines (89 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import {
Button,
Card,
Container,
Layout,
Stack,
} from '@openedx/paragon';
import { Add } from '@openedx/paragon/icons';
import { Helmet } from 'react-helmet';
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import NotFoundAlert from '@src/generic/NotFoundAlert';
import Loading from '@src/generic/Loading';
import SubHeader from '@src/generic/sub-header/SubHeader';
import Header from '@src/header';
import { useLibraryContext } from '../common/context/LibraryContext';
import { useContentLibrary, useCourseMigrations } from '../data/apiHooks';
import { HelpSidebar } from './HelpSidebar';
import { MigratedCourseCard } from './MigratedCourseCard';
import messages from './messages';
const EmptyState = () => (
<Container size="md" className="py-6">
<Card>
<Stack direction="horizontal" gap={3} className="my-6 justify-content-center">
<FormattedMessage {...messages.emptyStateText} />
<Button iconBefore={Add} disabled>
<FormattedMessage {...messages.emptyStateButtonText} />
</Button>
</Stack>
</Card>
</Container>
);
export const CourseImportHomePage = () => {
const intl = useIntl();
const { libraryId } = useLibraryContext();
const { data: libraryData } = useContentLibrary(libraryId);
const { data: courseMigrations } = useCourseMigrations(libraryId);
if (!courseMigrations) {
return <Loading />;
}
if (!libraryData) {
return <NotFoundAlert />;
}
return (
<div className="d-flex">
<div className="flex-grow-1">
<Helmet>
<title>{libraryData.title} | {process.env.SITE_NAME}</title>
</Helmet>
<Header
number={libraryData.slug}
title={libraryData.title}
org={libraryData.org}
contextId={libraryId}
isLibrary
containerProps={{
size: undefined,
}}
/>
<Container className="px-0 mt-4 mb-5 library-authoring-page">
<div className="px-4 bg-light-200 border-bottom">
<SubHeader
title={intl.formatMessage(messages.pageTitle)}
subtitle={intl.formatMessage(messages.pageSubtitle)}
hideBorder
/>
</div>
<Layout xs={[{ span: 9 }, { span: 3 }]}>
<Layout.Element>
{courseMigrations.length ? (
<Stack gap={3} className="pl-4 mt-4">
<h3>Previous Imports</h3>
{courseMigrations.map((courseMigration) => (
<MigratedCourseCard
key={courseMigration.source.key}
courseMigration={courseMigration}
/>
))}
</Stack>
) : (<EmptyState />)}
</Layout.Element>
<Layout.Element>
<HelpSidebar />
</Layout.Element>
</Layout>
</Container>
</div>
</div>
);
};