From da28fb975be2cd3ef5d17dcbb6b527fd52ecaba9 Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Wed, 28 Feb 2024 18:20:39 +0300 Subject: [PATCH] feat: Implement commit/cancel staged tags This implements the commit functionality for staged tags, taking account for implicit tags. This also handles the case for removing applied tags by clicking on the "x" in the TagBubble. --- .../ContentTagsCollapsible.jsx | 41 +++++++-- .../ContentTagsCollapsibleHelper.jsx | 89 +++++++++++-------- src/content-tags-drawer/TagBubble.jsx | 2 +- 3 files changed, 91 insertions(+), 41 deletions(-) diff --git a/src/content-tags-drawer/ContentTagsCollapsible.jsx b/src/content-tags-drawer/ContentTagsCollapsible.jsx index 118b20d3b3..d0e1125013 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.jsx +++ b/src/content-tags-drawer/ContentTagsCollapsible.jsx @@ -6,6 +6,7 @@ import { Collapsible, SelectableBox, Button, + Spinner, } from '@openedx/paragon'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -32,6 +33,7 @@ const CustomMenu = (props) => { selectRef, searchTerm, value, + commitStagedTags, } = props.selectProps; return ( @@ -66,7 +68,7 @@ const CustomMenu = (props) => { @@ -103,6 +105,24 @@ CustomMenu.propTypes = { value: PropTypes.string.isRequired, label: PropTypes.string.isRequired, })).isRequired, + commitStagedTags: PropTypes.func.isRequired, + }).isRequired, +}; + +const CustomLoadingIndicator = (props) => { + const { intl } = props.selectProps; + return ( + + ); +}; + +CustomLoadingIndicator.propTypes = { + selectProps: PropTypes.shape({ + intl: intlShape.isRequired, }).isRequired, }; @@ -196,12 +216,20 @@ const ContentTagsCollapsible = ({ const selectRef = React.useRef(null); const { - tagChangeHandler, appliedContentTagsTree, stagedContentTagsTree, contentTagsCount, checkedTags, + tagChangeHandler, + removeAppliedTagHandler, + appliedContentTagsTree, + stagedContentTagsTree, + contentTagsCount, + checkedTags, + commitStagedTags, + updateTags, } = useContentTagsCollapsibleHelper( contentId, taxonomyAndTagsData, addStagedContentTag, removeStagedContentTag, + stagedContentTags, ); const [searchTerm, setSearchTerm] = React.useState(''); @@ -235,7 +263,7 @@ const ContentTagsCollapsible = ({ ); // Call the `tagChangeHandler` with the unstaged tags to unselect them from the selectbox - // and update the staged content tags tree. Since the `handleStagedTagsMenuChange` function is + // and update the staged content tags tree. Since the `handleStagedTagsMenuChange` function is={} // only called when a change occurs in the react-select menu component we know that tags can only be // removed from there, hence the tagChangeHandler is always called with `checked=false`. unstagedTags.forEach(unstagedTag => tagChangeHandler(unstagedTag.value, false)); @@ -246,7 +274,7 @@ const ContentTagsCollapsible = ({
- +
@@ -255,6 +283,8 @@ const ContentTagsCollapsible = ({