Skip to content

Commit 095b731

Browse files
committed
feat: add manage tags action
1 parent 60eed85 commit 095b731

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

src/course-outline/outline-sidebar/OutlineInfoSidebar.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useIntl } from '@edx/frontend-platform/i18n';
2+
import { useToggle } from '@openedx/paragon';
23
import { SchoolOutline, Tag } from '@openedx/paragon/icons';
34

4-
import { ContentTagsSnippet } from '@src/content-tags-drawer';
5+
import { ContentTagsDrawerSheet, ContentTagsSnippet } from '@src/content-tags-drawer';
56
import { ComponentCountSnippet } from '@src/generic/block-type-utils';
67
import { useGetBlockTypes } from '@src/search-manager';
78

@@ -18,6 +19,8 @@ export const OutlineInfoSidebar = ({ courseId }: { courseId: string }) => {
1819
[`context_key = "${courseId}"`],
1920
);
2021

22+
const [isManageTagsDrawerOpen, openManageTagsDrawer, closeManageTagsDrawer] = useToggle(false);
23+
2124
return (
2225
<div>
2326
<SidebarTitle
@@ -34,10 +37,21 @@ export const OutlineInfoSidebar = ({ courseId }: { courseId: string }) => {
3437
<SidebarSection
3538
title={intl.formatMessage(messages.sidebarSectionTaxonomy)}
3639
icon={Tag}
40+
actions={[
41+
{
42+
label: intl.formatMessage(messages.sidebarSectionTaxonomyManageTags),
43+
onClick: openManageTagsDrawer,
44+
},
45+
]}
3746
>
3847
<ContentTagsSnippet contentId={courseId} />
3948
</SidebarSection>
4049
</SidebarContent>
50+
<ContentTagsDrawerSheet
51+
id={courseId}
52+
onClose={closeManageTagsDrawer}
53+
showSheet={isManageTagsDrawerOpen}
54+
/>
4155
</div>
4256
);
4357
};

src/course-outline/outline-sidebar/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ const messages = defineMessages({
8383
defaultMessage: 'Taxonomy Alignments',
8484
description: 'Title of the taxonomy section in the sidebar',
8585
},
86+
sidebarSectionTaxonomyManageTags: {
87+
id: 'course-authoring.course-outline.sidebar.sidebar-section-taxonomy.manage-tags-action',
88+
defaultMessage: 'Manage tags',
89+
description: 'Action to open the tags drawer',
90+
},
8691
});
8792

8893
export default messages;

src/generic/sidebar/SidebarSection.tsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
import { Icon, Stack } from '@openedx/paragon';
1+
import {
2+
Dropdown,
3+
Icon,
4+
IconButton,
5+
Stack,
6+
} from '@openedx/paragon';
7+
import { MoreVert } from '@openedx/paragon/icons';
28

39
export interface SidebarSectionProps {
410
/** Title of the section */
511
title: string;
612
/** Icon to be displayed in the section */
713
icon?: React.ComponentType;
14+
/** Actions to be displayed in the section */
15+
actions?: [
16+
{
17+
/** Label of the action */
18+
label: string;
19+
/** Function to be called when the action is clicked */
20+
onClick: () => void;
21+
},
22+
];
823
/** Content of the section */
924
children: React.ReactNode;
1025
}
@@ -26,13 +41,35 @@ export interface SidebarSectionProps {
2641
* </SidebarSection>
2742
* ```
2843
*/
29-
export const SidebarSection = ({ title, icon, children }: SidebarSectionProps) => (
44+
export const SidebarSection = ({
45+
title, icon, actions, children,
46+
}: SidebarSectionProps) => (
3047
<Stack gap={2}>
3148
<Stack direction="horizontal" gap={2}>
3249
{icon && <Icon src={icon} className="mr-1 text-primary" size="sm" />}
3350
<h3 className="h5 font-weight-bold text-primary mb-0">
3451
{title}
3552
</h3>
53+
{actions && (
54+
<Dropdown className="ml-auto">
55+
<Dropdown.Toggle
56+
as={IconButton}
57+
src={MoreVert}
58+
iconAs={Icon}
59+
size="sm"
60+
/>
61+
<Dropdown.Menu>
62+
{actions.map((action) => (
63+
<Dropdown.Item
64+
key={action.label}
65+
onClick={action.onClick}
66+
>
67+
{action.label}
68+
</Dropdown.Item>
69+
))}
70+
</Dropdown.Menu>
71+
</Dropdown>
72+
)}
3673
</Stack>
3774
{children}
3875
</Stack>

0 commit comments

Comments
 (0)