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
10 changed files
with
320 additions
and
9 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,2 +1,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as TaxonomyListPage } from './TaxonomyListPage'; | ||
export { default as TaxonomyDetailPage } from './taxonomy-detail/TaxonomyDetailPage'; |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
DataTable, | ||
TextFilter, | ||
} from '@edx/paragon'; | ||
import Proptypes from 'prop-types'; | ||
|
||
import { useTagListDataResponse, useTagListDataStatus } from '../api/hooks/selectors'; | ||
|
||
const TagListTable = ({ taxonomyId }) => { | ||
const useTagListData = () => { | ||
const { isError, isFetched } = useTagListDataStatus(taxonomyId); | ||
const tagList = useTagListDataResponse(taxonomyId); | ||
return { isError, isFetched, tagList }; | ||
}; | ||
|
||
const { isError, isFetched, tagList } = useTagListData(taxonomyId); | ||
|
||
if (!tagList || !tagList.results) { | ||
if (tagList) | ||
return JSON.stringify(tagList); | ||
|
||
return 'Loading...'; | ||
} | ||
|
||
return ( | ||
<DataTable | ||
isFilterable | ||
isSortable | ||
defaultColumnValues={{ Filter: TextFilter }} | ||
data={tagList.results} | ||
columns={[ | ||
{ | ||
Header: 'Name', | ||
accessor: 'name', | ||
}, | ||
]} | ||
> | ||
<DataTable.TableControlBar /> | ||
<DataTable.Table /> | ||
<DataTable.EmptyTable content="No results found" /> | ||
<DataTable.TableFooter /> | ||
</DataTable> | ||
); | ||
}; | ||
|
||
TagListTable.propTypes = { | ||
taxonomyId: Proptypes.number.isRequired, | ||
}; | ||
|
||
export default TagListTable; |
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,116 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
Container, | ||
Layout, | ||
} from '@edx/paragon'; | ||
import Proptypes from 'prop-types'; | ||
|
||
import PermissionDeniedAlert from '../../generic/PermissionDeniedAlert'; | ||
import Loading from '../../generic/Loading'; | ||
import Header from '../../header'; | ||
import SubHeader from '../../generic/sub-header/SubHeader'; | ||
import TaxonomyDetailSideCard from './TaxonomyDetailSideCard'; | ||
import TagListTable from './TagListTable'; | ||
import ExportModal from '../modals/ExportModal'; | ||
import { useTaxonomyDetailDataResponse, useTaxonomyDetailDataStatus } from '../api/hooks/selectors'; | ||
|
||
const TaxonomyDetailContent = ({ taxonomyId }) => { | ||
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} | ||
/> | ||
)} | ||
</> | ||
); | ||
|
||
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"> | ||
<SubHeader | ||
title={taxonomy.name} | ||
hideBorder | ||
/> | ||
</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; | ||
}; | ||
|
||
const TaxonomyDetailPage = ({ taxonomyId }) => ( | ||
<> | ||
<style> | ||
{` | ||
body { | ||
background-color: #E9E6E4; /* light-400 */ | ||
} | ||
`} | ||
</style> | ||
<Header isHiddenMainMenu /> | ||
<TaxonomyDetailContent taxonomyId={taxonomyId} /> | ||
</> | ||
); | ||
|
||
TaxonomyDetailPage.propTypes = { | ||
taxonomyId: Proptypes.number, | ||
}; | ||
|
||
TaxonomyDetailPage.defaultProps = { | ||
taxonomyId: undefined, | ||
}; | ||
|
||
TaxonomyDetailContent.propTypes = TaxonomyDetailPage.propTypes; | ||
TaxonomyDetailContent.defaultProps = TaxonomyDetailPage.defaultProps; | ||
|
||
export default TaxonomyDetailPage; |
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,27 @@ | ||
import { | ||
Card, | ||
} from '@edx/paragon'; | ||
import Proptypes from 'prop-types'; | ||
|
||
const TaxonomyDetailSideCard = ({ taxonomy }) => ( | ||
<Card> | ||
<Card.Header title="Taxonomy details" /> | ||
<Card.Section title="Title"> | ||
{taxonomy.name} | ||
</Card.Section> | ||
<Card.Divider className="ml-3 mr-3" /> | ||
<Card.Section title="Description"> | ||
{taxonomy.description} | ||
</Card.Section> | ||
<Card.Divider className="ml-3 mr-3" /> | ||
<Card.Section title="Copyright"> | ||
No copyright added | ||
</Card.Section> | ||
</Card> | ||
); | ||
|
||
TaxonomyDetailSideCard.propTypes = { | ||
taxonomy: Proptypes.object.isRequired, | ||
}; | ||
|
||
export default TaxonomyDetailSideCard; |