import { useEffect } from 'react'; import { StudioFooterSlot } from '@openedx/frontend-slot-footer'; import { useIntl } from '@edx/frontend-platform/i18n'; import { ActionRow, Button, Breadcrumb, Container, Icon, } from '@openedx/paragon'; import { Add, ArrowBack, InfoOutline } from '@openedx/paragon/icons'; import classNames from 'classnames'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; import { useLibraryRoutes } from '../routes'; import Loading from '../../generic/Loading'; import ErrorAlert from '../../generic/alert-error'; import SubHeader from '../../generic/sub-header/SubHeader'; import Header from '../../header'; import NotFoundAlert from '../../generic/NotFoundAlert'; import { ClearFiltersButton, FilterByBlockType, FilterByPublished, FilterByTags, SearchContextProvider, SearchKeywordsField, SearchSortWidget, } from '../../search-manager'; import { SubHeaderTitle } from '../LibraryAuthoringPage'; import { useCollection, useContentLibrary } from '../data/apiHooks'; import { useComponentPickerContext } from '../common/context/ComponentPickerContext'; import { useLibraryContext } from '../common/context/LibraryContext'; import { SidebarBodyComponentId, useSidebarContext } from '../common/context/SidebarContext'; import messages from './messages'; import { LibrarySidebar } from '../library-sidebar'; import LibraryCollectionComponents from './LibraryCollectionComponents'; const HeaderActions = () => { const intl = useIntl(); const { componentPickerMode } = useComponentPickerContext(); const { collectionId, readOnly } = useLibraryContext(); const { closeLibrarySidebar, openAddContentSidebar, openCollectionInfoSidebar, sidebarComponentInfo, } = useSidebarContext(); const { navigateTo } = useLibraryRoutes(); // istanbul ignore if: this should never happen if (!collectionId) { throw new Error('it should not be possible to render HeaderActions without a collectionId'); } const infoSidebarIsOpen = sidebarComponentInfo?.type === SidebarBodyComponentId.CollectionInfo && sidebarComponentInfo?.id === collectionId; const handleOnClickInfoSidebar = () => { if (infoSidebarIsOpen) { closeLibrarySidebar(); } else { openCollectionInfoSidebar(collectionId); } if (!componentPickerMode) { navigateTo({ collectionId }); } }; return (