From 45ac291d05d23cc8b08b66d9023ad13704052feb Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 9 Jul 2021 08:43:07 +0200 Subject: [PATCH 01/35] fix: solve ESLint issues --- .../operations/indicators/edition/index.js | 7 ++++--- app/src/js/applications/operations/routes/sims.js | 2 +- .../operations/series/edition/index.js | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/js/applications/operations/indicators/edition/index.js b/app/src/js/applications/operations/indicators/edition/index.js index 81680c8ad..2005471bd 100644 --- a/app/src/js/applications/operations/indicators/edition/index.js +++ b/app/src/js/applications/operations/indicators/edition/index.js @@ -12,11 +12,12 @@ import { CL_FREQ } from 'js/actions/constants/codeList'; const extractId = buildExtract('id'); const OperationsIndicatorsEditionContainer = (props) => { + const { indicator, id, loadIndicator } = props; useEffect(() => { - if (!props.indicator.id && props.id) { - props.loadIndicator(props.id); + if (!indicator.id && id) { + loadIndicator(id); } - }, [props.indicator, props.id, props.loadIndicator]) + }, [indicator, id, loadIndicator]) if (!props.indicator.id && props.id) return ; return ; diff --git a/app/src/js/applications/operations/routes/sims.js b/app/src/js/applications/operations/routes/sims.js index 3ec05aa65..37a3cb464 100644 --- a/app/src/js/applications/operations/routes/sims.js +++ b/app/src/js/applications/operations/routes/sims.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Switch, Route, Redirect } from 'react-router-dom'; +import { Switch, Route } from 'react-router-dom'; import MSDContainer, { CREATE, VIEW, diff --git a/app/src/js/applications/operations/series/edition/index.js b/app/src/js/applications/operations/series/edition/index.js index 5fe8b8aee..24e1226ff 100644 --- a/app/src/js/applications/operations/series/edition/index.js +++ b/app/src/js/applications/operations/series/edition/index.js @@ -13,18 +13,18 @@ const extractId = buildExtract('id'); const OperationsSeriesEditionContainer = props => { - + const { loadFamiliesList, statusFamilies, serie, id, loadSerie } = props; useEffect(() => { - if (!props.statusFamilies !== LOADED) { - props.loadFamiliesList(); + if (!statusFamilies !== LOADED) { + loadFamiliesList(); } - }, [props.loadFamiliesList, props.statusFamilies]) + }, [loadFamiliesList, statusFamilies]) useEffect(() => { - if (!props.serie.id && props.id) { - props.loadSerie(props.id); + if (!serie.id && id) { + loadSerie(id); } - }, [props.loadSerie, props.id, props.serie]) + }, [loadSerie, id, serie]) if (!props.serie.id && props.id) return ; return ; From 2bfcfac18a122caaa2fbf66a802ee690316dd3d3 Mon Sep 17 00:00:00 2001 From: BulotF Date: Fri, 16 Jul 2021 18:08:22 +0200 Subject: [PATCH 02/35] improve labels + sort codes by id + try of tree --- packages/codelists/package.json | 3 +- .../src/components/codelist-detail/edit.js | 6 ++-- .../src/components/codelist-detail/view.js | 24 ++++++++++---- packages/codelists/src/i18n/dictionary.js | 32 ++++++++++++++----- packages/codelists/src/utils/index.js | 24 ++++++++++++++ 5 files changed, 71 insertions(+), 18 deletions(-) diff --git a/packages/codelists/package.json b/packages/codelists/package.json index 5c3e4e8dd..b346a2f7e 100644 --- a/packages/codelists/package.json +++ b/packages/codelists/package.json @@ -28,6 +28,7 @@ "dependencies": { "bauhaus-utilities": "^0.0.0", "react-is": "^16.13.1", - "react-sliding-side-panel": "^1.0.14" + "react-sliding-side-panel": "^1.0.14", + "react-sortable-tree": "2.1.0" } } diff --git a/packages/codelists/src/components/codelist-detail/edit.js b/packages/codelists/src/components/codelist-detail/edit.js index c53907004..dcd64b574 100644 --- a/packages/codelists/src/components/codelist-detail/edit.js +++ b/packages/codelists/src/components/codelist-detail/edit.js @@ -129,7 +129,7 @@ const DumbCodelistDetailEdit = ({
- + {D1.creator} (a.code > b.code ? 1 : -1)); + return ( @@ -99,12 +105,16 @@ export const CodeListDetailView = ({ {codelist.codes && (
- } + text={} + title={D.listElements} + alone={true} + /> + + )} + {codelist.codes && ( +
+ } title={D.listElements} alone={true} /> diff --git a/packages/codelists/src/i18n/dictionary.js b/packages/codelists/src/i18n/dictionary.js index 00f3ae344..e9fc506cd 100644 --- a/packages/codelists/src/i18n/dictionary.js +++ b/packages/codelists/src/i18n/dictionary.js @@ -45,12 +45,12 @@ const dictionary = { en: 'Creator', }, labelTitle: { - fr: 'Libellé', - en: 'Label', + fr: 'Libellé (fr)', + en: 'Label (en)', }, descriptionTitle: { - fr: 'Description', - en: 'Description', + fr: 'Description (fr)', + en: 'Description (en)', }, listElements: { fr: 'Eléments', @@ -61,12 +61,12 @@ const dictionary = { en: 'Codes', }, codeLabel: { - fr: 'Libellé', - en: 'Label', + fr: 'Libellé (fr)', + en: 'Label (en)', }, codeDescription: { - fr: 'Description', - en: 'Description', + fr: 'Description (fr)', + en: 'Description (en)', }, statusValidatedM: { fr: 'Publié', @@ -108,10 +108,26 @@ const dictionary = { fr: "L'identifiant est obligatoire", en: 'The id is mandatory', }, + lastListUriSegmentMandatory: { + fr: "L'URI de la liste est obligatoire", + en: 'The list URI is mandatory', + }, + lastClassUriSegmentMandatory: { + fr: "L'URI du concept est obligatoire", + en: 'The concept URI is mandatory', + }, errorsLabelLg1Mandatory: { fr: 'Le label est obligatoire', en: 'The label is mandatory', }, + errorsCreatorMandatory: { + fr: 'Le propriétaire est obligatoire', + en: 'The creator is mandatory', + }, + errorsDisseminationStatusMandatory: { + fr: 'Le statut de diffusion est obligatoire', + en: 'The dissemination status is mandatory', + }, errors_1100: { fr: "L'identifiant n'est pas défini.", en: 'The identifiant is not defined.', diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 8247aa631..7b6b3356f 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -1,4 +1,5 @@ import React from 'react'; +import { getTreeFromFlatData } from 'react-sortable-tree'; import D from '../i18n/build-dictionary'; export const formatLabel = (component) => { @@ -8,8 +9,12 @@ export const formatLabel = (component) => { export const validateCodelist = (component) => { const validations = { id: 'errorsIdMandatory', + lastListUriSegment: 'lastListUriSegmentMandatory', + lastClassUriSegment: 'lastClassUriSegmentMandatory', labelLg1: 'errorsLabelLg1Mandatory', labelLg2: 'errorsLabelLg1Mandatory', + creator: 'errorsCreatorMandatory', + disseminationStatus: 'errorsDisseminationStatusMandatory', }; const field = Object.keys(validations).find((field) => !component[field]); @@ -23,3 +28,22 @@ export const validateCodelist = (component) => { return {}; }; + +export const treedData = (arrayData) => { + return ( + /* (arrayData.length !== 0 && */ + getTreeFromFlatData({ + flatData: arrayData.map((n) => ({ + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents ? n.parents[0] : 'root', + })), + getKey: (node) => node.id, + getParentKey: (node) => node.parent, + rootKey: 'root', + }) + /* ) || + [] */ + ); +}; From f91c05aa7a01f0bf44eb64e8107edf05f9c1ab9a Mon Sep 17 00:00:00 2001 From: BulotF Date: Mon, 19 Jul 2021 18:12:02 +0200 Subject: [PATCH 03/35] view codes tree (with CSS problem) --- .../src/components/codelist-detail/view.js | 10 ++++-- packages/codelists/src/utils/index.js | 28 +++++++-------- packages/codelists/src/utils/tree/index.js | 36 +++++++++++++++++++ 3 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 packages/codelists/src/utils/tree/index.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 1643732a5..e6f929c54 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -1,6 +1,4 @@ import React from 'react'; -import SortableTree from 'react-sortable-tree'; -import 'react-sortable-tree/style.css'; import { Note, UpdateButton, @@ -17,6 +15,7 @@ import { } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import { treedData } from '../../utils'; +import RmesTree from '../../utils/tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { rowParams } from './code-detail'; @@ -114,7 +113,12 @@ export const CodeListDetailView = ({ {codelist.codes && (
} + text={ + `item/${id}`} + /> + } title={D.listElements} alone={true} /> diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 7b6b3356f..bcac036de 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -30,20 +30,16 @@ export const validateCodelist = (component) => { }; export const treedData = (arrayData) => { - return ( - /* (arrayData.length !== 0 && */ - getTreeFromFlatData({ - flatData: arrayData.map((n) => ({ - id: n.code, - //title: '', - label: n.labelLg1, - parent: n.parents ? n.parents[0] : 'root', - })), - getKey: (node) => node.id, - getParentKey: (node) => node.parent, - rootKey: 'root', - }) - /* ) || - [] */ - ); + if (arrayData.length === 0) return []; + return getTreeFromFlatData({ + flatData: arrayData.map((n) => ({ + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents ? n.parents[0] : null, + })), + getKey: (node) => node.id, + getParentKey: (node) => node.parent, + rootKey: null, + }); }; diff --git a/packages/codelists/src/utils/tree/index.js b/packages/codelists/src/utils/tree/index.js new file mode 100644 index 000000000..30ef1dce0 --- /dev/null +++ b/packages/codelists/src/utils/tree/index.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; +import SortableTree from 'react-sortable-tree'; +import 'react-sortable-tree/style.css'; + +export default class RmesTree extends Component { + constructor(props) { + super(props); + this.state = { treeData: props.treeData }; + } + + componentWillReceiveProps({ treeData }) { + if (treeData !== this.props.treeData) this.setState({ treeData }); + } + + render() { + const { treeData } = this.state; + const { canDrag, linkPath } = this.props; + + return ( +
+ this.setState({ treeData })} + canDrag={canDrag || false} + canDrop={() => false} + generateNodeProps={(rowInfo) => ({ + buttons: [ + {rowInfo.node.label}, + ], + })} + /> +
+ ); + } +} From a6a98d4567371a5a6b5d1b74f559127f843d4e87 Mon Sep 17 00:00:00 2001 From: BulotF Date: Wed, 21 Jul 2021 18:15:09 +0200 Subject: [PATCH 04/35] show tree when treed codes --- .../src/components/codelist-detail/view.js | 4 +-- .../codelists/src/components/tree/index.js | 28 +++++++++++++++ packages/codelists/src/utils/index.js | 33 +++++++++++++++-- packages/codelists/src/utils/tree/index.js | 36 ------------------- 4 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 packages/codelists/src/components/tree/index.js delete mode 100644 packages/codelists/src/utils/tree/index.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index e6f929c54..853305cdf 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -15,7 +15,7 @@ import { } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import { treedData } from '../../utils'; -import RmesTree from '../../utils/tree'; +import RmesTree from '../tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { rowParams } from './code-detail'; @@ -110,7 +110,7 @@ export const CodeListDetailView = ({ />
)} - {codelist.codes && ( + {codelist.codes && sortedCodes.filter((code) => code.parents).length > 0 && (
{ + const [treeData, setTreeData] = useState(props.treeData); + + return ( +
+ setTreeData(treeData)} + canDrag={() => false} + canDrop={() => false} + generateNodeProps={(rowInfo) => ({ + buttons: [ + + {rowInfo.node.label} + , + ], + })} + /> +
+ ); +}; + +export default RmesTree; diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index bcac036de..568de86e4 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -29,15 +29,42 @@ export const validateCodelist = (component) => { return {}; }; +const treeElement = (n) => { + if (n.parents) { + /* return n.parents.map((p) => ({ + id: p || '_-_' || n.code, + //title: '', + label: n.labelLg1, + parent: p, + })); */ + return { + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents[0], + }; + } + return { + id: n.code, + //title: '', + label: n.labelLg1, + parent: null, + }; +}; + export const treedData = (arrayData) => { if (arrayData.length === 0) return []; - return getTreeFromFlatData({ - flatData: arrayData.map((n) => ({ + console.log(arrayData.map((n) => treeElement(n))); + console.log( + arrayData.map((n) => ({ id: n.code, //title: '', label: n.labelLg1, parent: n.parents ? n.parents[0] : null, - })), + })) + ); + return getTreeFromFlatData({ + flatData: arrayData.map((n) => treeElement(n)), getKey: (node) => node.id, getParentKey: (node) => node.parent, rootKey: null, diff --git a/packages/codelists/src/utils/tree/index.js b/packages/codelists/src/utils/tree/index.js deleted file mode 100644 index 30ef1dce0..000000000 --- a/packages/codelists/src/utils/tree/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; -import SortableTree from 'react-sortable-tree'; -import 'react-sortable-tree/style.css'; - -export default class RmesTree extends Component { - constructor(props) { - super(props); - this.state = { treeData: props.treeData }; - } - - componentWillReceiveProps({ treeData }) { - if (treeData !== this.props.treeData) this.setState({ treeData }); - } - - render() { - const { treeData } = this.state; - const { canDrag, linkPath } = this.props; - - return ( -
- this.setState({ treeData })} - canDrag={canDrag || false} - canDrop={() => false} - generateNodeProps={(rowInfo) => ({ - buttons: [ - {rowInfo.node.label}, - ], - })} - /> -
- ); - } -} From 11036e28f6d7471ff1d5484d13370dc25ef5e8b2 Mon Sep 17 00:00:00 2001 From: BulotF Date: Thu, 22 Jul 2021 11:40:58 +0200 Subject: [PATCH 05/35] allow multiple-parent code in the tree --- ...{code-detail.js => code-detail-columns.js} | 0 .../src/components/codelist-detail/view.js | 2 +- packages/codelists/src/utils/index.js | 23 ++++--------------- 3 files changed, 5 insertions(+), 20 deletions(-) rename packages/codelists/src/components/codelist-detail/{code-detail.js => code-detail-columns.js} (100%) diff --git a/packages/codelists/src/components/codelist-detail/code-detail.js b/packages/codelists/src/components/codelist-detail/code-detail-columns.js similarity index 100% rename from packages/codelists/src/components/codelist-detail/code-detail.js rename to packages/codelists/src/components/codelist-detail/code-detail-columns.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 853305cdf..5ce94518f 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -17,7 +17,7 @@ import PropTypes from 'prop-types'; import { treedData } from '../../utils'; import RmesTree from '../tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; -import { rowParams } from './code-detail'; +import { rowParams } from './code-detail-columns'; export const CodeListDetailView = ({ codelist, diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 568de86e4..a750e8a59 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -31,18 +31,12 @@ export const validateCodelist = (component) => { const treeElement = (n) => { if (n.parents) { - /* return n.parents.map((p) => ({ - id: p || '_-_' || n.code, - //title: '', - label: n.labelLg1, - parent: p, - })); */ - return { + return n.parents.map((p) => ({ id: n.code, //title: '', label: n.labelLg1, - parent: n.parents[0], - }; + parent: p, + })); } return { id: n.code, @@ -54,17 +48,8 @@ const treeElement = (n) => { export const treedData = (arrayData) => { if (arrayData.length === 0) return []; - console.log(arrayData.map((n) => treeElement(n))); - console.log( - arrayData.map((n) => ({ - id: n.code, - //title: '', - label: n.labelLg1, - parent: n.parents ? n.parents[0] : null, - })) - ); return getTreeFromFlatData({ - flatData: arrayData.map((n) => treeElement(n)), + flatData: arrayData.map((n) => treeElement(n)).flat(), getKey: (node) => node.id, getParentKey: (node) => node.parent, rootKey: null, From f84c6147d71454ffa9119ede2633504425bb1b6f Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 23 Jul 2021 10:50:51 +0200 Subject: [PATCH 06/35] fix: solve type when fetching families when creating series --- app/src/js/applications/operations/series/edition/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/js/applications/operations/series/edition/index.js b/app/src/js/applications/operations/series/edition/index.js index 24e1226ff..e70754f81 100644 --- a/app/src/js/applications/operations/series/edition/index.js +++ b/app/src/js/applications/operations/series/edition/index.js @@ -15,7 +15,7 @@ const extractId = buildExtract('id'); const OperationsSeriesEditionContainer = props => { const { loadFamiliesList, statusFamilies, serie, id, loadSerie } = props; useEffect(() => { - if (!statusFamilies !== LOADED) { + if (statusFamilies !== LOADED) { loadFamiliesList(); } }, [loadFamiliesList, statusFamilies]) From 9d752cd7b8c5495f2a4f0d8e4b3d84e461c31f5e Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 27 Jul 2021 16:47:11 +0200 Subject: [PATCH 07/35] feat: add lang and date to documents and links --- .../js/applications/operations/document/home.js | 14 +++++++++++++- .../js/applications/operations/document/index.js | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/js/applications/operations/document/home.js b/app/src/js/applications/operations/document/home.js index a80c5e4ce..6b10efcd6 100644 --- a/app/src/js/applications/operations/document/home.js +++ b/app/src/js/applications/operations/document/home.js @@ -30,10 +30,22 @@ const SearchableList = ({ ); const hits = items.filter(filter(search)); + const formatter = content => { + const extraInformations = [] + if(content.lang){ + extraInformations.push(content.lang); + } + if(content.updatedDate){ + + const [year, month, day] = content.updatedDate.split('-'); + extraInformations.push(`${day}/${month}/${year}`); + } + return `${content[label]} ${extraInformations.length > 0 ? `(${extraInformations.join(' - ')})` : ''}`; + } const hitEls = hits.map((item) => (
  • - {itemFormatter(item[label], item)} + {formatter(item)}
  • )); diff --git a/app/src/js/applications/operations/document/index.js b/app/src/js/applications/operations/document/index.js index fb165ccef..11a7721c1 100644 --- a/app/src/js/applications/operations/document/index.js +++ b/app/src/js/applications/operations/document/index.js @@ -33,6 +33,8 @@ export const mapStateToProps = state => { id: document.id, label: document.labelLg1 || document.labelLg2, uri: document.uri, + lang: document.lang, + updatedDate: document.updatedDate }; }) ), From 04e350d96babf04a6d35c5cd4a4597f1db6ed446 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 4 Aug 2021 13:42:54 +0200 Subject: [PATCH 08/35] fix: solve issue with Open ID Connect --- .../auth/open-id-connect-auth/login-container.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/js/applications/auth/open-id-connect-auth/login-container.js b/app/src/js/applications/auth/open-id-connect-auth/login-container.js index ca08b45ab..27d146512 100644 --- a/app/src/js/applications/auth/open-id-connect-auth/login-container.js +++ b/app/src/js/applications/auth/open-id-connect-auth/login-container.js @@ -1,4 +1,4 @@ -import React, { useEffect, useCallback } from 'react'; +import React, { useEffect, useCallback, useState } from 'react'; import { connect } from 'react-redux'; import { useHistory } from 'react-router-dom'; import Keycloak from 'keycloak'; @@ -10,6 +10,7 @@ const kcConfig = `${window.location.origin}/keycloak.json`; const kc = Keycloak(kcConfig); const LoginOpenIDConnect = ({ saveUserProps, authenticated, WrappedComponent }) => { + const [token, setToken] = useState(Auth.getToken()) const history = useHistory() const refreshToken = useCallback(() => { kc @@ -42,7 +43,10 @@ const LoginOpenIDConnect = ({ saveUserProps, authenticated, WrappedComponent }) saveUserProps( Auth.getAuthPropsFromToken(kc.tokenParsed) ); - kc.token && Auth.setToken(kc.token); + if(kc.token) { + Auth.setToken(kc.token); + setToken(kc.token) + } setInterval(() => refreshToken(), 20000); history.push({ pathname: history.location.pathname, state: 'init' }); }) @@ -53,7 +57,6 @@ const LoginOpenIDConnect = ({ saveUserProps, authenticated, WrappedComponent }) initLogin(); }, [initLogin]) - const token = Auth.getToken(); if (authenticated && token && Auth.isTokenValid(token)) return ; return ; From bf492b55141805fa4dfdbb52f552694f0deb71af Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 4 Aug 2021 13:51:21 +0200 Subject: [PATCH 09/35] Revert "allow multiple-parent code in the tree" This reverts commit 11036e28f6d7471ff1d5484d13370dc25ef5e8b2. --- ...{code-detail-columns.js => code-detail.js} | 0 .../src/components/codelist-detail/view.js | 2 +- packages/codelists/src/utils/index.js | 23 +++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) rename packages/codelists/src/components/codelist-detail/{code-detail-columns.js => code-detail.js} (100%) diff --git a/packages/codelists/src/components/codelist-detail/code-detail-columns.js b/packages/codelists/src/components/codelist-detail/code-detail.js similarity index 100% rename from packages/codelists/src/components/codelist-detail/code-detail-columns.js rename to packages/codelists/src/components/codelist-detail/code-detail.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 5ce94518f..853305cdf 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -17,7 +17,7 @@ import PropTypes from 'prop-types'; import { treedData } from '../../utils'; import RmesTree from '../tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; -import { rowParams } from './code-detail-columns'; +import { rowParams } from './code-detail'; export const CodeListDetailView = ({ codelist, diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index a750e8a59..568de86e4 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -31,12 +31,18 @@ export const validateCodelist = (component) => { const treeElement = (n) => { if (n.parents) { - return n.parents.map((p) => ({ - id: n.code, + /* return n.parents.map((p) => ({ + id: p || '_-_' || n.code, //title: '', label: n.labelLg1, parent: p, - })); + })); */ + return { + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents[0], + }; } return { id: n.code, @@ -48,8 +54,17 @@ const treeElement = (n) => { export const treedData = (arrayData) => { if (arrayData.length === 0) return []; + console.log(arrayData.map((n) => treeElement(n))); + console.log( + arrayData.map((n) => ({ + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents ? n.parents[0] : null, + })) + ); return getTreeFromFlatData({ - flatData: arrayData.map((n) => treeElement(n)).flat(), + flatData: arrayData.map((n) => treeElement(n)), getKey: (node) => node.id, getParentKey: (node) => node.parent, rootKey: null, From 34e97c4e91d6a788e95a3bbfd8695a4de21a1f7c Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 4 Aug 2021 13:51:34 +0200 Subject: [PATCH 10/35] Revert "show tree when treed codes" This reverts commit a6a98d4567371a5a6b5d1b74f559127f843d4e87. --- .../src/components/codelist-detail/view.js | 4 +-- .../codelists/src/components/tree/index.js | 28 --------------- packages/codelists/src/utils/index.js | 33 ++--------------- packages/codelists/src/utils/tree/index.js | 36 +++++++++++++++++++ 4 files changed, 41 insertions(+), 60 deletions(-) delete mode 100644 packages/codelists/src/components/tree/index.js create mode 100644 packages/codelists/src/utils/tree/index.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 853305cdf..e6f929c54 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -15,7 +15,7 @@ import { } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import { treedData } from '../../utils'; -import RmesTree from '../tree'; +import RmesTree from '../../utils/tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { rowParams } from './code-detail'; @@ -110,7 +110,7 @@ export const CodeListDetailView = ({ />
    )} - {codelist.codes && sortedCodes.filter((code) => code.parents).length > 0 && ( + {codelist.codes && (
    { - const [treeData, setTreeData] = useState(props.treeData); - - return ( -
    - setTreeData(treeData)} - canDrag={() => false} - canDrop={() => false} - generateNodeProps={(rowInfo) => ({ - buttons: [ - - {rowInfo.node.label} - , - ], - })} - /> -
    - ); -}; - -export default RmesTree; diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 568de86e4..bcac036de 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -29,42 +29,15 @@ export const validateCodelist = (component) => { return {}; }; -const treeElement = (n) => { - if (n.parents) { - /* return n.parents.map((p) => ({ - id: p || '_-_' || n.code, - //title: '', - label: n.labelLg1, - parent: p, - })); */ - return { - id: n.code, - //title: '', - label: n.labelLg1, - parent: n.parents[0], - }; - } - return { - id: n.code, - //title: '', - label: n.labelLg1, - parent: null, - }; -}; - export const treedData = (arrayData) => { if (arrayData.length === 0) return []; - console.log(arrayData.map((n) => treeElement(n))); - console.log( - arrayData.map((n) => ({ + return getTreeFromFlatData({ + flatData: arrayData.map((n) => ({ id: n.code, //title: '', label: n.labelLg1, parent: n.parents ? n.parents[0] : null, - })) - ); - return getTreeFromFlatData({ - flatData: arrayData.map((n) => treeElement(n)), + })), getKey: (node) => node.id, getParentKey: (node) => node.parent, rootKey: null, diff --git a/packages/codelists/src/utils/tree/index.js b/packages/codelists/src/utils/tree/index.js new file mode 100644 index 000000000..30ef1dce0 --- /dev/null +++ b/packages/codelists/src/utils/tree/index.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; +import SortableTree from 'react-sortable-tree'; +import 'react-sortable-tree/style.css'; + +export default class RmesTree extends Component { + constructor(props) { + super(props); + this.state = { treeData: props.treeData }; + } + + componentWillReceiveProps({ treeData }) { + if (treeData !== this.props.treeData) this.setState({ treeData }); + } + + render() { + const { treeData } = this.state; + const { canDrag, linkPath } = this.props; + + return ( +
    + this.setState({ treeData })} + canDrag={canDrag || false} + canDrop={() => false} + generateNodeProps={(rowInfo) => ({ + buttons: [ + {rowInfo.node.label}, + ], + })} + /> +
    + ); + } +} From 858528f7b1c15ac3da9c8e995a7af5d4f44aa001 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 4 Aug 2021 13:51:48 +0200 Subject: [PATCH 11/35] Revert "view codes tree (with CSS problem)" This reverts commit f91c05aa7a01f0bf44eb64e8107edf05f9c1ab9a. --- .../src/components/codelist-detail/view.js | 10 ++---- packages/codelists/src/utils/index.js | 28 ++++++++------- packages/codelists/src/utils/tree/index.js | 36 ------------------- 3 files changed, 19 insertions(+), 55 deletions(-) delete mode 100644 packages/codelists/src/utils/tree/index.js diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index e6f929c54..1643732a5 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -1,4 +1,6 @@ import React from 'react'; +import SortableTree from 'react-sortable-tree'; +import 'react-sortable-tree/style.css'; import { Note, UpdateButton, @@ -15,7 +17,6 @@ import { } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import { treedData } from '../../utils'; -import RmesTree from '../../utils/tree'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { rowParams } from './code-detail'; @@ -113,12 +114,7 @@ export const CodeListDetailView = ({ {codelist.codes && (
    `item/${id}`} - /> - } + text={} title={D.listElements} alone={true} /> diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index bcac036de..7b6b3356f 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -30,16 +30,20 @@ export const validateCodelist = (component) => { }; export const treedData = (arrayData) => { - if (arrayData.length === 0) return []; - return getTreeFromFlatData({ - flatData: arrayData.map((n) => ({ - id: n.code, - //title: '', - label: n.labelLg1, - parent: n.parents ? n.parents[0] : null, - })), - getKey: (node) => node.id, - getParentKey: (node) => node.parent, - rootKey: null, - }); + return ( + /* (arrayData.length !== 0 && */ + getTreeFromFlatData({ + flatData: arrayData.map((n) => ({ + id: n.code, + //title: '', + label: n.labelLg1, + parent: n.parents ? n.parents[0] : 'root', + })), + getKey: (node) => node.id, + getParentKey: (node) => node.parent, + rootKey: 'root', + }) + /* ) || + [] */ + ); }; diff --git a/packages/codelists/src/utils/tree/index.js b/packages/codelists/src/utils/tree/index.js deleted file mode 100644 index 30ef1dce0..000000000 --- a/packages/codelists/src/utils/tree/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import React, { Component } from 'react'; -import { Link } from 'react-router-dom'; -import SortableTree from 'react-sortable-tree'; -import 'react-sortable-tree/style.css'; - -export default class RmesTree extends Component { - constructor(props) { - super(props); - this.state = { treeData: props.treeData }; - } - - componentWillReceiveProps({ treeData }) { - if (treeData !== this.props.treeData) this.setState({ treeData }); - } - - render() { - const { treeData } = this.state; - const { canDrag, linkPath } = this.props; - - return ( -
    - this.setState({ treeData })} - canDrag={canDrag || false} - canDrop={() => false} - generateNodeProps={(rowInfo) => ({ - buttons: [ - {rowInfo.node.label}, - ], - })} - /> -
    - ); - } -} From 230aba96a62f6f71c68ffa54dbfc2fa1a0f60165 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 6 Aug 2021 15:32:25 +0200 Subject: [PATCH 12/35] feat: update packages --- package.json | 4 +- yarn.lock | 294 +++++++++++++++++++++++++++------------------------ 2 files changed, 160 insertions(+), 138 deletions(-) diff --git a/package.json b/package.json index 6604f2412..797d4e5f4 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,8 @@ "jest": "26.6.0", "jest-localstorage-mock": "2.4.3", "lcov-result-merger": "3.1.0", - "prettier": "2.0.5", - "webpack": "5.39.1" + "prettier": "2.3.2", + "webpack": "5.49.0" }, "dependencies": { "dompurify": "2.2.9", diff --git a/yarn.lock b/yarn.lock index 2cc0e279c..739d1fdd1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2633,10 +2633,10 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.48.tgz#18dc8091b285df90db2f25aa7d906cfc394b7f74" integrity sha512-LfZwXoGUDo0C3me81HXgkBg5CTQYb6xzEl+fNmbO4JdRiSKQ8A0GD1OBBvKAIsbCUgoyAty7m99GqqMQe784ew== -"@types/estree@^0.0.47": - version "0.0.47" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.47.tgz#d7a51db20f0650efec24cd04994f523d93172ed4" - integrity sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg== +"@types/estree@^0.0.50": + version "0.0.50" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83" + integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw== "@types/glob@^7.1.1": version "7.1.3" @@ -2711,6 +2711,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad" integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA== +"@types/json-schema@^7.0.8": + version "7.0.9" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" + integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== + "@types/json5@^0.0.29": version "0.0.29" resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" @@ -3005,13 +3010,13 @@ dependencies: eslint-visitor-keys "^1.1.0" -"@webassemblyjs/ast@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.0.tgz#a5aa679efdc9e51707a4207139da57920555961f" - integrity sha512-kX2W49LWsbthrmIRMbQZuQDhGtjyqXfEmmHyEi4XWnSZtPmxY0+3anPIzsnRb45VH/J55zlOfWvZuY47aJZTJg== +"@webassemblyjs/ast@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" + integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== dependencies: - "@webassemblyjs/helper-numbers" "1.11.0" - "@webassemblyjs/helper-wasm-bytecode" "1.11.0" + "@webassemblyjs/helper-numbers" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" "@webassemblyjs/ast@1.8.5": version "1.8.5" @@ -3031,10 +3036,10 @@ "@webassemblyjs/helper-wasm-bytecode" "1.9.0" "@webassemblyjs/wast-parser" "1.9.0" -"@webassemblyjs/floating-point-hex-parser@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.0.tgz#34d62052f453cd43101d72eab4966a022587947c" - integrity sha512-Q/aVYs/VnPDVYvsCBL/gSgwmfjeCb4LW8+TMrO3cSzJImgv8lxxEPM2JA5jMrivE7LSz3V+PFqtMbls3m1exDA== +"@webassemblyjs/floating-point-hex-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" + integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== "@webassemblyjs/floating-point-hex-parser@1.8.5": version "1.8.5" @@ -3046,10 +3051,10 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz#3c3d3b271bddfc84deb00f71344438311d52ffb4" integrity sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA== -"@webassemblyjs/helper-api-error@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.0.tgz#aaea8fb3b923f4aaa9b512ff541b013ffb68d2d4" - integrity sha512-baT/va95eXiXb2QflSx95QGT5ClzWpGaa8L7JnJbgzoYeaA27FCvuBXU758l+KXWRndEmUXjP0Q5fibhavIn8w== +"@webassemblyjs/helper-api-error@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" + integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== "@webassemblyjs/helper-api-error@1.8.5": version "1.8.5" @@ -3061,10 +3066,10 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz#203f676e333b96c9da2eeab3ccef33c45928b6a2" integrity sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw== -"@webassemblyjs/helper-buffer@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.0.tgz#d026c25d175e388a7dbda9694e91e743cbe9b642" - integrity sha512-u9HPBEl4DS+vA8qLQdEQ6N/eJQ7gT7aNvMIo8AAWvAl/xMrcOSiI2M0MAnMCy3jIFke7bEee/JwdX1nUpCtdyA== +"@webassemblyjs/helper-buffer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" + integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== "@webassemblyjs/helper-buffer@1.8.5": version "1.8.5" @@ -3115,19 +3120,19 @@ dependencies: "@webassemblyjs/ast" "1.9.0" -"@webassemblyjs/helper-numbers@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.0.tgz#7ab04172d54e312cc6ea4286d7d9fa27c88cd4f9" - integrity sha512-DhRQKelIj01s5IgdsOJMKLppI+4zpmcMQ3XboFPLwCpSNH6Hqo1ritgHgD0nqHeSYqofA6aBN/NmXuGjM1jEfQ== +"@webassemblyjs/helper-numbers@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" + integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.0" - "@webassemblyjs/helper-api-error" "1.11.0" + "@webassemblyjs/floating-point-hex-parser" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" "@xtuc/long" "4.2.2" -"@webassemblyjs/helper-wasm-bytecode@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.0.tgz#85fdcda4129902fe86f81abf7e7236953ec5a4e1" - integrity sha512-MbmhvxXExm542tWREgSFnOVo07fDpsBJg3sIl6fSp9xuu75eGz5lz31q7wTLffwL3Za7XNRCMZy210+tnsUSEA== +"@webassemblyjs/helper-wasm-bytecode@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" + integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== "@webassemblyjs/helper-wasm-bytecode@1.8.5": version "1.8.5" @@ -3139,15 +3144,15 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz#4fed8beac9b8c14f8c58b70d124d549dd1fe5790" integrity sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw== -"@webassemblyjs/helper-wasm-section@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.0.tgz#9ce2cc89300262509c801b4af113d1ca25c1a75b" - integrity sha512-3Eb88hcbfY/FCukrg6i3EH8H2UsD7x8Vy47iVJrP967A9JGqgBVL9aH71SETPx1JrGsOUVLo0c7vMCN22ytJew== +"@webassemblyjs/helper-wasm-section@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" + integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== dependencies: - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/helper-buffer" "1.11.0" - "@webassemblyjs/helper-wasm-bytecode" "1.11.0" - "@webassemblyjs/wasm-gen" "1.11.0" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" "@webassemblyjs/helper-wasm-section@1.8.5": version "1.8.5" @@ -3169,10 +3174,10 @@ "@webassemblyjs/helper-wasm-bytecode" "1.9.0" "@webassemblyjs/wasm-gen" "1.9.0" -"@webassemblyjs/ieee754@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.0.tgz#46975d583f9828f5d094ac210e219441c4e6f5cf" - integrity sha512-KXzOqpcYQwAfeQ6WbF6HXo+0udBNmw0iXDmEK5sFlmQdmND+tr773Ti8/5T/M6Tl/413ArSJErATd8In3B+WBA== +"@webassemblyjs/ieee754@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" + integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== dependencies: "@xtuc/ieee754" "^1.2.0" @@ -3190,10 +3195,10 @@ dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.0.tgz#f7353de1df38aa201cba9fb88b43f41f75ff403b" - integrity sha512-aqbsHa1mSQAbeeNcl38un6qVY++hh8OpCOzxhixSYgbRfNWcxJNJQwe2rezK9XEcssJbbWIkblaJRwGMS9zp+g== +"@webassemblyjs/leb128@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" + integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== dependencies: "@xtuc/long" "4.2.2" @@ -3211,10 +3216,10 @@ dependencies: "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.0.tgz#86e48f959cf49e0e5091f069a709b862f5a2cadf" - integrity sha512-A/lclGxH6SpSLSyFowMzO/+aDEPU4hvEiooCMXQPcQFPPJaYcPQNKGOCLUySJsYJ4trbpr+Fs08n4jelkVTGVw== +"@webassemblyjs/utf8@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" + integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== "@webassemblyjs/utf8@1.8.5": version "1.8.5" @@ -3226,19 +3231,19 @@ resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.0.tgz#04d33b636f78e6a6813227e82402f7637b6229ab" integrity sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w== -"@webassemblyjs/wasm-edit@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.0.tgz#ee4a5c9f677046a210542ae63897094c2027cb78" - integrity sha512-JHQ0damXy0G6J9ucyKVXO2j08JVJ2ntkdJlq1UTiUrIgfGMmA7Ik5VdC/L8hBK46kVJgujkBIoMtT8yVr+yVOQ== - dependencies: - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/helper-buffer" "1.11.0" - "@webassemblyjs/helper-wasm-bytecode" "1.11.0" - "@webassemblyjs/helper-wasm-section" "1.11.0" - "@webassemblyjs/wasm-gen" "1.11.0" - "@webassemblyjs/wasm-opt" "1.11.0" - "@webassemblyjs/wasm-parser" "1.11.0" - "@webassemblyjs/wast-printer" "1.11.0" +"@webassemblyjs/wasm-edit@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" + integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/helper-wasm-section" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-opt" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + "@webassemblyjs/wast-printer" "1.11.1" "@webassemblyjs/wasm-edit@1.8.5": version "1.8.5" @@ -3268,16 +3273,16 @@ "@webassemblyjs/wasm-parser" "1.9.0" "@webassemblyjs/wast-printer" "1.9.0" -"@webassemblyjs/wasm-gen@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.0.tgz#3cdb35e70082d42a35166988dda64f24ceb97abe" - integrity sha512-BEUv1aj0WptCZ9kIS30th5ILASUnAPEvE3tVMTrItnZRT9tXCLW2LEXT8ezLw59rqPP9klh9LPmpU+WmRQmCPQ== +"@webassemblyjs/wasm-gen@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" + integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== dependencies: - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/helper-wasm-bytecode" "1.11.0" - "@webassemblyjs/ieee754" "1.11.0" - "@webassemblyjs/leb128" "1.11.0" - "@webassemblyjs/utf8" "1.11.0" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" "@webassemblyjs/wasm-gen@1.8.5": version "1.8.5" @@ -3301,15 +3306,15 @@ "@webassemblyjs/leb128" "1.9.0" "@webassemblyjs/utf8" "1.9.0" -"@webassemblyjs/wasm-opt@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.0.tgz#1638ae188137f4bb031f568a413cd24d32f92978" - integrity sha512-tHUSP5F4ywyh3hZ0+fDQuWxKx3mJiPeFufg+9gwTpYp324mPCQgnuVKwzLTZVqj0duRDovnPaZqDwoyhIO8kYg== +"@webassemblyjs/wasm-opt@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" + integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== dependencies: - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/helper-buffer" "1.11.0" - "@webassemblyjs/wasm-gen" "1.11.0" - "@webassemblyjs/wasm-parser" "1.11.0" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" "@webassemblyjs/wasm-opt@1.8.5": version "1.8.5" @@ -3331,17 +3336,17 @@ "@webassemblyjs/wasm-gen" "1.9.0" "@webassemblyjs/wasm-parser" "1.9.0" -"@webassemblyjs/wasm-parser@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.0.tgz#3e680b8830d5b13d1ec86cc42f38f3d4a7700754" - integrity sha512-6L285Sgu9gphrcpDXINvm0M9BskznnzJTE7gYkjDbxET28shDqp27wpruyx3C2S/dvEwiigBwLA1cz7lNUi0kw== +"@webassemblyjs/wasm-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" + integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== dependencies: - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/helper-api-error" "1.11.0" - "@webassemblyjs/helper-wasm-bytecode" "1.11.0" - "@webassemblyjs/ieee754" "1.11.0" - "@webassemblyjs/leb128" "1.11.0" - "@webassemblyjs/utf8" "1.11.0" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" "@webassemblyjs/wasm-parser@1.8.5": version "1.8.5" @@ -3391,12 +3396,12 @@ "@webassemblyjs/helper-fsm" "1.9.0" "@xtuc/long" "4.2.2" -"@webassemblyjs/wast-printer@1.11.0": - version "1.11.0" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.0.tgz#680d1f6a5365d6d401974a8e949e05474e1fab7e" - integrity sha512-Fg5OX46pRdTgB7rKIUojkh9vXaVN6sGYCnEiJN1GYkb0RPwShZXp6KTDqmoMdQPKhcroOXh3fEzmkWmCYaKYhQ== +"@webassemblyjs/wast-printer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" + integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== dependencies: - "@webassemblyjs/ast" "1.11.0" + "@webassemblyjs/ast" "1.11.1" "@xtuc/long" "4.2.2" "@webassemblyjs/wast-printer@1.8.5": @@ -3468,6 +3473,11 @@ acorn-globals@^6.0.0: acorn "^7.1.1" acorn-walk "^7.1.1" +acorn-import-assertions@^1.7.6: + version "1.7.6" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz#580e3ffcae6770eebeec76c3b9723201e9d01f78" + integrity sha512-FlVvVFA1TX6l3lp8VjDnYYq7R1nyW6x3svAt4nDgrWQ9SBaSh9CnbwgSUTasgfNfOG5HlM1ehugCvM+hjo56LA== + acorn-jsx@^5.2.0, acorn-jsx@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" @@ -3498,11 +3508,16 @@ acorn@^7.1.1, acorn@^7.4.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.2.1, acorn@^8.2.4: +acorn@^8.2.4: version "8.4.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.0.tgz#af53266e698d7cffa416714b503066a82221be60" integrity sha512-ULr0LDaEqQrMFGyQ3bhJkLsbtrQ8QibAseGZeaSUiT/6zb9IvIkomWHJIvgvwad+hinRAgsI51JcWk2yvwyL+w== +acorn@^8.4.1: + version "8.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" + integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== + address@1.1.2, address@^1.0.1: version "1.1.2" resolved "https://registry.yarnpkg.com/address/-/address-1.1.2.tgz#bf1116c9c758c51b7a933d296b72c221ed9428b6" @@ -7027,10 +7042,10 @@ es-get-iterator@^1.0.2: is-string "^1.0.5" isarray "^2.0.5" -es-module-lexer@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.4.1.tgz#dda8c6a14d8f340a24e34331e0fab0cb50438e0e" - integrity sha512-ooYciCUtfw6/d2w56UVeqHPcoCFAiJdz5XOkYpv/Txl1HMUozpXjz/2RIQgqwKdXNDPSF1W7mJCFse3G+HDyAA== +es-module-lexer@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.7.1.tgz#c2c8e0f46f2df06274cdaf0dd3f3b33e0a0b267d" + integrity sha512-MgtWFl5No+4S3TmhDmCz2ObFGm6lEpTnzbQi+Dd+pw4mlTIZTmM2iAs5gRlmx5zS9luzobCSBSI90JM/1/JgOw== es-to-primitive@^1.2.1: version "1.2.1" @@ -14057,10 +14072,10 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= -prettier@2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" - integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== +prettier@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" + integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== pretty-bytes@5.3.0: version "5.3.0" @@ -15990,6 +16005,15 @@ schema-utils@^3.0.0: ajv "^6.12.5" ajv-keywords "^3.5.2" +schema-utils@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" + integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + scss-tokenizer@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1" @@ -16088,10 +16112,10 @@ serialize-javascript@^4.0.0: dependencies: randombytes "^2.1.0" -serialize-javascript@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" - integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== +serialize-javascript@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== dependencies: randombytes "^2.1.0" @@ -16378,7 +16402,7 @@ sort-keys@^1.0.0: dependencies: is-plain-obj "^1.0.0" -source-list-map@^2.0.0, source-list-map@^2.0.1: +source-list-map@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== @@ -17170,15 +17194,15 @@ terser-webpack-plugin@^2.1.2: terser "^4.6.12" webpack-sources "^1.4.3" -terser-webpack-plugin@^5.1.1: - version "5.1.3" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.1.3.tgz#30033e955ca28b55664f1e4b30a1347e61aa23af" - integrity sha512-cxGbMqr6+A2hrIB5ehFIF+F/iST5ZOxvOmy9zih9ySbP1C2oEWQSOUS+2SNBTjzx5xLKO4xnod9eywdfq1Nb9A== +terser-webpack-plugin@^5.1.3: + version "5.1.4" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.1.4.tgz#c369cf8a47aa9922bd0d8a94fe3d3da11a7678a1" + integrity sha512-C2WkFwstHDhVEmsmlCxrXUtVklS+Ir1A7twrYzrDrQQOIMOaVAYykaoo/Aq1K0QRkMoY2hhvDQY1cm4jnIMFwA== dependencies: jest-worker "^27.0.2" p-limit "^3.1.0" schema-utils "^3.0.0" - serialize-javascript "^5.0.1" + serialize-javascript "^6.0.0" source-map "^0.6.1" terser "^5.7.0" @@ -18233,13 +18257,10 @@ webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack- source-list-map "^2.0.0" source-map "~0.6.1" -webpack-sources@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.3.0.tgz#9ed2de69b25143a4c18847586ad9eccb19278cfa" - integrity sha512-WyOdtwSvOML1kbgtXbTDnEW0jkJ7hZr/bDByIwszhWd/4XX1A3XMkrbFMsuH4+/MfLlZCUzlAdg4r7jaGKEIgQ== - dependencies: - source-list-map "^2.0.1" - source-map "^0.6.1" +webpack-sources@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.0.tgz#b16973bcf844ebcdb3afde32eda1c04d0b90f89d" + integrity sha512-fahN08Et7P9trej8xz/Z7eRu8ltyiygEo/hnRi9KqBUs80KeDcnf96ZJo++ewWd84fEf3xSX9bp4ZS9hbw0OBw== webpack-virtual-modules@^0.2.0: version "0.2.2" @@ -18277,21 +18298,22 @@ webpack@4.42.0: watchpack "^1.6.0" webpack-sources "^1.4.1" -webpack@5.39.1: - version "5.39.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.39.1.tgz#d1e014b6d71e1aef385316ad528f21cd5b1f9784" - integrity sha512-ulOvoNCh2PvTUa+zbpRuEb1VPeQnhxpnHleMPVVCq3QqnaFogjsLyps+o42OviQFoaGtTQYrUqDXu1QNkvUPzw== +webpack@5.49.0: + version "5.49.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.49.0.tgz#e250362b781a9fb614ba0a97ed67c66b9c5310cd" + integrity sha512-XarsANVf28A7Q3KPxSnX80EkCcuOer5hTOEJWJNvbskOZ+EK3pobHarGHceyUZMxpsTHBHhlV7hiQyLZzGosYw== dependencies: "@types/eslint-scope" "^3.7.0" - "@types/estree" "^0.0.47" - "@webassemblyjs/ast" "1.11.0" - "@webassemblyjs/wasm-edit" "1.11.0" - "@webassemblyjs/wasm-parser" "1.11.0" - acorn "^8.2.1" + "@types/estree" "^0.0.50" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + acorn "^8.4.1" + acorn-import-assertions "^1.7.6" browserslist "^4.14.5" chrome-trace-event "^1.0.2" enhanced-resolve "^5.8.0" - es-module-lexer "^0.4.0" + es-module-lexer "^0.7.1" eslint-scope "5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" @@ -18300,11 +18322,11 @@ webpack@5.39.1: loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" - schema-utils "^3.0.0" + schema-utils "^3.1.0" tapable "^2.1.1" - terser-webpack-plugin "^5.1.1" + terser-webpack-plugin "^5.1.3" watchpack "^2.2.0" - webpack-sources "^2.3.0" + webpack-sources "^3.2.0" webpack@^4.33.0, webpack@^4.38.0: version "4.46.0" From b02ec4181387e417af8c255c51427291a81acb14 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 6 Aug 2021 15:32:57 +0200 Subject: [PATCH 13/35] fix: solve eslint issues --- .../codes-list-panel/codes-list-panel.js | 2 +- .../structure-component-selector/index.js | 1 - .../utilities/src/auth/components/auth.js | 2 +- .../actions/dissemination-status.action.js | 5 +++-- packages/utilities/src/utils/html-utils.js | 22 +------------------ 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/packages/structures/src/components/codes-list-panel/codes-list-panel.js b/packages/structures/src/components/codes-list-panel/codes-list-panel.js index 69e5243a4..94b32a6c7 100644 --- a/packages/structures/src/components/codes-list-panel/codes-list-panel.js +++ b/packages/structures/src/components/codes-list-panel/codes-list-panel.js @@ -18,7 +18,7 @@ export const CodesListPanelDumb = ({ isOpen, handleBack, codesList, getCodesList setCodes(sortByLabel(response.codes || [])) }); } - }, [codesList, isOpen]) + }, [codesList, isOpen, getCodesList]) return ( diff --git a/packages/structures/src/components/structure-component-selector/index.js b/packages/structures/src/components/structure-component-selector/index.js index 885c74764..3952e794b 100644 --- a/packages/structures/src/components/structure-component-selector/index.js +++ b/packages/structures/src/components/structure-component-selector/index.js @@ -10,7 +10,6 @@ import { ATTRIBUTE_PROPERTY_TYPE } from '../../utils/constants/dsd-components'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { Stores } from 'bauhaus-utilities'; -import { XSD_TYPES } from '../../utils/constants'; import Representation from '../representation'; export const StructureComponentsSelector = ({ diff --git a/packages/utilities/src/auth/components/auth.js b/packages/utilities/src/auth/components/auth.js index 73a71f545..df72ebc36 100644 --- a/packages/utilities/src/auth/components/auth.js +++ b/packages/utilities/src/auth/components/auth.js @@ -34,7 +34,7 @@ export function AuthDumb({ if(!userStamp && !isLoading){ loadUserStamp(userStamp); } - }, [userStamp, isLoading]) + }, [userStamp, isLoading, loadUserStamp]) const isAuthorized = !!roles.find((role) => { if(Array.isArray(role)){ const [r, check] = role diff --git a/packages/utilities/src/stores/actions/dissemination-status.action.js b/packages/utilities/src/stores/actions/dissemination-status.action.js index eee06d453..d551f1946 100644 --- a/packages/utilities/src/stores/actions/dissemination-status.action.js +++ b/packages/utilities/src/stores/actions/dissemination-status.action.js @@ -63,14 +63,15 @@ export const getDisseminationStatusListOptions = (state) => getDisseminationStat export const withDisseminationStatusListOptions = Component => { const componentWithDisseminationStatus = props => { + const { loadDisseminationStatusList } = props; // eslint-disable-next-line react-hooks/rules-of-hooks const disseminationStatusListOptions = useSelector(state => getDisseminationStatusListOptions(state)); // eslint-disable-next-line react-hooks/rules-of-hooks useEffect(() => { if(disseminationStatusListOptions.length === 0){ - props.loadDisseminationStatusList(); + loadDisseminationStatusList(); } - }, [disseminationStatusListOptions.length, props.loadDisseminationStatusList]); + }, [disseminationStatusListOptions.length, loadDisseminationStatusList]); return diff --git a/packages/utilities/src/utils/html-utils.js b/packages/utilities/src/utils/html-utils.js index bb9dcf185..0a47c4bcb 100644 --- a/packages/utilities/src/utils/html-utils.js +++ b/packages/utilities/src/utils/html-utils.js @@ -87,21 +87,6 @@ export function htmlFromEditorState(editorState) { export function editorStateFromHtml(html) { return EditorState.createWithContent(stateFromHTML(html)); } -function addNewLineAfter(str, regexp){ - return str.split('\n').reduce((acc, str, index, strings) => { - if(regexp.test(str) && !regexp.test(strings[index + 1]) && strings[index + 1]?.trim() !== ''){ - return [ - ...acc, - str, - '' - ] - } - return [ - ...acc, - str - ] - }, []) -} export function mdFromEditorState(editorState) { /* @@ -129,12 +114,7 @@ export function mdFromEditorState(editorState) { }) } } - let md = draftjsToMd(content); - - // Sometime the editor do not add a new line after un ordered and unordered lisr - // https://trello.com/c/t6jFYvMR/633-sims-rich-text - //md = addNewLineAfter(md,/^-\s/).join('\n'); - //md = addNewLineAfter(md, /^\d./).join('\n'); + const md = draftjsToMd(content); return md } From 42274c7006ddba3ca681a5809fe164b4fef76057 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Sat, 7 Aug 2021 14:06:55 +0200 Subject: [PATCH 14/35] fix: remove useless comment --- packages/codelists/src/utils/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 7b6b3356f..503813131 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -31,11 +31,9 @@ export const validateCodelist = (component) => { export const treedData = (arrayData) => { return ( - /* (arrayData.length !== 0 && */ getTreeFromFlatData({ flatData: arrayData.map((n) => ({ id: n.code, - //title: '', label: n.labelLg1, parent: n.parents ? n.parents[0] : 'root', })), @@ -43,7 +41,5 @@ export const treedData = (arrayData) => { getParentKey: (node) => node.parent, rootKey: 'root', }) - /* ) || - [] */ ); }; From 54b56aa4f91f3d077b83317b300d90eb1e9202db Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 9 Aug 2021 16:22:46 +0200 Subject: [PATCH 15/35] feat: add custom title --- .../applications/operations/document/home.js | 5 ++++- .../operations/families/edition/edition.js | 7 +++++-- .../applications/operations/families/home.js | 5 +++-- .../operations/indicators/home.js | 4 +++- .../operations/operations/home.js | 4 +++- .../js/applications/operations/series/home.js | 4 +++- .../i18n/dictionary/operations/documents.js | 4 ++++ .../js/i18n/dictionary/operations/index.js | 20 +++++++++++++++++++ packages/utilities/src/index.js | 1 + packages/utilities/src/utils/useTitle.js | 19 ++++++++++++++++++ 10 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 packages/utilities/src/utils/useTitle.js diff --git a/app/src/js/applications/operations/document/home.js b/app/src/js/applications/operations/document/home.js index 6b10efcd6..0bea14e42 100644 --- a/app/src/js/applications/operations/document/home.js +++ b/app/src/js/applications/operations/document/home.js @@ -10,7 +10,7 @@ import { } from '@inseefr/wilco'; import D from 'js/i18n'; import { BOTH, DOCUMENT, LINK, isLink, isDocument } from './utils'; -import { Auth, FilterToggleButtons } from 'bauhaus-utilities'; +import { Auth, FilterToggleButtons, useTitle } from 'bauhaus-utilities'; import { Link, useHistory } from 'react-router-dom'; const sessionStorageKey = 'documents-displayMode'; @@ -23,6 +23,7 @@ const SearchableList = ({ searchValue = '', itemFormatter = (content) => content, }) => { + const [search, handleSearch] = useState(searchValue); const filter = filterKeyDeburr( @@ -75,6 +76,8 @@ const SearchableList = ({ }; function DocumentHome({ documents }) { + useTitle(D.operationsTitle, D.documentsTitle) + const history = useHistory(); const queryMode = sessionStorage.getItem(sessionStorageKey); diff --git a/app/src/js/applications/operations/families/edition/edition.js b/app/src/js/applications/operations/families/edition/edition.js index c3183526e..7836da8f6 100644 --- a/app/src/js/applications/operations/families/edition/edition.js +++ b/app/src/js/applications/operations/families/edition/edition.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import { D1, D2 } from 'js/i18n'; import PropTypes from 'prop-types'; -import { EditorMarkdown, PageTitleBlock } from 'bauhaus-utilities'; +import { EditorMarkdown, PageTitleBlock, withTitle } from 'bauhaus-utilities'; import { CancelButton, SaveButton, @@ -13,6 +13,7 @@ import { LabelRequired, } from '@inseefr/wilco'; import { validate } from './validation'; +import D from '../../../../i18n/build-dictionary'; const defaultFamily = { prefLabelLg1: '', @@ -175,4 +176,6 @@ class OperationsFamilyEdition extends Component { } } -export default OperationsFamilyEdition; +export default withTitle(OperationsFamilyEdition, D.operationsTitle, props => { + return props.family.prefLabelLg1 || D.familiesCreateTitle +}); diff --git a/app/src/js/applications/operations/families/home.js b/app/src/js/applications/operations/families/home.js index 595454d2b..0007b1dd6 100644 --- a/app/src/js/applications/operations/families/home.js +++ b/app/src/js/applications/operations/families/home.js @@ -1,10 +1,11 @@ -import React from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import D from 'js/i18n'; -import { Auth } from 'bauhaus-utilities'; +import { Auth, useTitle } from 'bauhaus-utilities'; import OperationsObjectHome from 'js/applications/operations/shared/list'; function FamiliesHome({ families }) { + useTitle(D.operationsTitle, D.familiesTitle) return (
    diff --git a/app/src/js/applications/operations/operations/home.js b/app/src/js/applications/operations/operations/home.js index 4d794371b..47ca138e6 100644 --- a/app/src/js/applications/operations/operations/home.js +++ b/app/src/js/applications/operations/operations/home.js @@ -1,10 +1,12 @@ import React from 'react'; import PropTypes from 'prop-types'; import D from 'js/i18n'; -import { Auth } from 'bauhaus-utilities'; +import { Auth, useTitle } from 'bauhaus-utilities'; import OperationsObjectHome from 'js/applications/operations/shared/list'; function OperationsHome({ operations }) { + useTitle(D.operationsTitle, D.operationsTitle) + return ( { + document.title = page + ' - ' + application + ' - Bauhaus'; +} + +export const useTitle = (application, page) => { + useEffect(() => { + setDocumentTitle(application, page) + }, []) +} + +export const withTitle = (WrappedComponent, application, getPage = () => '') => props => { + const title = getPage(props); + useEffect(() => { + setDocumentTitle(application, title) + }, [title]) + return +}; From 7ac46b4e2ac825384e1bc7973a3f6c9b319b6af1 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 9 Aug 2021 16:38:19 +0200 Subject: [PATCH 16/35] feat: add title to Operation View Page --- .../operations/families/visualization/visualization.js | 7 +++++-- .../operations/indicators/visualization/general.js | 7 +++++-- .../operations/operations/visualization/home.js | 7 +++++-- .../applications/operations/series/visualization/home.js | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/js/applications/operations/families/visualization/visualization.js b/app/src/js/applications/operations/families/visualization/visualization.js index 1211b16a1..0c1324b53 100644 --- a/app/src/js/applications/operations/families/visualization/visualization.js +++ b/app/src/js/applications/operations/families/visualization/visualization.js @@ -3,7 +3,8 @@ import React from 'react'; import { Note } from '@inseefr/wilco'; import { D1, D2 } from 'js/i18n'; import RelationsView from 'js/applications/operations/shared/relations'; -import { HTMLUtils, PublicationFemale } from 'bauhaus-utilities'; +import { HTMLUtils, PublicationFemale, withTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; function OperationsFamilyVisualization({ attr, @@ -73,4 +74,6 @@ function OperationsFamilyVisualization({ ); } -export default OperationsFamilyVisualization; +export default withTitle(OperationsFamilyVisualization, D.operationsTitle, props => { + return props.attr?.prefLabelLg1; +}); diff --git a/app/src/js/applications/operations/indicators/visualization/general.js b/app/src/js/applications/operations/indicators/visualization/general.js index 3984e97d0..8d969ccf3 100644 --- a/app/src/js/applications/operations/indicators/visualization/general.js +++ b/app/src/js/applications/operations/indicators/visualization/general.js @@ -5,8 +5,9 @@ import { D1, D2 } from 'js/i18n'; import { getSeeAlsoByType } from 'js/applications/operations/shared/links/utils'; import DisplayLinks from 'js/applications/operations/shared/links/'; import SeeAlso from 'js/applications/operations/shared/seeAlso'; -import { HTMLUtils, PublicationMale } from 'bauhaus-utilities'; +import { HTMLUtils, PublicationMale, withTitle } from 'bauhaus-utilities'; import { PublishersView, CreatorsView } from 'bauhaus-operations'; +import D from '../../../../i18n/build-dictionary'; function DisplayMultiLangNote({ value1, @@ -136,4 +137,6 @@ function OperationsIndicatorVisualization(props) { ); } -export default OperationsIndicatorVisualization; +export default withTitle(OperationsIndicatorVisualization, D.operationsTitle, props => { + return props.attr?.prefLabelLg1; +}); diff --git a/app/src/js/applications/operations/operations/visualization/home.js b/app/src/js/applications/operations/operations/visualization/home.js index 49d87ab1e..fb64aa2c7 100644 --- a/app/src/js/applications/operations/operations/visualization/home.js +++ b/app/src/js/applications/operations/operations/visualization/home.js @@ -3,7 +3,8 @@ import PropTypes from 'prop-types'; import { Note } from '@inseefr/wilco'; import { D1, D2 } from 'js/i18n'; import RelationsView from 'js/applications/operations/shared/relations'; -import { PublicationFemale } from 'bauhaus-utilities'; +import { PublicationFemale, withTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; function OperationsOperationVisualization({ attr, @@ -59,4 +60,6 @@ OperationsOperationVisualization.propTypes = { attr: PropTypes.object.isRequired, }; -export default OperationsOperationVisualization; +export default withTitle(OperationsOperationVisualization, D.operationsTitle, props => { + return props.attr?.prefLabelLg1; +}); diff --git a/app/src/js/applications/operations/series/visualization/home.js b/app/src/js/applications/operations/series/visualization/home.js index 4269c174c..c0b5cfc7d 100644 --- a/app/src/js/applications/operations/series/visualization/home.js +++ b/app/src/js/applications/operations/series/visualization/home.js @@ -6,8 +6,9 @@ import RelationsView from 'js/applications/operations/shared/relations'; import DisplayLinks from 'js/applications/operations/shared/links/'; import SeeAlso from 'js/applications/operations/shared/seeAlso'; import { getSeeAlsoByType } from 'js/applications/operations/shared/links/utils'; -import { HTMLUtils, PublicationFemale } from 'bauhaus-utilities'; +import { HTMLUtils, PublicationFemale, withTitle } from 'bauhaus-utilities'; import { PublishersView, CreatorsView } from 'bauhaus-operations'; +import D from '../../../../i18n/build-dictionary'; function OperationsSerieVisualization({ attr, @@ -198,4 +199,6 @@ function OperationsSerieVisualization({ ); } -export default OperationsSerieVisualization; +export default withTitle(OperationsSerieVisualization, D.operationsTitle, props => { + return props.attr?.prefLabelLg1; +}); From 2d16adfa9e03607266dacbe87c576b46a797335b Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 9 Aug 2021 16:51:13 +0200 Subject: [PATCH 17/35] fix: rewrite Indictor Home Page --- .../operations/indicators/home.js | 48 ------------ .../operations/indicators/home.spec.js | 31 -------- .../operations/indicators/index.js | 77 +++++++++++-------- .../operations/indicators/index.spec.js | 32 -------- 4 files changed, 46 insertions(+), 142 deletions(-) delete mode 100644 app/src/js/applications/operations/indicators/home.js delete mode 100644 app/src/js/applications/operations/indicators/home.spec.js delete mode 100644 app/src/js/applications/operations/indicators/index.spec.js diff --git a/app/src/js/applications/operations/indicators/home.js b/app/src/js/applications/operations/indicators/home.js deleted file mode 100644 index 0b94f57a7..000000000 --- a/app/src/js/applications/operations/indicators/home.js +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { - PageTitle, - SearchableList, - NewButton, - VerticalMenu, -} from '@inseefr/wilco'; -import D from 'js/i18n'; -import { Auth, useTitle } from 'bauhaus-utilities'; - -function IndicatorsHome({ indicators }) { - useTitle(D.operationsTitle, D.indicatorsTitle) - - return ( -
    -
    - - - - - -
    - - -
    -
    -
    - ); -} - -IndicatorsHome.propTypes = { - indicators: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - }).isRequired - ), -}; - -export default IndicatorsHome; diff --git a/app/src/js/applications/operations/indicators/home.spec.js b/app/src/js/applications/operations/indicators/home.spec.js deleted file mode 100644 index 97913c1d9..000000000 --- a/app/src/js/applications/operations/indicators/home.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import IndicatorsHome from './home'; -import { MemoryRouter } from 'react-router-dom'; - -import { Provider } from 'react-redux'; -import configureStore from 'redux-mock-store'; - -const mockStore = configureStore([]); -const store = mockStore({ users: { results: {stamp: 'stamp'}}, app: { auth: { user: { roles: [] } } } }); - -describe('IndicatorsHome', () => { - it('should display the PageTitle component', () => { - const { container } = render( - - - , - { wrapper: MemoryRouter } - ); - expect(container.querySelectorAll('h1').length).toBe(1); - }); - it('should display the SearchableList component', () => { - const { container } = render( - - - , - { wrapper: MemoryRouter } - ); - expect(container.querySelectorAll('.list-group').length).toBe(1); - }); -}); diff --git a/app/src/js/applications/operations/indicators/index.js b/app/src/js/applications/operations/indicators/index.js index c28a8e65e..63fa3bf92 100644 --- a/app/src/js/applications/operations/indicators/index.js +++ b/app/src/js/applications/operations/indicators/index.js @@ -1,38 +1,53 @@ import React from 'react'; -import { Loading } from '@inseefr/wilco'; -import IndicatorsHome from './home'; -import loadIndicatorsList from 'js/actions/operations/indicators/list'; -import { connect } from 'react-redux'; -import { NOT_LOADED, LOADED } from 'js/constants'; -import { Auth } from 'bauhaus-utilities'; +import PropTypes from 'prop-types'; +import { + PageTitle, + SearchableList, + NewButton, + VerticalMenu, Loading, +} from '@inseefr/wilco'; +import D from 'js/i18n'; +import { Auth, useTitle } from 'bauhaus-utilities'; +import { LOADED, NOT_LOADED } from '../../../constants'; +import { useSelector } from 'react-redux'; -function IndicatorsHomeContainer({ indicators, status, permission }) { +function IndicatorsHome() { + useTitle(D.operationsTitle, D.indicatorsTitle) + + const { results: indicators = [], status = NOT_LOADED } = useSelector(state => state.operationsIndicatorsList) if (status !== LOADED) return ; - return ; -} -export const mapStateToProps = state => { - if (!state.operationsIndicatorsList) { - return { - status: NOT_LOADED, - indicators: [], - }; - } - const { results: indicators, status, err } = state.operationsIndicatorsList; - const permission = Auth.getPermission(state); - return { - indicators, - status, - permission, - err, - }; -}; + return ( +
    +
    + + + + + +
    + + +
    +
    +
    + ); +} -const mapDispatchToProps = { - loadIndicatorsList, +IndicatorsHome.propTypes = { + indicators: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + }).isRequired + ), }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(IndicatorsHomeContainer); +export default IndicatorsHome; diff --git a/app/src/js/applications/operations/indicators/index.spec.js b/app/src/js/applications/operations/indicators/index.spec.js deleted file mode 100644 index db6a51efe..000000000 --- a/app/src/js/applications/operations/indicators/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import { mapStateToProps } from './index'; - -describe('IndicatorsHomeContainer', () => { - it('should return indicators if available', () => { - const result = mapStateToProps({}); - expect(result).toEqual({ indicators: [], status: 'NOT_LOADED' }); - }); - it('if the id of the indicators is not defined should return an empty object', () => { - const result = mapStateToProps({ - operationsIndicatorsList: { - results: 'results', - status: 'LOADED', - err: 'err', - }, - app: { - auth: { - type: 'authType', - user: { - roles: 'roles', - stamp: 'stamp', - }, - }, - }, - }); - expect(result).toEqual({ - err: 'err', - indicators: 'results', - permission: { authType: 'authType', roles: 'roles', stamp: 'stamp' }, - status: 'LOADED', - }); - }); -}); From e966a3247662ad131469e0bbf35fd0a62144d694 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 10 Aug 2021 13:18:30 +0200 Subject: [PATCH 18/35] feat: add title for structures home page --- app/src/js/applications/structures/home.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/js/applications/structures/home.js b/app/src/js/applications/structures/home.js index b8b7270ff..b2e12be52 100644 --- a/app/src/js/applications/structures/home.js +++ b/app/src/js/applications/structures/home.js @@ -10,8 +10,10 @@ import { import { StructureAPI } from 'bauhaus-structures'; import D from 'js/i18n'; import { getEnvVar } from 'js/utils/env'; +import { useTitle } from 'bauhaus-utilities'; const Home = () => { + useTitle(D.structuresTitle, D.structuresTitle); const [DSDs, setDSDs] = useState([]); useEffect(() => { From d5a2fd19d29052f14bb30a82fbce8ec368329bf2 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 10 Aug 2021 13:22:26 +0200 Subject: [PATCH 19/35] feat: add all titles to structures --- app/src/index.js | 2 +- .../js/applications/structures/edition/create/component.js | 3 +++ .../js/applications/structures/edition/update/component.js | 4 ++++ app/src/js/applications/structures/visualization/dsd.js | 4 +++- app/src/js/i18n/dictionary/dsds.js | 4 ++++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/index.js b/app/src/index.js index 5b5f22820..6239ebd8d 100755 --- a/app/src/index.js +++ b/app/src/index.js @@ -15,7 +15,7 @@ import 'bauhaus-structures/dist/index.css'; import 'bauhaus-utilities/dist/index.css'; import 'main.scss'; - +console.log("lol") Api.getInit() .then( (res) => (res.ok ? res.json() : Promise.reject(res.statusText)), diff --git a/app/src/js/applications/structures/edition/create/component.js b/app/src/js/applications/structures/edition/create/component.js index bf2b01ad9..e75f2619a 100644 --- a/app/src/js/applications/structures/edition/create/component.js +++ b/app/src/js/applications/structures/edition/create/component.js @@ -1,7 +1,10 @@ import React from 'react'; import Edition from '../component'; +import { useTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; const Create = () => { + useTitle(D.structuresTitle, D.structuresCreateTitle) return ; }; diff --git a/app/src/js/applications/structures/edition/update/component.js b/app/src/js/applications/structures/edition/update/component.js index e7c1c36f4..c27193d67 100644 --- a/app/src/js/applications/structures/edition/update/component.js +++ b/app/src/js/applications/structures/edition/update/component.js @@ -3,6 +3,8 @@ import Edition from '../component'; import { Loading } from '@inseefr/wilco'; import { StructureAPI } from 'bauhaus-structures'; import { useLocation, useParams } from 'react-router-dom'; +import { useTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; const Update = () => { const location = useLocation(); @@ -10,6 +12,8 @@ const Update = () => { const { dsdId } = useParams(); const [structure, setStructure] = useState({}); + useTitle(D.structuresTitle, structure?.labelLg1); + useEffect(() => { StructureAPI.getStructure(dsdId) .then(res => setStructure(res)) diff --git a/app/src/js/applications/structures/visualization/dsd.js b/app/src/js/applications/structures/visualization/dsd.js index a37ba9820..365cc0fd8 100644 --- a/app/src/js/applications/structures/visualization/dsd.js +++ b/app/src/js/applications/structures/visualization/dsd.js @@ -7,7 +7,8 @@ import { Stores, PageTitleBlock, DateUtils, - PublicationFemale + PublicationFemale, + useTitle } from 'bauhaus-utilities'; import Components from './components'; import { D1, D2 } from 'js/i18n'; @@ -20,6 +21,7 @@ import D from 'bauhaus-structures/src/i18n/build-dictionary'; import api from 'bauhaus-structures/src/apis/structure-api'; export const StructureView = ({secondLang, structure, publish, serverSideError}) => { + useTitle(D.structuresTitle, structure?.labelLg1) const { labelLg1, labelLg2, diff --git a/app/src/js/i18n/dictionary/dsds.js b/app/src/js/i18n/dictionary/dsds.js index 99fa97732..e4a8fa98c 100644 --- a/app/src/js/i18n/dictionary/dsds.js +++ b/app/src/js/i18n/dictionary/dsds.js @@ -1,5 +1,9 @@ export default { structuresTitle: { fr: 'Structures', en: 'Structures' }, + structuresCreateTitle: { + fr: 'Créer une nouvelle structure', + en: 'Create a new structure', + }, dsdsSearchTitle: { fr: 'Data structure definition - Recherche', en: 'Data structure definition - Search', From 22ffe04c5ce317de5e2e0754faeae503643288c8 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 10 Aug 2021 13:25:13 +0200 Subject: [PATCH 20/35] refactor: remove useless files --- .../structures/edition/create/component.js | 11 -- .../structures/edition/create/index.js | 12 +- .../structures/edition/update/component.js | 61 -------- .../structures/edition/update/index.js | 62 +++++++- .../visualization/components/components.js | 60 -------- .../visualization/components/index.js | 61 +++++++- .../structures/visualization/dsd.js | 132 ----------------- .../structures/visualization/index.js | 133 +++++++++++++++++- .../{dsd.spec.js => index.spec.js} | 0 9 files changed, 264 insertions(+), 268 deletions(-) delete mode 100644 app/src/js/applications/structures/edition/create/component.js delete mode 100644 app/src/js/applications/structures/edition/update/component.js delete mode 100644 app/src/js/applications/structures/visualization/components/components.js delete mode 100644 app/src/js/applications/structures/visualization/dsd.js rename app/src/js/applications/structures/visualization/{dsd.spec.js => index.spec.js} (100%) diff --git a/app/src/js/applications/structures/edition/create/component.js b/app/src/js/applications/structures/edition/create/component.js deleted file mode 100644 index e75f2619a..000000000 --- a/app/src/js/applications/structures/edition/create/component.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react'; -import Edition from '../component'; -import { useTitle } from 'bauhaus-utilities'; -import D from 'js/i18n'; - -const Create = () => { - useTitle(D.structuresTitle, D.structuresCreateTitle) - return ; -}; - -export default Create; diff --git a/app/src/js/applications/structures/edition/create/index.js b/app/src/js/applications/structures/edition/create/index.js index b404d7fd4..e75f2619a 100644 --- a/app/src/js/applications/structures/edition/create/index.js +++ b/app/src/js/applications/structures/edition/create/index.js @@ -1 +1,11 @@ -export { default } from './component'; +import React from 'react'; +import Edition from '../component'; +import { useTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; + +const Create = () => { + useTitle(D.structuresTitle, D.structuresCreateTitle) + return ; +}; + +export default Create; diff --git a/app/src/js/applications/structures/edition/update/component.js b/app/src/js/applications/structures/edition/update/component.js deleted file mode 100644 index c27193d67..000000000 --- a/app/src/js/applications/structures/edition/update/component.js +++ /dev/null @@ -1,61 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import Edition from '../component'; -import { Loading } from '@inseefr/wilco'; -import { StructureAPI } from 'bauhaus-structures'; -import { useLocation, useParams } from 'react-router-dom'; -import { useTitle } from 'bauhaus-utilities'; -import D from '../../../../i18n/build-dictionary'; - -const Update = () => { - const location = useLocation(); - const [loading, setLoading] = useState(true); - const { dsdId } = useParams(); - - const [structure, setStructure] = useState({}); - useTitle(D.structuresTitle, structure?.labelLg1); - - useEffect(() => { - StructureAPI.getStructure(dsdId) - .then(res => setStructure(res)) - .finally(() => { - setLoading(false); - }); - }, [dsdId]); - const duplicate = location.pathname.indexOf('/duplicate') >= 0; - - if (loading) return ; - - if(duplicate){ - return ( - { - return { - component: cd.component, - order: cd.order, - required: cd.required, - attachment: cd.attachment - } - }) - }} - /> - ); - } - - return ( - - ); -}; - -export default Update; diff --git a/app/src/js/applications/structures/edition/update/index.js b/app/src/js/applications/structures/edition/update/index.js index b404d7fd4..c27193d67 100644 --- a/app/src/js/applications/structures/edition/update/index.js +++ b/app/src/js/applications/structures/edition/update/index.js @@ -1 +1,61 @@ -export { default } from './component'; +import React, { useState, useEffect } from 'react'; +import Edition from '../component'; +import { Loading } from '@inseefr/wilco'; +import { StructureAPI } from 'bauhaus-structures'; +import { useLocation, useParams } from 'react-router-dom'; +import { useTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; + +const Update = () => { + const location = useLocation(); + const [loading, setLoading] = useState(true); + const { dsdId } = useParams(); + + const [structure, setStructure] = useState({}); + useTitle(D.structuresTitle, structure?.labelLg1); + + useEffect(() => { + StructureAPI.getStructure(dsdId) + .then(res => setStructure(res)) + .finally(() => { + setLoading(false); + }); + }, [dsdId]); + const duplicate = location.pathname.indexOf('/duplicate') >= 0; + + if (loading) return ; + + if(duplicate){ + return ( + { + return { + component: cd.component, + order: cd.order, + required: cd.required, + attachment: cd.attachment + } + }) + }} + /> + ); + } + + return ( + + ); +}; + +export default Update; diff --git a/app/src/js/applications/structures/visualization/components/components.js b/app/src/js/applications/structures/visualization/components/components.js deleted file mode 100644 index ca31a762b..000000000 --- a/app/src/js/applications/structures/visualization/components/components.js +++ /dev/null @@ -1,60 +0,0 @@ -import React, { useState, useEffect, useCallback } from 'react'; -import { - StructureComponentsSelector, - getFormattedCodeList, - ComponentSpecificationModal, - CodesListPanel -} from 'bauhaus-structures'; -import { ConceptsAPI } from 'bauhaus-utilities'; - -const Components = ({ componentDefinitions = []}) => { - const [concepts, setConcepts] = useState([]); - const [codesLists, setCodesLists] = useState([]); - const [modalOpened, setModalOpened] = useState(false); - const [selectedComponent, setSelectedComponent] = useState({}); - - const [codesListNotation, setCodesListNotation] = useState(undefined); - const handleCodesListDetail = useCallback(notation => { - setCodesListNotation(notation); - }, []) - - useEffect(() => { - ConceptsAPI.getConceptList().then(res => setConcepts(res)); - }, []); - - useEffect(() => { - getFormattedCodeList().then(res => setCodesLists(res)); - }, []); - - const handleSpecificationClick = useCallback(component => { - setSelectedComponent(component); - setModalOpened(true); - }, []); - return ( -
    - {modalOpened && ( - setModalOpened(false)} - structureComponents={componentDefinitions} - disabled={true} - specification={{ - attachment: selectedComponent.attachment, - required: selectedComponent.required, - }} - /> - )} - - setCodesListNotation(undefined)}/> - -
    - ); -}; - -export default Components; diff --git a/app/src/js/applications/structures/visualization/components/index.js b/app/src/js/applications/structures/visualization/components/index.js index 8188d191b..ca31a762b 100644 --- a/app/src/js/applications/structures/visualization/components/index.js +++ b/app/src/js/applications/structures/visualization/components/index.js @@ -1 +1,60 @@ -export { default } from './components'; +import React, { useState, useEffect, useCallback } from 'react'; +import { + StructureComponentsSelector, + getFormattedCodeList, + ComponentSpecificationModal, + CodesListPanel +} from 'bauhaus-structures'; +import { ConceptsAPI } from 'bauhaus-utilities'; + +const Components = ({ componentDefinitions = []}) => { + const [concepts, setConcepts] = useState([]); + const [codesLists, setCodesLists] = useState([]); + const [modalOpened, setModalOpened] = useState(false); + const [selectedComponent, setSelectedComponent] = useState({}); + + const [codesListNotation, setCodesListNotation] = useState(undefined); + const handleCodesListDetail = useCallback(notation => { + setCodesListNotation(notation); + }, []) + + useEffect(() => { + ConceptsAPI.getConceptList().then(res => setConcepts(res)); + }, []); + + useEffect(() => { + getFormattedCodeList().then(res => setCodesLists(res)); + }, []); + + const handleSpecificationClick = useCallback(component => { + setSelectedComponent(component); + setModalOpened(true); + }, []); + return ( +
    + {modalOpened && ( + setModalOpened(false)} + structureComponents={componentDefinitions} + disabled={true} + specification={{ + attachment: selectedComponent.attachment, + required: selectedComponent.required, + }} + /> + )} + + setCodesListNotation(undefined)}/> + +
    + ); +}; + +export default Components; diff --git a/app/src/js/applications/structures/visualization/dsd.js b/app/src/js/applications/structures/visualization/dsd.js deleted file mode 100644 index 365cc0fd8..000000000 --- a/app/src/js/applications/structures/visualization/dsd.js +++ /dev/null @@ -1,132 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { useParams } from 'react-router-dom'; -import { Note, Loading, ErrorBloc } from '@inseefr/wilco'; -import { useSelector } from 'react-redux'; -import { - CheckSecondLang, - Stores, - PageTitleBlock, - DateUtils, - PublicationFemale, - useTitle -} from 'bauhaus-utilities'; -import Components from './components'; -import { D1, D2 } from 'js/i18n'; -import { - StructureAPI, - StructureVisualizationControl, - StructuresUtils -} from 'bauhaus-structures'; -import D from 'bauhaus-structures/src/i18n/build-dictionary'; -import api from 'bauhaus-structures/src/apis/structure-api'; - -export const StructureView = ({secondLang, structure, publish, serverSideError}) => { - useTitle(D.structuresTitle, structure?.labelLg1) - const { - labelLg1, - labelLg2, - descriptionLg1, - descriptionLg2, - componentDefinitions = [], - } = structure; - - return ( - <> - - - - -
    - -
  • - {D1.idTitle} : {structure.identifiant} -
  • -
  • - {D1.createdDateTitle} : {DateUtils.stringToDate(structure.created)} -
  • -
  • - {D1.modifiedDateTitle} : {DateUtils.stringToDate(structure.modified)} -
  • -
  • - {D.componentValididationStatusTitle} :{' '} - -
  • -
  • - {D.creator} :{' '} - {structure.creator} -
  • -
  • - {D.contributor} :{' '} - {structure.contributor} -
  • -
  • - {D.disseminationStatusTitle} :{' '} - {StructuresUtils.getDisseminationStatus(structure.disseminationStatus)} -
  • - - } - title={D1.globalInformationsTitle} - alone={true} - /> -
    -
    - - {secondLang && ( - - )} -
    - - - ); -} -const Structure = () => { - const { dsdId } = useParams(); - const [structure, setStructure] = useState({}); - const [loading, setLoading] = useState(true); - const [serverSideError, setServerSideError] = useState(); - const secondLang = useSelector((state) => - Stores.SecondLang.getSecondLang(state) - ); - - useEffect(() => { - StructureAPI.getStructure(dsdId) - .then((res) => setStructure(res)) - .finally(() => setLoading(false)); - }, [dsdId]); - - const publish = () => { - setLoading(true); - setServerSideError(); - return api.publishStructure(structure) - .then(() => api.getStructure(structure.id)) - .then(component => setStructure(component)) - .finally(() => setLoading(false)) - .catch(error => { - setServerSideError(D['errors_' + JSON.parse(error).code]) - }) - } - - if (loading) { - return ; - } - - return -}; - -export default Structure; diff --git a/app/src/js/applications/structures/visualization/index.js b/app/src/js/applications/structures/visualization/index.js index db3b198dc..365cc0fd8 100644 --- a/app/src/js/applications/structures/visualization/index.js +++ b/app/src/js/applications/structures/visualization/index.js @@ -1 +1,132 @@ -export { default } from './dsd'; +import React, { useState, useEffect } from 'react'; +import { useParams } from 'react-router-dom'; +import { Note, Loading, ErrorBloc } from '@inseefr/wilco'; +import { useSelector } from 'react-redux'; +import { + CheckSecondLang, + Stores, + PageTitleBlock, + DateUtils, + PublicationFemale, + useTitle +} from 'bauhaus-utilities'; +import Components from './components'; +import { D1, D2 } from 'js/i18n'; +import { + StructureAPI, + StructureVisualizationControl, + StructuresUtils +} from 'bauhaus-structures'; +import D from 'bauhaus-structures/src/i18n/build-dictionary'; +import api from 'bauhaus-structures/src/apis/structure-api'; + +export const StructureView = ({secondLang, structure, publish, serverSideError}) => { + useTitle(D.structuresTitle, structure?.labelLg1) + const { + labelLg1, + labelLg2, + descriptionLg1, + descriptionLg2, + componentDefinitions = [], + } = structure; + + return ( + <> + + + + +
    + +
  • + {D1.idTitle} : {structure.identifiant} +
  • +
  • + {D1.createdDateTitle} : {DateUtils.stringToDate(structure.created)} +
  • +
  • + {D1.modifiedDateTitle} : {DateUtils.stringToDate(structure.modified)} +
  • +
  • + {D.componentValididationStatusTitle} :{' '} + +
  • +
  • + {D.creator} :{' '} + {structure.creator} +
  • +
  • + {D.contributor} :{' '} + {structure.contributor} +
  • +
  • + {D.disseminationStatusTitle} :{' '} + {StructuresUtils.getDisseminationStatus(structure.disseminationStatus)} +
  • + + } + title={D1.globalInformationsTitle} + alone={true} + /> +
    +
    + + {secondLang && ( + + )} +
    + + + ); +} +const Structure = () => { + const { dsdId } = useParams(); + const [structure, setStructure] = useState({}); + const [loading, setLoading] = useState(true); + const [serverSideError, setServerSideError] = useState(); + const secondLang = useSelector((state) => + Stores.SecondLang.getSecondLang(state) + ); + + useEffect(() => { + StructureAPI.getStructure(dsdId) + .then((res) => setStructure(res)) + .finally(() => setLoading(false)); + }, [dsdId]); + + const publish = () => { + setLoading(true); + setServerSideError(); + return api.publishStructure(structure) + .then(() => api.getStructure(structure.id)) + .then(component => setStructure(component)) + .finally(() => setLoading(false)) + .catch(error => { + setServerSideError(D['errors_' + JSON.parse(error).code]) + }) + } + + if (loading) { + return ; + } + + return +}; + +export default Structure; diff --git a/app/src/js/applications/structures/visualization/dsd.spec.js b/app/src/js/applications/structures/visualization/index.spec.js similarity index 100% rename from app/src/js/applications/structures/visualization/dsd.spec.js rename to app/src/js/applications/structures/visualization/index.spec.js From 880bed159a0a8acdea8a341fdab0242acee894c1 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 10 Aug 2021 13:36:13 +0200 Subject: [PATCH 21/35] feat: add title to structure component --- packages/structures/src/components/component-detail/edit.js | 5 ++++- packages/structures/src/components/component-detail/view.js | 3 ++- .../src/components/{search => component-search}/search.js | 4 ++-- packages/structures/src/components/components-list/index.js | 4 +++- .../components/{dsd-search => structure-search}/search.js | 3 ++- packages/structures/src/i18n/dictionary.js | 6 ++++++ packages/structures/src/index.js | 4 ++-- 7 files changed, 21 insertions(+), 8 deletions(-) rename packages/structures/src/components/{search => component-search}/search.js (96%) rename packages/structures/src/components/{dsd-search => structure-search}/search.js (98%) diff --git a/packages/structures/src/components/component-detail/edit.js b/packages/structures/src/components/component-detail/edit.js index 6c6b632eb..b52f19f2b 100644 --- a/packages/structures/src/components/component-detail/edit.js +++ b/packages/structures/src/components/component-detail/edit.js @@ -7,7 +7,7 @@ import { LabelRequired, Select, } from '@inseefr/wilco'; -import { AppContext, Stores } from 'bauhaus-utilities'; +import { AppContext, Stores, useTitle } from 'bauhaus-utilities'; import { validateComponent } from '../../utils'; import { MUTUALIZED_COMPONENT_TYPES } from '../../utils/constants/dsd-components'; import { XSD_CODE_LIST, XSD_TYPES } from '../../utils/constants/xsd'; @@ -36,6 +36,9 @@ const DumbComponentDetailEdit = ({ const [codesListPanelOpened, setCodesListPanelOpened] = useState(false); const [component, setComponent] = useState(defaultComponent); const { lg1, lg2 } = useContext(AppContext); + + useTitle(D.componentTitle, component?.labelLg1 || D.componentsCreateTitle) + useEffect(() => { setComponent({ ...initialComponent, ...defaultComponent }); }, [initialComponent]); diff --git a/packages/structures/src/components/component-detail/view.js b/packages/structures/src/components/component-detail/view.js index 34c0dc300..1a06da541 100644 --- a/packages/structures/src/components/component-detail/view.js +++ b/packages/structures/src/components/component-detail/view.js @@ -13,7 +13,7 @@ import { typeUriToLabel, getAllAttachment, getDisseminationStatus } from '../../ import { XSD_CODE_LIST, XSD_TYPES } from '../../utils/constants/xsd'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { ATTRIBUTE_TYPE } from '../../utils/constants/dsd-components'; -import { HTMLUtils, ValidationButton, DateUtils, PublicationMale } from 'bauhaus-utilities'; +import { HTMLUtils, ValidationButton, DateUtils, PublicationMale,useTitle } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import "./view.scss"; import { CodesListPanel } from '../codes-list-panel/codes-list-panel'; @@ -41,6 +41,7 @@ export const ComponentDetailView = ({ publishComponent, serverSideError }) => { + useTitle(D.componentTitle, component?.labelLg1) const [codesListPanelOpened, setCodesListPanelOpened] = useState(false); const typeValue = typeUriToLabel(component.type); diff --git a/packages/structures/src/components/search/search.js b/packages/structures/src/components/component-search/search.js similarity index 96% rename from packages/structures/src/components/search/search.js rename to packages/structures/src/components/component-search/search.js index 97f4151dc..b5524c4c8 100644 --- a/packages/structures/src/components/search/search.js +++ b/packages/structures/src/components/component-search/search.js @@ -9,7 +9,7 @@ import { ArrayUtils, AdvancedSearchList, ItemToSelectModel, - AbstractAdvancedSearchComponent, Stores, + AbstractAdvancedSearchComponent, Stores, withTitle, } from 'bauhaus-utilities'; import { useSelector } from 'react-redux'; @@ -158,4 +158,4 @@ const SearchListContainer = () => { return ; }; -export default SearchListContainer; +export default withTitle(SearchListContainer, D.componentTitle, () => D.structuresAdvancedSearch); diff --git a/packages/structures/src/components/components-list/index.js b/packages/structures/src/components/components-list/index.js index 364d78256..8bb73dbf3 100644 --- a/packages/structures/src/components/components-list/index.js +++ b/packages/structures/src/components/components-list/index.js @@ -7,7 +7,7 @@ import { Loading, } from '@inseefr/wilco'; import './component-list.scss'; -import { FilterToggleButtons } from 'bauhaus-utilities'; +import { FilterToggleButtons, useTitle } from 'bauhaus-utilities'; import { MUTUALIZED_COMPONENT_TYPES } from '../../utils/constants/dsd-components'; import { useHistory } from 'react-router-dom'; @@ -19,6 +19,8 @@ const ALL = 'ALL'; const sessionStorageKey = 'components-displayMode'; function ComponentsList() { + useTitle(D.structuresTitle, D.componentTitle); + const history = useHistory(); const [items, setItems] = useState([]); const [loading, setLoading] = useState(true); diff --git a/packages/structures/src/components/dsd-search/search.js b/packages/structures/src/components/structure-search/search.js similarity index 98% rename from packages/structures/src/components/dsd-search/search.js rename to packages/structures/src/components/structure-search/search.js index 8f33beee2..65562bb35 100644 --- a/packages/structures/src/components/dsd-search/search.js +++ b/packages/structures/src/components/structure-search/search.js @@ -11,6 +11,7 @@ import { AdvancedSearchList, AbstractAdvancedSearchComponent, ItemToSelectModel, Stores, + withTitle } from 'bauhaus-utilities'; import { useSelector } from 'react-redux'; @@ -187,4 +188,4 @@ const SearchListContainer = () => { return ; }; -export default SearchListContainer; +export default withTitle(SearchListContainer, D.structuresTitle, () => D.structuresAdvancedSearch); diff --git a/packages/structures/src/i18n/dictionary.js b/packages/structures/src/i18n/dictionary.js index b6512bad4..434a34e96 100644 --- a/packages/structures/src/i18n/dictionary.js +++ b/packages/structures/src/i18n/dictionary.js @@ -275,5 +275,11 @@ const dictionary = { fr: 'Provisoire, jamais publiée', en: 'Temporary, never published', }, + structuresTitle: { fr: 'Structures', en: 'Structures' }, + structuresAdvancedSearch: { fr: 'Recherche Avancée', en: 'Advanced Search' }, + componentsCreateTitle: { + fr: 'Créer un nouveau composant', + en: 'Create a new component', + } }; export default dictionary; diff --git a/packages/structures/src/index.js b/packages/structures/src/index.js index 76bb44367..b367e6d05 100644 --- a/packages/structures/src/index.js +++ b/packages/structures/src/index.js @@ -1,6 +1,6 @@ export * from './apis'; export { default as StructuresComponentsList } from './components/components-list'; -export { default as StructuresComponentsSearch } from './components/search/search'; +export { default as StructuresComponentsSearch } from './components/component-search/search'; export * as StructuresConstants from './utils/constants'; export { default as StructuresComponentView } from './components/component-detail/view-container'; @@ -8,7 +8,7 @@ export { default as StructuresComponentEdit } from './components/component-detai export { StructureComponentsSelector } from './components/structure-component-selector'; export { default as ComponentSelector } from './components/component-selector'; export { MutualizedComponentsSelector } from './components/mutualized-component-selector'; -export { default as StructuresSearch } from './components/dsd-search/search'; +export { default as StructuresSearch } from './components/structure-search/search'; export { default as StructureVisualizationControl } from './components/structure-visualization/controls'; export * as StructuresUtils from './utils'; From 3a508d1e8225fa11f634bd12353d7ea0909c1df8 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 10 Aug 2021 13:40:31 +0200 Subject: [PATCH 22/35] fix: solve wrong import --- app/src/js/applications/structures/visualization/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/js/applications/structures/visualization/index.spec.js b/app/src/js/applications/structures/visualization/index.spec.js index 7b7ea2fae..19b656c6c 100644 --- a/app/src/js/applications/structures/visualization/index.spec.js +++ b/app/src/js/applications/structures/visualization/index.spec.js @@ -1,5 +1,5 @@ import React from 'react'; -import {StructureView} from './dsd'; +import {StructureView} from './index'; import { render } from '@testing-library/react'; import {MemoryRouter} from 'react-router'; import { Provider } from 'react-redux'; From 2ce9a71a2f1f5ca3215f4d00672698d2d449c736 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 11 Aug 2021 11:13:54 +0200 Subject: [PATCH 23/35] feat: add dedicated title --- .../operations/document/edition/edition.js | 6 +- .../operations/document/visualization/home.js | 5 +- .../operations/families/search.js | 25 ++++---- .../operations/indicators/edition/edition.js | 6 +- .../operations/operations/edition/edition.js | 7 ++- .../operations/series/edition/edition.js | 6 +- .../applications/operations/series/search.js | 63 ++++++++----------- .../js/applications/operations/tree/index.js | 3 + app/src/js/i18n/dictionary/app.js | 2 + .../js/i18n/dictionary/operations/index.js | 8 +++ packages/utilities/src/utils/useTitle.js | 2 +- 11 files changed, 72 insertions(+), 61 deletions(-) diff --git a/app/src/js/applications/operations/document/edition/edition.js b/app/src/js/applications/operations/document/edition/edition.js index f5c49d593..857a11b69 100644 --- a/app/src/js/applications/operations/document/edition/edition.js +++ b/app/src/js/applications/operations/document/edition/edition.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import D, { D1, D2 } from 'js/i18n'; import PropTypes from 'prop-types'; -import { EditorMarkdown, PageTitleBlock } from 'bauhaus-utilities'; +import { EditorMarkdown, PageTitleBlock, withTitle } from 'bauhaus-utilities'; import { validate } from 'js/applications/operations/document/edition/validation'; import { LINK, DOCUMENT } from '../utils'; import Dropzone from 'react-dropzone'; @@ -281,4 +281,6 @@ class OperationsDocumentationEdition extends Component { } } -export default OperationsDocumentationEdition; +export default withTitle(OperationsDocumentationEdition, D.operationsTitle, props => { + return props.document.labelLg1 || (props.type === LINK ? D.linksCreateTitle : D.documentsCreateTitle) +}); diff --git a/app/src/js/applications/operations/document/visualization/home.js b/app/src/js/applications/operations/document/visualization/home.js index 994b06faa..c17b42301 100644 --- a/app/src/js/applications/operations/document/visualization/home.js +++ b/app/src/js/applications/operations/document/visualization/home.js @@ -1,9 +1,9 @@ import { Note } from '@inseefr/wilco'; -import { D1, D2 } from 'js/i18n'; +import D, { D1, D2 } from 'js/i18n'; import PropTypes from 'prop-types'; import React, { useEffect, useState } from 'react'; import { isDocument, isLink } from '../utils'; -import { API } from 'bauhaus-utilities'; +import { API, useTitle } from 'bauhaus-utilities'; import RelationsView from '../../shared/relations'; function formatSims(sims){ @@ -50,6 +50,7 @@ function OperationsDocumentationVisualization({ langs: { lg1, lg2 }, langOptions }) { + useTitle(D.operationsTitle, attr.labelLg1) const sims = formatSims(attr.sims); const [baseURI, setBaseURI] = useState(''); useEffect(() => { diff --git a/app/src/js/applications/operations/families/search.js b/app/src/js/applications/operations/families/search.js index f5949bc64..de6a237c0 100644 --- a/app/src/js/applications/operations/families/search.js +++ b/app/src/js/applications/operations/families/search.js @@ -1,6 +1,6 @@ import D from 'js/i18n'; import { Link, Redirect } from 'react-router-dom'; -import React, { Component } from 'react'; +import React, { useEffect, useState } from 'react'; import { Loading } from '@inseefr/wilco'; import api from 'js/remote-api/operations-api'; @@ -8,6 +8,7 @@ import { ArrayUtils, AbstractAdvancedSearchComponent, AdvancedSearchList, + useTitle } from 'bauhaus-utilities'; const filterLabel = ArrayUtils.filterKeyDeburr(['prefLabelLg1']); @@ -59,22 +60,20 @@ class SearchFormList extends AbstractAdvancedSearchComponent { ); } } -class SearchListContainer extends Component { - constructor(props) { - super(props); - this.state = {}; - } - componentWillMount() { +const SearchListContainer = () => { + useTitle(D.operationsTitle, D.familiesTitle + ' - ' + D.advancedSearch) + const [data, setData] = useState(); + + useEffect(() => { api.getFamiliesSearchList().then(data => { - this.setState({ data: sortByLabel(data) }); + setData(sortByLabel(data)); }); - } + }, []); - render() { - const { data } = this.state; - if (!data) return ; - return ; + if(!data){ + return } + return } export default SearchListContainer; diff --git a/app/src/js/applications/operations/indicators/edition/edition.js b/app/src/js/applications/operations/indicators/edition/edition.js index a8c03964b..14ceeb53e 100644 --- a/app/src/js/applications/operations/indicators/edition/edition.js +++ b/app/src/js/applications/operations/indicators/edition/edition.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import { EditorMarkdown, ItemToSelectModel, - PageTitleBlock, + PageTitleBlock, withTitle, } from 'bauhaus-utilities'; import { PublishersInput, CreatorsInput } from 'bauhaus-operations'; import { CL_FREQ } from 'js/actions/constants/codeList'; @@ -370,4 +370,6 @@ class OperationsIndicatorEdition extends Component { } } -export default OperationsIndicatorEdition; +export default withTitle(OperationsIndicatorEdition, D.operationsTitle, props => { + return props.indicator?.prefLabelLg1 || D.indicatorsCreateTitle; +}); diff --git a/app/src/js/applications/operations/operations/edition/edition.js b/app/src/js/applications/operations/operations/edition/edition.js index 64864baf0..3400a82f0 100644 --- a/app/src/js/applications/operations/operations/edition/edition.js +++ b/app/src/js/applications/operations/operations/edition/edition.js @@ -13,7 +13,7 @@ import { Select, } from '@inseefr/wilco'; import { validate } from './validation'; -import { PageTitleBlock } from 'bauhaus-utilities'; +import { PageTitleBlock, withTitle } from 'bauhaus-utilities'; const defaultOperation = { prefLabelLg1: '', @@ -191,4 +191,7 @@ class OperationsOperationEdition extends Component { } } -export default OperationsOperationEdition; +export default withTitle(OperationsOperationEdition, D.operationsTitle, props => { + return props.operation?.prefLabelLg1 || D.operationsCreateTitle; +}); + diff --git a/app/src/js/applications/operations/series/edition/edition.js b/app/src/js/applications/operations/series/edition/edition.js index 9027e8a2f..6656ae23a 100644 --- a/app/src/js/applications/operations/series/edition/edition.js +++ b/app/src/js/applications/operations/series/edition/edition.js @@ -16,7 +16,7 @@ import { CL_SOURCE_CATEGORY, CL_FREQ } from 'js/actions/constants/codeList'; import { EditorMarkdown, ItemToSelectModel, - PageTitleBlock, + PageTitleBlock, withTitle, } from 'bauhaus-utilities'; import { PublishersInput, CreatorsInput } from 'bauhaus-operations'; @@ -491,4 +491,6 @@ class OperationsSerieEdition extends Component { } } -export default OperationsSerieEdition; +export default withTitle(OperationsSerieEdition, D.operationsTitle, props => { + return props.serie?.prefLabelLg1 || D.seriesCreateTitle; +}); diff --git a/app/src/js/applications/operations/series/search.js b/app/src/js/applications/operations/series/search.js index 88dc6c2d6..7b38e0351 100644 --- a/app/src/js/applications/operations/series/search.js +++ b/app/src/js/applications/operations/series/search.js @@ -1,15 +1,15 @@ import D from 'js/i18n'; import { Link, Redirect } from 'react-router-dom'; -import React, { Component } from 'react'; +import React, { useEffect, useState } from 'react'; import { Loading, Select } from '@inseefr/wilco'; import api from 'js/remote-api/operations-api'; -import { connect } from 'react-redux'; +import { useSelector } from 'react-redux'; import { ArrayUtils, AbstractAdvancedSearchComponent, AdvancedSearchList, ItemToSelectModel, - Stores, + Stores, useTitle, } from 'bauhaus-utilities'; import { CL_SOURCE_CATEGORY } from 'js/actions/constants/codeList'; @@ -197,41 +197,30 @@ export class SearchFormList extends AbstractAdvancedSearchComponent { ); } } -class SearchListContainer extends Component { - constructor(props) { - super(props); - this.state = {}; - } - componentWillMount() { - api.getSeriesSearchList().then((data) => { - this.setState({ data: sortByLabel(data) }); - }); - } - render() { - const { data } = this.state; - const { categories, organisations, stamps } = this.props; +const SearchListContainer = () => { + useTitle(D.operationsTitle, D.seriesTitle + ' - ' + D.advancedSearch) - if (!data) return ; - return ( - - ); - } -} + const [data, setData] = useState(); + const categories = useSelector(state => state.operationsCodesList.results[CL_SOURCE_CATEGORY] || {}); + const organisations = useSelector(state => state.operationsOrganisations.results); + const stamps = useSelector(state => Stores.Stamps.getStampList(state) || []); -const mapStateToProps = (state) => { - const categories = - state.operationsCodesList.results[CL_SOURCE_CATEGORY] || {}; - return { - categories, - organisations: state.operationsOrganisations.results, - stamps: Stores.Stamps.getStampList(state) || [], - }; -}; + useEffect(() => { + api.getSeriesSearchList().then((data) => { + setData(sortByLabel(data)); + }); + }, []); + + if (!data) return ; + return ( + + ); +} -export default connect(mapStateToProps)(SearchListContainer); +export default SearchListContainer; diff --git a/app/src/js/applications/operations/tree/index.js b/app/src/js/applications/operations/tree/index.js index e2be61fcb..f8420a207 100644 --- a/app/src/js/applications/operations/tree/index.js +++ b/app/src/js/applications/operations/tree/index.js @@ -7,6 +7,7 @@ import D from 'js/i18n'; import { goBack, PageTitle, ReturnButton, ActionToolbar } from '@inseefr/wilco'; import './tree.scss'; +import { useTitle } from 'bauhaus-utilities'; export const formatLeaf = ( leaf, @@ -63,6 +64,8 @@ export const updateTree = (treeData, leaf, familyIndex, seriesIndex) => { }; const TreeComponent = props => { + useTitle(D.operationsTitle, D.operationsTreeTitle) + const [treeData, setTreeData] = useState([]); const [selectedLeaf, setSelectedLeaf] = useState({}); diff --git a/app/src/js/i18n/dictionary/app.js b/app/src/js/i18n/dictionary/app.js index 0ed08ac37..f78ae3bdd 100644 --- a/app/src/js/i18n/dictionary/app.js +++ b/app/src/js/i18n/dictionary/app.js @@ -425,6 +425,8 @@ const dictionary = { }, btnExport: { fr: "Options d'export", en: 'Export options' }, btnExportValidate: { fr: 'Exporter en odt', en: 'Export to odt' }, + advancedSearch: { fr: 'Recherche Avancée', en: 'Advanced Search' }, + }; export default dictionary; diff --git a/app/src/js/i18n/dictionary/operations/index.js b/app/src/js/i18n/dictionary/operations/index.js index 5876d05aa..eeb0a392b 100644 --- a/app/src/js/i18n/dictionary/operations/index.js +++ b/app/src/js/i18n/dictionary/operations/index.js @@ -29,6 +29,14 @@ const dictionary = { fr: 'Créer une nouvelle famille', en: 'Create a new family', }, + documentsCreateTitle: { + fr: 'Créer un nouveau document', + en: 'Create a new document', + }, + linksCreateTitle: { + fr: 'Créer un nouveau lien', + en: 'Create a new link', + }, seriesCreateTitle: { fr: 'Créer une nouvelle série', en: 'Create a new series', diff --git a/packages/utilities/src/utils/useTitle.js b/packages/utilities/src/utils/useTitle.js index f9c3a9cc9..7c9a96dc4 100644 --- a/packages/utilities/src/utils/useTitle.js +++ b/packages/utilities/src/utils/useTitle.js @@ -7,7 +7,7 @@ export const setDocumentTitle = (application, page) => { export const useTitle = (application, page) => { useEffect(() => { setDocumentTitle(application, page) - }, []) + }, [application, page]) } export const withTitle = (WrappedComponent, application, getPage = () => '') => props => { From 56a5286a49bfeb5cf2ccaf27ee6cafb928aeba94 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Wed, 11 Aug 2021 17:40:01 +0200 Subject: [PATCH 24/35] feat: add new dedicated title --- app/src/js/applications/collections/edition-creation/home.js | 4 +++- app/src/js/applications/collections/visualization/home.js | 5 +++-- app/src/js/applications/concepts/advanced-search/home.js | 4 ++-- app/src/js/applications/concepts/edition-creation/home.js | 3 ++- app/src/js/applications/concepts/visualization/home.js | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/js/applications/collections/edition-creation/home.js b/app/src/js/applications/collections/edition-creation/home.js index 69be06392..60796d9b5 100644 --- a/app/src/js/applications/collections/edition-creation/home.js +++ b/app/src/js/applications/collections/edition-creation/home.js @@ -5,6 +5,8 @@ import CollectionEditionCreationControls from './controls'; import GeneralEdition from './general'; import MembersEdition from './members'; import { propTypes as generalPropTypes } from 'js/utils/collections/general'; +import { withTitle } from 'bauhaus-utilities'; +import D from '../../../i18n/build-dictionary'; class CollectionEditionCreation extends Component { constructor(props) { @@ -140,4 +142,4 @@ CollectionEditionCreation.propTypes = { langs: PropTypes.object.isRequired, }; -export default CollectionEditionCreation; +export default withTitle(CollectionEditionCreation, D.collectionsTitle, props => props.general.prefLabelLg1 || D.createCollectionTitle); diff --git a/app/src/js/applications/collections/visualization/home.js b/app/src/js/applications/collections/visualization/home.js index 801dc5a03..9ec5c8d0a 100644 --- a/app/src/js/applications/collections/visualization/home.js +++ b/app/src/js/applications/collections/visualization/home.js @@ -7,7 +7,8 @@ import CollectionMembers from './members'; import { propTypes as generalPropTypes } from 'js/utils/collections/general'; import { propTypes as membersPropTypes } from 'js/utils/collections/members'; import { propTypes as permissionOverviewPropTypes } from 'js/utils/auth/permission-overview'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, withTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; class CollectionVisualization extends Component { constructor(props) { @@ -63,4 +64,4 @@ CollectionVisualization.propTypes = { langs: PropTypes.object.isRequired, }; -export default CollectionVisualization; +export default withTitle(CollectionVisualization, D.collectionsTitle, props => props.general.prefLabelLg1); diff --git a/app/src/js/applications/concepts/advanced-search/home.js b/app/src/js/applications/concepts/advanced-search/home.js index e78a419a6..5a1dd185e 100644 --- a/app/src/js/applications/concepts/advanced-search/home.js +++ b/app/src/js/applications/concepts/advanced-search/home.js @@ -6,7 +6,7 @@ import Controls from './controls'; import DatePickerRmes from 'js/applications/shared/date-picker-rmes'; import D from 'js/i18n'; import { filterKeyDate } from 'js/utils/array-utils'; -import { ArrayUtils } from 'bauhaus-utilities'; +import { ArrayUtils, withTitle } from 'bauhaus-utilities'; const filterLabel = ArrayUtils.filterKeyDeburr(['label']); const filterAltLabel = ArrayUtils.filterKeyDeburr(['altLabel']); @@ -293,4 +293,4 @@ ConceptSearchList.propTypes = { disseminationStatusList: PropTypes.array.isRequired, }; -export default ConceptSearchList; +export default withTitle(ConceptSearchList, D.conceptsTitle, () => D.advancedSearch); diff --git a/app/src/js/applications/concepts/edition-creation/home.js b/app/src/js/applications/concepts/edition-creation/home.js index 7cd3b7b9b..0c91870a9 100644 --- a/app/src/js/applications/concepts/edition-creation/home.js +++ b/app/src/js/applications/concepts/edition-creation/home.js @@ -17,6 +17,7 @@ import D from 'js/i18n'; import isVersioningPossible from 'js/utils/concepts/is-versioning-possible'; import { VERSIONING, NO_VERSIONING } from 'js/constants'; import { withRouter } from 'react-router'; +import { withTitle } from 'bauhaus-utilities'; class ConceptEditionCreation extends Component { constructor(props) { @@ -275,4 +276,4 @@ ConceptEditionCreation.propTypes = { langs: PropTypes.object.isRequired, }; -export default withRouter(ConceptEditionCreation); +export default withRouter(withTitle(ConceptEditionCreation, D.conceptsTitle, props => props?.general?.prefLabelLg1 || D.createConceptTitle)); diff --git a/app/src/js/applications/concepts/visualization/home.js b/app/src/js/applications/concepts/visualization/home.js index fc18e0c62..d5196a6b8 100644 --- a/app/src/js/applications/concepts/visualization/home.js +++ b/app/src/js/applications/concepts/visualization/home.js @@ -12,7 +12,7 @@ import { propTypes as notePropTypes } from 'js/utils/concepts/notes'; import { propTypesBilingual as linksPropTypes } from 'js/utils/concepts/links'; import { propTypes as permissionOverviewPropTypes } from 'js/utils/auth/permission-overview'; import { getModalMessage } from 'js/utils/concepts/build-validation-message'; -import { CheckSecondLang, DateUtils, PageTitleBlock } from 'bauhaus-utilities'; +import { CheckSecondLang, DateUtils, PageTitleBlock, useTitle } from 'bauhaus-utilities'; const ConceptVisualization = ({ id, @@ -26,6 +26,7 @@ const ConceptVisualization = ({ validateConcept, deleteConcept, }) => { + useTitle( D.conceptsTitle, general?.prefLabelLg1); const [modalValid, setModalValid] = useState(false); const handleClickValidation = useCallback(() => { From cd5390d8a73826f81a3800f6abc83281670452a7 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Thu, 12 Aug 2021 11:45:10 +0200 Subject: [PATCH 25/35] refactor: rewrite export page for concept --- .../concepts/export/home-container.js | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/app/src/js/applications/concepts/export/home-container.js b/app/src/js/applications/concepts/export/home-container.js index b1e401b71..6f1b2b4c8 100644 --- a/app/src/js/applications/concepts/export/home-container.js +++ b/app/src/js/applications/concepts/export/home-container.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { Redirect } from 'react-router-dom'; import * as select from 'js/reducers'; @@ -9,46 +9,42 @@ import exportConceptList from 'js/actions/concepts/export-multi'; import loadConceptList from 'js/actions/concepts/list'; import { OK } from 'js/constants'; -class ConceptsToExportContainer extends Component { - constructor() { - super(); - this.state = { - exportRequested: false, - }; - this.handleExportConceptList = (ids, MimeType) => { - this.props.exportConceptList(ids, MimeType); - this.setState({ - exportRequested: true, - }); - }; - } +const ConceptsToExportContainer = ({ + concepts, + exportStatus, + loadConceptList, + exportConceptList + }) => { + const [exportRequested, setExportRequested] = useState(false) + + useEffect(() => { + if(!concepts){ + loadConceptList() + } + }, [concepts, loadConceptList]); - componentWillMount() { - if (!this.props.concepts) this.props.loadConceptList(); + const handleExportConceptList = (ids, MimeType) => { + exportConceptList(ids, MimeType); + setExportRequested(true); } - render() { - const { concepts, exportStatus } = this.props; - const { exportRequested } = this.state; - if (exportRequested) { - if (exportStatus === OK) { - return ; - } - return ; + if (exportRequested) { + if (exportStatus === OK) { + return ; } + return ; + } - if (!concepts) { - return ; - } - return ( - - ); + if (!concepts) { + return ; } + return ( + + ); } - const mapStateToProps = state => ({ concepts: select.getConceptList(state), exportStatus: select.getStatus(state, EXPORT_CONCEPT_LIST), From 2a2625db525ab4181228bb4c1abaac173972b23e Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Thu, 12 Aug 2021 12:25:27 +0200 Subject: [PATCH 26/35] feat: add dedicated title --- .../js/applications/codelists/routes/index.js | 1 - .../collections/export/home-container.js | 4 ++ .../collections/validation/home-container.js | 62 ++++++++--------- .../concepts/export/home-container.js | 3 + .../concepts/validation/home-container.js | 67 +++++++++---------- .../src/components/codelist-detail/edit.js | 7 +- .../src/components/codelist-detail/view.js | 4 +- .../codelists/src/components/home/home.js | 2 + .../codelists/src/components/search/search.js | 4 +- packages/codelists/src/i18n/dictionary.js | 5 ++ 10 files changed, 85 insertions(+), 74 deletions(-) diff --git a/app/src/js/applications/codelists/routes/index.js b/app/src/js/applications/codelists/routes/index.js index e9751dea6..adc7799ef 100644 --- a/app/src/js/applications/codelists/routes/index.js +++ b/app/src/js/applications/codelists/routes/index.js @@ -11,7 +11,6 @@ import { } from 'bauhaus-codelists'; const CodesListComponent = () => { - document.title = 'Bauhaus - ' + D.codelistsTitle; document.getElementById('root-app').classList = ['codelists']; return ( <> diff --git a/app/src/js/applications/collections/export/home-container.js b/app/src/js/applications/collections/export/home-container.js index 45adf69df..40343d8aa 100644 --- a/app/src/js/applications/collections/export/home-container.js +++ b/app/src/js/applications/collections/export/home-container.js @@ -8,6 +8,8 @@ import { Loading } from '@inseefr/wilco'; import exportCollectionList from 'js/actions/collections/export-multi'; import loadCollectionList from 'js/actions/collections/list'; import { OK } from 'js/constants'; +import { useTitle } from 'bauhaus-utilities'; +import D from '../../../i18n/build-dictionary'; const CollectionsToExportContainer = ({ collections, @@ -15,6 +17,8 @@ const CollectionsToExportContainer = ({ loadCollectionList, exportCollectionList, }) => { + useTitle(D.collectionsTitle, D.exportTitle) + const [exportRequested, setExportRequested] = useState(false); const handleExportCollectionList = useCallback( diff --git a/app/src/js/applications/collections/validation/home-container.js b/app/src/js/applications/collections/validation/home-container.js index 7587dc0c6..9decd5618 100644 --- a/app/src/js/applications/collections/validation/home-container.js +++ b/app/src/js/applications/collections/validation/home-container.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { Redirect } from 'react-router'; import CollectionsToValidate from './home'; @@ -8,43 +8,37 @@ import validateCollectionList from 'js/actions/collections/validate'; import loadCollectionValidateList from 'js/actions/collections/validate-list'; import { VALIDATE_COLLECTION_LIST } from 'js/actions/constants'; import { OK } from 'js/constants'; -import { Auth } from 'bauhaus-utilities'; +import { Auth, useTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; -class CollectionsToValidateContainer extends Component { - constructor(props) { - super(props); - this.state = { - validationRequested: false, - }; +const CollectionsToValidateContainer = + ({ validateCollectionList, collections, loadCollectionValidateList, permission, validationStatus }) => { + useTitle(D.collectionsTitle, D.btnValid); - this.handleValidateCollectionList = ids => { - this.props.validateCollectionList(ids); - this.setState({ - validationRequested: true, - }); - }; - } - componentWillMount() { - if (!this.props.collections) this.props.loadCollectionValidateList(); - } + const [validationRequested, setValidationRequested] = useState(false); + + const handleValidateCollectionList = ids => { + validateCollectionList(ids); + setValidationRequested(true) + }; + + useEffect(() => { + if (!collections) loadCollectionValidateList(); + }, [collections, loadCollectionValidateList]); - render() { - const { validationRequested } = this.state; - const { collections, permission, validationStatus } = this.props; - if (validationRequested) { - if (validationStatus === OK) { - return ; - } else return ; - } - if (!collections) return ; - return ( - - ); + if (validationRequested) { + if (validationStatus === OK) { + return ; + } else return ; } + if (!collections) return ; + return ( + + ); } const mapStateToProps = state => ({ diff --git a/app/src/js/applications/concepts/export/home-container.js b/app/src/js/applications/concepts/export/home-container.js index 6f1b2b4c8..9a4e927ad 100644 --- a/app/src/js/applications/concepts/export/home-container.js +++ b/app/src/js/applications/concepts/export/home-container.js @@ -8,6 +8,8 @@ import { Loading } from '@inseefr/wilco'; import exportConceptList from 'js/actions/concepts/export-multi'; import loadConceptList from 'js/actions/concepts/list'; import { OK } from 'js/constants'; +import { useTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; const ConceptsToExportContainer = ({ concepts, @@ -15,6 +17,7 @@ const ConceptsToExportContainer = ({ loadConceptList, exportConceptList }) => { + useTitle(D.conceptsTitle, D.exportTitle) const [exportRequested, setExportRequested] = useState(false) useEffect(() => { diff --git a/app/src/js/applications/concepts/validation/home-container.js b/app/src/js/applications/concepts/validation/home-container.js index ddd0d2c67..17c5e136c 100644 --- a/app/src/js/applications/concepts/validation/home-container.js +++ b/app/src/js/applications/concepts/validation/home-container.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { Redirect } from 'react-router'; import ConceptsToValidate from './home'; @@ -8,43 +8,40 @@ import * as select from 'js/reducers'; import validateConceptList from 'js/actions/concepts/validate'; import loadConceptValidateList from 'js/actions/concepts/validate-list'; import { OK } from 'js/constants'; -import { Auth } from 'bauhaus-utilities'; +import { Auth, useTitle } from 'bauhaus-utilities'; +import D from 'js/i18n'; -class ConceptsToValidateContainer extends Component { - constructor(props) { - super(props); - this.state = { - validationRequested: false, - }; - this.handleValidateConceptList = ids => { - this.props.validateConceptList(ids); - this.setState({ - validationRequested: true, - }); - }; - } - componentWillMount() { - if (!this.props.concepts) this.props.loadConceptValidateList(); - } - render() { - const { validationRequested } = this.state; - const { concepts, permission, validationStatus } = this.props; - if (validationRequested) { - if (validationStatus === OK) { - return ; - } else { - return ; - } +const ConceptsToValidateContainer = ({ + concepts, validateConceptList, loadConceptValidateList, permission, validationStatus + }) => { + + useTitle(D.conceptsTitle, D.btnValid); + const [validationRequested, setValidationRequested] = useState(false); + + const handleValidateConceptList = ids => { + validateConceptList(ids); + setValidationRequested(true) + }; + + useEffect(() => { + if (!concepts) loadConceptValidateList(); + }, [concepts, loadConceptValidateList]); + + if (validationRequested) { + if (validationStatus === OK) { + return ; + } else { + return ; } - if (!concepts) return ; - return ( - - ); } + if (!concepts) return ; + return ( + + ); } const mapStateToProps = state => ({ diff --git a/packages/codelists/src/components/codelist-detail/edit.js b/packages/codelists/src/components/codelist-detail/edit.js index dcd64b574..01336ec64 100644 --- a/packages/codelists/src/components/codelist-detail/edit.js +++ b/packages/codelists/src/components/codelist-detail/edit.js @@ -7,9 +7,9 @@ import { LabelRequired, Select, } from '@inseefr/wilco'; -import { Stores } from 'bauhaus-utilities'; +import { Stores, useTitle } from 'bauhaus-utilities'; import { validateCodelist } from '../../utils'; -import { D1, D2 } from '../../i18n/build-dictionary'; +import D, { D1, D2 } from '../../i18n/build-dictionary'; import PropTypes from 'prop-types'; import { default as ReactSelect } from 'react-select'; import dayjs from 'dayjs'; @@ -27,7 +27,10 @@ const DumbCodelistDetailEdit = ({ stampListOptions, serverSideError, }) => { + const [codelist, setCodelist] = useState(defaultCodelist); + useTitle(D.codelistsTitle, codelist?.labelLg1 || D.codelistsCreateTitle) + useEffect(() => { setCodelist({ ...initialCodelist, ...defaultCodelist }); }, [initialCodelist]); diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 1643732a5..97c9fdfdf 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -13,7 +13,7 @@ import { HTMLUtils, ValidationButton, DateUtils, - PublicationFemale, + PublicationFemale, useTitle, } from 'bauhaus-utilities'; import PropTypes from 'prop-types'; import { treedData } from '../../utils'; @@ -30,6 +30,8 @@ export const CodeListDetailView = ({ publishComponent, serverSideError, }) => { + useTitle(D.codelistsTitle, codelist?.labelLg1) + const descriptionLg1 = HTMLUtils.renderMarkdownElement( codelist.descriptionLg1 ); diff --git a/packages/codelists/src/components/home/home.js b/packages/codelists/src/components/home/home.js index 6dcf749cc..64211cea2 100644 --- a/packages/codelists/src/components/home/home.js +++ b/packages/codelists/src/components/home/home.js @@ -9,8 +9,10 @@ import { import { API } from '../../apis'; import { formatLabel } from '../../utils'; import D from '../../i18n/build-dictionary'; +import { useTitle } from 'bauhaus-utilities'; function CodeListsList() { + useTitle(D.codelistsTitle, D.codelistsTitle) const [items, setItems] = useState([]); const [loading, setLoading] = useState(true); diff --git a/packages/codelists/src/components/search/search.js b/packages/codelists/src/components/search/search.js index 9cf19843c..a7fa427ea 100644 --- a/packages/codelists/src/components/search/search.js +++ b/packages/codelists/src/components/search/search.js @@ -6,7 +6,7 @@ import { ArrayUtils, AbstractAdvancedSearchComponent, AdvancedSearchList, - Stores, + Stores, useTitle, } from 'bauhaus-utilities'; import { API } from '../../apis'; import D from '../../i18n/build-dictionary'; @@ -190,6 +190,8 @@ class SearchFormList extends AbstractAdvancedSearchComponent { } const SearchListContainer = () => { + useTitle(D.codelistsTitle, D.advancedSearch) + const [loading, setLoading] = useState(true); const [items, setItems] = useState([]); const stampListOptions = useSelector((state) => diff --git a/packages/codelists/src/i18n/dictionary.js b/packages/codelists/src/i18n/dictionary.js index e9fc506cd..ed75fac11 100644 --- a/packages/codelists/src/i18n/dictionary.js +++ b/packages/codelists/src/i18n/dictionary.js @@ -1,5 +1,10 @@ const dictionary = { + advancedSearch: { fr: 'Recherche Avancée', en: 'Advanced Search' }, codelistsTitle: { fr: 'Listes de codes', en: 'Code lists' }, + codelistsCreateTitle: { + fr: 'Créer une liste de code', + en: 'Create a code list', + }, lastListUriSegmentTitle: { fr: 'Uri Liste : commence par http://rdf.insee.fr/codes/', en: 'Uri Liste : starts with http://rdf.insee.fr/codes/', From e54daeb949bb0b964b97054dae1f0414b9dc87dc Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 13 Aug 2021 10:01:36 +0200 Subject: [PATCH 27/35] fix: remove useless import --- app/src/js/applications/codelists/routes/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/js/applications/codelists/routes/index.js b/app/src/js/applications/codelists/routes/index.js index adc7799ef..01a37e403 100644 --- a/app/src/js/applications/codelists/routes/index.js +++ b/app/src/js/applications/codelists/routes/index.js @@ -6,7 +6,6 @@ import { Home, CodelistComponentView, CodelistEdit, - D, SearchFormList, } from 'bauhaus-codelists'; From 988ea86b0dad7d4516ae2dec2e42b9e3421b7cfe Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 13 Aug 2021 10:02:01 +0200 Subject: [PATCH 28/35] refactor: rewrite familiesComponent to functionnal component --- .../applications/operations/families/index.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/js/applications/operations/families/index.js b/app/src/js/applications/operations/families/index.js index 1dac5cba7..8fc2929a1 100644 --- a/app/src/js/applications/operations/families/index.js +++ b/app/src/js/applications/operations/families/index.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { useEffect } from 'react'; import { Loading } from '@inseefr/wilco'; import FamiliesHome from './home'; import loadFamiliesList from 'js/actions/operations/families/list'; @@ -6,17 +6,15 @@ import { connect } from 'react-redux'; import { NOT_LOADED, LOADED } from 'js/constants'; import { getFamilies } from 'js/reducers/index'; -export class FamiliesHomeContainer extends Component { - componentDidMount() { - if (this.props.status !== LOADED) { - this.props.loadFamiliesList(); +const FamiliesHomeContainer = ({ status, loadFamiliesList, families}) => { + useEffect(() => { + if(status !== LOADED){ + loadFamiliesList() } - } - render() { - const { families, status } = this.props; - if (status !== LOADED) return ; - return ; - } + }, [status, loadFamiliesList]) + + if (status !== LOADED) return ; + return ; } export const mapStateToProps = state => { From 65f2a2004242fc80d03979def149290ae0a5bf8a Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Sun, 15 Aug 2021 16:10:33 +0200 Subject: [PATCH 29/35] feat: add title to classifications. --- .../classifications/correspondences/home.js | 2 + .../visualization/home-general.js | 77 +++++++++---------- .../classifications/families/home.js | 2 + .../families/visualization/home.js | 5 +- .../js/applications/classifications/home.js | 3 + .../classifications/series/home.js | 3 + .../series/visualization/home.js | 22 +++--- .../classifications/visualization/home.js | 4 +- .../visualization/tree/home.js | 4 +- 9 files changed, 68 insertions(+), 54 deletions(-) diff --git a/app/src/js/applications/classifications/correspondences/home.js b/app/src/js/applications/classifications/correspondences/home.js index 4e90b3664..7091f2acd 100644 --- a/app/src/js/applications/classifications/correspondences/home.js +++ b/app/src/js/applications/classifications/correspondences/home.js @@ -2,8 +2,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PageTitle, SearchableList } from '@inseefr/wilco'; import D from 'js/i18n'; +import { useTitle } from 'bauhaus-utilities'; const CorrespondencesHome = ({ correspondences }) => { + useTitle(D.classificationsTitle, D.correspondencesTitle); return (
    diff --git a/app/src/js/applications/classifications/correspondences/visualization/home-general.js b/app/src/js/applications/classifications/correspondences/visualization/home-general.js index dd474009d..c69d65289 100644 --- a/app/src/js/applications/classifications/correspondences/visualization/home-general.js +++ b/app/src/js/applications/classifications/correspondences/visualization/home-general.js @@ -1,46 +1,44 @@ -import React, { Component } from 'react'; +import React from 'react'; import { PageTitle, Note } from '@inseefr/wilco'; import CorrespondenceControls from './controls'; import { generalFields } from './general-fields'; import { ExplanatoryNote } from 'js/applications/shared/explanatory-note'; import { D1, D2 } from 'js/i18n'; -import { propTypes as correspondencePropTypes } from 'js/applications/classifications/utils/correspondence/general'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, useTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; -class HomeGeneral extends Component { - static propTypes = { - correspondence: correspondencePropTypes.isRequired, - }; - render() { - const { - correspondence, - secondLang, - langs: { lg1, lg2 }, - } = this.props; - const { - labelLg1, - labelLg2, - firstClassLabelLg2, - secondClassLabelLg2, - } = correspondence; - const title = secondLang ? labelLg2 : labelLg1; - return ( -
    - {title && } - - -
    - {(!secondLang || - (secondLang && (firstClassLabelLg2 || secondClassLabelLg2))) && ( - - )} -
    - +const HomeGeneral = ({ + correspondence, + secondLang, + langs: { lg1, lg2 }, + }) => { + const { + labelLg1, + labelLg2, + firstClassLabelLg2, + secondClassLabelLg2, + } = correspondence; + const title = secondLang ? labelLg2 : labelLg1; + + useTitle(D.classificationsTitle, labelLg1); + + return ( +
    + {title && } + + +
    + {(!secondLang || + (secondLang && (firstClassLabelLg2 || secondClassLabelLg2))) && ( + + )} +
    + {correspondence.descriptionLg1 && (
    )} -
    - ); - } +
    + ); } export default HomeGeneral; diff --git a/app/src/js/applications/classifications/families/home.js b/app/src/js/applications/classifications/families/home.js index f0edd0757..96f005b37 100644 --- a/app/src/js/applications/classifications/families/home.js +++ b/app/src/js/applications/classifications/families/home.js @@ -2,8 +2,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PageTitle, SearchableList } from '@inseefr/wilco'; import D from 'js/i18n'; +import { useTitle } from 'bauhaus-utilities'; const FamiliesHome = ({ families }) => { + useTitle(D.classificationsTitle, D.familiesTitle); return (
    diff --git a/app/src/js/applications/classifications/families/visualization/home.js b/app/src/js/applications/classifications/families/visualization/home.js index 5c31713b2..46999fd3e 100644 --- a/app/src/js/applications/classifications/families/visualization/home.js +++ b/app/src/js/applications/classifications/families/visualization/home.js @@ -2,7 +2,8 @@ import React from 'react'; import { PageTitle } from '@inseefr/wilco'; import Controls from './controls'; import Members from './members'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, useTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; const FamilyVisualization = ({ family: { @@ -11,6 +12,8 @@ const FamilyVisualization = ({ }, secondLang, }) => { + useTitle(D.classificationsTitle, prefLabelLg1); + return (
    diff --git a/app/src/js/applications/classifications/home.js b/app/src/js/applications/classifications/home.js index ba6f679c0..adb5ff7f8 100644 --- a/app/src/js/applications/classifications/home.js +++ b/app/src/js/applications/classifications/home.js @@ -2,8 +2,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PageTitle, SearchableList } from '@inseefr/wilco'; import D from 'js/i18n'; +import { useTitle } from 'bauhaus-utilities'; const ClassificationsHome = ({ classifications }) => { + useTitle(D.classificationsTitle, D.classificationsTitle); + return (
    diff --git a/app/src/js/applications/classifications/series/home.js b/app/src/js/applications/classifications/series/home.js index 34f026cc7..7a53f5e86 100644 --- a/app/src/js/applications/classifications/series/home.js +++ b/app/src/js/applications/classifications/series/home.js @@ -2,8 +2,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PageTitle, SearchableList } from '@inseefr/wilco'; import D from 'js/i18n'; +import { useTitle } from 'bauhaus-utilities'; const SeriesHome = ({ series }) => { + useTitle(D.classificationsTitle, D.seriesTitle); + return (
    diff --git a/app/src/js/applications/classifications/series/visualization/home.js b/app/src/js/applications/classifications/series/visualization/home.js index db111647f..56181c025 100644 --- a/app/src/js/applications/classifications/series/visualization/home.js +++ b/app/src/js/applications/classifications/series/visualization/home.js @@ -1,19 +1,20 @@ -import React, { Component } from 'react'; +import React from 'react'; import { PageSubtitle, PageTitle } from '@inseefr/wilco'; import Controls from './controls'; import General from './general'; import Notes from './notes'; import Members from './members'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, useTitle } from 'bauhaus-utilities'; +import D from '../../../../i18n/build-dictionary'; -class SeriesVisualization extends Component { - render() { - const { - series: { general, members }, - secondLang, - langs, - } = this.props; - const notes = { +const SeriesVisualization = ({ + series: { general, members }, + secondLang, + langs, + }) => { + useTitle(D.classificationsTitle, general?.prefLabelLg1); + + const notes = { scopeNoteLg1: general.scopeNoteLg1, scopeNoteLg2: general.scopeNoteLg2, }; @@ -34,7 +35,6 @@ class SeriesVisualization extends Component { )}
    ); - } } export default SeriesVisualization; diff --git a/app/src/js/applications/classifications/visualization/home.js b/app/src/js/applications/classifications/visualization/home.js index 0f749db9a..a79ba0e5a 100644 --- a/app/src/js/applications/classifications/visualization/home.js +++ b/app/src/js/applications/classifications/visualization/home.js @@ -6,7 +6,7 @@ import General from './general'; import Notes from './notes'; import Levels from './levels'; import D from 'js/i18n'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, useTitle } from 'bauhaus-utilities'; const ClassificationVisualization = props => { const { @@ -15,6 +15,8 @@ const ClassificationVisualization = props => { secondLang, langs, } = props; + useTitle(D.classificationsTitle, general?.prefLabelLg1); + const notes = { scopeNoteLg1: general.scopeNoteLg1, scopeNoteLg2: general.scopeNoteLg2, diff --git a/app/src/js/applications/classifications/visualization/tree/home.js b/app/src/js/applications/classifications/visualization/tree/home.js index 33cb71035..3cd5e984b 100644 --- a/app/src/js/applications/classifications/visualization/tree/home.js +++ b/app/src/js/applications/classifications/visualization/tree/home.js @@ -4,9 +4,11 @@ import { PageTitle } from '@inseefr/wilco'; import Controls from './controls'; import DnDTree from 'js/applications/shared/tree/dnd'; import D from 'js/i18n'; -import { CheckSecondLang } from 'bauhaus-utilities'; +import { CheckSecondLang, useTitle } from 'bauhaus-utilities'; const ClassificationTree = ({ data, prefLabel }) => { + useTitle(D.classificationsTitle, D.classificationTreeTitle + ': ' + prefLabel); + return (
    From b5cca289b94c95dcbe8f31e54a8fc36c6d9ec575 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Sun, 15 Aug 2021 16:17:06 +0200 Subject: [PATCH 30/35] fix: missing export --- app/src/js/applications/operations/families/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/js/applications/operations/families/index.js b/app/src/js/applications/operations/families/index.js index 8fc2929a1..8880915df 100644 --- a/app/src/js/applications/operations/families/index.js +++ b/app/src/js/applications/operations/families/index.js @@ -6,7 +6,7 @@ import { connect } from 'react-redux'; import { NOT_LOADED, LOADED } from 'js/constants'; import { getFamilies } from 'js/reducers/index'; -const FamiliesHomeContainer = ({ status, loadFamiliesList, families}) => { +export const FamiliesHomeContainer = ({ status, loadFamiliesList, families}) => { useEffect(() => { if(status !== LOADED){ loadFamiliesList() From 155656e7b92eda17f865efde4ac86df58ad1d81a Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 16 Aug 2021 17:29:29 +0200 Subject: [PATCH 31/35] refactor: rewrite home page for Concepts and Collections --- app/src/js/applications/collections/home.js | 123 ++++++++------------ app/src/js/applications/concepts/home.js | 94 ++++++--------- 2 files changed, 87 insertions(+), 130 deletions(-) diff --git a/app/src/js/applications/collections/home.js b/app/src/js/applications/collections/home.js index dd936ab7d..72922726f 100644 --- a/app/src/js/applications/collections/home.js +++ b/app/src/js/applications/collections/home.js @@ -1,6 +1,5 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import { withRouter } from 'react-router-dom'; import { PageTitle, Button, @@ -13,87 +12,67 @@ import { propTypes as collectionOverviewPropTypes } from 'js/utils/collections/c import { propTypes as permissionOverviewPropTypes } from 'js/utils/auth/permission-overview'; import D from 'js/i18n'; -class CollectionsHome extends Component { - static propTypes = { - collections: PropTypes.arrayOf(collectionOverviewPropTypes.isRequired), - permission: permissionOverviewPropTypes.isRequired, - }; +const CollectionsHome = ({ + collections, + permission: { authType, roles }, + }) => { - constructor() { - super(); - - this.handleClick = e => { - e.preventDefault(); - this.props.history.push('/collection/create'); - }; - this.handleClickExport = e => { - e.preventDefault(); - this.props.history.push('/collections/export'); - }; - this.handleClickValidate = e => { - e.preventDefault(); - this.props.history.push('/collections/validation'); - }; - } - - render() { - const { - collections, - permission: { authType, roles }, - } = this.props; - const authImpl = check(authType); - const adminOrCreator = authImpl.isAdminOrCollectionCreator(roles); - const adminOrContributor = authImpl.isAdminOrContributor(roles); - return ( -
    -
    - - {adminOrContributor && ( -
    - ); - } +
    + ); } +CollectionsHome.propTypes = { + collections: PropTypes.arrayOf(collectionOverviewPropTypes.isRequired), + permission: permissionOverviewPropTypes.isRequired, +}; -export default withRouter(CollectionsHome); +export default CollectionsHome; diff --git a/app/src/js/applications/concepts/home.js b/app/src/js/applications/concepts/home.js index 6cdc0db9d..d34282fa2 100755 --- a/app/src/js/applications/concepts/home.js +++ b/app/src/js/applications/concepts/home.js @@ -1,6 +1,5 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; -import { withRouter } from 'react-router-dom'; import { PageTitle, SearchableList, @@ -14,68 +13,47 @@ import { propTypes as conceptOverviewPropTypes } from 'js/utils/concepts/concept import { propTypes as permissionOverviewPropTypes } from 'js/utils/auth/permission-overview'; import D from 'js/i18n'; -class ConceptsHome extends Component { - constructor() { - super(); - - this.handleClick = e => { - e.preventDefault(); - this.props.history.push('/concept/create'); - }; - this.handleClickExport = e => { - e.preventDefault(); - this.props.history.push('/concepts/export'); - }; - this.handleClickValidate = e => { - e.preventDefault(); - this.props.history.push('/concepts/validation'); - }; - } - - render() { - const { - concepts, - permission: { authType, roles }, - } = this.props; - const authImpl = check(authType); - const adminOrContributor = authImpl.isAdminOrContributor(roles); - const adminOrCreator = authImpl.isAdminOrConceptCreator(roles); - return ( -
    -
    - - {adminOrContributor && ( - - )} - - {adminOrCreator && ( - - )} - -
    - - { + const authImpl = check(authType); + const adminOrContributor = authImpl.isAdminOrContributor(roles); + const adminOrCreator = authImpl.isAdminOrConceptCreator(roles); + return ( +
    +
    + + {adminOrContributor && ( + + )} + + {adminOrCreator && ( + -
    + )} + +
    + +
    - ); - } +
    + ); } - ConceptsHome.propTypes = { concepts: PropTypes.arrayOf(conceptOverviewPropTypes.isRequired), permission: permissionOverviewPropTypes.isRequired, }; -export default withRouter(ConceptsHome); +export default ConceptsHome; From d98edfd5248298e1e4c95f954675e3d028fe611c Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 17 Aug 2021 10:24:57 +0200 Subject: [PATCH 32/35] feat: add codelist --- app/src/index.js | 1 + .../components/code-detail/code-columns.js | 14 ++ .../src/components/code-detail/edit.js | 171 ++++++++++++++++++ .../src/components/code-detail/edit.scss | 13 ++ .../src/components/code-detail/index.js | 52 ++++++ .../src/components/code-detail/title.js | 17 ++ .../src/components/code-detail/view.js | 104 +++++++++++ .../src/components/code-detail/view.scss | 11 ++ .../src/components/codelist-detail/view.js | 14 +- .../src/components/codes-tree/index.js | 72 ++++++++ .../collapsible-panel.spec.js | 43 +++++ .../src/components/collapsible-panel/index.js | 63 +++++++ .../codelists/src/components/tree/index.js | 37 ++++ .../codelists/src/components/tree/tree.scss | 4 + packages/codelists/src/utils/index.js | 59 ++++-- 15 files changed, 655 insertions(+), 20 deletions(-) create mode 100644 packages/codelists/src/components/code-detail/code-columns.js create mode 100644 packages/codelists/src/components/code-detail/edit.js create mode 100644 packages/codelists/src/components/code-detail/edit.scss create mode 100644 packages/codelists/src/components/code-detail/index.js create mode 100644 packages/codelists/src/components/code-detail/title.js create mode 100644 packages/codelists/src/components/code-detail/view.js create mode 100644 packages/codelists/src/components/code-detail/view.scss create mode 100644 packages/codelists/src/components/codes-tree/index.js create mode 100644 packages/codelists/src/components/collapsible-panel/collapsible-panel.spec.js create mode 100644 packages/codelists/src/components/collapsible-panel/index.js create mode 100644 packages/codelists/src/components/tree/index.js create mode 100644 packages/codelists/src/components/tree/tree.scss diff --git a/app/src/index.js b/app/src/index.js index 6239ebd8d..ffd0f3e3b 100755 --- a/app/src/index.js +++ b/app/src/index.js @@ -13,6 +13,7 @@ import '@inseefr/iam/dist/index.css'; import 'bauhaus-operations/dist/index.css'; import 'bauhaus-structures/dist/index.css'; import 'bauhaus-utilities/dist/index.css'; +import 'bauhaus-codelists/dist/index.css'; import 'main.scss'; console.log("lol") diff --git a/packages/codelists/src/components/code-detail/code-columns.js b/packages/codelists/src/components/code-detail/code-columns.js new file mode 100644 index 000000000..2b5d079d8 --- /dev/null +++ b/packages/codelists/src/components/code-detail/code-columns.js @@ -0,0 +1,14 @@ +import { D1, D2 } from '../../i18n/build-dictionary'; + +export const rowParams = [ + { + dataField: 'code', + text: D1.codeTitle, + width: '8%', + isKey: true, + }, + { dataField: 'labelLg1', text: D1.codeLabel, width: '16%' }, + { dataField: 'labelLg2', text: D2.codeLabel, width: '16%' }, + { dataField: 'descriptionLg1', text: D1.codeDescription, width: '30%' }, + { dataField: 'descriptionLg2', text: D2.codeDescription, width: '30%' }, +]; diff --git a/packages/codelists/src/components/code-detail/edit.js b/packages/codelists/src/components/code-detail/edit.js new file mode 100644 index 000000000..143af4e5a --- /dev/null +++ b/packages/codelists/src/components/code-detail/edit.js @@ -0,0 +1,171 @@ +import React, { useState, useCallback, useEffect } from 'react'; +import { + CancelButton, + SaveButton, + ActionToolbar, + ErrorBloc, + LabelRequired, + Select, +} from '@inseefr/wilco'; +import PropTypes from 'prop-types'; +import { Stores } from 'bauhaus-utilities'; +import { validateCode } from '../../utils'; +import D, { D1, D2 } from '../../i18n/build-dictionary'; +import './edit.scss'; + +/** + * TODO: + * - Afficher le TreeView à gauche + * - Ajouter le formulaire vide à droite + * - Ajouter les boutons (qui ne font rien pour le moment) + * - Gérer le click sur un code -> initaliser le formulaire avec les bonnes données + * - Gérer l'ajout d'un nouveau code + * - Gérer la sauvegarde d'un code existant + * - Gérer la transformation TreeView -> Structure de données pour l'API + * - Gérer la suppression d'un code et remontée des enfants + * - gérer la suppression d'un code et suppression des enfants + * - Gérer le DragnDrop + */ +const DumbCodeDetailEdit = ({ + code: initialCode, + codes, + handleSave, + handleBack, + serverSideError, +}) => { + const [code, setCode] = useState({}); + useEffect(() => { + setCode({ ...initialCode }); + }, [initialCode]); + const [parents, setParents] = useState(code.parents); + + const handleChange = useCallback( + (e) => { + const { name, value } = e.target; + setCode({ + ...code, + [name]: value, + }); + }, + [code] + ); + + const codesOptions = codes + .map((code) => { + return { + label: code.code + ' - ' + code.labelLg1, + value: code.code, + }; + }) + .concat({ label: '', value: '' }); + + const handleSaveClick = useCallback(() => { + handleSave(code); + }, [code, handleSave]); + + const { field, message } = validateCode(code); + return ( + + + + + + {message && } + {serverSideError && } +
    +
    + {D.parentCodeTitle} + +
    +
    +
    +
    + {D1.codeLabel} + +
    +
    + {D2.codeLabel} + +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + + + ); +}; + +DumbCodeDetailEdit.propTypes = { + code: PropTypes.object, + handleSave: PropTypes.func, + handleBack: PropTypes.func, + secondLang: PropTypes.bool, +}; + +export const CodeDetailEdit = Stores.DisseminationStatus.withDisseminationStatusListOptions( + DumbCodeDetailEdit +); diff --git a/packages/codelists/src/components/code-detail/edit.scss b/packages/codelists/src/components/code-detail/edit.scss new file mode 100644 index 000000000..a57d955c4 --- /dev/null +++ b/packages/codelists/src/components/code-detail/edit.scss @@ -0,0 +1,13 @@ +.code-list-zone { + display: flex; + div:nth-child(1){ + flex: 1; + margin-bottom: 0; + } + + button { + padding: .5em 2em; + margin: 0 0 0 1em; + align-self: flex-end; + } +} diff --git a/packages/codelists/src/components/code-detail/index.js b/packages/codelists/src/components/code-detail/index.js new file mode 100644 index 000000000..4932288ba --- /dev/null +++ b/packages/codelists/src/components/code-detail/index.js @@ -0,0 +1,52 @@ +import React, { useCallback, useState } from 'react'; +import { CodeDetailEdit } from './edit'; +import { CodeDetailView } from './view'; +import CodeTitle from './title'; +import { useSelector } from 'react-redux'; +import { Stores } from 'bauhaus-utilities'; + +export const CodeDetail = (props) => { + const secondLang = useSelector(Stores.SecondLang.getSecondLang); + + const [mode, setMode] = useState( + !props.readOnly && !props.code?.labelLg1 ? 'EDIT' : 'VIEW' + ); + + const handleViewUpdate = useCallback(() => setMode('EDIT'), []); + const handleEditUpdate = useCallback( + (code) => { + props.handleSave(code); + setMode('VIEW'); + }, + [props] + ); + const handleEditBack = useCallback( + () => (!props.code.labelLg1 ? props.handleBack() : setMode('VIEW')), + [props] + ); + return ( +
    + {mode === 'VIEW' && ( + + + + + + )} + {mode === 'EDIT' && ( + + )} +
    + ); +}; diff --git a/packages/codelists/src/components/code-detail/title.js b/packages/codelists/src/components/code-detail/title.js new file mode 100644 index 000000000..413e19c48 --- /dev/null +++ b/packages/codelists/src/components/code-detail/title.js @@ -0,0 +1,17 @@ +import React from 'react'; +import { CheckSecondLang, PageTitleBlock } from 'bauhaus-utilities'; + +const CodeTitle = ({ code, secondLang }) => { + return ( + + + + + ); +}; + +export default CodeTitle; diff --git a/packages/codelists/src/components/code-detail/view.js b/packages/codelists/src/components/code-detail/view.js new file mode 100644 index 000000000..cb9c08cb5 --- /dev/null +++ b/packages/codelists/src/components/code-detail/view.js @@ -0,0 +1,104 @@ +import React from 'react'; +import { + Note, + UpdateButton, + ActionToolbar, + ReturnButton, + ErrorBloc, +} from '@inseefr/wilco'; +import D, { D1, D2 } from '../../i18n/build-dictionary'; +import { HTMLUtils, ValidationButton } from 'bauhaus-utilities'; +import PropTypes from 'prop-types'; +import './view.scss'; + +export const CodeDetailView = ({ + code, + codes, + handleUpdate, + handleBack, + updatable, + secondLang, + col = 3, + publishComponent, + serverSideError, +}) => { + const descriptionLg1 = HTMLUtils.renderMarkdownElement(code.descriptionLg1); + const descriptionLg2 = HTMLUtils.renderMarkdownElement(code.descriptionLg2); + + const publish = () => { + publishComponent(); + }; + + const codesOptions = codes.map((code) => { + return { + label: code.code + ' - ' + code.labelLg1, + value: code.code, + }; + }); + + return ( + + + + + {updatable && } + + + +
    + + {codesOptions + .filter( + ({ value }) => + code.parents && + code.parents.some((parent) => parent === value) + ) + .map((code) => ( +
  • {code.label}
  • + ))} + + } + title={D1.parentCodeTitle} + alone={true} + /> +
    +
    + +
    +
    + + {secondLang && ( + + )} +
    +
    + + {secondLang && ( + + )} +
    +
    + ); +}; + +CodeDetailView.propTypes = { + code: PropTypes.object, + codes: PropTypes.array, + handleUpdate: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), + handleBack: PropTypes.func, + updatable: PropTypes.bool, + secondLang: PropTypes.bool, + publishComponent: PropTypes.func, +}; diff --git a/packages/codelists/src/components/code-detail/view.scss b/packages/codelists/src/components/code-detail/view.scss new file mode 100644 index 000000000..7b6124f7a --- /dev/null +++ b/packages/codelists/src/components/code-detail/view.scss @@ -0,0 +1,11 @@ +.code-list-zone-view { + display: flex; + justify-content: space-between; + align-items: center; + + button { + padding: .5em 2em; + margin: 0 0 0 1em; + align-self: flex-end; + } +} diff --git a/packages/codelists/src/components/codelist-detail/view.js b/packages/codelists/src/components/codelist-detail/view.js index 97c9fdfdf..483fa6dbe 100644 --- a/packages/codelists/src/components/codelist-detail/view.js +++ b/packages/codelists/src/components/codelist-detail/view.js @@ -19,6 +19,7 @@ import PropTypes from 'prop-types'; import { treedData } from '../../utils'; import D, { D1, D2 } from '../../i18n/build-dictionary'; import { rowParams } from './code-detail'; +import CodesTree from '../codes-tree'; export const CodeListDetailView = ({ codelist, @@ -45,7 +46,7 @@ export const CodeListDetailView = ({ const unsortedCodes = Object.values(codelist.codes); const sortedCodes = unsortedCodes.sort((a, b) => (a.code > b.code ? 1 : -1)); - + const codes = Object.values(codelist.codes); return ( @@ -113,12 +114,13 @@ export const CodeListDetailView = ({ />
    )} - {codelist.codes && ( + {codelist.codes && codes.filter((code) => code.parents).length > 0 && (
    - } - title={D.listElements} - alone={true} +
    )} diff --git a/packages/codelists/src/components/codes-tree/index.js b/packages/codelists/src/components/codes-tree/index.js new file mode 100644 index 000000000..b35061989 --- /dev/null +++ b/packages/codelists/src/components/codes-tree/index.js @@ -0,0 +1,72 @@ +import React, { useCallback, useState } from 'react'; +import PropTypes from 'prop-types'; +import SlidingPanel from 'react-sliding-side-panel'; +import D from '../../i18n/build-dictionary'; +import { CollapsiblePanel } from '../collapsible-panel'; +import { CodeDetail } from '../code-detail'; +import RmesTree from '../tree'; + +const CodesTree = ({ hidden = false, codes, tree, handleAdd, readOnly }) => { + const [openPanel, setOpenPanel] = useState(false); + const [selectedCode, setSelectedCode] = useState(null); + + const seeClickHandler = useCallback( + (e) => { + const chosenCode = codes.find( + (c) => c.code === e.target.parentElement.dataset.componentId + ); + setSelectedCode(chosenCode); + setOpenPanel(true); + }, + [codes] + ); + + /* const addClickHandler = useCallback( + (e) => { + handleAdd(e.id); + }, + [handleAdd] + ); */ + + return ( +
    + ); +}; + +CollapsiblePanel.propTypes = { + id: PropTypes.string.isRequired, + title: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired, + children: PropTypes.oneOfType([ + PropTypes.array, + PropTypes.object, + PropTypes.element, + ]).isRequired, + hidden: PropTypes.bool, + collapsible: PropTypes.bool, +}; diff --git a/packages/codelists/src/components/tree/index.js b/packages/codelists/src/components/tree/index.js new file mode 100644 index 000000000..b19fbce21 --- /dev/null +++ b/packages/codelists/src/components/tree/index.js @@ -0,0 +1,37 @@ +import React, { useState } from 'react'; +import SortableTree from 'react-sortable-tree'; +import 'react-sortable-tree/style.css'; +import D from '../../i18n/build-dictionary'; + +import './tree.scss'; + +const RmesTree = (props) => { + const [treeData, setTreeData] = useState(props.treeData); + + console.log(treeData); + console.log(props.treeData); + return ( +
    + setTreeData(treeData)} + canDrag={!props.readOnly} + canDrop={() => !props.readOnly} + generateNodeProps={(rowInfo) => ({ + buttons: [ + , + ], + })} + /> +
    + ); +}; + +export default RmesTree; diff --git a/packages/codelists/src/components/tree/tree.scss b/packages/codelists/src/components/tree/tree.scss new file mode 100644 index 000000000..732f091cc --- /dev/null +++ b/packages/codelists/src/components/tree/tree.scss @@ -0,0 +1,4 @@ +.code-tree-detail { + border: none; + background: transparent; +} diff --git a/packages/codelists/src/utils/index.js b/packages/codelists/src/utils/index.js index 503813131..8426e22c4 100644 --- a/packages/codelists/src/utils/index.js +++ b/packages/codelists/src/utils/index.js @@ -6,7 +6,7 @@ export const formatLabel = (component) => { return {component.labelLg1}; }; -export const validateCodelist = (component) => { +export const validateCodelist = (codelist) => { const validations = { id: 'errorsIdMandatory', lastListUriSegment: 'lastListUriSegmentMandatory', @@ -17,7 +17,7 @@ export const validateCodelist = (component) => { disseminationStatus: 'errorsDisseminationStatusMandatory', }; - const field = Object.keys(validations).find((field) => !component[field]); + const field = Object.keys(validations).find((field) => !codelist[field]); if (field) { return { @@ -29,17 +29,48 @@ export const validateCodelist = (component) => { return {}; }; +export const validateCode = (code) => { + const validations = { + id: 'errorsIdMandatory', + labelLg1: 'errorsLabelLg1Mandatory', + labelLg2: 'errorsLabelLg1Mandatory', + }; + + const field = Object.keys(validations).find((field) => !code[field]); + + if (field) { + return { + field, + message: D[validations[field]], + }; + } + + return {}; +}; + +const treeElement = (n) => { + if (n.parents) { + return n.parents.map((p) => ({ + id: n.code, + title: n.code + ' - ' + n.labelLg1, + label: n.labelLg1, + parent: p, + })); + } + return { + id: n.code, + title: n.code + ' - ' + n.labelLg1, + label: n.labelLg1, + parent: null, + }; +}; + export const treedData = (arrayData) => { - return ( - getTreeFromFlatData({ - flatData: arrayData.map((n) => ({ - id: n.code, - label: n.labelLg1, - parent: n.parents ? n.parents[0] : 'root', - })), - getKey: (node) => node.id, - getParentKey: (node) => node.parent, - rootKey: 'root', - }) - ); + if (arrayData.length === 0) return []; + return getTreeFromFlatData({ + flatData: arrayData.map((n) => treeElement(n)).flat(), + getKey: (node) => node.id, + getParentKey: (node) => node.parent, + rootKey: null, + }); }; From b1e38d7aaeb56e3e134e1144e841d4933a271e82 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Tue, 17 Aug 2021 10:26:41 +0200 Subject: [PATCH 33/35] fix: remove console.log --- app/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/index.js b/app/src/index.js index ffd0f3e3b..4e56dc217 100755 --- a/app/src/index.js +++ b/app/src/index.js @@ -16,7 +16,7 @@ import 'bauhaus-utilities/dist/index.css'; import 'bauhaus-codelists/dist/index.css'; import 'main.scss'; -console.log("lol") + Api.getInit() .then( (res) => (res.ok ? res.json() : Promise.reject(res.statusText)), From 34f9ea07db21ba6efb6a01aa7a836e03d448fe64 Mon Sep 17 00:00:00 2001 From: Alice Lambois <35219063+alicela@users.noreply.github.com> Date: Tue, 17 Aug 2021 12:12:53 +0200 Subject: [PATCH 34/35] Remove duplicated creatorTitle --- app/src/js/i18n/dictionary/operations/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/js/i18n/dictionary/operations/index.js b/app/src/js/i18n/dictionary/operations/index.js index eeb0a392b..fe1570642 100644 --- a/app/src/js/i18n/dictionary/operations/index.js +++ b/app/src/js/i18n/dictionary/operations/index.js @@ -45,10 +45,6 @@ const dictionary = { fr: 'Créer un nouvel indicateur', en: 'Create a new indicator', }, - creatorTitle: { - fr: 'Propriétaires', - en: 'Owners', - }, operationsSearchTitle: { fr: 'Opérations - Recherche', en: 'Operations - Search', From 1b5fb3126483fc52cf720a3773cbde26233a12e8 Mon Sep 17 00:00:00 2001 From: Alice Lambois Date: Wed, 18 Aug 2021 09:42:51 +0200 Subject: [PATCH 35/35] Change version 3.0.8 --- .kubernetes/deployment.yml | 2 +- app/package.json | 2 +- sonar-project.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.kubernetes/deployment.yml b/.kubernetes/deployment.yml index a75c0a464..3bab7d340 100644 --- a/.kubernetes/deployment.yml +++ b/.kubernetes/deployment.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: bauhaus - image: nicolaslaval/bauhaus:3.0.7 + image: nicolaslaval/bauhaus:3.0.8 env: - name: API_BASE_HOST value: 'https://bauhaus-api.toto.fr/api' diff --git a/app/package.json b/app/package.json index 44aa21332..470d81cbf 100755 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "Bauhaus", - "version": "3.0.7", + "version": "3.0.8", "description": "Web application for the management of concepts, classifications and other statistical objects", "repository": { "type": "git", diff --git a/sonar-project.properties b/sonar-project.properties index dd87ccb74..5fced6082 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,7 +4,7 @@ sonar.host.url=https://sonarcloud.io # Project name & version sonar.projectName=Bauhaus -sonar.projectVersion=3.0.7 +sonar.projectVersion=3.0.8 # Path to sources sonar.sources=app/src,packages/operations/src,packages/structures/src,packages/utilities/src