Skip to content

Commit 3212a84

Browse files
committed
feat: Enable button on empty state
1 parent 4f84483 commit 3212a84

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/library-authoring/import-course/CourseImportHomePage.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,33 @@ import { HelpSidebar } from './HelpSidebar';
2020
import { ImportedCourseCard } from './ImportedCourseCard';
2121
import messages from './messages';
2222

23+
const ImportCourseButton = () => {
24+
const navigate = useNavigate();
25+
26+
if (getConfig().ENABLE_COURSE_IMPORT_IN_LIBRARY === 'true') {
27+
return (
28+
<Button iconBefore={Add} onClick={() => navigate('courses')}>
29+
<FormattedMessage {...messages.importCourseButton} />
30+
</Button>
31+
);
32+
}
33+
34+
return null;
35+
};
36+
2337
const EmptyState = () => (
2438
<Container size="md" className="py-6">
2539
<Card>
2640
<Stack direction="horizontal" gap={3} className="my-6 justify-content-center">
2741
<FormattedMessage {...messages.emptyStateText} />
28-
<Button iconBefore={Add} disabled>
29-
<FormattedMessage {...messages.emptyStateButtonText} />
30-
</Button>
42+
<ImportCourseButton />
3143
</Stack>
3244
</Card>
3345
</Container>
3446
);
3547

3648
export const CourseImportHomePage = () => {
3749
const intl = useIntl();
38-
const navigate = useNavigate();
3950
const { libraryId, libraryData, readOnly } = useLibraryContext();
4051
const { data: courseImports } = useCourseImports(libraryId);
4152

@@ -66,13 +77,7 @@ export const CourseImportHomePage = () => {
6677
title={intl.formatMessage(messages.pageTitle)}
6778
subtitle={intl.formatMessage(messages.pageSubtitle)}
6879
hideBorder
69-
headerActions={
70-
getConfig().ENABLE_COURSE_IMPORT_IN_LIBRARY === 'true' && (
71-
<Button onClick={() => navigate('courses')}>
72-
{intl.formatMessage(messages.importCourseButton)}
73-
</Button>
74-
)
75-
}
80+
headerActions={<ImportCourseButton />}
7681
/>
7782
</div>
7883
<Layout xs={[{ span: 9 }, { span: 3 }]}>

src/studio-home/card-item/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,26 @@ const CardMenu = ({
176176

177177
const SelectAction = ({
178178
itemId,
179+
title,
179180
selectMode,
180181
}: {
181182
itemId: string,
183+
title: string,
182184
selectMode: 'single' | 'multiple';
183185
}) => {
184186
if (selectMode === 'single') {
185187
return (
186188
<Form.Radio
187189
value={itemId}
190+
aria-label={title}
188191
name={`select-card-item-${itemId}`}
189192
/>
190193
);
191194
}
192195

193196
// Multiple
194197
return (
195-
<Form.Checkbox value={itemId} />
198+
<Form.Checkbox value={itemId} aria-label={title} />
196199
);
197200
};
198201

@@ -339,6 +342,7 @@ const CardItem: React.FC<Props> = ({
339342
<SelectAction
340343
itemId={itemId}
341344
selectMode={selectMode}
345+
title={title}
342346
/>
343347
) : (
344348
<CardMenu

0 commit comments

Comments
 (0)