Skip to content

Commit c3dc8a1

Browse files
committed
feat: Add new content button on the end of block list
1 parent ca6f216 commit c3dc8a1

4 files changed

Lines changed: 49 additions & 7 deletions

File tree

src/library-authoring/add-content/PickLibraryContentModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const PickLibraryContentModal: React.FC<PickLibraryContentModalProps> = (
6565
showToast(intl.formatMessage(messages.successAssociateComponentMessage));
6666
})
6767
.catch(() => {
68-
showToast(intl.formatMessage(messages.errorAssociateComponentMessage));
68+
showToast(intl.formatMessage(messages.errorAssociateComponentToCollectionMessage));
6969
});
7070
}, [selectedComponents]);
7171

src/library-authoring/units/LibraryUnitBlocks.tsx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { FormattedMessage } from '@edx/frontend-platform/i18n';
1+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
22
import {
3-
ActionRow, Badge, Icon, Stack, useToggle,
3+
ActionRow, Badge, Button, Icon, Stack, useToggle,
44
} from '@openedx/paragon';
5-
import { Description } from '@openedx/paragon/icons';
5+
import { Add, Description } from '@openedx/paragon/icons';
66
import { useQueryClient } from '@tanstack/react-query';
77
import classNames from 'classnames';
88
import { useEffect, useState } from 'react';
@@ -22,8 +22,10 @@ import { libraryAuthoringQueryKeys, useContainerChildren } from '../data/apiHook
2222
import { LibraryBlock } from '../LibraryBlock';
2323
import { useLibraryRoutes } from '../routes';
2424
import messages from './messages';
25+
import { useSidebarContext } from '../common/context/SidebarContext';
2526

2627
export const LibraryUnitBlocks = () => {
28+
const intl = useIntl();
2729
const [orderedBlocks, setOrderedBlocks] = useState<LibraryBlockMetadata[]>([]);
2830
const [isManageTagsDrawerOpen, openManageTagsDrawer, closeManageTagsDrawer] = useToggle(false);
2931
const { navigateTo } = useLibraryRoutes();
@@ -33,9 +35,14 @@ export const LibraryUnitBlocks = () => {
3335
unitId,
3436
showOnlyPublished,
3537
componentId,
38+
readOnly,
3639
setComponentId,
3740
} = useLibraryContext();
3841

42+
const {
43+
openAddContentSidebar,
44+
} = useSidebarContext();
45+
3946
const queryClient = useQueryClient();
4047
const {
4148
data: blocks,
@@ -128,6 +135,31 @@ export const LibraryUnitBlocks = () => {
128135
<DraggableList itemList={orderedBlocks} setState={setOrderedBlocks} updateOrder={handleReorder}>
129136
{renderedBlocks}
130137
</DraggableList>
138+
<div className="d-flex">
139+
<div className="w-100 mr-2">
140+
<Button
141+
className="ml-2"
142+
iconBefore={Add}
143+
variant="outline-primary rounded-0"
144+
disabled={readOnly}
145+
onClick={openAddContentSidebar}
146+
block
147+
>
148+
{intl.formatMessage(messages.newContentButton)}
149+
</Button>
150+
</div>
151+
<div className="w-100 ml-2">
152+
<Button
153+
className="ml-2"
154+
iconBefore={Add}
155+
variant="outline-primary rounded-0"
156+
disabled
157+
block
158+
>
159+
{intl.formatMessage(messages.addExistingContentButton)}
160+
</Button>
161+
</div>
162+
</div>
131163
<ContentTagsDrawerSheet
132164
id={componentId}
133165
onClose={onTagSidebarClose}

src/library-authoring/units/LibraryUnitPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const HeaderActions = () => {
6767
disabled={readOnly}
6868
onClick={openAddContentSidebar}
6969
>
70-
{intl.formatMessage(messages.newContentButton)}
70+
{intl.formatMessage(messages.addContentButton)}
7171
</Button>
7272
</div>
7373
);

src/library-authoring/units/messages.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ const messages = defineMessages({
66
defaultMessage: 'Unit Info',
77
description: 'Button text to unit sidebar from unit page',
88
},
9-
newContentButton: {
10-
id: 'course-authoring.library-authoring.unit-header.buttons.new-content',
9+
addContentButton: {
10+
id: 'course-authoring.library-authoring.unit-header.buttons.add-content',
1111
defaultMessage: 'Add Content',
12+
description: 'Text of button to add content to unit',
13+
},
14+
addExistingContentButton: {
15+
id: 'course-authoring.library-authoring.unit-header.buttons.add-existing-content',
16+
defaultMessage: 'Add Existing Content',
17+
description: 'Text of button to add existing content to unit',
18+
},
19+
newContentButton: {
20+
id: 'course-authoring.library-authoring.unit-header.buttons.add-new-content',
21+
defaultMessage: 'Add New Content',
1222
description: 'Text of button to add new content to unit',
1323
},
1424
breadcrumbsAriaLabel: {

0 commit comments

Comments
 (0)