diff --git a/src/library-authoring/LibraryAuthoringPage.scss b/src/library-authoring/LibraryAuthoringPage.scss new file mode 100644 index 0000000000..3ce8cb718a --- /dev/null +++ b/src/library-authoring/LibraryAuthoringPage.scss @@ -0,0 +1,11 @@ +.library-authoring-page { + .header-actions { + .normal-border { + border: 1px solid; + } + + .open-border { + border: 2px solid; + } + } +} diff --git a/src/library-authoring/LibraryAuthoringPage.test.tsx b/src/library-authoring/LibraryAuthoringPage.test.tsx index 3dbd737bc5..848a109ff1 100644 --- a/src/library-authoring/LibraryAuthoringPage.test.tsx +++ b/src/library-authoring/LibraryAuthoringPage.test.tsx @@ -375,17 +375,22 @@ describe('', () => { expect((await screen.findAllByText(libraryData.title))[0]).toBeInTheDocument(); expect((await screen.findAllByText(libraryData.title))[1]).toBeInTheDocument(); + // Open by default; close the library info sidebar const closeButton = screen.getByRole('button', { name: /close/i }); fireEvent.click(closeButton); - expect(screen.queryByText('Draft')).not.toBeInTheDocument(); expect(screen.queryByText('(Never Published)')).not.toBeInTheDocument(); + // Open library info sidebar with 'Library info' button const libraryInfoButton = screen.getByRole('button', { name: /library info/i }); fireEvent.click(libraryInfoButton); - expect(screen.getByText('Draft')).toBeInTheDocument(); expect(screen.getByText('(Never Published)')).toBeInTheDocument(); + + // CLose library info sidebar with 'Library info' button + fireEvent.click(libraryInfoButton); + expect(screen.queryByText('Draft')).not.toBeInTheDocument(); + expect(screen.queryByText('(Never Published)')).not.toBeInTheDocument(); }); it('show the "View All" button when viewing library with many components', async () => { diff --git a/src/library-authoring/LibraryAuthoringPage.tsx b/src/library-authoring/LibraryAuthoringPage.tsx index c2eb969292..c2cc8bc7f9 100644 --- a/src/library-authoring/LibraryAuthoringPage.tsx +++ b/src/library-authoring/LibraryAuthoringPage.tsx @@ -1,4 +1,5 @@ import React, { useContext, useEffect } from 'react'; +import classNames from 'classnames'; import { StudioFooter } from '@edx/frontend-component-footer'; import { useIntl } from '@edx/frontend-platform/i18n'; import { @@ -33,7 +34,7 @@ import LibraryCollections from './LibraryCollections'; import LibraryHome from './LibraryHome'; import { useContentLibrary } from './data/apiHooks'; import { LibrarySidebar } from './library-sidebar'; -import { LibraryContext } from './common/context'; +import { LibraryContext, SidebarBodyComponentId } from './common/context'; import messages from './messages'; enum TabList { @@ -51,22 +52,41 @@ const HeaderActions = ({ canEditLibrary }: HeaderActionsProps) => { const { openAddContentSidebar, openInfoSidebar, + closeLibrarySidebar, + sidebarBodyComponent, } = useContext(LibraryContext); if (!canEditLibrary) { return null; } + const infoSidebarIsOpen = () => ( + sidebarBodyComponent === SidebarBodyComponentId.Info + ); + + const handleOnClickInfoSidebar = () => { + if (infoSidebarIsOpen()) { + closeLibrarySidebar(); + } else { + openInfoSidebar(); + } + }; + return ( - <> +
- +
); }; @@ -132,7 +152,7 @@ const LibraryAuthoringPage = () => { }; return ( - +
{ ) : ( <> - + {library.title} {library.canEditLibrary && ( @@ -75,6 +75,8 @@ const LibraryInfoHeader = ({ library } : LibraryInfoHeaderProps) => { iconAs={Icon} alt={intl.formatMessage(messages.editNameButtonAlt)} onClick={handleClick} + className="mt-1" + size="inline" /> )} diff --git a/src/library-authoring/library-sidebar/LibrarySidebar.tsx b/src/library-authoring/library-sidebar/LibrarySidebar.tsx index 314de8792a..1f8afe782f 100644 --- a/src/library-authoring/library-sidebar/LibrarySidebar.tsx +++ b/src/library-authoring/library-sidebar/LibrarySidebar.tsx @@ -49,11 +49,13 @@ const LibrarySidebar = ({ library }: LibrarySidebarProps) => { {buildHeader()}