-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
cb07e88
commit c328c51
Showing
4 changed files
with
169 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<> | ||
<Row className="fr-mb-1w"> | ||
<Col className="text-right"> | ||
<Button | ||
data-tooltip-id="save-affiliations-button" | ||
disabled={!decidedAffiliations.length} | ||
icon="ri-save-line" | ||
onClick={() => export2json({ decidedAffiliations, label: 'affiliations', searchParams })} | ||
size="sm" | ||
> | ||
Save decided affiliations | ||
</Button> | ||
<Tooltip id="save-affiliations-button" hidden={!decidedAffiliations.length}> | ||
Save the decided affiliations in order to restore it later | ||
</Tooltip> | ||
<Button | ||
data-tooltip-id="restore-affiliations-button" | ||
icon="ri-file-upload-line" | ||
onClick={() => setDisplayFileUpload(true)} | ||
secondary | ||
size="sm" | ||
> | ||
Restore affiliations | ||
</Button> | ||
<Tooltip id="restore-affiliations-button"> | ||
Restore affiliations from saved file | ||
</Tooltip> | ||
</Col> | ||
</Row> | ||
{displayFileUpload && ( | ||
<Row className="fr-mb-1w"> | ||
<Col> | ||
<File | ||
accept=".json" | ||
hint="Select JSON file to restore from previous state" | ||
label="JSON file" | ||
onChange={(e) => { importJson(e, options, setAllAffiliations, setSearchParams, tagAffiliations); setDisplayFileUpload(false); }} | ||
/> | ||
</Col> | ||
</Row> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
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, | ||
}; |
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,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 ( | ||
<Row className="fr-mb-1w"> | ||
<Col className="text-right"> | ||
<ButtonDropdown data={allDatasets} label="datasets" searchParams={searchParams} /> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
|
||
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, | ||
}; |
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,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 ( | ||
<Row className="fr-mb-1w"> | ||
<Col className="text-right"> | ||
<ButtonDropdown data={allPublications} label="publications" searchParams={searchParams} /> | ||
</Col> | ||
</Row> | ||
); | ||
} | ||
|
||
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, | ||
}; |
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