forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { StudioFooter } from '@edx/frontend-component-footer'; | ||
import { Outlet } from 'react-router-dom'; | ||
|
||
import Header from '../header'; | ||
|
||
const TaxonomyLayout = () => ( | ||
<> | ||
<style> | ||
{` | ||
body { | ||
background-color: #E9E6E4; /* light-400 */ | ||
} | ||
`} | ||
</style> | ||
<Header isHiddenMainMenu /> | ||
<Outlet /> | ||
<StudioFooter /> | ||
</> | ||
); | ||
|
||
export default TaxonomyLayout; |
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,2 +1,3 @@ | ||
export { default as TaxonomyListPage } from './TaxonomyListPage'; | ||
export { default as TaxonomyLayout } from './TaxonomyLayout'; | ||
export { default as TaxonomyDetailPage } from './taxonomy-detail/TaxonomyDetailPage'; |
This file was deleted.
Oops, something went wrong.
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,21 +1,128 @@ | ||
import { StudioFooter } from '@edx/frontend-component-footer'; | ||
|
||
import Header from '../../header'; | ||
import TaxonomyDetailContent from './TaxonomyDetailContent'; | ||
|
||
const TaxonomyDetailPage = () => ( | ||
<> | ||
<style> | ||
{` | ||
body { | ||
background-color: #E9E6E4; /* light-400 */ | ||
} | ||
`} | ||
</style> | ||
<Header isHiddenMainMenu /> | ||
<TaxonomyDetailContent /> | ||
<StudioFooter /> | ||
</> | ||
); | ||
import React, { useState } from 'react'; | ||
import { | ||
Breadcrumb, | ||
Container, | ||
Layout, | ||
} from '@edx/paragon'; | ||
import { Link, useParams } from 'react-router-dom'; | ||
|
||
import PermissionDeniedAlert from '../../generic/PermissionDeniedAlert'; | ||
import Loading from '../../generic/Loading'; | ||
import SubHeader from '../../generic/sub-header/SubHeader'; | ||
import TaxonomyDetailMenu from './TaxonomyDetailMenu'; | ||
import TaxonomyDetailSideCard from './TaxonomyDetailSideCard'; | ||
import TagListTable from './TagListTable'; | ||
import ExportModal from '../modals/ExportModal'; | ||
import { useTaxonomyDetailDataResponse, useTaxonomyDetailDataStatus } from '../api/hooks/selectors'; | ||
|
||
const TaxonomyDetailPage = () => { | ||
const { taxonomyId } = useParams(); | ||
|
||
const useTaxonomyDetailData = () => { | ||
const { isError, isFetched } = useTaxonomyDetailDataStatus(taxonomyId); | ||
const taxonomy = useTaxonomyDetailDataResponse(taxonomyId); | ||
return { isError, isFetched, taxonomy }; | ||
}; | ||
|
||
const { isError, isFetched, taxonomy } = useTaxonomyDetailData(taxonomyId); | ||
|
||
const [isExportModalOpen, setIsExportModalOpen] = useState(false); | ||
|
||
if (isError) { | ||
return ( | ||
<PermissionDeniedAlert /> | ||
); | ||
} | ||
|
||
if (!isFetched) { | ||
return ( | ||
<Loading /> | ||
); | ||
} | ||
|
||
const renderModals = () => ( | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
<> | ||
{isExportModalOpen && ( | ||
<ExportModal | ||
isOpen={isExportModalOpen} | ||
onClose={() => setIsExportModalOpen(false)} | ||
taxonomyId={taxonomyId} | ||
taxonomyName={taxonomy.name} | ||
/> | ||
)} | ||
</> | ||
); | ||
|
||
const onClickMenuItem = (menuName) => { | ||
switch (menuName) { | ||
case 'export': | ||
setIsExportModalOpen(true); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
const getHeaderActions = () => ( | ||
<TaxonomyDetailMenu | ||
id={taxonomy.id} | ||
name={taxonomy.name} | ||
disabled={ | ||
// We don't show the export menu, because the system-taxonomies | ||
// can't be exported. The API returns and error. | ||
// The entire menu has been disabled because currently only | ||
// the export menu exists. | ||
// ToDo: When adding more menus, change this logic to hide only the export menu. | ||
taxonomy.systemDefined | ||
} | ||
onClickMenuItem={onClickMenuItem} | ||
/> | ||
); | ||
|
||
if (taxonomy) { | ||
return ( | ||
<> | ||
<div className="pt-4.5 pr-4.5 pl-4.5 pb-2 bg-light-100 box-shadow-down-2"> | ||
<Container size="xl"> | ||
<Breadcrumb | ||
links={[ | ||
{ label: 'Taxonomies', to: '/taxonomy-list/' }, | ||
]} | ||
activeLabel={taxonomy.name} | ||
linkAs={Link} | ||
/> | ||
<SubHeader | ||
title={taxonomy.name} | ||
hideBorder | ||
headerActions={getHeaderActions()} | ||
/> | ||
</Container> | ||
</div> | ||
<div className="bg-light-400 m-4"> | ||
<Container size="xl"> | ||
<Layout | ||
lg={[{ span: 9 }, { span: 3 }]} | ||
md={[{ span: 9 }, { span: 3 }]} | ||
sm={[{ span: 9 }, { span: 3 }]} | ||
xs={[{ span: 9 }, { span: 3 }]} | ||
xl={[{ span: 9 }, { span: 3 }]} | ||
> | ||
<Layout.Element> | ||
<TagListTable taxonomyId={taxonomyId} /> | ||
</Layout.Element> | ||
<Layout.Element> | ||
<TaxonomyDetailSideCard taxonomy={taxonomy} /> | ||
</Layout.Element> | ||
</Layout> | ||
</Container> | ||
</div> | ||
{renderModals()} | ||
</> | ||
); | ||
} | ||
|
||
return undefined; | ||
}; | ||
|
||
export default TaxonomyDetailPage; |