diff --git a/src/content-tags-drawer/ContentTagsCollapsible.jsx b/src/content-tags-drawer/ContentTagsCollapsible.jsx index fced38cb8a..b58f33184d 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.jsx +++ b/src/content-tags-drawer/ContentTagsCollapsible.jsx @@ -5,12 +5,13 @@ import React from 'react'; import Select, { components } from 'react-select'; import { - Badge, Collapsible, Button, Spinner, + Chip, + Icon, } from '@openedx/paragon'; -import classNames from 'classnames'; +import { Tag, KeyboardArrowDown, KeyboardArrowUp } from '@openedx/paragon/icons'; import { SelectableBox } from '@edx/frontend-lib-content-components'; import { useIntl } from '@edx/frontend-platform/i18n'; import { debounce } from 'lodash'; @@ -363,71 +364,84 @@ const ContentTagsCollapsible = ({ return (
- -
- -
+ + + + + -
+ + + +

{name}

+ - {canTagObject && ( - ({ + ...base, + background: state.isFocused ? 'black' : base.background, + color: state.isFocused ? 'white' : base.color, + }), + }} + menuIsOpen={selectMenuIsOpen} + onFocus={onSelectMenuFocus} + onKeyDown={handleSelectOnKeyDown} + ref={/** @type {React.RefObject} */(selectRef)} + isMulti + isLoading={updateTags.isLoading} + isDisabled={updateTags.isLoading} + name="tags-select" + placeholder={intl.formatMessage(messages.collapsibleAddTagsPlaceholderText)} + isSearchable + className="d-flex flex-column flex-fill" + classNamePrefix="react-select-add-tags" + onInputChange={handleSearchChange} + onChange={handleStagedTagsMenuChange} + components={{ + Menu: CustomMenu, + LoadingIndicator: CustomLoadingIndicator, + IndicatorsContainer: CustomIndicatorsContainer, + }} + closeMenuOnSelect={false} + blurInputOnSelect={false} + handleSelectableBoxChange={handleSelectableBoxChange} + checkedTags={checkedTags} + taxonomyId={taxonomyId} + appliedContentTagsTree={appliedContentTagsTree} + stagedContentTagsTree={stagedContentTagsTree} + handleCommitStagedTags={handleCommitStagedTags} + handleCancelStagedTags={handleCancelStagedTags} + searchTerm={searchTerm} + selectCancelRef={selectCancelRef} + selectAddRef={selectAddRef} + selectInlineAddRef={selectInlineAddRef} + value={stagedContentTags} + /> + )} +
+ +
+
+ {contentTagsCount} - +
); diff --git a/src/content-tags-drawer/ContentTagsCollapsible.scss b/src/content-tags-drawer/ContentTagsCollapsible.scss index 67a51a77e3..d6dc4df8da 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.scss +++ b/src/content-tags-drawer/ContentTagsCollapsible.scss @@ -4,6 +4,10 @@ .collapsible-trigger { border: none !important; + + .pgn__icon { + margin-left: -3px; + } } } @@ -57,3 +61,7 @@ color: white !important; } } + +.taxonomy-tags-count-chip > .pgn__chip { + background: none; +} diff --git a/src/content-tags-drawer/ContentTagsCollapsible.test.jsx b/src/content-tags-drawer/ContentTagsCollapsible.test.jsx index e048ce6107..8fc99a7699 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.test.jsx +++ b/src/content-tags-drawer/ContentTagsCollapsible.test.jsx @@ -177,7 +177,7 @@ describe('', () => { it('should render taxonomy tags data along content tags number badge', async () => { const { container, getByText } = await getComponent(); expect(getByText('Taxonomy 1')).toBeInTheDocument(); - expect(container.getElementsByClassName('badge').length).toBe(1); + expect(container.getElementsByClassName('taxonomy-tags-count-chip').length).toBe(1); expect(getByText('3')).toBeInTheDocument(); }); @@ -546,13 +546,14 @@ describe('', () => { expect(appliedTag).not.toBeInTheDocument(); }); - it('should render taxonomy tags data without tags number badge', async () => { + it('should render taxonomy tags data with tags number badge as cero', async () => { const updatedData = { ...data }; updatedData.taxonomyAndTagsData = { ...updatedData.taxonomyAndTagsData }; updatedData.taxonomyAndTagsData.contentTags = []; const { container, getByText } = await getComponent(updatedData); expect(getByText('Taxonomy 1')).toBeInTheDocument(); - expect(container.getElementsByClassName('invisible').length).toBe(1); + expect(container.getElementsByClassName('taxonomy-tags-count-chip').length).toBe(1); + expect(getByText('0')).toBeInTheDocument(); }); }); diff --git a/src/content-tags-drawer/ContentTagsDrawer.jsx b/src/content-tags-drawer/ContentTagsDrawer.jsx index f81ac351bb..a20e78bc5f 100644 --- a/src/content-tags-drawer/ContentTagsDrawer.jsx +++ b/src/content-tags-drawer/ContentTagsDrawer.jsx @@ -8,7 +8,6 @@ import React, { import PropTypes from 'prop-types'; import { Container, - CloseButton, Spinner, } from '@openedx/paragon'; import { useIntl } from '@edx/frontend-platform/i18n'; @@ -135,10 +134,8 @@ const ContentTagsDrawer = ({ id, onClose }) => {
- onCloseDrawer()} data-testid="drawer-close-button" /> - {intl.formatMessage(messages.headerSubtitle)} { isContentDataLoaded - ?

{ contentName }

+ ?

{ contentName }

: (
{ )}
+

{intl.formatMessage(messages.headerSubtitle)}

{ isTaxonomyListLoaded && isContentTaxonomyTagsLoaded ? taxonomies.map((data) => ( diff --git a/src/content-tags-drawer/ContentTagsDrawer.test.jsx b/src/content-tags-drawer/ContentTagsDrawer.test.jsx index 8ff9d52f29..91392689e5 100644 --- a/src/content-tags-drawer/ContentTagsDrawer.test.jsx +++ b/src/content-tags-drawer/ContentTagsDrawer.test.jsx @@ -19,7 +19,6 @@ import { getTaxonomyListData } from '../taxonomy/data/api'; import messages from './messages'; const contentId = 'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@7f47fe2dbcaf47c5a071671c741fe1ab'; -const mockOnClose = jest.fn(); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -250,7 +249,7 @@ describe('', () => { await waitFor(() => { expect(getByText('Taxonomy 1')).toBeInTheDocument(); }); expect(getByText('Taxonomy 1')).toBeInTheDocument(); expect(getByText('Taxonomy 2')).toBeInTheDocument(); - const tagCountBadges = container.getElementsByClassName('badge'); + const tagCountBadges = container.getElementsByClassName('taxonomy-tags-count-chip'); expect(tagCountBadges[0].textContent).toBe('2'); expect(tagCountBadges[1].textContent).toBe('1'); }); @@ -354,30 +353,6 @@ describe('', () => { expect(queryByText('Tag 3')).not.toBeInTheDocument(); }); - it('should call closeManageTagsDrawer when CloseButton is clicked', async () => { - const postMessageSpy = jest.spyOn(window.parent, 'postMessage'); - - const { getByTestId } = render(); - - // Find the CloseButton element by its test ID and trigger a click event - const closeButton = getByTestId('drawer-close-button'); - fireEvent.click(closeButton); - - expect(postMessageSpy).toHaveBeenCalledWith('closeManageTagsDrawer', '*'); - - postMessageSpy.mockRestore(); - }); - - it('should call onClose param when CloseButton is clicked', async () => { - render(); - - // Find the CloseButton element by its test ID and trigger a click event - const closeButton = screen.getByTestId('drawer-close-button'); - fireEvent.click(closeButton); - - expect(mockOnClose).toHaveBeenCalled(); - }); - it('should call closeManageTagsDrawer when Escape key is pressed and no selectable box is active', () => { const postMessageSpy = jest.spyOn(window.parent, 'postMessage'); diff --git a/src/course-outline/card-header/CardHeader.test.jsx b/src/course-outline/card-header/CardHeader.test.jsx index 0e40058c3f..c734300433 100644 --- a/src/course-outline/card-header/CardHeader.test.jsx +++ b/src/course-outline/card-header/CardHeader.test.jsx @@ -206,7 +206,7 @@ describe('', () => { fireEvent.click(manageTagsMenuItem); // Check if the drawer is open - expect(screen.getByTestId('drawer-close-button')).toBeInTheDocument(); + expect(screen.getAllByText('Manage tags').length).toBe(2); }); it('calls onClickEdit when the button is clicked', async () => {