forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
143 lines (133 loc) · 4.72 KB
/
index.tsx
File metadata and controls
143 lines (133 loc) · 4.72 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Container, Layout, Stack, Row,
} from '@openedx/paragon';
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
import { LoadingSpinner } from '../generic/Loading';
import SubHeader from '../generic/sub-header/SubHeader';
import getPageHeadTitle from '../generic/utils';
import ProcessingNotification from '../generic/processing-notification';
import { SavingErrorAlert } from '../generic/saving-error-alert';
import messages from './messages';
import ContentGroupsSection from './content-groups-section';
import ExperimentConfigurationsSection from './experiment-configurations-section';
import TeamGroupsSection from './team-groups-section';
import EnrollmentTrackGroupsSection from './enrollment-track-groups-section';
import GroupConfigurationSidebar from './group-configuration-sidebar';
import { useGroupConfigurations } from './hooks';
import ConnectionErrorAlert from '../generic/ConnectionErrorAlert';
import { AvailableGroup } from './types';
const GroupConfigurations = () => {
const { formatMessage } = useIntl();
const { courseId, courseDetails } = useCourseAuthoringContext();
const {
isLoading,
savingStatus,
errorMessage,
contentGroupActions,
experimentConfigurationActions,
processingNotificationTitle,
isShowProcessingNotification,
groupConfigurations: {
allGroupConfigurations,
shouldShowEnrollmentTrack,
shouldShowExperimentGroups,
experimentGroupConfigurations,
},
isLoadingDenied,
} = useGroupConfigurations(courseId);
document.title = getPageHeadTitle(
courseDetails?.name ?? '',
formatMessage(messages.headingTitle),
);
if (isLoadingDenied) {
return (
<Container size="xl" className="course-unit px-4 mt-4">
<ConnectionErrorAlert />
</Container>
);
}
if (isLoading) {
return (
<Row className="m-0 mt-4 justify-content-center">
<LoadingSpinner />
</Row>
);
}
const enrollmentTrackGroup: AvailableGroup = shouldShowEnrollmentTrack
? allGroupConfigurations.find((group) => group.scheme === 'enrollment_track')
: null;
const contentGroup: AvailableGroup[] = allGroupConfigurations.find((group) => group.scheme === 'cohort');
const teamGroups: AvailableGroup[] = allGroupConfigurations.filter((group) => group.scheme === 'team');
return (
<>
<Container size="xl" className="group-configurations px-4">
<div className="mt-5" />
<SubHeader
title={formatMessage(messages.headingTitle)}
subtitle={formatMessage(messages.headingSubtitle)}
/>
<Layout
lg={[{ span: 9 }, { span: 3 }]}
md={[{ span: 9 }, { span: 3 }]}
sm={[{ span: 9 }, { span: 3 }]}
xs={[{ span: 9 }, { span: 3 }]}
xl={[{ span: 9 }, { span: 3 }]}
>
<Layout.Element>
<Stack
gap={3}
data-testid="group-configurations-main-content-wrapper"
>
{!!teamGroups && teamGroups.length > 0 && (
teamGroups.map((teamGroup) => (
<TeamGroupsSection
key={teamGroup.id}
availableGroup={teamGroup}
/>
))
)}
{!!enrollmentTrackGroup && (
<EnrollmentTrackGroupsSection
availableGroup={enrollmentTrackGroup}
/>
)}
{!!contentGroup && (
<ContentGroupsSection
availableGroup={contentGroup}
contentGroupActions={contentGroupActions}
/>
)}
{shouldShowExperimentGroups && (
<ExperimentConfigurationsSection
courseId={courseId}
availableGroups={experimentGroupConfigurations}
experimentConfigurationActions={experimentConfigurationActions}
/>
)}
</Stack>
</Layout.Element>
<Layout.Element>
<GroupConfigurationSidebar
courseId={courseId}
shouldShowExperimentGroups={shouldShowExperimentGroups}
shouldShowContentGroup={!!contentGroup}
shouldShowEnrollmentTrackGroup={!!enrollmentTrackGroup}
/>
</Layout.Element>
</Layout>
</Container>
<div className="alert-toast">
<SavingErrorAlert
savingStatus={savingStatus}
errorMessage={errorMessage}
/>
<ProcessingNotification
isShow={isShowProcessingNotification}
title={processingNotificationTitle}
/>
</div>
</>
);
};
export default GroupConfigurations;