From c328c51e684664be32c9954c34c7b22da5b97b32 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 28 Feb 2024 21:16:59 +0100 Subject: [PATCH] split actions into tabs --- .../src/pages/actions/actionsAffiliations.jsx | 79 +++++++++++++++++++ client/src/pages/actions/actionsDatasets.jsx | 34 ++++++++ .../src/pages/actions/actionsPublications.jsx | 37 +++++++++ client/src/pages/index.jsx | 30 ++++--- 4 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 client/src/pages/actions/actionsAffiliations.jsx create mode 100644 client/src/pages/actions/actionsDatasets.jsx create mode 100644 client/src/pages/actions/actionsPublications.jsx diff --git a/client/src/pages/actions/actionsAffiliations.jsx b/client/src/pages/actions/actionsAffiliations.jsx new file mode 100644 index 00000000..07d1f38f --- /dev/null +++ b/client/src/pages/actions/actionsAffiliations.jsx @@ -0,0 +1,79 @@ +import { Col, File, Row } from '@dataesr/react-dsfr'; +import PropTypes from 'prop-types'; +import { useState } from 'react'; +import { useSearchParams } from 'react-router-dom'; +import { Tooltip } from 'react-tooltip'; + +import Button from '../../components/button'; +import { export2json, importJson } from '../../utils/files'; +import { status } from '../../config'; + +export default function ActionsAffiliations({ + allAffiliations, + options, + setAllAffiliations, + tagAffiliations, +}) { + const [searchParams, setSearchParams] = useSearchParams(); + const [displayFileUpload, setDisplayFileUpload] = useState(false); + const decidedAffiliations = allAffiliations?.filter((affiliation) => affiliation.status !== status.tobedecided.id) || []; + + return ( + <> + + + + + + + Restore affiliations from saved file + + + + {displayFileUpload && ( + + + { importJson(e, options, setAllAffiliations, setSearchParams, tagAffiliations); setDisplayFileUpload(false); }} + /> + + + )} + + ); +} + +ActionsAffiliations.propTypes = { + allAffiliations: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string.isRequired, + nameHtml: PropTypes.string.isRequired, + key: PropTypes.string.isRequired, + status: PropTypes.string.isRequired, + works: PropTypes.arrayOf(PropTypes.string).isRequired, + worksNumber: PropTypes.number.isRequired, + })).isRequired, + options: PropTypes.object.isRequired, + setAllAffiliations: PropTypes.func.isRequired, + tagAffiliations: PropTypes.func.isRequired, +}; diff --git a/client/src/pages/actions/actionsDatasets.jsx b/client/src/pages/actions/actionsDatasets.jsx new file mode 100644 index 00000000..daa11c9d --- /dev/null +++ b/client/src/pages/actions/actionsDatasets.jsx @@ -0,0 +1,34 @@ +import { Col, Row } from '@dataesr/react-dsfr'; +import PropTypes from 'prop-types'; +import { useSearchParams } from 'react-router-dom'; + +import ButtonDropdown from '../../components/button-dropdown'; + +export default function ActionsDatasets({ + allDatasets, + options, + setAllDatasets, +}) { + const [searchParams, setSearchParams] = useSearchParams(); + + return ( + + + + + + ); +} + +ActionsDatasets.propTypes = { + allDatasets: PropTypes.arrayOf(PropTypes.shape({ + affiliations: PropTypes.arrayOf(PropTypes.object), + allIds: PropTypes.arrayOf(PropTypes.object).isRequired, + datasource: PropTypes.arrayOf(PropTypes.string).isRequired, + id: PropTypes.string.isRequired, + status: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + })).isRequired, + options: PropTypes.object.isRequired, + setAllDatasets: PropTypes.func.isRequired, +}; diff --git a/client/src/pages/actions/actionsPublications.jsx b/client/src/pages/actions/actionsPublications.jsx new file mode 100644 index 00000000..68a1e393 --- /dev/null +++ b/client/src/pages/actions/actionsPublications.jsx @@ -0,0 +1,37 @@ +import { Col, File, Row } from '@dataesr/react-dsfr'; +import PropTypes from 'prop-types'; +import { useState } from 'react'; +import { useSearchParams } from 'react-router-dom'; + +import ButtonDropdown from '../../components/button-dropdown'; +import { export2json, importJson } from '../../utils/files'; +import { status } from '../../config'; + +export default function ActionsPublications({ + allPublications, + options, + setAllPublications, +}) { + const [searchParams, setSearchParams] = useSearchParams(); + + return ( + + + + + + ); +} + +ActionsPublications.propTypes = { + allPublications: PropTypes.arrayOf(PropTypes.shape({ + affiliations: PropTypes.arrayOf(PropTypes.object).isRequired, + allIds: PropTypes.arrayOf(PropTypes.object).isRequired, + datasource: PropTypes.arrayOf(PropTypes.string).isRequired, + id: PropTypes.string.isRequired, + status: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + })).isRequired, + options: PropTypes.object.isRequired, + setAllPublications: PropTypes.func.isRequired, +}; diff --git a/client/src/pages/index.jsx b/client/src/pages/index.jsx index 8ed0bb36..7cd1d041 100644 --- a/client/src/pages/index.jsx +++ b/client/src/pages/index.jsx @@ -9,7 +9,9 @@ import { useQuery } from '@tanstack/react-query'; import { useEffect, useState } from 'react'; import useWebSocket from 'react-use-websocket'; -import Actions from './actions'; +import ActionsAffiliations from './actions/actionsAffiliations'; +import ActionsDatasets from './actions/actionsDatasets'; +import ActionsPublications from './actions/actionsPublications'; import AffiliationsTab from './affiliationsTab'; import { PageSpinner } from '../components/spinner'; import Stepper from '../components/stepper'; @@ -151,15 +153,6 @@ export default function Home() { - {isFetching && ( <> @@ -167,7 +160,7 @@ export default function Home() { )} {!isFetching && (allAffiliations?.length > 0 || allDatasets?.length > 0 || allPublications?.length > 0) && ( - + aff.source === 'OpenAlex')} @@ -177,6 +170,12 @@ export default function Home() { /> + + +