From 6d805b3487f9253c2cacfa035a95fd90ebfcb1b5 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 27 Sep 2024 14:25:07 +0100 Subject: [PATCH] uniformise useTitle hook behavior --- .../modules-codelists/components/codelist-detail/edit.jsx | 2 +- .../components/codelist-partial-detail/edit.jsx | 5 +---- .../collections/edition-creation/creation-container.jsx | 5 +---- .../collections/edition-creation/edition-container.jsx | 5 +---- .../modules-concepts/edition-creation/creation-container.jsx | 2 +- .../modules-concepts/edition-creation/edition-container.jsx | 2 +- src/packages/modules-datasets/datasets/edit/edit.jsx | 2 +- src/packages/modules-datasets/distributions/edit.jsx | 5 +---- src/packages/modules-operations/document/edition/edition.jsx | 4 +--- src/packages/modules-operations/families/edition/index.jsx | 5 +---- src/packages/modules-operations/families/index.tsx | 2 +- src/packages/modules-operations/indicators/edition/index.jsx | 5 +---- src/packages/modules-operations/operations/edition/index.tsx | 5 +---- src/packages/modules-operations/series/edition/index.jsx | 5 +---- .../modules-structures/components/component-detail/edit.jsx | 2 +- 15 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/packages/modules-codelists/components/codelist-detail/edit.jsx b/src/packages/modules-codelists/components/codelist-detail/edit.jsx index 1d1ca4fdf..d2272b235 100644 --- a/src/packages/modules-codelists/components/codelist-detail/edit.jsx +++ b/src/packages/modules-codelists/components/codelist-detail/edit.jsx @@ -40,7 +40,7 @@ export const DumbCodelistDetailEdit = ({ const [clientSideErrors, setClientSideErrors] = useState({}); const [submitting, setSubmitting] = useState(false); - useTitle(D.codelistsTitle, codelist?.labelLg1 || D.codelistsCreateTitle); + useTitle(D.codelistsTitle, codelist?.labelLg1); const permission = usePermission(); const stamp = permission?.stamp; diff --git a/src/packages/modules-codelists/components/codelist-partial-detail/edit.jsx b/src/packages/modules-codelists/components/codelist-partial-detail/edit.jsx index e76856db0..cf803fe56 100644 --- a/src/packages/modules-codelists/components/codelist-partial-detail/edit.jsx +++ b/src/packages/modules-codelists/components/codelist-partial-detail/edit.jsx @@ -43,10 +43,7 @@ export const DumbCodelistPartialDetailEdit = ({ const [clientSideErrors, setClientSideErrors] = useState({}); const [submitting, setSubmitting] = useState(false); - useTitle( - D.codelistsPartialTitle, - codelist?.labelLg1 || D.codelistsCreateTitle - ); + useTitle(D.codelistsPartialTitle, codelist?.labelLg1); const handleParentCode = useCallback( (code) => { diff --git a/src/packages/modules-concepts/collections/edition-creation/creation-container.jsx b/src/packages/modules-concepts/collections/edition-creation/creation-container.jsx index 4cfa7c1f7..90fefb71a 100644 --- a/src/packages/modules-concepts/collections/edition-creation/creation-container.jsx +++ b/src/packages/modules-concepts/collections/edition-creation/creation-container.jsx @@ -51,10 +51,7 @@ export const Component = () => { ); const { general, members } = collection; - useTitle( - D.collectionsTitle, - general?.prefLabelLg1 || D.createCollectionTitle - ); + useTitle(D.collectionsTitle, general?.prefLabelLg1); if (saving) { return ; diff --git a/src/packages/modules-concepts/collections/edition-creation/edition-container.jsx b/src/packages/modules-concepts/collections/edition-creation/edition-container.jsx index cb1ab5359..58c43235f 100644 --- a/src/packages/modules-concepts/collections/edition-creation/edition-container.jsx +++ b/src/packages/modules-concepts/collections/edition-creation/edition-container.jsx @@ -59,10 +59,7 @@ export const Component = () => { ); const { general, members } = collection; - useTitle( - D.collectionsTitle, - general?.prefLabelLg1 || D.createCollectionTitle - ); + useTitle(D.collectionsTitle, general?.prefLabelLg1); if (saving) { return ; diff --git a/src/packages/modules-concepts/edition-creation/creation-container.jsx b/src/packages/modules-concepts/edition-creation/creation-container.jsx index e666a4de7..87a357e26 100644 --- a/src/packages/modules-concepts/edition-creation/creation-container.jsx +++ b/src/packages/modules-concepts/edition-creation/creation-container.jsx @@ -48,7 +48,7 @@ export const Component = () => { const { general, notes, links } = concept; - useTitle(D.conceptsTitle, general?.prefLabelLg1 || D.createConceptTitle); + useTitle(D.conceptsTitle, general?.prefLabelLg1); const conceptsWithLinks = mergeWithAllConcepts(concepts, links); diff --git a/src/packages/modules-concepts/edition-creation/edition-container.jsx b/src/packages/modules-concepts/edition-creation/edition-container.jsx index aef6bc570..8fcffcbf9 100644 --- a/src/packages/modules-concepts/edition-creation/edition-container.jsx +++ b/src/packages/modules-concepts/edition-creation/edition-container.jsx @@ -78,7 +78,7 @@ export const Component = () => { const { general, notes, links } = concept; - useTitle(D.conceptsTitle, general?.prefLabelLg1 || D.createConceptTitle); + useTitle(D.conceptsTitle, general?.prefLabelLg1); const conceptsWithLinks = mergeWithAllConcepts(concepts, links ?? []); diff --git a/src/packages/modules-datasets/datasets/edit/edit.jsx b/src/packages/modules-datasets/datasets/edit/edit.jsx index 9f36765b8..bb7d47684 100644 --- a/src/packages/modules-datasets/datasets/edit/edit.jsx +++ b/src/packages/modules-datasets/datasets/edit/edit.jsx @@ -84,7 +84,7 @@ export const Component = () => { }, }); - useTitle(D.datasetsTitle, editingDataset?.labelLg1 || D.datasetsCreateTitle); + useTitle(D.datasetsTitle, editingDataset?.labelLg1); if (!editingDataset.id && isEditing) { return ; diff --git a/src/packages/modules-datasets/distributions/edit.jsx b/src/packages/modules-datasets/distributions/edit.jsx index 5796a17f8..ad88f2a18 100644 --- a/src/packages/modules-datasets/distributions/edit.jsx +++ b/src/packages/modules-datasets/distributions/edit.jsx @@ -72,10 +72,7 @@ export const Component = () => { }, }); - useTitle( - D.distributionsTitle, - editingDistribution?.labelLg1 || D.distributionsCreateTitle - ); + useTitle(D.distributionsTitle, editingDistribution?.labelLg1); if (!distribution && isEditing) { return ; diff --git a/src/packages/modules-operations/document/edition/edition.jsx b/src/packages/modules-operations/document/edition/edition.jsx index 8265dde32..455190a39 100644 --- a/src/packages/modules-operations/document/edition/edition.jsx +++ b/src/packages/modules-operations/document/edition/edition.jsx @@ -73,9 +73,7 @@ const OperationsDocumentationEdition = (props) => { useTitle( type === LINK ? D.titleLink : D.titleDocument, - props.document.labelLg1 || type === LINK - ? D.linksCreateTitle - : D.documentsCreateTitle + props.document.labelLg1 ); const goBack = useGoBack(); diff --git a/src/packages/modules-operations/families/edition/index.jsx b/src/packages/modules-operations/families/edition/index.jsx index 18e87aee4..e887c2c5e 100644 --- a/src/packages/modules-operations/families/edition/index.jsx +++ b/src/packages/modules-operations/families/edition/index.jsx @@ -19,10 +19,7 @@ export const Component = () => { } }, [id]); - useTitle( - D.familiesTitle + ' - ' + D.operationsTitle, - family?.prefLabelLg1 || D.familiesCreateTitle - ); + useTitle(D.familiesTitle + ' - ' + D.operationsTitle, family?.prefLabelLg1); if (!family.id && id) return ; return ; diff --git a/src/packages/modules-operations/families/index.tsx b/src/packages/modules-operations/families/index.tsx index 8d6d39738..fd284f68a 100644 --- a/src/packages/modules-operations/families/index.tsx +++ b/src/packages/modules-operations/families/index.tsx @@ -24,7 +24,7 @@ export const Component = () => { title={D.familiesSearchTitle} childPath="operations/family" searchURL="/operations/families/search" - createButton={} + createButton={} /> ); }; diff --git a/src/packages/modules-operations/indicators/edition/index.jsx b/src/packages/modules-operations/indicators/edition/index.jsx index b36ce5dae..0932b5f8c 100644 --- a/src/packages/modules-operations/indicators/edition/index.jsx +++ b/src/packages/modules-operations/indicators/edition/index.jsx @@ -38,10 +38,7 @@ export const Component = (props) => { OperationsApi.getSeriesList().then((payload) => setSeries(payload)); }, []); - useTitle( - D.indicatorsTitle, - indicator?.prefLabelLg1 || D.indicatorsCreateTitle - ); + useTitle(D.indicatorsTitle, indicator?.prefLabelLg1); if (!indicator.id && id) return ; diff --git a/src/packages/modules-operations/operations/edition/index.tsx b/src/packages/modules-operations/operations/edition/index.tsx index 72c15cd56..d25d82b74 100644 --- a/src/packages/modules-operations/operations/edition/index.tsx +++ b/src/packages/modules-operations/operations/edition/index.tsx @@ -30,10 +30,7 @@ export const Component = () => { ); }, [stamp]); - useTitle( - D.operationsTitle, - operation?.prefLabelLg1 || D.operationsCreateTitle - ); + useTitle(D.operationsTitle, operation?.prefLabelLg1); if (!operation?.id && id) return ; diff --git a/src/packages/modules-operations/series/edition/index.jsx b/src/packages/modules-operations/series/edition/index.jsx index 99920a380..54b761b7d 100644 --- a/src/packages/modules-operations/series/edition/index.jsx +++ b/src/packages/modules-operations/series/edition/index.jsx @@ -46,10 +46,7 @@ export const Component = (props) => { OperationsApi.getSeriesList().then((results) => setSeries(results)); }, []); - useTitle( - D.seriesTitle + ' - ' + D.operationsTitle, - serie?.prefLabelLg1 || D.seriesCreateTitle - ); + useTitle(D.seriesTitle + ' - ' + D.operationsTitle, serie?.prefLabelLg1); if (!serie.id && id) return ; diff --git a/src/packages/modules-structures/components/component-detail/edit.jsx b/src/packages/modules-structures/components/component-detail/edit.jsx index 616665d26..264562189 100644 --- a/src/packages/modules-structures/components/component-detail/edit.jsx +++ b/src/packages/modules-structures/components/component-detail/edit.jsx @@ -182,7 +182,7 @@ export const DumbComponentDetailEdit = ({ const [submitting, setSubmitting] = useState(false); const { lg1, lg2 } = useAppContext(); - useTitle(D.componentTitle, component?.labelLg1 || D.componentsCreateTitle); + useTitle(D.componentTitle, component?.labelLg1); const permission = usePermission(); const stamp = permission?.stamp;