-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Collections page (in libraries) (#1281)
- Loading branch information
1 parent
0d472ae
commit b7ae82b
Showing
31 changed files
with
1,244 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,46 @@ | ||
import React, { useContext, useCallback } from 'react'; | ||
import { useParams } from 'react-router'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import type { MessageDescriptor } from 'react-intl'; | ||
import { | ||
Button, Stack, | ||
} from '@openedx/paragon'; | ||
import { Add } from '@openedx/paragon/icons'; | ||
import { ClearFiltersButton } from '../search-manager'; | ||
import messages from './messages'; | ||
import { LibraryContext } from './common/context'; | ||
import { useContentLibrary } from './data/apiHooks'; | ||
|
||
type NoSearchResultsProps = { | ||
searchType?: 'collection' | 'component', | ||
}; | ||
|
||
export const NoComponents = ({ searchType = 'component' }: NoSearchResultsProps) => { | ||
const { openAddContentSidebar, openCreateCollectionModal } = useContext(LibraryContext); | ||
export const NoComponents = ({ | ||
infoText = messages.noComponents, | ||
addBtnText = messages.addComponent, | ||
handleBtnClick, | ||
}: { | ||
infoText?: MessageDescriptor; | ||
addBtnText?: MessageDescriptor; | ||
handleBtnClick: () => void; | ||
}) => { | ||
const { libraryId } = useParams(); | ||
const { data: libraryData } = useContentLibrary(libraryId); | ||
const canEditLibrary = libraryData?.canEditLibrary ?? false; | ||
|
||
const handleOnClickButton = useCallback(() => { | ||
if (searchType === 'collection') { | ||
openCreateCollectionModal(); | ||
} else { | ||
openAddContentSidebar(); | ||
} | ||
}, [searchType]); | ||
|
||
return ( | ||
<Stack direction="horizontal" gap={3} className="mt-6 justify-content-center"> | ||
{searchType === 'collection' | ||
? <FormattedMessage {...messages.noCollections} /> | ||
: <FormattedMessage {...messages.noComponents} />} | ||
<FormattedMessage {...infoText} /> | ||
{canEditLibrary && ( | ||
<Button iconBefore={Add} onClick={handleOnClickButton}> | ||
{searchType === 'collection' | ||
? <FormattedMessage {...messages.addCollection} /> | ||
: <FormattedMessage {...messages.addComponent} />} | ||
<Button iconBefore={Add} onClick={handleBtnClick}> | ||
<FormattedMessage {...addBtnText} /> | ||
</Button> | ||
)} | ||
</Stack> | ||
); | ||
}; | ||
|
||
export const NoSearchResults = ({ searchType = 'component' }: NoSearchResultsProps) => ( | ||
export const NoSearchResults = ({ | ||
infoText = messages.noSearchResults, | ||
}: { | ||
infoText?: MessageDescriptor; | ||
}) => ( | ||
<Stack direction="horizontal" gap={3} className="my-6 justify-content-center"> | ||
{searchType === 'collection' | ||
? <FormattedMessage {...messages.noSearchResultsCollections} /> | ||
: <FormattedMessage {...messages.noSearchResults} />} | ||
<FormattedMessage {...infoText} /> | ||
<ClearFiltersButton variant="primary" size="md" /> | ||
</Stack> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,8 @@ | |
height: 100vh; | ||
overflow-y: auto; | ||
} | ||
|
||
// Reduce breadcrumb bottom margin | ||
ol.list-inline { | ||
margin-bottom: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.