From 476119d64ea93e5507d2c618a4e8a4c6705d361b Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 23 May 2024 15:54:37 +0200 Subject: [PATCH 01/15] Mutualize fetching functions --- package-lock.json | 166 +++++++++++++++--- package.json | 4 +- src/components/app-top-bar.jsx | 3 +- src/components/dialogs/commons/utils.tsx | 4 +- .../dialogs/contingency-list-selector.jsx | 5 - .../event/dynamic-simulation-event-dialog.tsx | 7 +- .../dialogs/import-modification-dialog.tsx | 5 - .../creation/battery-creation-dialog.jsx | 7 +- .../battery-modification-dialog.jsx | 7 +- .../by-filter-deletion-dialog.tsx | 7 +- .../by-filter-deletion-form.tsx | 10 -- .../by-formula/by-formula-dialog.jsx | 7 +- .../by-formula/formula/formula-form.tsx | 14 +- .../formula/reference-autocomplete-input.tsx | 5 +- .../delete-attaching-line-dialog.jsx | 7 +- .../delete-voltage-level-on-line-dialog.jsx | 7 +- .../equipment-deletion-dialog.jsx | 7 +- .../generation-dispatch-dialog.jsx | 7 +- .../generation-dispatch-form.jsx | 11 -- .../generator-scaling-dialog.jsx | 7 +- .../variation/variation-form.jsx | 6 - .../creation/generator-creation-dialog.jsx | 7 +- .../generator-modification-dialog.jsx | 7 +- .../line-attach-to-voltage-level-dialog.jsx | 7 +- .../line-split-with-voltage-level-dialog.jsx | 7 +- .../line/creation/line-creation-dialog.jsx | 2 +- .../modification/line-modification-dialog.jsx | 7 +- .../lines-attach-to-split-lines-dialog.jsx | 7 +- .../load-scaling/load-scaling-dialog.jsx | 7 +- .../load-scaling/variation/variation-form.jsx | 7 - .../load/creation/load-creation-dialog.jsx | 7 +- .../modification/load-modification-dialog.jsx | 7 +- .../shunt-compensator-creation-dialog.jsx | 7 +- .../shunt-compensator-modification-dialog.jsx | 7 +- .../creation/substation-creation-dialog.jsx | 7 +- .../substation-modification-dialog.jsx | 7 +- .../tabular-creation-dialog.jsx | 7 +- .../tabular-modification-dialog.jsx | 7 +- ...o-windings-transformer-creation-dialog.jsx | 7 +- ...ndings-transformer-modification-dialog.jsx | 7 +- .../voltage-init-modification-dialog.tsx | 8 +- .../voltage-level-creation-dialog.jsx | 7 +- .../voltage-level-modification-dialog.jsx | 7 +- .../vsc/creation/vsc-creation-dialog.jsx | 2 +- .../modification/vsc-modification-dialog.tsx | 7 +- .../common/parameters-creation-dialog.tsx | 11 +- .../parameters/load-flow-parameters.jsx | 5 - .../security-analysis-parameters.jsx | 5 - .../sensi/sensitivity-analysis-parameters.jsx | 5 - .../dialogs/parameters/sensi/table-cell.tsx | 10 -- .../voltageinit/voltage-init-parameters.tsx | 5 - .../parameters/widget/ParameterLine.tsx | 10 -- .../network-modification-node-editor.jsx | 3 +- .../network/filter-creation-panel.tsx | 6 - .../security-analysis-export-button.tsx | 3 +- .../sensitivity-analysis-result-tab.jsx | 3 +- .../shortcircuit-analysis-export-button.tsx | 3 +- src/components/utils/dnd-table/dnd-table.jsx | 7 - src/components/utils/inputs/input-hooks.jsx | 5 - src/components/voltage-init-result.jsx | 3 +- src/redux/store.js | 2 + src/services/case.ts | 2 +- src/services/config-notification.js | 3 +- src/services/config.js | 2 +- src/services/directory-notification.js | 3 +- src/services/directory.js | 27 +-- src/services/dynamic-simulation.ts | 2 +- src/services/explore.ts | 2 +- src/services/loadflow.js | 2 +- src/services/metadata.ts | 2 +- src/services/network-conversion.ts | 2 +- src/services/network-modification.js | 2 +- src/services/security-analysis.js | 2 +- src/services/sensitivity-analysis.js | 2 +- src/services/study-notification.js | 3 +- src/services/study/dynamic-simulation.js | 2 +- src/services/study/filter.ts | 2 +- src/services/study/geo-data.js | 2 +- src/services/study/index.js | 2 +- src/services/study/loadflow.js | 6 +- src/services/study/network-map.js | 2 +- src/services/study/network-modifications.js | 7 +- src/services/study/network.js | 4 +- src/services/study/non-evacuated-energy.js | 6 +- src/services/study/security-analysis.js | 2 +- src/services/study/sensitivity-analysis.js | 6 +- src/services/study/short-circuit-analysis.js | 6 +- src/services/study/study.ts | 2 +- src/services/study/tree-subtree.js | 2 +- src/services/study/voltage-init.js | 6 +- src/services/user-admin.js | 2 +- src/services/utils.js | 143 +-------------- src/services/voltage-init.ts | 2 +- 93 files changed, 379 insertions(+), 429 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a7d34b5b1..0e3cfc0e6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.55.0", + "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -3200,18 +3200,24 @@ } }, "node_modules/@gridsuite/commons-ui": { - "version": "0.55.0", - "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.55.0.tgz", - "integrity": "sha512-uCZhoE12/+G7//Msi9MkDudi/Q6VjjHA2Z9dv4zC82Kut0SJkdnMFiIwwl8wmtygxycd86OxpM1rV29MneZNSQ==", + "version": "0.58.0", + "resolved": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", + "integrity": "sha512-nJYq9ielHScIl+++vBp/j21ZDuQwAIZJ9K053CVPNuzro+9Qkd/DO86vrCuFXw5/UKk2qsdLLXC0sdum0zUUAw==", + "license": "MPL-2.0", "dependencies": { + "@react-querybuilder/dnd": "^7.2.0", + "@react-querybuilder/material": "^7.2.0", "autosuggest-highlight": "^3.3.4", "clsx": "^2.1.0", "jwt-decode": "^4.0.0", + "localized-countries": "^2.0.0", "memoize-one": "^6.0.0", "oidc-client": "^1.11.5", "prop-types": "^15.8.1", "react-csv-downloader": "^3.1.0", - "react-request-fullscreen": "^1.1.2", + "react-dnd": "^16.0.1", + "react-dnd-html5-backend": "^16.0.1", + "react-querybuilder": "^7.2.0", "react-virtualized": "^9.22.5", "uuid": "^9.0.1" }, @@ -3226,11 +3232,14 @@ "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", "@mui/material": "^5.15.14", + "ag-grid-community": "^31.0.0", + "ag-grid-react": "^31.2.0", "notistack": "^3.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.2", "react-intl": "^6.6.4", + "react-papaparse": "^4.1.0", "react-router-dom": "^6.22.3", "yup": "^1.4.0" } @@ -5213,6 +5222,45 @@ "@babel/runtime": "^7.0.0" } }, + "node_modules/@react-dnd/asap": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@react-dnd/asap/-/asap-5.0.2.tgz", + "integrity": "sha512-WLyfoHvxhs0V9U+GTsGilGgf2QsPl6ZZ44fnv0/b8T3nQyvzxidxsg/ZltbWssbsRDlYW8UKSQMTGotuTotZ6A==" + }, + "node_modules/@react-dnd/invariant": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@react-dnd/invariant/-/invariant-4.0.2.tgz", + "integrity": "sha512-xKCTqAK/FFauOM9Ta2pswIyT3D8AQlfrYdOi/toTPEhqCuAs1v5tcJ3Y08Izh1cJ5Jchwy9SeAXmMg6zrKs2iw==" + }, + "node_modules/@react-dnd/shallowequal": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@react-dnd/shallowequal/-/shallowequal-4.0.2.tgz", + "integrity": "sha512-/RVXdLvJxLg4QKvMoM5WlwNR9ViO9z8B/qPcc+C0Sa/teJY7QG7kJ441DwzOjMYEY7GmU4dj5EcGHIkKZiQZCA==" + }, + "node_modules/@react-querybuilder/dnd": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/@react-querybuilder/dnd/-/dnd-7.3.0.tgz", + "integrity": "sha512-o0NV47BCzApO/xs4U/eTJRETaRkrlVqXdpD1uxepeMW4E/iu6Se1mAQ7fSlvpq2Q8MjVmzEmnUz72xyQbsgXgQ==", + "peerDependencies": { + "react": ">=18", + "react-dnd": ">=14.0.0", + "react-dnd-html5-backend": ">=14.0.0", + "react-querybuilder": "^7.3.0" + } + }, + "node_modules/@react-querybuilder/material": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/@react-querybuilder/material/-/material-7.3.0.tgz", + "integrity": "sha512-qSGN6sBchSPp2rnqcjpFUDUDMykPW9UzZ1hZjkv1h+1RgrqTMZaOv2qoZsz/XFtfXTRViW7GqQfiSsSO2JLmKg==", + "peerDependencies": { + "@emotion/react": "^11", + "@emotion/styled": "^11", + "@mui/icons-material": ">=5.0.0", + "@mui/material": ">=5.0.0", + "react": ">=18", + "react-querybuilder": "^7.3.0" + } + }, "node_modules/@reduxjs/toolkit": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.3.tgz", @@ -8303,9 +8351,9 @@ } }, "node_modules/clsx": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", - "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", "engines": { "node": ">=6" } @@ -9314,6 +9362,24 @@ "node": ">=8" } }, + "node_modules/dnd-core": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/dnd-core/-/dnd-core-16.0.1.tgz", + "integrity": "sha512-HK294sl7tbw6F6IeuK16YSBUoorvHpY8RHO+9yFfaJyCDVb6n7PRcezrOEOa2SBCqiYpemh5Jx20ZcjKdFAVng==", + "dependencies": { + "@react-dnd/asap": "^5.0.1", + "@react-dnd/invariant": "^4.0.1", + "redux": "^4.2.0" + } + }, + "node_modules/dnd-core/node_modules/redux": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", + "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", + "dependencies": { + "@babel/runtime": "^7.9.2" + } + }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -11057,8 +11123,7 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-diff": { "version": "1.3.0", @@ -12112,9 +12177,9 @@ } }, "node_modules/immer": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.4.tgz", - "integrity": "sha512-cuBuGK40P/sk5IzWa9QPUaAdvPHjkk1c+xYsd9oZw+YQQEV+10G0P5uMpGctZZKnyQ+ibRO08bD25nWLmYi2pw==", + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", + "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/immer" @@ -15524,6 +15589,14 @@ "node": ">=0.10.0" } }, + "node_modules/numeric-quantity": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/numeric-quantity/-/numeric-quantity-2.0.1.tgz", + "integrity": "sha512-+Bt2X6YxM5bg8XIBl76NVeG2eL0Y5VQRoyz6GLYrZXW/TDh7We+tGeX4/WZWhaVGOg5ZjNBEOZt9a86slMhOJA==", + "engines": { + "node": ">=16" + } + }, "node_modules/nwsapi": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", @@ -16428,6 +16501,43 @@ "react": "^16.6.3 || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-dnd": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-16.0.1.tgz", + "integrity": "sha512-QeoM/i73HHu2XF9aKksIUuamHPDvRglEwdHL4jsp784BgUuWcg6mzfxT0QDdQz8Wj0qyRKx2eMg8iZtWvU4E2Q==", + "dependencies": { + "@react-dnd/invariant": "^4.0.1", + "@react-dnd/shallowequal": "^4.0.1", + "dnd-core": "^16.0.1", + "fast-deep-equal": "^3.1.3", + "hoist-non-react-statics": "^3.3.2" + }, + "peerDependencies": { + "@types/hoist-non-react-statics": ">= 3.3.1", + "@types/node": ">= 12", + "@types/react": ">= 16", + "react": ">= 16.14" + }, + "peerDependenciesMeta": { + "@types/hoist-non-react-statics": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-dnd-html5-backend": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-16.0.1.tgz", + "integrity": "sha512-Wu3dw5aDJmOGw8WjH1I1/yTH+vlXEL4vmjk5p+MHxP8HuHJS1lAGeIdG/hze1AvNeXWo/JgULV87LyQOr+r5jw==", + "dependencies": { + "dnd-core": "^16.0.1" + } + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -16600,10 +16710,25 @@ "react": ">0.13.0" } }, + "node_modules/react-querybuilder": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/react-querybuilder/-/react-querybuilder-7.3.0.tgz", + "integrity": "sha512-VzIhlXi4lPwGrR9xpC3fK3GJS5ZDzos4yuU5B7lfHkaY4f5GTidx5d6Ij/G6O+qgh1tmvQcEfC/E776SYOkhxw==", + "dependencies": { + "@reduxjs/toolkit": "^2.2.3", + "clsx": "^2.1.1", + "immer": "^10.1.1", + "numeric-quantity": "^2.0.1", + "react-redux": "^9.1.2" + }, + "peerDependencies": { + "react": ">=18" + } + }, "node_modules/react-redux": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz", - "integrity": "sha512-6qoDzIO+gbrza8h3hjMA9aq4nwVFCKFtY2iLxCtVT38Swyy2C/dJCGBXHeHLtx6qlg/8qzc2MrhOeduf5K32wQ==", + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.2.tgz", + "integrity": "sha512-0OA4dhM1W48l3uzmv6B7TXPCGmokUU4p1M44DGN2/D9a1FjVPukVjER1PcPX97jIg6aUeLq1XJo1IpfbgULn0w==", "dependencies": { "@types/use-sync-external-store": "^0.0.3", "use-sync-external-store": "^1.0.0" @@ -16611,16 +16736,12 @@ "peerDependencies": { "@types/react": "^18.2.25", "react": "^18.0", - "react-native": ">=0.69", "redux": "^5.0.0" }, "peerDependenciesMeta": { "@types/react": { "optional": true }, - "react-native": { - "optional": true - }, "redux": { "optional": true } @@ -16635,11 +16756,6 @@ "node": ">=0.10.0" } }, - "node_modules/react-request-fullscreen": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/react-request-fullscreen/-/react-request-fullscreen-1.1.2.tgz", - "integrity": "sha512-WsQ/htbZag9qNfWPb2fEm0if+oUsRK3rTKKJ007n64Mk0PY82gAbLwVKZ+7OmzkHm6f/PSkxf8pdYlzBUmXR/Q==" - }, "node_modules/react-resizable": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/react-resizable/-/react-resizable-3.0.5.tgz", diff --git a/package.json b/package.json index 7a7b5c250e..3d79c33433 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.55.0", + "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -106,8 +106,8 @@ "jest-environment-jsdom": "^29.7.0", "license-checker": "^25.0.1", "prettier": "^2.8.8", - "typescript": "5.1.6", "ts-node": "^10.9.2", + "typescript": "5.1.6", "vite": "^5.2.7", "vite-plugin-eslint": "^1.8.1", "vite-plugin-svgr": "^4.2.0", diff --git a/src/components/app-top-bar.jsx b/src/components/app-top-bar.jsx index 988119bd91..544e704dd3 100644 --- a/src/components/app-top-bar.jsx +++ b/src/components/app-top-bar.jsx @@ -15,6 +15,7 @@ import { OverflowableText, TagRenderer, TopBar, + fetchAppsAndUrls, } from '@gridsuite/commons-ui'; import GridStudyLogoLight from '../images/GridStudy_logo_light.svg?react'; import GridStudyLogoDark from '../images/GridStudy_logo_dark.svg?react'; @@ -62,7 +63,7 @@ import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES, } from './utils/equipment-types'; -import { fetchAppsAndUrls, fetchVersion } from '../services/utils'; +import { fetchVersion } from '../services/utils'; import { RunButtonContainer } from './run-button-container'; import { useComputationResultsCount } from '../hooks/use-computation-results-count'; diff --git a/src/components/dialogs/commons/utils.tsx b/src/components/dialogs/commons/utils.tsx index 2c22b1b00d..62e22fd317 100644 --- a/src/components/dialogs/commons/utils.tsx +++ b/src/components/dialogs/commons/utils.tsx @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export function getIdOrValue(value: { id: string; label: string } | string) { +export function getIdOrValue(value: any) { return typeof value !== 'string' ? value?.id ?? null : value; } -export function getLabelOrValue(value: { id: string; label: string } | string) { +export function getLabelOrValue(value: any) { return typeof value !== 'string' ? value?.label ?? null : value; } diff --git a/src/components/dialogs/contingency-list-selector.jsx b/src/components/dialogs/contingency-list-selector.jsx index 49730abc02..54ac169627 100644 --- a/src/components/dialogs/contingency-list-selector.jsx +++ b/src/components/dialogs/contingency-list-selector.jsx @@ -26,8 +26,6 @@ import { updateConfigParameter } from '../../services/config'; import { fetchContingencyAndFiltersLists } from '../../services/directory'; import { fetchContingencyCount } from '../../services/study'; import { DirectoryItemSelector } from '@gridsuite/commons-ui'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; import { isNodeBuilt } from 'components/graph/util/model-functions'; function makeButton(onClick, message, disabled) { @@ -247,9 +245,6 @@ const ContingencyListSelector = (props) => { onClose={addFavorites} types={CONTINGENCY_TYPES} title={intl.formatMessage({ id: 'ContingencyListsSelection' })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> ); diff --git a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx index 4c6b8d5e66..b3be84972c 100644 --- a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx +++ b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx @@ -26,8 +26,11 @@ import { fetchDynamicSimulationEvent, saveDynamicSimulationEvent, } from '../../../../services/dynamic-simulation'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; -import { FetchStatus } from '../../../../services/utils'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; export type DynamicSimulationEventDialogProps = { studyUuid: string; diff --git a/src/components/dialogs/import-modification-dialog.tsx b/src/components/dialogs/import-modification-dialog.tsx index a7121f8cb2..759a5e7239 100644 --- a/src/components/dialogs/import-modification-dialog.tsx +++ b/src/components/dialogs/import-modification-dialog.tsx @@ -16,8 +16,6 @@ import { CopyType } from '../graph/menus/network-modification-node-editor'; import { copyOrMoveModifications } from '../../services/study'; import { UUID } from 'crypto'; import { FunctionComponent } from 'react'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; /** * Dialog to select some network modifications and append them in the current node @@ -74,9 +72,6 @@ const ImportModificationDialog: FunctionComponent< title={intl.formatMessage({ id: 'ModificationsSelection', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> ); }; diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx index 0684d2a6ab..b49049ee16 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx @@ -10,7 +10,11 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -60,7 +64,6 @@ import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modi import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import PropTypes from 'prop-types'; import { createBattery } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx index 79039153e0..ba414ef18a 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx @@ -8,7 +8,11 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -55,7 +59,6 @@ import { } from '../../../set-points/set-points-utils'; import { modifyBattery } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx index 5054879bd0..d13f2abf0d 100644 --- a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx +++ b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx @@ -14,7 +14,11 @@ import { SPECIFIC_METADATA, TYPE, } from '../../../utils/field-constants'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { FunctionComponent, useCallback, useEffect } from 'react'; import ModificationDialog from '../../commons/modificationDialog'; @@ -22,7 +26,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipmentByFilter } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import ByFilterDeletionForm from './by-filter-deletion-form'; import { ByFilterDeletionDialogProps, diff --git a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-form.tsx b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-form.tsx index 83cf95ab53..811719fdd0 100644 --- a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-form.tsx +++ b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-form.tsx @@ -17,12 +17,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { DirectoryItemsInput } from '@gridsuite/commons-ui'; import { getIdOrValue } from '../../commons/utils'; -import { - fetchDirectoryContent, - fetchPath, - fetchRootFolders, -} from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; const ByFilterDeletionForm = () => { const intl = useIntl(); @@ -69,10 +63,6 @@ const ByFilterDeletionForm = () => { label={'filter'} equipmentTypes={[equipmentTypeWatch]} disable={!equipmentTypeWatch} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> ); }, [equipmentTypeWatch]); diff --git a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx index 8ae5f33cc9..20dff73d76 100644 --- a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx @@ -7,9 +7,12 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; -import { FetchStatus } from '../../../../services/utils'; import { useForm } from 'react-hook-form'; import ModificationDialog from '../../commons/modificationDialog'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; diff --git a/src/components/dialogs/network-modifications/by-formula/formula/formula-form.tsx b/src/components/dialogs/network-modifications/by-formula/formula/formula-form.tsx index 6f63063c26..1634ac76d2 100644 --- a/src/components/dialogs/network-modifications/by-formula/formula/formula-form.tsx +++ b/src/components/dialogs/network-modifications/by-formula/formula/formula-form.tsx @@ -24,12 +24,6 @@ import DragHandleIcon from '@mui/icons-material/DragHandle'; import { getIdOrValue, getLabelOrValue } from '../../../commons/utils'; import { useIntl } from 'react-intl'; import Grid from '@mui/material/Grid'; -import { - fetchDirectoryContent, - fetchPath, - fetchRootFolders, -} from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; interface FormulaProps { name: String; @@ -60,10 +54,6 @@ const FormulaForm: FunctionComponent = ({ name, index }) => { label={'filter'} titleId={'FiltersListsSelection'} disable={!equipmentTypeWatch} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> ); @@ -90,7 +80,9 @@ const FormulaForm: FunctionComponent = ({ name, index }) => { /> ); - const inputTransform = (value: { id: string; label: string } | string) => { + const inputTransform = ( + value: { id: string; label: string } | string | null + ) => { const newVal = value ?? null; return ( OPERATOR_OPTIONS.find( diff --git a/src/components/dialogs/network-modifications/by-formula/formula/reference-autocomplete-input.tsx b/src/components/dialogs/network-modifications/by-formula/formula/reference-autocomplete-input.tsx index a30c9494cc..01f0eef1e7 100644 --- a/src/components/dialogs/network-modifications/by-formula/formula/reference-autocomplete-input.tsx +++ b/src/components/dialogs/network-modifications/by-formula/formula/reference-autocomplete-input.tsx @@ -48,8 +48,9 @@ const ReferenceAutocompleteInput: FunctionComponent<{ [intl] ); - const inputTransform = (value: { id: string; label: string } | string) => - options.find((option) => option?.id === value) || value; + const inputTransform = ( + value: { id: string; label: string } | string | null + ) => options.find((option) => option?.id === value) || value; const outputTransform = (value: any) => { return value?.id ?? value; diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index ed308c11be..d5aa2afb2b 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { @@ -24,7 +28,6 @@ import ModificationDialog from '../../commons/modificationDialog'; import DeleteAttachingLineForm from './delete-attaching-line-form'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { deleteAttachingLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx index 31a764c595..184d0f17df 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; @@ -23,7 +27,6 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import DeleteVoltageLevelOnLineForm from './delete-voltage-level-on-line-form'; import { deleteVoltageLevelOnLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx index 83ee4198c0..7417a99b52 100644 --- a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx +++ b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx @@ -12,7 +12,11 @@ import { EQUIPMENT_ID, TYPE, } from '../../../utils/field-constants'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import React, { useCallback, useEffect } from 'react'; import ModificationDialog from '../../commons/modificationDialog'; @@ -22,7 +26,6 @@ import PropTypes from 'prop-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipment } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx index 306eb7e684..316828c8d7 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { @@ -30,7 +34,6 @@ import ModificationDialog from '../../commons/modificationDialog'; import GenerationDispatchForm from './generation-dispatch-form'; import { addSelectedFieldToRows } from 'components/utils/dnd-table/dnd-table'; import { generationDispatch } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LOSS_COEFFICIENT]: null, diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.jsx index 7b2365acf5..c910d153b5 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.jsx @@ -25,9 +25,6 @@ import FrequencyReservePane from './frequency-reserve-pane'; import { FormattedMessage } from 'react-intl'; import { FieldLabel } from '@gridsuite/commons-ui'; import SubstationsGeneratorsOrderingPane from './substations-generators-ordering-pane'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; -import { fetchPath } from '../../../../services/directory.js'; const GenerationDispatchForm = () => { const handleCoefficientValueChange = (id, value) => { @@ -57,10 +54,6 @@ const GenerationDispatchForm = () => { equipmentTypes={[EQUIPMENT_TYPES.GENERATOR]} elementType={ElementType.FILTER} titleId={'FiltersListsSelection'} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> @@ -98,10 +91,6 @@ const GenerationDispatchForm = () => { equipmentTypes={[EQUIPMENT_TYPES.GENERATOR]} elementType={ElementType.FILTER} titleId={'FiltersListsSelection'} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx index 5c661e2ae7..a0e24ac4b8 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx @@ -11,7 +11,11 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import GeneratorScalingForm from './generator-scaling-form'; import { useCallback, useEffect } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; import { @@ -20,7 +24,6 @@ import { } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { generatorScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx index 20f21857b4..3a8abefb9e 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx @@ -25,8 +25,6 @@ import { ActivePowerAdornment, gridItem } from '../../../dialogUtils'; import { ElementType, useSnackMessage } from '@gridsuite/commons-ui'; import { IDENTIFIER_LIST } from './variation-utils'; import { fetchElementsMetadata } from 'services/explore'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchPath } from '../../../../../services/directory.js'; const GENERATORS = [EQUIPMENT_TYPES.GENERATOR]; @@ -131,10 +129,6 @@ const VariationForm = ({ name, index }) => { label={'filter'} titleId={'FiltersListsSelection'} itemFilter={itemFilter} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> ); diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx index 801e9df2b4..88ae26a8ba 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx @@ -10,7 +10,11 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -74,7 +78,6 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import { createGenerator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx index 309739a172..efdc6b4e1a 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx @@ -8,7 +8,11 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -71,7 +75,6 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyGenerator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index ac0cd93251..189668f1c9 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ATTACHMENT_LINE_ID, @@ -45,7 +49,6 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { attachLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index 6890336e05..a7805fad46 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { BUS_OR_BUSBAR_SECTION, @@ -43,7 +47,6 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { divideLine } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index 671f5ec3b3..dbf0d4186c 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -9,6 +9,7 @@ import { CustomFormProvider, TextInput, useSnackMessage, + FetchStatus, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Grid } from '@mui/material'; @@ -44,7 +45,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY, diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index 8910816468..e079e49084 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -6,7 +6,11 @@ */ import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ADDITIONAL_PROPERTIES, @@ -60,7 +64,6 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyLine } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index 18549a725a..a110194148 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { sanitizeString } from 'components/dialogs/dialogUtils'; import PropTypes from 'prop-types'; @@ -38,7 +42,6 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { linesAttachToSplitLines } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx index bfb68b4500..f26bebccab 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx @@ -11,7 +11,11 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import LoadScalingForm from './load-scaling-form'; import { useCallback, useEffect } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; import { @@ -20,7 +24,6 @@ import { } from 'components/network/constants'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { loadScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.jsx b/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.jsx index 3f072575dd..f1e58560fc 100644 --- a/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.jsx +++ b/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.jsx @@ -26,9 +26,6 @@ import { FloatInput } from '@gridsuite/commons-ui'; import { ActivePowerAdornment, gridItem } from '../../../dialogUtils'; import { ElementType } from '@gridsuite/commons-ui'; import { IDENTIFIER_LIST } from './variation-utils'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; -import { fetchPath } from '../../../../../services/directory.js'; const LOADS = [EQUIPMENT_TYPES.LOAD]; @@ -68,10 +65,6 @@ const VariationForm = ({ name, index }) => { label={'filter'} titleId={'FiltersListsSelection'} itemFilter={itemFilter} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> ); diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx index f3f66dc644..61c520fe23 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { EQUIPMENT_ID, @@ -36,7 +40,6 @@ import LoadCreationForm from './load-creation-form'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { createLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx index 3600224472..a26bfe99d6 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; @@ -29,7 +33,6 @@ import { EQUIPMENT_TYPES, } from 'components/utils/equipment-types'; import { modifyLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index 3c276fc00a..b41332d7f8 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { @@ -50,7 +54,6 @@ import { } from '../characteristics-pane/characteristics-form-utils'; import ShuntCompensatorCreationForm from './shunt-compensator-creation-form'; import { createShuntCompensator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx index 2c216b4d02..312fbbed58 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { ADDITIONAL_PROPERTIES, CHARACTERISTICS_CHOICE, @@ -38,7 +42,6 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyShuntCompensator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index 4ad443eb0e..20ce11a317 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -10,7 +10,11 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import React, { useCallback, useEffect } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; @@ -24,7 +28,6 @@ import { sanitizeString } from '../../../dialogUtils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { createSubstation } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx index 862a5dd27b..deba850873 100644 --- a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx @@ -8,7 +8,11 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -27,7 +31,6 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifySubstation } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx index d3392ceb02..9b3e71a1ff 100644 --- a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx @@ -7,7 +7,11 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; @@ -20,7 +24,6 @@ import { } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabularCreation } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils'; import TabularCreationForm from './tabular-creation-form'; import { convertCreationFieldFromBackToFront, diff --git a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx index 98c808f39a..3c76ac5409 100644 --- a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx @@ -7,7 +7,11 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; @@ -16,7 +20,6 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { MODIFICATIONS_TABLE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabulareModification } from 'services/study/network-modifications'; -import { FetchStatus } from 'services/utils'; import TabularModificationForm from './tabular-modification-form'; import { convertValueFromBackToFront, diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index 6ddce34cf9..a7e1c0281b 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Grid } from '@mui/material'; import { @@ -54,7 +58,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { sanitizeString } from '../../../dialogUtils'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx index fe39e8fd79..6bb3299195 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Grid } from '@mui/material'; import { @@ -107,7 +111,6 @@ import { fetchNetworkElementInfos, fetchVoltageLevelsListInfos, } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx index 14a28ed513..0b57e5322a 100644 --- a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { FetchStatus } from '@gridsuite/commons-ui'; import React, { FunctionComponent, useCallback, @@ -53,13 +54,6 @@ export const EquipmentTypeTabs = { BUS_TAB: 5, }; -enum FetchStatus { - SUCCEED = 'SUCCEED', - FAILED = 'FAILED', - IDLE = 'IDLE', - RUNNING = 'RUNNING', -} - interface CloseFunction { (): void; } diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx index 49d31eabcb..322bb7c978 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx @@ -5,7 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { sanitizeString } from 'components/dialogs/dialogUtils'; import EquipmentSearchDialog from 'components/dialogs/equipment-search-dialog'; @@ -45,7 +49,6 @@ import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { createVoltageLevel } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx index df9b977fa4..3c4d9977f2 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx @@ -21,7 +21,11 @@ import { } from 'components/utils/field-constants'; import yup from 'components/utils/yup-config'; import { yupResolver } from '@hookform/resolvers/yup'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; @@ -32,7 +36,6 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyVoltageLevel } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx index 612bd5e7d2..8ffc8af1c4 100644 --- a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx @@ -10,6 +10,7 @@ import { CustomFormProvider, TextInput, useSnackMessage, + FetchStatus, } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -47,7 +48,6 @@ import { getVscHvdcLinePaneSchema, getVscHvdcLineTabFormData, } from '../hvdc-line-pane/vsc-hvdc-line-pane-utils'; -import { FetchStatus } from '../../../../../services/utils'; import { getConverterStationCreationData, getConverterStationFormEditData, diff --git a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx index 429ea08864..d05e3f28d4 100644 --- a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx @@ -40,7 +40,6 @@ import { REACTIVE_CAPABILITY_CURVE_TABLE, REACTIVE_LIMITS, } from '../../../../utils/field-constants'; -import { FetchStatus } from '../../../../../services/utils'; import { getVscHvdcLineModificationPaneSchema, getVscHvdcLineModificationTabFormData, @@ -64,7 +63,11 @@ import { setCurrentReactiveCapabilityCurveTable, setSelectedReactiveLimits, } from 'components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-utils'; -import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + useSnackMessage, + FetchStatus, +} from '@gridsuite/commons-ui'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx index e48eb843b3..b1208ab484 100644 --- a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx +++ b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx @@ -13,11 +13,7 @@ import { FieldValues, useForm, UseFormGetValues } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Button, CircularProgress, Grid, Typography } from '@mui/material'; import { FormattedMessage, useIntl } from 'react-intl'; -import { - fetchDirectoryContent, - fetchPath, - fetchRootFolders, -} from 'services/directory'; +import { fetchPath } from 'services/directory'; import { CustomFormProvider, DirectoryItemSelector, @@ -25,7 +21,7 @@ import { TreeViewFinderNodeProps, } from '@gridsuite/commons-ui'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; -import { createParameter, fetchElementsMetadata } from 'services/explore'; +import { createParameter } from 'services/explore'; import { UniqueNameInput } from 'components/dialogs/commons/unique-name-input'; import { ReduxState } from 'redux/reducer.type'; import { UUID } from 'crypto'; @@ -180,9 +176,6 @@ const CreateParameterDialog = ({ title={intl.formatMessage({ id: 'showSelectDirectoryDialog', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> diff --git a/src/components/dialogs/parameters/load-flow-parameters.jsx b/src/components/dialogs/parameters/load-flow-parameters.jsx index 4f3a283e77..16a4254a9d 100644 --- a/src/components/dialogs/parameters/load-flow-parameters.jsx +++ b/src/components/dialogs/parameters/load-flow-parameters.jsx @@ -32,8 +32,6 @@ import { mergeSx } from '../../utils/functions'; import CreateParameterDialog from './common/parameters-creation-dialog'; import { DirectoryItemSelector } from '@gridsuite/commons-ui'; import { fetchLoadFlowParameters } from '../../../services/loadflow'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; const CountrySelector = ({ value, label, callback }) => { const { translate, countryCodes } = useLocalizedCountries(); @@ -720,9 +718,6 @@ export const LoadFlowParameters = ({ parametersBackend }) => { validationButtonText={intl.formatMessage({ id: 'validate', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> )} diff --git a/src/components/dialogs/parameters/security-analysis-parameters.jsx b/src/components/dialogs/parameters/security-analysis-parameters.jsx index a0d2db1393..66b8fef4b7 100644 --- a/src/components/dialogs/parameters/security-analysis-parameters.jsx +++ b/src/components/dialogs/parameters/security-analysis-parameters.jsx @@ -27,8 +27,6 @@ import CreateParameterDialog from './common/parameters-creation-dialog'; import { DirectoryItemSelector } from '@gridsuite/commons-ui'; import { fetchSecurityAnalysisParameters } from '../../../services/security-analysis'; import { ElementType, useSnackMessage } from '@gridsuite/commons-ui'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; const formatValues = (values, isDivision) => { let result = {}; @@ -390,9 +388,6 @@ export const SecurityAnalysisParameters = ({ parametersBackend }) => { validationButtonText={intl.formatMessage({ id: 'validate', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> )} diff --git a/src/components/dialogs/parameters/sensi/sensitivity-analysis-parameters.jsx b/src/components/dialogs/parameters/sensi/sensitivity-analysis-parameters.jsx index 75104e58a7..429a5a9f23 100644 --- a/src/components/dialogs/parameters/sensi/sensitivity-analysis-parameters.jsx +++ b/src/components/dialogs/parameters/sensi/sensitivity-analysis-parameters.jsx @@ -72,8 +72,6 @@ import { } from './utils'; import { mergeSx } from 'components/utils/functions'; import CreateParameterDialog from '../common/parameters-creation-dialog'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; const formSchema = yup .object() @@ -661,9 +659,6 @@ export const SensitivityAnalysisParameters = ({ validationButtonText={intl.formatMessage({ id: 'validate', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> )} diff --git a/src/components/dialogs/parameters/sensi/table-cell.tsx b/src/components/dialogs/parameters/sensi/table-cell.tsx index f5c055732f..a3e4112e61 100644 --- a/src/components/dialogs/parameters/sensi/table-cell.tsx +++ b/src/components/dialogs/parameters/sensi/table-cell.tsx @@ -14,12 +14,6 @@ import { FloatInput, TextInput, } from '@gridsuite/commons-ui'; -import { - fetchDirectoryContent, - fetchPath, - fetchRootFolders, -} from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; function EditableTableCell( arrayFormName: string, @@ -50,10 +44,6 @@ function EditableTableCell( label={undefined} itemFilter={undefined} onRowChanged={handleDirectoryItemsChange} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> )} {column.menuItems && ( diff --git a/src/components/dialogs/parameters/voltageinit/voltage-init-parameters.tsx b/src/components/dialogs/parameters/voltageinit/voltage-init-parameters.tsx index 4d4e6fc62a..2a2a6a66da 100644 --- a/src/components/dialogs/parameters/voltageinit/voltage-init-parameters.tsx +++ b/src/components/dialogs/parameters/voltageinit/voltage-init-parameters.tsx @@ -43,8 +43,6 @@ import { } from './voltage-init-utils'; import { getVoltageInitParameters } from 'services/voltage-init'; import { mergeSx } from 'components/utils/functions'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; import { GeneralParameters } from './general-parameters'; import { GENERAL, @@ -359,9 +357,6 @@ export const VoltageInitParameters = ({ validationButtonText={intl.formatMessage({ id: 'validate', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> )} diff --git a/src/components/dialogs/parameters/widget/ParameterLine.tsx b/src/components/dialogs/parameters/widget/ParameterLine.tsx index 1d93cdc8b5..08e697c226 100644 --- a/src/components/dialogs/parameters/widget/ParameterLine.tsx +++ b/src/components/dialogs/parameters/widget/ParameterLine.tsx @@ -13,12 +13,6 @@ import { Mark } from '@mui/base/useSlider'; import { DirectoryItemsInput } from '@gridsuite/commons-ui'; import { SelectInputProps } from '@mui/material/Select/SelectInput'; import { mergeSx } from '../../../utils/functions'; -import { - fetchDirectoryContent, - fetchPath, - fetchRootFolders, -} from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; export enum ParameterType { Switch, @@ -232,10 +226,6 @@ const ParamLineDirectoryItemsInput: FunctionComponent< hideErrorMessage={props.hideErrorMessage} label={undefined} itemFilter={undefined} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> diff --git a/src/components/graph/menus/network-modification-node-editor.jsx b/src/components/graph/menus/network-modification-node-editor.jsx index 52f1e05e00..76c6409f7f 100644 --- a/src/components/graph/menus/network-modification-node-editor.jsx +++ b/src/components/graph/menus/network-modification-node-editor.jsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useEffect, useRef, useState } from 'react'; -import { useSnackMessage } from '@gridsuite/commons-ui'; +import { useSnackMessage, FetchStatus } from '@gridsuite/commons-ui'; import { useDispatch, useSelector } from 'react-redux'; import LineAttachToVoltageLevelDialog from 'components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog'; import NetworkModificationsMenu from 'components/graph/menus/network-modifications-menu'; @@ -74,7 +74,6 @@ import { stashModifications, fetchNetworkModifications, } from '../../../services/study/network-modifications'; -import { FetchStatus } from '../../../services/utils'; import { copyOrMoveModifications } from '../../../services/study'; import { MODIFICATION_TYPES } from 'components/utils/modification-type'; import RestoreModificationDialog from 'components/dialogs/restore-modification-dialog'; diff --git a/src/components/network/filter-creation-panel.tsx b/src/components/network/filter-creation-panel.tsx index 6cddf0dbbf..b05780e80d 100644 --- a/src/components/network/filter-creation-panel.tsx +++ b/src/components/network/filter-creation-panel.tsx @@ -21,11 +21,8 @@ import { FILTER_NAME, NAME } from 'components/utils/field-constants'; import { GridSection } from 'components/dialogs/dialogUtils'; import { FormattedMessage, useIntl } from 'react-intl'; import { - fetchDirectoryContent, fetchPath, - fetchRootFolders, } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; import { UniqueNameInput } from 'components/dialogs/commons/unique-name-input'; import { useSelector } from 'react-redux'; import { @@ -207,9 +204,6 @@ const FilterCreationPanel: React.FC = ({ title={intl.formatMessage({ id: 'showSelectDirectoryDialog', })} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> diff --git a/src/components/results/securityanalysis/security-analysis-export-button.tsx b/src/components/results/securityanalysis/security-analysis-export-button.tsx index 02340f8367..a782be6830 100644 --- a/src/components/results/securityanalysis/security-analysis-export-button.tsx +++ b/src/components/results/securityanalysis/security-analysis-export-button.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useSnackMessage } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; import { ExportButton } from 'components/utils/export-button'; import { UUID } from 'crypto'; import { @@ -17,7 +17,6 @@ import { } from 'react'; import { useIntl } from 'react-intl'; import { downloadSecurityAnalysisResultZippedCsv } from 'services/study/security-analysis'; -import { downloadZipFile } from 'services/utils'; import { RESULT_TYPE } from './security-analysis-result-utils'; import { PERMANENT_LIMIT_NAME } from '../common/utils'; diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx index e35d859147..a9684a0b4d 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx @@ -29,8 +29,7 @@ import { useOpenLoaderShortWait } from '../../dialogs/commons/handle-loader'; import { RESULTS_LOADING_DELAY } from '../../network/constants'; import React, { useCallback } from 'react'; import { exportSensitivityResultsAsCsv } from '../../../services/study/sensitivity-analysis'; -import { downloadZipFile } from '../../../services/utils'; -import { useSnackMessage } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { ExportButton } from '../../utils/export-button'; import { setSensitivityAnalysisResultFilter } from 'redux/actions'; diff --git a/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx b/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx index 581d89eab0..7802963813 100644 --- a/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx +++ b/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx @@ -13,10 +13,9 @@ import { useState, } from 'react'; import { ExportButton } from '../../utils/export-button'; -import { useSnackMessage } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { downloadShortCircuitResultZippedCsv } from '../../../services/study/short-circuit-analysis'; -import { downloadZipFile } from '../../../services/utils'; import { ShortCircuitAnalysisType } from './shortcircuit-analysis-result.type'; import { UUID } from 'crypto'; diff --git a/src/components/utils/dnd-table/dnd-table.jsx b/src/components/utils/dnd-table/dnd-table.jsx index 45181d583d..b21f9ac0d0 100644 --- a/src/components/utils/dnd-table/dnd-table.jsx +++ b/src/components/utils/dnd-table/dnd-table.jsx @@ -34,9 +34,6 @@ import { FieldErrorAlert } from '@gridsuite/commons-ui'; import DndTableAddRowsDialog from './dnd-table-add-rows-dialog'; import { DirectoryItemsInput } from '@gridsuite/commons-ui'; import ChipItemsInput from '../rhf-inputs/chip-items-input'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; -import { fetchPath } from '../../../services/directory.js'; export const MAX_ROWS_NUMBER = 100; const styles = { @@ -134,10 +131,6 @@ function EditableTableCell({ elementType={column.elementType} titleId={column.titleId} hideErrorMessage={true} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} - fetchDirectoryElementPath={fetchPath} /> )} {column.chipItems && ( diff --git a/src/components/utils/inputs/input-hooks.jsx b/src/components/utils/inputs/input-hooks.jsx index ce0be13591..6b5d56bdd4 100644 --- a/src/components/utils/inputs/input-hooks.jsx +++ b/src/components/utils/inputs/input-hooks.jsx @@ -40,8 +40,6 @@ import { DirectoryItemSelector } from '@gridsuite/commons-ui'; import { useCSVReader } from 'react-papaparse'; import { isNodeExists } from '../../../services/study'; import { mergeSx } from '../functions'; -import { fetchDirectoryContent, fetchRootFolders } from 'services/directory'; -import { fetchElementsMetadata } from 'services/explore'; export const useInputForm = () => { const validationMap = useRef(new Map()); @@ -358,9 +356,6 @@ export const useDirectoryElements = ({ equipmentTypes={equipmentTypes} title={intl.formatMessage({ id: titleId })} itemFilter={itemFilter} - fetchDirectoryContent={fetchDirectoryContent} - fetchRootFolders={fetchRootFolders} - fetchElementsInfos={fetchElementsMetadata} /> ); diff --git a/src/components/voltage-init-result.jsx b/src/components/voltage-init-result.jsx index e1bc3c7ba5..9c1913e18f 100644 --- a/src/components/voltage-init-result.jsx +++ b/src/components/voltage-init-result.jsx @@ -14,7 +14,7 @@ import { LinearProgress, Stack, Typography } from '@mui/material'; import { Lens } from '@mui/icons-material'; import Button from '@mui/material/Button'; import { useParams } from 'react-router-dom'; -import { useSnackMessage } from '@gridsuite/commons-ui'; +import { useSnackMessage, FetchStatus } from '@gridsuite/commons-ui'; import { cloneVoltageInitModifications, getVoltageInitModifications, @@ -22,7 +22,6 @@ import { import CircularProgress from '@mui/material/CircularProgress'; import { Box } from '@mui/system'; import VoltageInitModificationDialog from './dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog'; -import { FetchStatus } from '../services/utils'; import { ComputationReportViewer } from './results/common/computation-report-viewer'; import { REPORT_TYPES } from './utils/report-type'; import { useOpenLoaderShortWait } from './dialogs/commons/handle-loader'; diff --git a/src/redux/store.js b/src/redux/store.js index 43e7b6283a..8aabc6431a 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -7,8 +7,10 @@ import { legacy_createStore as createStore } from 'redux'; import { reducer } from './reducer'; +import { setCommonStore } from '@gridsuite/commons-ui'; export const store = createStore(reducer); +setCommonStore(store); // to avoid to reset the state with HMR // https://redux.js.org/usage/configuring-your-store#hot-reloading diff --git a/src/services/case.ts b/src/services/case.ts index 1a6fec9098..0111a32411 100644 --- a/src/services/case.ts +++ b/src/services/case.ts @@ -6,7 +6,7 @@ */ import { UUID } from 'crypto'; -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_CASE_QUERIES = import.meta.env.VITE_API_GATEWAY + '/case'; diff --git a/src/services/config-notification.js b/src/services/config-notification.js index c3441065f9..50713d37e1 100644 --- a/src/services/config-notification.js +++ b/src/services/config-notification.js @@ -6,7 +6,8 @@ */ import { APP_NAME } from '../utils/config-params'; import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getUrlWithToken, getWsBase } from './utils'; +import { getUrlWithToken } from './utils'; +import { getWsBase } from '@gridsuite/commons-ui'; const PREFIX_CONFIG_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/config-notification'; diff --git a/src/services/config.js b/src/services/config.js index 9d78b22db7..980e5e5be7 100644 --- a/src/services/config.js +++ b/src/services/config.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { getAppName } from '../utils/config-params'; -import { backendFetch, backendFetchJson } from './utils'; +import { backendFetch, backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_CONFIG_QUERIES = import.meta.env.VITE_API_GATEWAY + '/config'; diff --git a/src/services/directory-notification.js b/src/services/directory-notification.js index 89314bb952..2a51a06f78 100644 --- a/src/services/directory-notification.js +++ b/src/services/directory-notification.js @@ -6,7 +6,8 @@ */ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getToken, getUrlWithToken, getWsBase } from './utils'; +import { getToken, getUrlWithToken } from './utils'; +import { getWsBase } from '@gridsuite/commons-ui'; const PREFIX_DIRECTORY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/directory-notification'; diff --git a/src/services/directory.js b/src/services/directory.js index d35dab1081..80dfbe241d 100644 --- a/src/services/directory.js +++ b/src/services/directory.js @@ -5,33 +5,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson, getRequestParamFromList } from './utils'; +import { + backendFetchJson, + getRequestParamFromList, +} from '@gridsuite/commons-ui'; const PREFIX_DIRECTORY_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/directory'; -export function fetchRootFolders(types) { - console.info('Fetching Root Directories'); - - // Add params to Url - const typesParams = getRequestParamFromList(types, 'elementTypes'); - const urlSearchParams = new URLSearchParams(typesParams); - - const fetchRootFoldersUrl = `${PREFIX_DIRECTORY_SERVER_QUERIES}/v1/root-directories?${urlSearchParams}`; - return backendFetchJson(fetchRootFoldersUrl); -} - -export function fetchDirectoryContent(directoryUuid, types) { - console.info("Fetching Folder content '%s'", directoryUuid); - - // Add params to Url - const typesParams = getRequestParamFromList(types, 'elementTypes'); - const urlSearchParams = new URLSearchParams(typesParams); - - const fetchDirectoryContentUrl = `${PREFIX_DIRECTORY_SERVER_QUERIES}/v1/directories/${directoryUuid}/elements?${urlSearchParams}`; - return backendFetchJson(fetchDirectoryContentUrl); -} - export function fetchContingencyAndFiltersLists(listIds) { console.info('Fetching contingency and filters lists'); diff --git a/src/services/dynamic-simulation.ts b/src/services/dynamic-simulation.ts index a3b2a109f9..7607ccfeab 100644 --- a/src/services/dynamic-simulation.ts +++ b/src/services/dynamic-simulation.ts @@ -10,7 +10,7 @@ import { backendFetch, backendFetchJson, getRequestParamFromList, -} from './utils'; +} from '@gridsuite/commons-ui'; import { getStudyUrlWithNodeUuid } from './study'; import { UUID } from 'crypto'; import { diff --git a/src/services/explore.ts b/src/services/explore.ts index 6292e83dfe..ab882a3fc1 100644 --- a/src/services/explore.ts +++ b/src/services/explore.ts @@ -9,7 +9,7 @@ import { backendFetch, backendFetchJson, getRequestParamFromList, -} from './utils'; +} from '@gridsuite/commons-ui'; import { UUID } from 'crypto'; const PREFIX_EXPLORE_SERVER_QUERIES = diff --git a/src/services/loadflow.js b/src/services/loadflow.js index f6b4acfbce..f4a507d68a 100644 --- a/src/services/loadflow.js +++ b/src/services/loadflow.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_LOADFLOW_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/loadflow'; diff --git a/src/services/metadata.ts b/src/services/metadata.ts index ec8c98e3d2..d07d8dad2e 100644 --- a/src/services/metadata.ts +++ b/src/services/metadata.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { fetchAppsAndUrls } from './utils'; +import { fetchAppsAndUrls } from '@gridsuite/commons-ui'; import { PredefinedProperties } from 'components/dialogs/network-modifications/common/properties/property-utils'; export interface Metadata { diff --git a/src/services/network-conversion.ts b/src/services/network-conversion.ts index 9da901593c..c30bb369a2 100644 --- a/src/services/network-conversion.ts +++ b/src/services/network-conversion.ts @@ -6,7 +6,7 @@ */ import { UUID } from 'crypto'; -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_NETWORK_CONVERSION_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/network-conversion'; diff --git a/src/services/network-modification.js b/src/services/network-modification.js index e48d38b223..8f6d0f7c20 100644 --- a/src/services/network-modification.js +++ b/src/services/network-modification.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetch, backendFetchJson } from './utils'; +import { backendFetch, backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_NETWORK_MODIFICATION_QUERIES = import.meta.env.VITE_API_GATEWAY + '/network-modification'; diff --git a/src/services/security-analysis.js b/src/services/security-analysis.js index 2d86db534c..e18683621f 100644 --- a/src/services/security-analysis.js +++ b/src/services/security-analysis.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_SECURITY_ANALYSIS_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/security-analysis'; diff --git a/src/services/sensitivity-analysis.js b/src/services/sensitivity-analysis.js index fe54dc9ac9..e9a18bcc5f 100644 --- a/src/services/sensitivity-analysis.js +++ b/src/services/sensitivity-analysis.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; const PREFIX_SENSITIVITY_ANALYSIS_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/sensitivity-analysis'; diff --git a/src/services/study-notification.js b/src/services/study-notification.js index 580507120a..8699df45a0 100644 --- a/src/services/study-notification.js +++ b/src/services/study-notification.js @@ -7,7 +7,8 @@ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getUrlWithToken, getWsBase } from './utils'; +import { getUrlWithToken } from './utils'; +import { getWsBase } from '@gridsuite/commons-ui'; const PREFIX_STUDY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/study-notification'; diff --git a/src/services/study/dynamic-simulation.js b/src/services/study/dynamic-simulation.js index 813ff1888b..6fc7e36c99 100644 --- a/src/services/study/dynamic-simulation.js +++ b/src/services/study/dynamic-simulation.js @@ -16,7 +16,7 @@ import { backendFetchJson, backendFetchText, getRequestParamFromList, -} from '../utils'; +} from '@gridsuite/commons-ui'; export function getDynamicMappings(studyUuid) { console.info(`Fetching dynamic mappings on '${studyUuid}' ...`); diff --git a/src/services/study/filter.ts b/src/services/study/filter.ts index 453f9d1953..a7dbc6426f 100644 --- a/src/services/study/filter.ts +++ b/src/services/study/filter.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson } from '../utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; import { UUID } from 'crypto'; import { getStudyUrlWithNodeUuid } from './index'; import { RuleGroupTypeExport } from '../../components/dialogs/filter/expert/expert-filter.type'; diff --git a/src/services/study/geo-data.js b/src/services/study/geo-data.js index c2591e98df..d0292ebdad 100644 --- a/src/services/study/geo-data.js +++ b/src/services/study/geo-data.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson, getQueryParamsList } from '../utils'; +import { backendFetchJson, getQueryParamsList } from '@gridsuite/commons-ui'; import { getStudyUrlWithNodeUuid } from './index'; export function fetchSubstationPositions( diff --git a/src/services/study/index.js b/src/services/study/index.js index 9ce1ffe94a..d4bfc22665 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.js @@ -11,7 +11,7 @@ import { backendFetchText, getQueryParamsList, getRequestParamFromList, -} from '../utils'; +} from '@gridsuite/commons-ui'; export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; diff --git a/src/services/study/loadflow.js b/src/services/study/loadflow.js index 10d3e8097e..7ca4294a2c 100644 --- a/src/services/study/loadflow.js +++ b/src/services/study/loadflow.js @@ -10,7 +10,11 @@ import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES, } from './index'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; export function getDefaultLoadFlowProvider() { console.info('get default load flow provier'); diff --git a/src/services/study/network-map.js b/src/services/study/network-map.js index a65558ea9d..93244485d1 100644 --- a/src/services/study/network-map.js +++ b/src/services/study/network-map.js @@ -6,7 +6,7 @@ */ import { getStudyUrlWithNodeUuid } from './index'; -import { backendFetchJson, getQueryParamsList } from '../utils'; +import { backendFetchJson, getQueryParamsList } from '@gridsuite/commons-ui'; import { createFilter } from '../explore'; import { NAME } from '../../components/utils/field-constants.js'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types.js'; diff --git a/src/services/study/network-modifications.js b/src/services/study/network-modifications.js index 0a2110ba5b..9771f7d8c5 100644 --- a/src/services/study/network-modifications.js +++ b/src/services/study/network-modifications.js @@ -10,7 +10,11 @@ import { toModificationOperation, toModificationUnsetOperation, } from '../../components/utils/utils'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES } from './index'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types'; import { @@ -1837,6 +1841,7 @@ export function modifyVsc( body: JSON.stringify(vscModification), }); } + export function modifyByFormula( studyUuid, currentNodeUuid, diff --git a/src/services/study/network.js b/src/services/study/network.js index 4f2b85e1ed..aee0611dbb 100644 --- a/src/services/study/network.js +++ b/src/services/study/network.js @@ -15,8 +15,8 @@ import { backendFetchJson, backendFetchText, getRequestParamFromList, - getUrlWithToken, -} from '../utils'; +} from '@gridsuite/commons-ui'; +import { getUrlWithToken } from '../utils'; /* voltage-levels */ export function getVoltageLevelSingleLineDiagram( diff --git a/src/services/study/non-evacuated-energy.js b/src/services/study/non-evacuated-energy.js index 230b7d8a16..330a4fdcb0 100644 --- a/src/services/study/non-evacuated-energy.js +++ b/src/services/study/non-evacuated-energy.js @@ -10,7 +10,11 @@ import { getStudyUrlWithNodeUuid, PREFIX_STUDY_QUERIES, } from './index'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; export function startNonEvacuatedEnergy(studyUuid, currentNodeUuid) { console.info( diff --git a/src/services/study/security-analysis.js b/src/services/study/security-analysis.js index 376c712d3b..854d1c99bc 100644 --- a/src/services/study/security-analysis.js +++ b/src/services/study/security-analysis.js @@ -16,7 +16,7 @@ import { backendFetchJson, backendFetchText, getRequestParamFromList, -} from '../utils'; +} from '@gridsuite/commons-ui'; export function startSecurityAnalysis( studyUuid, diff --git a/src/services/study/sensitivity-analysis.js b/src/services/study/sensitivity-analysis.js index 30bc61dc71..33d01d63e8 100644 --- a/src/services/study/sensitivity-analysis.js +++ b/src/services/study/sensitivity-analysis.js @@ -10,7 +10,11 @@ import { getStudyUrl, getStudyUrlWithNodeUuid, } from './index'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; const GET_PARAMETERS_PREFIX = import.meta.env.VITE_API_GATEWAY + '/sensitivity-analysis/v1/parameters'; diff --git a/src/services/study/short-circuit-analysis.js b/src/services/study/short-circuit-analysis.js index 3016d51126..6be1475810 100644 --- a/src/services/study/short-circuit-analysis.js +++ b/src/services/study/short-circuit-analysis.js @@ -10,7 +10,11 @@ import { getShortCircuitAnalysisTypeFromEnum, ShortCircuitAnalysisType, } from '../../components/results/shortcircuit/shortcircuit-analysis-result.type'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; export function startShortCircuitAnalysis(studyUuid, currentNodeUuid, busId) { console.info( diff --git a/src/services/study/study.ts b/src/services/study/study.ts index 55c00de947..5a24d06b40 100644 --- a/src/services/study/study.ts +++ b/src/services/study/study.ts @@ -7,7 +7,7 @@ import { UUID } from 'crypto'; import { PREFIX_STUDY_QUERIES } from '.'; -import { backendFetch } from '../utils'; +import { backendFetch } from '@gridsuite/commons-ui'; interface BasicStudyInfos { uniqueId: string; diff --git a/src/services/study/tree-subtree.js b/src/services/study/tree-subtree.js index 2483cc87a7..d58930c0a3 100644 --- a/src/services/study/tree-subtree.js +++ b/src/services/study/tree-subtree.js @@ -6,7 +6,7 @@ */ import { getStudyUrl } from './index'; -import { backendFetch, backendFetchJson } from '../utils'; +import { backendFetch, backendFetchJson } from '@gridsuite/commons-ui'; export function copySubtree( sourceStudyUuid, diff --git a/src/services/study/voltage-init.js b/src/services/study/voltage-init.js index 5d2c29fdf7..64383a0aeb 100644 --- a/src/services/study/voltage-init.js +++ b/src/services/study/voltage-init.js @@ -6,7 +6,11 @@ */ import { getStudyUrl, getStudyUrlWithNodeUuid } from './index'; -import { backendFetch, backendFetchJson, backendFetchText } from '../utils'; +import { + backendFetch, + backendFetchJson, + backendFetchText, +} from '@gridsuite/commons-ui'; export function startVoltageInit(studyUuid, currentNodeUuid) { console.info( diff --git a/src/services/user-admin.js b/src/services/user-admin.js index 55d81fb592..cf6921a5a6 100644 --- a/src/services/user-admin.js +++ b/src/services/user-admin.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetch } from './utils'; +import { backendFetch } from '@gridsuite/commons-ui'; const PREFIX_USER_ADMIN_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/user-admin'; diff --git a/src/services/utils.js b/src/services/utils.js index becbde9414..9ea750a2a0 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -5,139 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { store } from '../redux/store'; - -export const FetchStatus = { - SUCCEED: 'SUCCEED', - FAILED: 'FAILED', - IDLE: 'IDLE', - RUNNING: 'RUNNING', -}; - -export const getWsBase = () => - document.baseURI - .replace(/^http:\/\//, 'ws://') - .replace(/^https:\/\//, 'wss://'); - -export const getRequestParamFromList = (params, paramName) => { - return new URLSearchParams( - params?.length ? params.map((param) => [paramName, param]) : [] - ); -}; - -const parseError = (text) => { - try { - return JSON.parse(text); - } catch (err) { - return null; - } -}; - -const handleError = (response) => { - return response.text().then((text) => { - const errorName = 'HttpResponseError : '; - let error; - const errorJson = parseError(text); - if ( - errorJson && - errorJson.status && - errorJson.error && - errorJson.message - ) { - error = new Error( - errorName + - errorJson.status + - ' ' + - errorJson.error + - ', message : ' + - errorJson.message - ); - error.status = errorJson.status; - } else { - error = new Error( - errorName + - response.status + - ' ' + - response.statusText + - ', message : ' + - text - ); - error.status = response.status; - } - throw error; - }); -}; +import { fetchAppsAndUrls, fetchEnv } from '@gridsuite/commons-ui'; export const getToken = () => { const state = store.getState(); return state.user.id_token; }; -const prepareRequest = (init, token) => { - if (!(typeof init == 'undefined' || typeof init == 'object')) { - throw new TypeError( - 'Argument 2 of backendFetch is not an object' + typeof init - ); - } - const initCopy = Object.assign({}, init); - initCopy.headers = new Headers(initCopy.headers || {}); - const tokenCopy = token ? token : getToken(); - initCopy.headers.append('Authorization', 'Bearer ' + tokenCopy); - return initCopy; -}; - -const safeFetch = (url, initCopy) => { - return fetch(url, initCopy).then((response) => - response.ok ? response : handleError(response) - ); -}; - -export const backendFetch = (url, init, token) => { - const initCopy = prepareRequest(init, token); - return safeFetch(url, initCopy); -}; - -export const backendFetchText = (url, init, token) => { - const initCopy = prepareRequest(init, token); - return safeFetch(url, initCopy).then((safeResponse) => safeResponse.text()); -}; - -export const backendFetchJson = (url, init, token) => { - const initCopy = prepareRequest(init, token); - return safeFetch(url, initCopy).then((safeResponse) => - safeResponse.status === 204 ? null : safeResponse.json() - ); -}; - -export const backendFetchFile = (url, init, token) => { - const initCopy = prepareRequest(init, token); - return safeFetch(url, initCopy).then((safeResponse) => safeResponse.blob()); -}; - -const FILE_TYPE = { - ZIP: 'ZIP', -}; -export const downloadZipFile = (blob, fileName) => { - downloadFile(blob, fileName, FILE_TYPE.ZIP); -}; - -const downloadFile = (blob, filename, type) => { - let contentType; - if (type === FILE_TYPE.ZIP) { - contentType = 'application/octet-stream'; - } - const href = window.URL.createObjectURL(new Blob([blob], { contentType })); - const link = document.createElement('a'); - link.href = href; - link.setAttribute('download', filename); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); -}; - -function fetchEnv() { - return fetch('env.json').then((res) => res.json()); -} - export function fetchIdpSettings() { return fetch('idpSettings.json'); } @@ -168,13 +42,6 @@ export function fetchAuthorizationCodeFlowFeatureFlag() { }); } -export function fetchAppsAndUrls() { - console.info(`Fetching apps and urls...`); - return fetchEnv() - .then((env) => fetch(env.appsMetadataServerUrl + '/apps-metadata.json')) - .then((response) => response.json()); -} - export function fetchVersion() { console.info(`Fetching global metadata...`); return fetchEnv() @@ -201,14 +68,6 @@ export const fetchDefaultParametersValues = () => { return studyMetadata.defaultParametersValues; }); }; -export const getQueryParamsList = (params, paramName) => { - if (params !== undefined && params.length > 0) { - const urlSearchParams = new URLSearchParams(); - params.forEach((id) => urlSearchParams.append(paramName, id)); - return urlSearchParams.toString(); - } - return ''; -}; export function getUrlWithToken(baseUrl) { if (baseUrl.includes('?')) { diff --git a/src/services/voltage-init.ts b/src/services/voltage-init.ts index 4284bbc413..81f8b0e174 100644 --- a/src/services/voltage-init.ts +++ b/src/services/voltage-init.ts @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { UUID } from 'crypto'; -import { backendFetchJson } from './utils'; +import { backendFetchJson } from '@gridsuite/commons-ui'; export const PREFIX_VOLTAGE_INIT_QUERIES = import.meta.env.VITE_API_GATEWAY + '/voltage-init'; From 03d42e2b0c8afe3583937def52b47ff093c66ccd Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 23 May 2024 16:04:55 +0200 Subject: [PATCH 02/15] Reinstate enum --- .../voltage-init-modification-dialog.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx index 0b57e5322a..8afd4f7393 100644 --- a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FetchStatus } from '@gridsuite/commons-ui'; import React, { FunctionComponent, useCallback, @@ -54,6 +53,12 @@ export const EquipmentTypeTabs = { BUS_TAB: 5, }; +enum FetchStatus { + SUCCEED = 'SUCCEED', + FAILED = 'FAILED', + IDLE = 'IDLE', + RUNNING = 'RUNNING', +} interface CloseFunction { (): void; } From 2aa16987350a156e28d6a40c758e47b799ace150 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 23 May 2024 20:16:00 +0200 Subject: [PATCH 03/15] Remove fetchPath and fetchElementsMetadata --- package-lock.json | 166 +++--------------- package.json | 4 +- .../variation/variation-form.jsx | 5 +- .../voltage-init-modification-dialog.tsx | 8 +- .../common/parameters-creation-dialog.tsx | 4 +- .../network-modification-node-editor.jsx | 9 +- .../network/filter-creation-panel.tsx | 6 +- src/components/study-container.jsx | 9 +- src/services/explore.ts | 42 +---- src/services/study/index.js | 14 ++ 10 files changed, 64 insertions(+), 203 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e3cfc0e6d..6a7d34b5b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", + "@gridsuite/commons-ui": "0.55.0", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -3200,24 +3200,18 @@ } }, "node_modules/@gridsuite/commons-ui": { - "version": "0.58.0", - "resolved": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", - "integrity": "sha512-nJYq9ielHScIl+++vBp/j21ZDuQwAIZJ9K053CVPNuzro+9Qkd/DO86vrCuFXw5/UKk2qsdLLXC0sdum0zUUAw==", - "license": "MPL-2.0", + "version": "0.55.0", + "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.55.0.tgz", + "integrity": "sha512-uCZhoE12/+G7//Msi9MkDudi/Q6VjjHA2Z9dv4zC82Kut0SJkdnMFiIwwl8wmtygxycd86OxpM1rV29MneZNSQ==", "dependencies": { - "@react-querybuilder/dnd": "^7.2.0", - "@react-querybuilder/material": "^7.2.0", "autosuggest-highlight": "^3.3.4", "clsx": "^2.1.0", "jwt-decode": "^4.0.0", - "localized-countries": "^2.0.0", "memoize-one": "^6.0.0", "oidc-client": "^1.11.5", "prop-types": "^15.8.1", "react-csv-downloader": "^3.1.0", - "react-dnd": "^16.0.1", - "react-dnd-html5-backend": "^16.0.1", - "react-querybuilder": "^7.2.0", + "react-request-fullscreen": "^1.1.2", "react-virtualized": "^9.22.5", "uuid": "^9.0.1" }, @@ -3232,14 +3226,11 @@ "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", "@mui/material": "^5.15.14", - "ag-grid-community": "^31.0.0", - "ag-grid-react": "^31.2.0", "notistack": "^3.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.2", "react-intl": "^6.6.4", - "react-papaparse": "^4.1.0", "react-router-dom": "^6.22.3", "yup": "^1.4.0" } @@ -5222,45 +5213,6 @@ "@babel/runtime": "^7.0.0" } }, - "node_modules/@react-dnd/asap": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@react-dnd/asap/-/asap-5.0.2.tgz", - "integrity": "sha512-WLyfoHvxhs0V9U+GTsGilGgf2QsPl6ZZ44fnv0/b8T3nQyvzxidxsg/ZltbWssbsRDlYW8UKSQMTGotuTotZ6A==" - }, - "node_modules/@react-dnd/invariant": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@react-dnd/invariant/-/invariant-4.0.2.tgz", - "integrity": "sha512-xKCTqAK/FFauOM9Ta2pswIyT3D8AQlfrYdOi/toTPEhqCuAs1v5tcJ3Y08Izh1cJ5Jchwy9SeAXmMg6zrKs2iw==" - }, - "node_modules/@react-dnd/shallowequal": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@react-dnd/shallowequal/-/shallowequal-4.0.2.tgz", - "integrity": "sha512-/RVXdLvJxLg4QKvMoM5WlwNR9ViO9z8B/qPcc+C0Sa/teJY7QG7kJ441DwzOjMYEY7GmU4dj5EcGHIkKZiQZCA==" - }, - "node_modules/@react-querybuilder/dnd": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/@react-querybuilder/dnd/-/dnd-7.3.0.tgz", - "integrity": "sha512-o0NV47BCzApO/xs4U/eTJRETaRkrlVqXdpD1uxepeMW4E/iu6Se1mAQ7fSlvpq2Q8MjVmzEmnUz72xyQbsgXgQ==", - "peerDependencies": { - "react": ">=18", - "react-dnd": ">=14.0.0", - "react-dnd-html5-backend": ">=14.0.0", - "react-querybuilder": "^7.3.0" - } - }, - "node_modules/@react-querybuilder/material": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/@react-querybuilder/material/-/material-7.3.0.tgz", - "integrity": "sha512-qSGN6sBchSPp2rnqcjpFUDUDMykPW9UzZ1hZjkv1h+1RgrqTMZaOv2qoZsz/XFtfXTRViW7GqQfiSsSO2JLmKg==", - "peerDependencies": { - "@emotion/react": "^11", - "@emotion/styled": "^11", - "@mui/icons-material": ">=5.0.0", - "@mui/material": ">=5.0.0", - "react": ">=18", - "react-querybuilder": "^7.3.0" - } - }, "node_modules/@reduxjs/toolkit": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.3.tgz", @@ -8351,9 +8303,9 @@ } }, "node_modules/clsx": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", - "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", "engines": { "node": ">=6" } @@ -9362,24 +9314,6 @@ "node": ">=8" } }, - "node_modules/dnd-core": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/dnd-core/-/dnd-core-16.0.1.tgz", - "integrity": "sha512-HK294sl7tbw6F6IeuK16YSBUoorvHpY8RHO+9yFfaJyCDVb6n7PRcezrOEOa2SBCqiYpemh5Jx20ZcjKdFAVng==", - "dependencies": { - "@react-dnd/asap": "^5.0.1", - "@react-dnd/invariant": "^4.0.1", - "redux": "^4.2.0" - } - }, - "node_modules/dnd-core/node_modules/redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "dependencies": { - "@babel/runtime": "^7.9.2" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -11123,7 +11057,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.3.0", @@ -12177,9 +12112,9 @@ } }, "node_modules/immer": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", - "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", + "version": "10.0.4", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.4.tgz", + "integrity": "sha512-cuBuGK40P/sk5IzWa9QPUaAdvPHjkk1c+xYsd9oZw+YQQEV+10G0P5uMpGctZZKnyQ+ibRO08bD25nWLmYi2pw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/immer" @@ -15589,14 +15524,6 @@ "node": ">=0.10.0" } }, - "node_modules/numeric-quantity": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/numeric-quantity/-/numeric-quantity-2.0.1.tgz", - "integrity": "sha512-+Bt2X6YxM5bg8XIBl76NVeG2eL0Y5VQRoyz6GLYrZXW/TDh7We+tGeX4/WZWhaVGOg5ZjNBEOZt9a86slMhOJA==", - "engines": { - "node": ">=16" - } - }, "node_modules/nwsapi": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", @@ -16501,43 +16428,6 @@ "react": "^16.6.3 || ^17.0.0 || ^18.0.0" } }, - "node_modules/react-dnd": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-16.0.1.tgz", - "integrity": "sha512-QeoM/i73HHu2XF9aKksIUuamHPDvRglEwdHL4jsp784BgUuWcg6mzfxT0QDdQz8Wj0qyRKx2eMg8iZtWvU4E2Q==", - "dependencies": { - "@react-dnd/invariant": "^4.0.1", - "@react-dnd/shallowequal": "^4.0.1", - "dnd-core": "^16.0.1", - "fast-deep-equal": "^3.1.3", - "hoist-non-react-statics": "^3.3.2" - }, - "peerDependencies": { - "@types/hoist-non-react-statics": ">= 3.3.1", - "@types/node": ">= 12", - "@types/react": ">= 16", - "react": ">= 16.14" - }, - "peerDependenciesMeta": { - "@types/hoist-non-react-statics": { - "optional": true - }, - "@types/node": { - "optional": true - }, - "@types/react": { - "optional": true - } - } - }, - "node_modules/react-dnd-html5-backend": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-16.0.1.tgz", - "integrity": "sha512-Wu3dw5aDJmOGw8WjH1I1/yTH+vlXEL4vmjk5p+MHxP8HuHJS1lAGeIdG/hze1AvNeXWo/JgULV87LyQOr+r5jw==", - "dependencies": { - "dnd-core": "^16.0.1" - } - }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -16710,25 +16600,10 @@ "react": ">0.13.0" } }, - "node_modules/react-querybuilder": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/react-querybuilder/-/react-querybuilder-7.3.0.tgz", - "integrity": "sha512-VzIhlXi4lPwGrR9xpC3fK3GJS5ZDzos4yuU5B7lfHkaY4f5GTidx5d6Ij/G6O+qgh1tmvQcEfC/E776SYOkhxw==", - "dependencies": { - "@reduxjs/toolkit": "^2.2.3", - "clsx": "^2.1.1", - "immer": "^10.1.1", - "numeric-quantity": "^2.0.1", - "react-redux": "^9.1.2" - }, - "peerDependencies": { - "react": ">=18" - } - }, "node_modules/react-redux": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.2.tgz", - "integrity": "sha512-0OA4dhM1W48l3uzmv6B7TXPCGmokUU4p1M44DGN2/D9a1FjVPukVjER1PcPX97jIg6aUeLq1XJo1IpfbgULn0w==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz", + "integrity": "sha512-6qoDzIO+gbrza8h3hjMA9aq4nwVFCKFtY2iLxCtVT38Swyy2C/dJCGBXHeHLtx6qlg/8qzc2MrhOeduf5K32wQ==", "dependencies": { "@types/use-sync-external-store": "^0.0.3", "use-sync-external-store": "^1.0.0" @@ -16736,12 +16611,16 @@ "peerDependencies": { "@types/react": "^18.2.25", "react": "^18.0", + "react-native": ">=0.69", "redux": "^5.0.0" }, "peerDependenciesMeta": { "@types/react": { "optional": true }, + "react-native": { + "optional": true + }, "redux": { "optional": true } @@ -16756,6 +16635,11 @@ "node": ">=0.10.0" } }, + "node_modules/react-request-fullscreen": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/react-request-fullscreen/-/react-request-fullscreen-1.1.2.tgz", + "integrity": "sha512-WsQ/htbZag9qNfWPb2fEm0if+oUsRK3rTKKJ007n64Mk0PY82gAbLwVKZ+7OmzkHm6f/PSkxf8pdYlzBUmXR/Q==" + }, "node_modules/react-resizable": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/react-resizable/-/react-resizable-3.0.5.tgz", diff --git a/package.json b/package.json index 3d79c33433..7a7b5c250e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", + "@gridsuite/commons-ui": "0.55.0", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -106,8 +106,8 @@ "jest-environment-jsdom": "^29.7.0", "license-checker": "^25.0.1", "prettier": "^2.8.8", - "ts-node": "^10.9.2", "typescript": "5.1.6", + "ts-node": "^10.9.2", "vite": "^5.2.7", "vite-plugin-eslint": "^1.8.1", "vite-plugin-svgr": "^4.2.0", diff --git a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx index 3a8abefb9e..5511217c94 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.jsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { DirectoryItemsInput } from '@gridsuite/commons-ui'; +import { DirectoryItemsInput, fetchElementsInfos } from '@gridsuite/commons-ui'; import { FILTERS, ID, @@ -24,7 +24,6 @@ import { FloatInput } from '@gridsuite/commons-ui'; import { ActivePowerAdornment, gridItem } from '../../../dialogUtils'; import { ElementType, useSnackMessage } from '@gridsuite/commons-ui'; import { IDENTIFIER_LIST } from './variation-utils'; -import { fetchElementsMetadata } from 'services/explore'; const GENERATORS = [EQUIPMENT_TYPES.GENERATOR]; @@ -52,7 +51,7 @@ const VariationForm = ({ name, index }) => { const updateMetadata = useCallback( (filtersWithoutMetadata) => { const ids = filtersWithoutMetadata.map((f) => f.id); - fetchElementsMetadata(ids, [], []) + fetchElementsInfos(ids, [], []) .then((results) => { const newFilters = filters.map((filter) => { const filterWithMetadata = results.find( diff --git a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx index 8afd4f7393..aa5e856017 100644 --- a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx @@ -54,10 +54,10 @@ export const EquipmentTypeTabs = { }; enum FetchStatus { - SUCCEED = 'SUCCEED', - FAILED = 'FAILED', - IDLE = 'IDLE', - RUNNING = 'RUNNING', + SUCCEED = 'SUCCEED', + FAILED = 'FAILED', + IDLE = 'IDLE', + RUNNING = 'RUNNING', } interface CloseFunction { (): void; diff --git a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx index b1208ab484..534cd81bce 100644 --- a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx +++ b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx @@ -13,11 +13,11 @@ import { FieldValues, useForm, UseFormGetValues } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Button, CircularProgress, Grid, Typography } from '@mui/material'; import { FormattedMessage, useIntl } from 'react-intl'; -import { fetchPath } from 'services/directory'; import { CustomFormProvider, DirectoryItemSelector, ElementType, + fetchDirectoryElementPath, TreeViewFinderNodeProps, } from '@gridsuite/commons-ui'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; @@ -74,7 +74,7 @@ const CreateParameterDialog = ({ const nameError = errors[NAME]; const fetchDefaultDirectoryForStudy = useCallback(() => { - fetchPath(studyUuid).then((res) => { + fetchDirectoryElementPath(studyUuid).then((res) => { if (res) { setDefaultFolder({ id: res[1].elementUuid, diff --git a/src/components/graph/menus/network-modification-node-editor.jsx b/src/components/graph/menus/network-modification-node-editor.jsx index 76c6409f7f..b080346d3b 100644 --- a/src/components/graph/menus/network-modification-node-editor.jsx +++ b/src/components/graph/menus/network-modification-node-editor.jsx @@ -6,7 +6,11 @@ */ import React, { useCallback, useEffect, useRef, useState } from 'react'; -import { useSnackMessage, FetchStatus } from '@gridsuite/commons-ui'; +import { + useSnackMessage, + FetchStatus, + fetchDirectoryElementPath, +} from '@gridsuite/commons-ui'; import { useDispatch, useSelector } from 'react-redux'; import LineAttachToVoltageLevelDialog from 'components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog'; import NetworkModificationsMenu from 'components/graph/menus/network-modifications-menu'; @@ -81,7 +85,6 @@ import ImportModificationDialog from 'components/dialogs/import-modification-dia import { Box } from '@mui/system'; import { RestoreFromTrash } from '@mui/icons-material'; import ByFilterDeletionDialog from '../../dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog'; -import { fetchPath } from '../../../services/directory'; import { useModificationLabelComputer } from '../util/use-modification-label-computer'; import { createModifications } from '../../../services/explore'; import { areUuidsEqual } from 'components/utils/utils'; @@ -516,7 +519,7 @@ const NetworkModificationNodeEditor = () => { }, [studyUuid, currentNode?.id, currentNode?.type, snackError, dispatch]); const fetchDefaultDirectoryForStudy = useCallback(() => { - fetchPath(studyUuid).then((pathArray) => { + fetchDirectoryElementPath(studyUuid).then((pathArray) => { if (pathArray?.length > 0) { setStudyPath(pathArray); } diff --git a/src/components/network/filter-creation-panel.tsx b/src/components/network/filter-creation-panel.tsx index b05780e80d..c893e6e79b 100644 --- a/src/components/network/filter-creation-panel.tsx +++ b/src/components/network/filter-creation-panel.tsx @@ -11,6 +11,7 @@ import { CustomFormProvider, DirectoryItemSelector, ElementType, + fetchDirectoryElementPath, SelectInput, TreeViewFinderNodeProps, } from '@gridsuite/commons-ui'; @@ -20,9 +21,6 @@ import { useForm } from 'react-hook-form'; import { FILTER_NAME, NAME } from 'components/utils/field-constants'; import { GridSection } from 'components/dialogs/dialogUtils'; import { FormattedMessage, useIntl } from 'react-intl'; -import { - fetchPath, -} from 'services/directory'; import { UniqueNameInput } from 'components/dialogs/commons/unique-name-input'; import { useSelector } from 'react-redux'; import { @@ -75,7 +73,7 @@ const FilterCreationPanel: React.FC = ({ useState(); const fetchDefaultDirectoryForStudy = useCallback(() => { - fetchPath(studyUuid).then((res) => { + fetchDirectoryElementPath(studyUuid).then((res) => { if (res) { setDefaultFolder({ id: res[1].elementUuid, diff --git a/src/components/study-container.jsx b/src/components/study-container.jsx index 881980269d..e149e33468 100644 --- a/src/components/study-container.jsx +++ b/src/components/study-container.jsx @@ -24,7 +24,11 @@ import { limitReductionModified, } from '../redux/actions'; import WaitingLoader from './utils/waiting-loader'; -import { useIntlRef, useSnackMessage } from '@gridsuite/commons-ui'; +import { + useIntlRef, + useSnackMessage, + fetchDirectoryElementPath, +} from '@gridsuite/commons-ui'; import NetworkModificationTreeModel from './graph/network-modification-tree-model'; import { getFirstNodeOfType, @@ -41,7 +45,6 @@ import { connectDeletedStudyNotificationsWebsocket, connectNotificationsWsUpdateDirectories, } from '../services/directory-notification'; -import { fetchPath } from '../services/directory'; import { useAllComputingStatus } from './computing-status/use-all-computing-status'; import { fetchCaseName, fetchStudyExists } from '../services/study'; import { fetchNetworkModificationTree } from '../services/study/tree-subtree'; @@ -384,7 +387,7 @@ export function StudyContainer({ view, onChangeTab }) { ); const fetchStudyPath = useCallback(() => { - fetchPath(studyUuid) + fetchDirectoryElementPath(studyUuid) .then((response) => { const parentDirectoriesNames = response .slice(1) diff --git a/src/services/explore.ts b/src/services/explore.ts index ab882a3fc1..0cac388aa9 100644 --- a/src/services/explore.ts +++ b/src/services/explore.ts @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - backendFetch, - backendFetchJson, - getRequestParamFromList, -} from '@gridsuite/commons-ui'; +import { backendFetch } from '@gridsuite/commons-ui'; import { UUID } from 'crypto'; const PREFIX_EXPLORE_SERVER_QUERIES = @@ -17,42 +13,6 @@ const PREFIX_EXPLORE_SERVER_QUERIES = const PREFIX_DIRECTORY_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/directory'; -export function fetchElementsMetadata( - ids: UUID[], - elementTypes: string[], - equipmentTypes?: string[] -) { - console.info('Fetching elements metadata'); - - // Add params to Url - const idsParams = getRequestParamFromList( - ids.filter((id) => id), // filter falsy elements - 'ids' - ); - - const equipmentTypesParams = getRequestParamFromList( - equipmentTypes, - 'equipmentTypes' - ); - - const elementTypesParams = getRequestParamFromList( - elementTypes, - 'elementTypes' - ); - - const params = [ - ...idsParams, - ...equipmentTypesParams, - ...elementTypesParams, - ]; - - const urlSearchParams = new URLSearchParams(params); - - const url = `${PREFIX_EXPLORE_SERVER_QUERIES}/v1/explore/elements/metadata?${urlSearchParams}`; - console.debug(url); - return backendFetchJson(url); -} - export function createParameter( newParameter: any, name: string, diff --git a/src/services/study/index.js b/src/services/study/index.js index d4bfc22665..9a0324f748 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.js @@ -13,6 +13,20 @@ import { getRequestParamFromList, } from '@gridsuite/commons-ui'; +// By moving above utils functions in commons-ui and removing import from services/utils +// created multiple circular dependencies issues, so in the meantime its other +// functions are being exported as a crutch... To be removed once circular +// dependencies are fixed +export { + fetchMapBoxToken, + getUrlWithToken, + fetchDefaultParametersValues, + fetchVersion, + fetchAuthorizationCodeFlowFeatureFlag, + fetchIdpSettings, + getToken, +} from '../utils'; + export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; export const getStudyUrl = (studyUuid) => From bbceb6722ee0e32c1b09a53cdc87c1fd67faffbb Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Fri, 24 May 2024 10:41:11 +0200 Subject: [PATCH 04/15] Cast --- src/services/dynamic-simulation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/dynamic-simulation.ts b/src/services/dynamic-simulation.ts index 7607ccfeab..b879ccc5a7 100644 --- a/src/services/dynamic-simulation.ts +++ b/src/services/dynamic-simulation.ts @@ -133,7 +133,7 @@ export function deleteDynamicSimulationEvents( ); const eventIdsParams = getRequestParamFromList( - events.map((event) => event.uuid), + events.map((event) => event.uuid) as string[], 'eventUuids' ); From 316add9ac963ecfad490c6b19f87eacb9105b5dd Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Mon, 27 May 2024 14:32:41 +0200 Subject: [PATCH 05/15] PR remarks --- src/components/app-top-bar.jsx | 4 +- .../common/properties/property-utils.ts | 2 +- src/services/metadata.ts | 40 ------------------- src/services/study/geo-data.js | 6 +-- src/services/study/index.js | 3 +- src/services/study/network-map.js | 6 +-- src/services/utils.js | 11 +---- 7 files changed, 12 insertions(+), 60 deletions(-) delete mode 100644 src/services/metadata.ts diff --git a/src/components/app-top-bar.jsx b/src/components/app-top-bar.jsx index 544e704dd3..32c5bde503 100644 --- a/src/components/app-top-bar.jsx +++ b/src/components/app-top-bar.jsx @@ -15,7 +15,7 @@ import { OverflowableText, TagRenderer, TopBar, - fetchAppsAndUrls, + fetchAppsMetadata, } from '@gridsuite/commons-ui'; import GridStudyLogoLight from '../images/GridStudy_logo_light.svg?react'; import GridStudyLogoDark from '../images/GridStudy_logo_dark.svg?react'; @@ -243,7 +243,7 @@ const AppTopBar = ({ user, tabIndex, onChangeTab, userManager }) => { useEffect(() => { if (user !== null) { - fetchAppsAndUrls().then((res) => { + fetchAppsMetadata().then((res) => { setAppsAndUrls(res); }); } diff --git a/src/components/dialogs/network-modifications/common/properties/property-utils.ts b/src/components/dialogs/network-modifications/common/properties/property-utils.ts index 2c12091188..1e1ac192e9 100644 --- a/src/components/dialogs/network-modifications/common/properties/property-utils.ts +++ b/src/components/dialogs/network-modifications/common/properties/property-utils.ts @@ -14,7 +14,7 @@ import { VALUE, } from 'components/utils/field-constants'; import { isBlankOrEmpty } from 'components/utils/validation-functions'; -import { fetchStudyMetadata } from 'services/metadata'; +import { fetchStudyMetadata } from '@gridsuite/commons-ui'; export type Property = { [NAME]: string; diff --git a/src/services/metadata.ts b/src/services/metadata.ts deleted file mode 100644 index d07d8dad2e..0000000000 --- a/src/services/metadata.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2024, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -import { fetchAppsAndUrls } from '@gridsuite/commons-ui'; -import { PredefinedProperties } from 'components/dialogs/network-modifications/common/properties/property-utils'; - -export interface Metadata { - name: string; - url: string; - appColor: string; - hiddenInAppsMenu: boolean; - resources: unknown; -} - -export interface StudyMetadata extends Metadata { - name: 'Study'; - predefinedEquipmentProperties: { - [networkElementType: string]: PredefinedProperties; - }; - defaultCountry?: string; -} - -const isStudyMetadata = (metadata: Metadata): metadata is StudyMetadata => { - return metadata.name === 'Study'; -}; - -export function fetchStudyMetadata() { - console.info(`Fetching study metadata...`); - return fetchAppsAndUrls().then((res: [Metadata]) => { - const studyMetadata = res.filter(isStudyMetadata); - if (!studyMetadata) { - return Promise.reject('Study entry could not be found in metadata'); - } - return studyMetadata[0]; // There should be only one study metadata - }); -} diff --git a/src/services/study/geo-data.js b/src/services/study/geo-data.js index d0292ebdad..03e77c11a8 100644 --- a/src/services/study/geo-data.js +++ b/src/services/study/geo-data.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson, getQueryParamsList } from '@gridsuite/commons-ui'; +import { backendFetchJson, getRequestParamFromList } from '@gridsuite/commons-ui'; import { getStudyUrlWithNodeUuid } from './index'; export function fetchSubstationPositions( @@ -19,7 +19,7 @@ export function fetchSubstationPositions( const paramsList = substationsIds && substationsIds.length > 0 - ? '?' + getQueryParamsList(substationsIds, 'substationId') + ? '?' + getRequestParamFromList(substationsIds, 'substationId') : ''; const fetchSubstationPositionsUrl = @@ -37,7 +37,7 @@ export function fetchLinePositions(studyUuid, currentNodeUuid, linesIds) { const paramsList = linesIds && linesIds.length > 0 - ? '?' + getQueryParamsList(linesIds, 'lineId') + ? '?' + getRequestParamFromList(linesIds, 'lineId') : ''; const fetchLinePositionsUrl = diff --git a/src/services/study/index.js b/src/services/study/index.js index 9a0324f748..c9be0382f0 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.js @@ -9,7 +9,6 @@ import { backendFetch, backendFetchJson, backendFetchText, - getQueryParamsList, getRequestParamFromList, } from '@gridsuite/commons-ui'; @@ -67,7 +66,7 @@ export function getNetworkAreaDiagramUrl( depth: depth, }) + '&' + - getQueryParamsList(voltageLevelsIds, 'voltageLevelsIds').toString() + getRequestParamFromList(voltageLevelsIds, 'voltageLevelsIds').toString() ); } diff --git a/src/services/study/network-map.js b/src/services/study/network-map.js index b0868ebf06..32928919b8 100644 --- a/src/services/study/network-map.js +++ b/src/services/study/network-map.js @@ -6,7 +6,7 @@ */ import { getStudyUrlWithNodeUuid } from './index'; -import { backendFetchJson, getQueryParamsList } from '@gridsuite/commons-ui'; +import { backendFetchJson, getRequestParamFromList } from '@gridsuite/commons-ui'; import { createFilter } from '../explore'; import { NAME } from '../../components/utils/field-constants.js'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types.js'; @@ -41,7 +41,7 @@ export function fetchAllEquipments(studyUuid, currentNodeUuid, substationsIds) { getStudyUrlWithNodeUuid(studyUuid, currentNodeUuid) + '/network-map/all' + '?' + - getQueryParamsList(substationsIds, 'substationId'); + getRequestParamFromList(substationsIds, 'substationId'); console.debug(fetchEquipmentsUrl); return backendFetchJson(fetchEquipmentsUrl); } @@ -71,7 +71,7 @@ export function fetchVoltageLevelEquipments( encodeURIComponent(voltageLevelId) + '/equipments' + '?' + - getQueryParamsList(substationsIds, 'substationId') + + getRequestParamFromList(substationsIds, 'substationId') + urlSearchParams.toString(); console.debug(fetchEquipmentsUrl); return backendFetchJson(fetchEquipmentsUrl); diff --git a/src/services/utils.js b/src/services/utils.js index 9ea750a2a0..cc57f72e25 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { store } from '../redux/store'; -import { fetchAppsAndUrls, fetchEnv } from '@gridsuite/commons-ui'; +import { fetchEnv, fetchStudyMetadata } from '@gridsuite/commons-ui'; export const getToken = () => { const state = store.getState(); @@ -54,17 +54,10 @@ export function fetchVersion() { } export const fetchDefaultParametersValues = () => { - return fetchAppsAndUrls().then((res) => { + return fetchStudyMetadata().then((studyMetadata) => { console.info( 'fecthing default parameters values from apps-metadata file' ); - const studyMetadata = res.find((metadata) => metadata.name === 'Study'); - if (!studyMetadata) { - return Promise.reject( - 'Study entry could not be found in metadatas' - ); - } - return studyMetadata.defaultParametersValues; }); }; From 829902a65598cee36743df65a49d2404243857d4 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Mon, 27 May 2024 16:46:19 +0200 Subject: [PATCH 06/15] Lint --- src/services/study/geo-data.js | 5 ++++- src/services/study/network-map.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/study/geo-data.js b/src/services/study/geo-data.js index 03e77c11a8..d61a119b96 100644 --- a/src/services/study/geo-data.js +++ b/src/services/study/geo-data.js @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetchJson, getRequestParamFromList } from '@gridsuite/commons-ui'; +import { + backendFetchJson, + getRequestParamFromList, +} from '@gridsuite/commons-ui'; import { getStudyUrlWithNodeUuid } from './index'; export function fetchSubstationPositions( diff --git a/src/services/study/network-map.js b/src/services/study/network-map.js index 32928919b8..a93000c578 100644 --- a/src/services/study/network-map.js +++ b/src/services/study/network-map.js @@ -6,7 +6,10 @@ */ import { getStudyUrlWithNodeUuid } from './index'; -import { backendFetchJson, getRequestParamFromList } from '@gridsuite/commons-ui'; +import { + backendFetchJson, + getRequestParamFromList, +} from '@gridsuite/commons-ui'; import { createFilter } from '../explore'; import { NAME } from '../../components/utils/field-constants.js'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types.js'; From 3b72b360a5bb67f48e80aa9992ca1e2f908a1c55 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 10:18:10 +0200 Subject: [PATCH 07/15] PR remarks --- package.json | 2 +- .../dialogs/commons/unique-name-input.tsx | 3 +-- src/services/explore.ts | 17 ----------------- src/services/study/network-map.js | 2 +- 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 7a7b5c250e..cc106f266f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.55.0", + "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", diff --git a/src/components/dialogs/commons/unique-name-input.tsx b/src/components/dialogs/commons/unique-name-input.tsx index fe2eae537d..6ba31388b9 100644 --- a/src/components/dialogs/commons/unique-name-input.tsx +++ b/src/components/dialogs/commons/unique-name-input.tsx @@ -11,8 +11,7 @@ import React, { useCallback, useEffect, } from 'react'; -import { useDebounce } from '@gridsuite/commons-ui'; -import { elementExists } from 'services/explore'; +import { elementExists, useDebounce } from '@gridsuite/commons-ui'; import { FormattedMessage } from 'react-intl'; import { InputAdornment, TextFieldProps } from '@mui/material'; import CheckIcon from '@mui/icons-material/Check'; diff --git a/src/services/explore.ts b/src/services/explore.ts index 0cac388aa9..b9b676b18c 100644 --- a/src/services/explore.ts +++ b/src/services/explore.ts @@ -10,8 +10,6 @@ import { UUID } from 'crypto'; const PREFIX_EXPLORE_SERVER_QUERIES = import.meta.env.VITE_API_GATEWAY + '/explore'; -const PREFIX_DIRECTORY_SERVER_QUERIES = - import.meta.env.VITE_API_GATEWAY + '/directory'; export function createParameter( newParameter: any, @@ -35,21 +33,6 @@ export function createParameter( ); } -export function elementExists( - directoryUuid: UUID, - elementName: string, - type: string -) { - const existsElementUrl = `${PREFIX_DIRECTORY_SERVER_QUERIES}/v1/directories/${directoryUuid}/elements/${elementName}/types/${type}`; - - console.debug(existsElementUrl); - return backendFetch(existsElementUrl, { method: 'head' }).then( - (response) => { - return response.status !== 204; // HTTP 204 : No-content - } - ); -} - export interface ModificationElementCreationProps { elementUuid: UUID; description: string; diff --git a/src/services/study/network-map.js b/src/services/study/network-map.js index a93000c578..f4dd719e35 100644 --- a/src/services/study/network-map.js +++ b/src/services/study/network-map.js @@ -9,8 +9,8 @@ import { getStudyUrlWithNodeUuid } from './index'; import { backendFetchJson, getRequestParamFromList, + createFilter, } from '@gridsuite/commons-ui'; -import { createFilter } from '../explore'; import { NAME } from '../../components/utils/field-constants.js'; import { EQUIPMENT_TYPES } from '../../components/utils/equipment-types.js'; From 7331846a6683dae68f58fe62b5ca081834f76c40 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 10:19:05 +0200 Subject: [PATCH 08/15] Set target commons ui version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cc106f266f..2163606a42 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.58.0.tgz", + "@gridsuite/commons-ui": "0.59.0", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", From ffbc9135b8702efcc34ed564b6cd40d70893038a Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 11:41:30 +0200 Subject: [PATCH 09/15] Restore FetchStatus --- .../event/dynamic-simulation-event-dialog.tsx | 7 ++----- .../battery/creation/battery-creation-dialog.jsx | 7 ++----- .../battery/modification/battery-modification-dialog.jsx | 7 ++----- .../by-filter-deletion/by-filter-deletion-dialog.tsx | 7 ++----- .../network-modifications/by-formula/by-formula-dialog.jsx | 7 ++----- .../delete-attaching-line/delete-attaching-line-dialog.jsx | 7 ++----- .../delete-voltage-level-on-line-dialog.jsx | 7 ++----- .../generation-dispatch/generation-dispatch-dialog.jsx | 7 ++----- .../generator-scaling/generator-scaling-dialog.jsx | 7 ++----- .../line-attach-to-voltage-level-dialog.jsx | 7 ++----- .../line-split-with-voltage-level-dialog.jsx | 7 ++----- .../line/creation/line-creation-dialog.jsx | 2 +- .../line/modification/line-modification-dialog.jsx | 7 ++----- .../lines-attach-to-split-lines-dialog.jsx | 7 ++----- .../load-scaling/load-scaling-dialog.jsx | 7 ++----- .../load/creation/load-creation-dialog.jsx | 7 ++----- .../creation/shunt-compensator-creation-dialog.jsx | 7 ++----- .../substation/creation/substation-creation-dialog.jsx | 7 ++----- .../modification/substation-modification-dialog.jsx | 7 ++----- .../tabular-creation/tabular-creation-dialog.jsx | 7 ++----- .../tabular-modification/tabular-modification-dialog.jsx | 7 ++----- .../creation/two-windings-transformer-creation-dialog.jsx | 7 ++----- .../creation/voltage-level-creation-dialog.jsx | 7 ++----- .../modification/voltage-level-modification-dialog.jsx | 7 ++----- .../vsc/modification/vsc-modification-dialog.tsx | 7 ++----- .../graph/menus/network-modification-node-editor.jsx | 2 +- src/components/voltage-init-result.jsx | 3 ++- src/services/utils.js | 7 +++++++ 28 files changed, 59 insertions(+), 123 deletions(-) diff --git a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx index b3be84972c..4c6b8d5e66 100644 --- a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx +++ b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx @@ -26,11 +26,8 @@ import { fetchDynamicSimulationEvent, saveDynamicSimulationEvent, } from '../../../../services/dynamic-simulation'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; +import { FetchStatus } from '../../../../services/utils'; export type DynamicSimulationEventDialogProps = { studyUuid: string; diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx index b49049ee16..b1cbde663b 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx @@ -10,11 +10,7 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -71,6 +67,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx index ba414ef18a..71939c0337 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx @@ -8,11 +8,7 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -66,6 +62,7 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx index d13f2abf0d..5054879bd0 100644 --- a/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx +++ b/src/components/dialogs/network-modifications/by-filter-deletion/by-filter-deletion-dialog.tsx @@ -14,11 +14,7 @@ import { SPECIFIC_METADATA, TYPE, } from '../../../utils/field-constants'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { FunctionComponent, useCallback, useEffect } from 'react'; import ModificationDialog from '../../commons/modificationDialog'; @@ -26,6 +22,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipmentByFilter } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; import ByFilterDeletionForm from './by-filter-deletion-form'; import { ByFilterDeletionDialogProps, diff --git a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx index 20dff73d76..c0815126c3 100644 --- a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx @@ -7,11 +7,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; import ModificationDialog from '../../commons/modificationDialog'; @@ -34,6 +30,7 @@ import { getFormulaInitialValue, getFormulaSchema, } from './formula/formula-utils'; +import { FetchStatus } from '../../../../services/utils'; function getFieldOrValue(input) { const value = input.replace(',', '.'); diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index d5aa2afb2b..9c37d519ee 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { @@ -29,6 +25,7 @@ import DeleteAttachingLineForm from './delete-attaching-line-form'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { deleteAttachingLine } from '../../../../services/study/network-modifications'; import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [ATTACHED_LINE_ID]: null, diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx index 184d0f17df..8803eb9577 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; @@ -28,6 +24,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import DeleteVoltageLevelOnLineForm from './delete-voltage-level-on-line-form'; import { deleteVoltageLevelOnLine } from '../../../../services/study/network-modifications'; import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LINE_TO_ATTACH_TO_1_ID]: null, diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx index 316828c8d7..306eb7e684 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { @@ -34,6 +30,7 @@ import ModificationDialog from '../../commons/modificationDialog'; import GenerationDispatchForm from './generation-dispatch-form'; import { addSelectedFieldToRows } from 'components/utils/dnd-table/dnd-table'; import { generationDispatch } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LOSS_COEFFICIENT]: null, diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx index a0e24ac4b8..5c661e2ae7 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.jsx @@ -11,11 +11,7 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import GeneratorScalingForm from './generator-scaling-form'; import { useCallback, useEffect } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; import { @@ -24,6 +20,7 @@ import { } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { generatorScaling } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index 189668f1c9..91ef870817 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ATTACHMENT_LINE_ID, @@ -52,6 +48,7 @@ import { attachLine } from '../../../../services/study/network-modifications'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [ATTACHMENT_LINE_ID]: '', diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index a7805fad46..3168f9c721 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { BUS_OR_BUSBAR_SECTION, @@ -49,6 +45,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { divideLine } from '../../../../services/study/network-modifications'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LINE1_ID]: '', diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index dbf0d4186c..f8995f539f 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -9,7 +9,6 @@ import { CustomFormProvider, TextInput, useSnackMessage, - FetchStatus, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Grid } from '@mui/material'; @@ -90,6 +89,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { ...getHeaderEmptyFormData(), diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index e079e49084..85541317e7 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -6,11 +6,7 @@ */ import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ADDITIONAL_PROPERTIES, @@ -71,6 +67,7 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; export const LineCreationDialogTab = { CHARACTERISTICS_TAB: 0, diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index a110194148..c20fdcc526 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { sanitizeString } from 'components/dialogs/dialogUtils'; import PropTypes from 'prop-types'; @@ -43,6 +39,7 @@ import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modi import { FORM_LOADING_DELAY } from 'components/network/constants'; import { linesAttachToSplitLines } from '../../../../services/study/network-modifications'; import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LINE_TO_ATTACH_TO_1_ID]: null, diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx index f26bebccab..bfb68b4500 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.jsx @@ -11,11 +11,7 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import LoadScalingForm from './load-scaling-form'; import { useCallback, useEffect } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; import { @@ -24,6 +20,7 @@ import { } from 'components/network/constants'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { loadScaling } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [VARIATION_TYPE]: VARIATION_TYPES.DELTA_P.id, diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx index 61c520fe23..cfa2ba0b1c 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { EQUIPMENT_ID, @@ -47,6 +43,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a load in the network diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index b41332d7f8..eefe1cc76c 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { @@ -61,6 +57,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index 20ce11a317..51affeffb5 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -10,11 +10,7 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import React, { useCallback, useEffect } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; @@ -36,6 +32,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx index deba850873..9641cc2c83 100644 --- a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx @@ -8,11 +8,7 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -38,6 +34,7 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx index 9b3e71a1ff..ae465b8dd2 100644 --- a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx @@ -7,11 +7,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; @@ -33,6 +29,7 @@ import { } from './tabular-creation-utils'; import { useIntl } from 'react-intl'; import { formatModification } from '../tabular-modification/tabular-modification-utils'; +import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx index 3c76ac5409..7c658ed2d0 100644 --- a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx @@ -7,11 +7,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; @@ -29,6 +25,7 @@ import { TABULAR_MODIFICATION_TYPES, } from './tabular-modification-utils'; import { useIntl } from 'react-intl'; +import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index a7e1c0281b..081db1ae46 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Grid } from '@mui/material'; import { @@ -110,6 +106,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a two windings transformer in the network diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx index 322bb7c978..4530de7a94 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { sanitizeString } from 'components/dialogs/dialogUtils'; import EquipmentSearchDialog from 'components/dialogs/equipment-search-dialog'; @@ -56,6 +52,7 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a load in the network diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx index 3c4d9977f2..5fe56635c9 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx @@ -21,11 +21,7 @@ import { } from 'components/utils/field-constants'; import yup from 'components/utils/yup-config'; import { yupResolver } from '@hookform/resolvers/yup'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; @@ -43,6 +39,7 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx index d05e3f28d4..eca375e095 100644 --- a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx @@ -63,11 +63,7 @@ import { setCurrentReactiveCapabilityCurveTable, setSelectedReactiveLimits, } from 'components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-utils'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { emptyProperties, getConcatenatedProperties, @@ -75,6 +71,7 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; +import { FetchStatus } from '../../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/graph/menus/network-modification-node-editor.jsx b/src/components/graph/menus/network-modification-node-editor.jsx index b080346d3b..49a554fb6c 100644 --- a/src/components/graph/menus/network-modification-node-editor.jsx +++ b/src/components/graph/menus/network-modification-node-editor.jsx @@ -8,7 +8,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useSnackMessage, - FetchStatus, fetchDirectoryElementPath, } from '@gridsuite/commons-ui'; import { useDispatch, useSelector } from 'react-redux'; @@ -88,6 +87,7 @@ import ByFilterDeletionDialog from '../../dialogs/network-modifications/by-filte import { useModificationLabelComputer } from '../util/use-modification-label-computer'; import { createModifications } from '../../../services/explore'; import { areUuidsEqual } from 'components/utils/utils'; +import { FetchStatus } from '../../../services/utils'; export const styles = { listContainer: (theme) => ({ diff --git a/src/components/voltage-init-result.jsx b/src/components/voltage-init-result.jsx index 9c1913e18f..c4ab1c0837 100644 --- a/src/components/voltage-init-result.jsx +++ b/src/components/voltage-init-result.jsx @@ -14,7 +14,7 @@ import { LinearProgress, Stack, Typography } from '@mui/material'; import { Lens } from '@mui/icons-material'; import Button from '@mui/material/Button'; import { useParams } from 'react-router-dom'; -import { useSnackMessage, FetchStatus } from '@gridsuite/commons-ui'; +import { useSnackMessage } from '@gridsuite/commons-ui'; import { cloneVoltageInitModifications, getVoltageInitModifications, @@ -30,6 +30,7 @@ import { RESULTS_LOADING_DELAY } from './network/constants'; import { RenderTableAndExportCsv } from './utils/renderTable-ExportCsv'; import { useParameterState } from './dialogs/parameters/parameters'; import { PARAM_DEVELOPER_MODE } from '../utils/config-params'; +import { FetchStatus } from '../services/utils'; const styles = { container: { diff --git a/src/services/utils.js b/src/services/utils.js index cc57f72e25..fd75412772 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -7,6 +7,13 @@ import { store } from '../redux/store'; import { fetchEnv, fetchStudyMetadata } from '@gridsuite/commons-ui'; +export const FetchStatus = { + SUCCEED: 'SUCCEED', + FAILED: 'FAILED', + IDLE: 'IDLE', + RUNNING: 'RUNNING', +}; + export const getToken = () => { const state = store.getState(); return state.user.id_token; From 809ac13e9884b93bf8e60070112ee37f13e85740 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 11:56:42 +0200 Subject: [PATCH 10/15] Clean up imports --- .../battery/creation/battery-creation-dialog.jsx | 2 +- .../battery/modification/battery-modification-dialog.jsx | 2 +- .../network-modifications/by-formula/by-formula-dialog.jsx | 2 +- .../delete-attaching-line/delete-attaching-line-dialog.jsx | 2 +- .../delete-voltage-level-on-line-dialog.jsx | 2 +- .../equipment-deletion/equipment-deletion-dialog.jsx | 7 ++----- .../generator/creation/generator-creation-dialog.jsx | 7 ++----- .../modification/generator-modification-dialog.jsx | 7 ++----- .../line-attach-to-voltage-level-dialog.jsx | 2 +- .../line-split-with-voltage-level-dialog.jsx | 2 +- .../line/creation/line-creation-dialog.jsx | 2 +- .../line/modification/line-modification-dialog.jsx | 2 +- .../lines-attach-to-split-lines-dialog.jsx | 2 +- .../load/creation/load-creation-dialog.jsx | 2 +- .../load/modification/load-modification-dialog.jsx | 7 ++----- .../creation/shunt-compensator-creation-dialog.jsx | 2 +- .../modification/shunt-compensator-modification-dialog.jsx | 7 ++----- .../substation/creation/substation-creation-dialog.jsx | 2 +- .../modification/substation-modification-dialog.jsx | 2 +- .../tabular-creation/tabular-creation-dialog.jsx | 2 +- .../tabular-modification/tabular-modification-dialog.jsx | 2 +- .../creation/two-windings-transformer-creation-dialog.jsx | 2 +- .../two-windings-transformer-modification-dialog.jsx | 7 ++----- .../voltage-init-modification-dialog.tsx | 1 + .../creation/voltage-level-creation-dialog.jsx | 2 +- .../modification/voltage-level-modification-dialog.jsx | 2 +- .../vsc/creation/vsc-creation-dialog.jsx | 2 +- .../vsc/modification/vsc-modification-dialog.tsx | 2 +- .../graph/menus/network-modification-node-editor.jsx | 2 +- src/components/voltage-init-result.jsx | 2 +- 30 files changed, 36 insertions(+), 53 deletions(-) diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx index b1cbde663b..0684d2a6ab 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.jsx @@ -60,6 +60,7 @@ import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modi import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import PropTypes from 'prop-types'; import { createBattery } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, @@ -67,7 +68,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx index 71939c0337..79039153e0 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.jsx @@ -55,6 +55,7 @@ import { } from '../../../set-points/set-points-utils'; import { modifyBattery } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, @@ -62,7 +63,6 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx index c0815126c3..8ae5f33cc9 100644 --- a/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-formula/by-formula-dialog.jsx @@ -9,6 +9,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; +import { FetchStatus } from '../../../../services/utils'; import { useForm } from 'react-hook-form'; import ModificationDialog from '../../commons/modificationDialog'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; @@ -30,7 +31,6 @@ import { getFormulaInitialValue, getFormulaSchema, } from './formula/formula-utils'; -import { FetchStatus } from '../../../../services/utils'; function getFieldOrValue(input) { const value = input.replace(',', '.'); diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx index 9c37d519ee..ed308c11be 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.jsx @@ -24,8 +24,8 @@ import ModificationDialog from '../../commons/modificationDialog'; import DeleteAttachingLineForm from './delete-attaching-line-form'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { deleteAttachingLine } from '../../../../services/study/network-modifications'; -import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; import { FetchStatus } from '../../../../services/utils'; +import DeleteAttachingLineIllustration from './delete-attaching-line-illustration'; const emptyFormData = { [ATTACHED_LINE_ID]: null, diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx index 8803eb9577..31a764c595 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.jsx @@ -23,8 +23,8 @@ import yup from 'components/utils/yup-config'; import ModificationDialog from '../../commons/modificationDialog'; import DeleteVoltageLevelOnLineForm from './delete-voltage-level-on-line-form'; import { deleteVoltageLevelOnLine } from '../../../../services/study/network-modifications'; -import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; import { FetchStatus } from '../../../../services/utils'; +import DeleteVoltageLevelOnLineIllustration from './delete-voltage-level-on-line-illustration'; const emptyFormData = { [LINE_TO_ATTACH_TO_1_ID]: null, diff --git a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx index 7417a99b52..83ee4198c0 100644 --- a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx +++ b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.jsx @@ -12,11 +12,7 @@ import { EQUIPMENT_ID, TYPE, } from '../../../utils/field-constants'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import React, { useCallback, useEffect } from 'react'; import ModificationDialog from '../../commons/modificationDialog'; @@ -26,6 +22,7 @@ import PropTypes from 'prop-types'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { deleteEquipment } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx index 88ae26a8ba..801e9df2b4 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.jsx @@ -10,11 +10,7 @@ import ModificationDialog from '../../../commons/modificationDialog'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; import { useFormSearchCopy } from '../../../form-search-copy-hook'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -78,6 +74,7 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; import { createGenerator } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx index efdc6b4e1a..309739a172 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.jsx @@ -8,11 +8,7 @@ import { useForm } from 'react-hook-form'; import ModificationDialog from '../../../commons/modificationDialog'; import React, { useCallback, useEffect, useState } from 'react'; -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -75,6 +71,7 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyGenerator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx index 91ef870817..ac0cd93251 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.jsx @@ -45,10 +45,10 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; import { attachLine } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; -import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [ATTACHMENT_LINE_ID]: '', diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx index 3168f9c721..6890336e05 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.jsx @@ -43,9 +43,9 @@ import { buildNewBusbarSections } from 'components/utils/utils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { divideLine } from '../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; -import { FetchStatus } from '../../../../services/utils'; const emptyFormData = { [LINE1_ID]: '', diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx index f8995f539f..671f5ec3b3 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx @@ -44,6 +44,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; +import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY, @@ -89,7 +90,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { ...getHeaderEmptyFormData(), diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx index 85541317e7..8910816468 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-dialog.jsx @@ -60,6 +60,7 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyLine } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, @@ -67,7 +68,6 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; export const LineCreationDialogTab = { CHARACTERISTICS_TAB: 0, diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx index c20fdcc526..18549a725a 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.jsx @@ -38,8 +38,8 @@ import { import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { linesAttachToSplitLines } from '../../../../services/study/network-modifications'; -import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; import { FetchStatus } from '../../../../services/utils'; +import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; const emptyFormData = { [LINE_TO_ATTACH_TO_1_ID]: null, diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx index cfa2ba0b1c..f3f66dc644 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.jsx @@ -36,6 +36,7 @@ import LoadCreationForm from './load-creation-form'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { createLoad } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, @@ -43,7 +44,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a load in the network diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx index a26bfe99d6..3600224472 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; @@ -33,6 +29,7 @@ import { EQUIPMENT_TYPES, } from 'components/utils/equipment-types'; import { modifyLoad } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx index eefe1cc76c..3c276fc00a 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.jsx @@ -50,6 +50,7 @@ import { } from '../characteristics-pane/characteristics-form-utils'; import ShuntCompensatorCreationForm from './shunt-compensator-creation-form'; import { createShuntCompensator } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, @@ -57,7 +58,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx index 312fbbed58..2c216b4d02 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { ADDITIONAL_PROPERTIES, CHARACTERISTICS_CHOICE, @@ -42,6 +38,7 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyShuntCompensator } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx index 51affeffb5..4ad443eb0e 100644 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx @@ -24,6 +24,7 @@ import { sanitizeString } from '../../../dialogUtils'; import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { createSubstation } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, @@ -32,7 +33,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_ID]: '', diff --git a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx index 9641cc2c83..862a5dd27b 100644 --- a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.jsx @@ -27,6 +27,7 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifySubstation } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, @@ -34,7 +35,6 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx index ae465b8dd2..5548b1662b 100644 --- a/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-creation/tabular-creation-dialog.jsx @@ -20,6 +20,7 @@ import { } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabularCreation } from 'services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; import TabularCreationForm from './tabular-creation-form'; import { convertCreationFieldFromBackToFront, @@ -29,7 +30,6 @@ import { } from './tabular-creation-utils'; import { useIntl } from 'react-intl'; import { formatModification } from '../tabular-modification/tabular-modification-utils'; -import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx index 7c658ed2d0..21601bfb40 100644 --- a/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/tabular-modification/tabular-modification-dialog.jsx @@ -16,6 +16,7 @@ import { FORM_LOADING_DELAY } from 'components/network/constants'; import { MODIFICATIONS_TABLE, TYPE } from 'components/utils/field-constants'; import ModificationDialog from 'components/dialogs/commons/modificationDialog'; import { createTabulareModification } from 'services/study/network-modifications'; +import { FetchStatus } from '../../../../services/utils'; import TabularModificationForm from './tabular-modification-form'; import { convertValueFromBackToFront, @@ -25,7 +26,6 @@ import { TABULAR_MODIFICATION_TYPES, } from './tabular-modification-utils'; import { useIntl } from 'react-intl'; -import { FetchStatus } from '../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx index 081db1ae46..6ddce34cf9 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx @@ -54,6 +54,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import React, { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; +import { FetchStatus } from '../../../../../services/utils'; import { microUnitToUnit, unitToMicroUnit } from 'utils/unit-converter'; import { sanitizeString } from '../../../dialogUtils'; import EquipmentSearchDialog from '../../../equipment-search-dialog'; @@ -106,7 +107,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a two windings transformer in the network diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx index 6bb3299195..fe39e8fd79 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog.jsx @@ -5,11 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - CustomFormProvider, - useSnackMessage, - FetchStatus, -} from '@gridsuite/commons-ui'; +import { CustomFormProvider, useSnackMessage } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { Box, Grid } from '@mui/material'; import { @@ -111,6 +107,7 @@ import { fetchNetworkElementInfos, fetchVoltageLevelsListInfos, } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, diff --git a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx index aa5e856017..14a28ed513 100644 --- a/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog.tsx @@ -59,6 +59,7 @@ enum FetchStatus { IDLE = 'IDLE', RUNNING = 'RUNNING', } + interface CloseFunction { (): void; } diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx index 4530de7a94..49d31eabcb 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.jsx @@ -45,6 +45,7 @@ import { kiloUnitToUnit, unitToKiloUnit } from 'utils/unit-converter'; import { FORM_LOADING_DELAY } from 'components/network/constants'; import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { createVoltageLevel } from '../../../../../services/study/network-modifications'; +import { FetchStatus } from '../../../../../services/utils'; import { copyEquipmentPropertiesForCreation, creationPropertiesSchema, @@ -52,7 +53,6 @@ import { getPropertiesFromModification, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; /** * Dialog to create a load in the network diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx index 5fe56635c9..df9b977fa4 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.jsx @@ -32,6 +32,7 @@ import { import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyVoltageLevel } from '../../../../../services/study/network-modifications'; import { fetchNetworkElementInfos } from '../../../../../services/study/network'; +import { FetchStatus } from '../../../../../services/utils'; import { emptyProperties, getConcatenatedProperties, @@ -39,7 +40,6 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const emptyFormData = { [EQUIPMENT_NAME]: '', diff --git a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx index 8ffc8af1c4..612bd5e7d2 100644 --- a/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx +++ b/src/components/dialogs/network-modifications/vsc/creation/vsc-creation-dialog.jsx @@ -10,7 +10,6 @@ import { CustomFormProvider, TextInput, useSnackMessage, - FetchStatus, } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -48,6 +47,7 @@ import { getVscHvdcLinePaneSchema, getVscHvdcLineTabFormData, } from '../hvdc-line-pane/vsc-hvdc-line-pane-utils'; +import { FetchStatus } from '../../../../../services/utils'; import { getConverterStationCreationData, getConverterStationFormEditData, diff --git a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx index eca375e095..429ea08864 100644 --- a/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/vsc/modification/vsc-modification-dialog.tsx @@ -40,6 +40,7 @@ import { REACTIVE_CAPABILITY_CURVE_TABLE, REACTIVE_LIMITS, } from '../../../../utils/field-constants'; +import { FetchStatus } from '../../../../../services/utils'; import { getVscHvdcLineModificationPaneSchema, getVscHvdcLineModificationTabFormData, @@ -71,7 +72,6 @@ import { modificationPropertiesSchema, toModificationProperties, } from '../../common/properties/property-utils'; -import { FetchStatus } from '../../../../../services/utils'; const formSchema = yup .object() diff --git a/src/components/graph/menus/network-modification-node-editor.jsx b/src/components/graph/menus/network-modification-node-editor.jsx index 49a554fb6c..b6044bff83 100644 --- a/src/components/graph/menus/network-modification-node-editor.jsx +++ b/src/components/graph/menus/network-modification-node-editor.jsx @@ -77,6 +77,7 @@ import { stashModifications, fetchNetworkModifications, } from '../../../services/study/network-modifications'; +import { FetchStatus } from '../../../services/utils'; import { copyOrMoveModifications } from '../../../services/study'; import { MODIFICATION_TYPES } from 'components/utils/modification-type'; import RestoreModificationDialog from 'components/dialogs/restore-modification-dialog'; @@ -87,7 +88,6 @@ import ByFilterDeletionDialog from '../../dialogs/network-modifications/by-filte import { useModificationLabelComputer } from '../util/use-modification-label-computer'; import { createModifications } from '../../../services/explore'; import { areUuidsEqual } from 'components/utils/utils'; -import { FetchStatus } from '../../../services/utils'; export const styles = { listContainer: (theme) => ({ diff --git a/src/components/voltage-init-result.jsx b/src/components/voltage-init-result.jsx index c4ab1c0837..e1bc3c7ba5 100644 --- a/src/components/voltage-init-result.jsx +++ b/src/components/voltage-init-result.jsx @@ -22,6 +22,7 @@ import { import CircularProgress from '@mui/material/CircularProgress'; import { Box } from '@mui/system'; import VoltageInitModificationDialog from './dialogs/network-modifications/voltage-init-modification/voltage-init-modification-dialog'; +import { FetchStatus } from '../services/utils'; import { ComputationReportViewer } from './results/common/computation-report-viewer'; import { REPORT_TYPES } from './utils/report-type'; import { useOpenLoaderShortWait } from './dialogs/commons/handle-loader'; @@ -30,7 +31,6 @@ import { RESULTS_LOADING_DELAY } from './network/constants'; import { RenderTableAndExportCsv } from './utils/renderTable-ExportCsv'; import { useParameterState } from './dialogs/parameters/parameters'; import { PARAM_DEVELOPER_MODE } from '../utils/config-params'; -import { FetchStatus } from '../services/utils'; const styles = { container: { From 33ca3754037683cb27de682473fbafc3c12643a9 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 12:41:58 +0200 Subject: [PATCH 11/15] Inline downloadZipFile --- .../securityanalysis/security-analysis-export-button.tsx | 4 ++-- .../sensitivity-analysis-result-tab.jsx | 4 ++-- .../shortcircuit/shortcircuit-analysis-export-button.tsx | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/results/securityanalysis/security-analysis-export-button.tsx b/src/components/results/securityanalysis/security-analysis-export-button.tsx index a782be6830..28937a59ad 100644 --- a/src/components/results/securityanalysis/security-analysis-export-button.tsx +++ b/src/components/results/securityanalysis/security-analysis-export-button.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadFile, FileType } from '@gridsuite/commons-ui'; import { ExportButton } from 'components/utils/export-button'; import { UUID } from 'crypto'; import { @@ -84,7 +84,7 @@ export const SecurityAnalysisExportButton: FunctionComponent< enumValueTranslations ) .then((fileBlob) => { - downloadZipFile(fileBlob, `${resultType}-results.zip`); + downloadFile(fileBlob, `${resultType}-results.zip`, FileType.ZIP); setIsCsvExportSuccessful(true); }) .catch((error) => { diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx index a9684a0b4d..ee28a1fa1d 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx @@ -29,7 +29,7 @@ import { useOpenLoaderShortWait } from '../../dialogs/commons/handle-loader'; import { RESULTS_LOADING_DELAY } from '../../network/constants'; import React, { useCallback } from 'react'; import { exportSensitivityResultsAsCsv } from '../../../services/study/sensitivity-analysis'; -import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadFile, FileType } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { ExportButton } from '../../utils/export-button'; import { setSensitivityAnalysisResultFilter } from 'redux/actions'; @@ -128,7 +128,7 @@ const SensitivityAnalysisResultTab = ({ studyUuid, nodeUuid }) => { }) .then((response) => { response.blob().then((blob) => { - downloadZipFile(blob, 'sensitivity_analyse_results.zip'); + downloadFile(blob, 'sensitivity_analyse_results.zip', FileType.ZIP); setIsCsvExportSuccessful(true); }); }) diff --git a/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx b/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx index 7802963813..c119b12fb7 100644 --- a/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx +++ b/src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx @@ -13,7 +13,7 @@ import { useState, } from 'react'; import { ExportButton } from '../../utils/export-button'; -import { useSnackMessage, downloadZipFile } from '@gridsuite/commons-ui'; +import { useSnackMessage, downloadFile, FileType } from '@gridsuite/commons-ui'; import { useIntl } from 'react-intl'; import { downloadShortCircuitResultZippedCsv } from '../../../services/study/short-circuit-analysis'; import { ShortCircuitAnalysisType } from './shortcircuit-analysis-result.type'; @@ -81,11 +81,12 @@ export const ShortCircuitExportButton: FunctionComponent< ) .then((response) => { response.blob().then((fileBlob: Blob) => { - downloadZipFile( + downloadFile( fileBlob, analysisType === ShortCircuitAnalysisType.ONE_BUS ? 'oneBus-results.zip' - : 'allBuses_results.zip' + : 'allBuses_results.zip', + FileType.ZIP ); setIsCsvExportSuccessful(true); }); From 0a500a026f777dd7d8979f1cee8b0f67cb45200e Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 15:43:21 +0200 Subject: [PATCH 12/15] Remove getToken --- src/services/directory-notification.js | 6 +++--- src/services/study/index.js | 1 - src/services/utils.js | 16 +++++++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/services/directory-notification.js b/src/services/directory-notification.js index 2a51a06f78..0841ec33a0 100644 --- a/src/services/directory-notification.js +++ b/src/services/directory-notification.js @@ -6,8 +6,8 @@ */ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getToken, getUrlWithToken } from './utils'; -import { getWsBase } from '@gridsuite/commons-ui'; +import { getUrlWithToken } from './utils'; +import { getWsBase, getUserToken } from '@gridsuite/commons-ui'; const PREFIX_DIRECTORY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/directory-notification'; @@ -39,7 +39,7 @@ export function connectNotificationsWsUpdateDirectories() { const webSocketUrl = `${webSocketBaseUrl}${PREFIX_DIRECTORY_NOTIFICATION_WS}/notify?updateType=directories`; const reconnectingWebSocket = new ReconnectingWebSocket( - () => `${webSocketUrl}&access_token=${getToken()}` + () => `${webSocketUrl}&access_token=${getUserToken()}` ); reconnectingWebSocket.onopen = function () { console.info( diff --git a/src/services/study/index.js b/src/services/study/index.js index c9be0382f0..90a926bd67 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.js @@ -23,7 +23,6 @@ export { fetchVersion, fetchAuthorizationCodeFlowFeatureFlag, fetchIdpSettings, - getToken, } from '../utils'; export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; diff --git a/src/services/utils.js b/src/services/utils.js index fd75412772..9c47d53141 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -4,8 +4,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { store } from '../redux/store'; -import { fetchEnv, fetchStudyMetadata } from '@gridsuite/commons-ui'; +import { + fetchEnv, + fetchStudyMetadata, + getUserToken, +} from '@gridsuite/commons-ui'; export const FetchStatus = { SUCCEED: 'SUCCEED', @@ -14,11 +17,6 @@ export const FetchStatus = { RUNNING: 'RUNNING', }; -export const getToken = () => { - const state = store.getState(); - return state.user.id_token; -}; - export function fetchIdpSettings() { return fetch('idpSettings.json'); } @@ -71,9 +69,9 @@ export const fetchDefaultParametersValues = () => { export function getUrlWithToken(baseUrl) { if (baseUrl.includes('?')) { - return baseUrl + '&access_token=' + getToken(); + return baseUrl + '&access_token=' + getUserToken(); } else { - return baseUrl + '?access_token=' + getToken(); + return baseUrl + '?access_token=' + getUserToken(); } } From a9f6f686688b0faf42a564faa528f015d5dd14fb Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 16:04:10 +0200 Subject: [PATCH 13/15] Remove unused function --- src/services/explore.ts | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/services/explore.ts b/src/services/explore.ts index b9b676b18c..af5e3db0d0 100644 --- a/src/services/explore.ts +++ b/src/services/explore.ts @@ -55,30 +55,4 @@ export function createModifications( body: JSON.stringify(modificationList), } ); -} - -/** - * Create Filter - * @returns {Promise} - */ -export function createFilter( - newFilter: any, - name: string, - description: string, - parentDirectoryUuid: string -) { - let urlSearchParams = new URLSearchParams(); - urlSearchParams.append('name', name); - urlSearchParams.append('description', description); - urlSearchParams.append('parentDirectoryUuid', parentDirectoryUuid); - return backendFetch( - PREFIX_EXPLORE_SERVER_QUERIES + - '/v1/explore/filters?' + - urlSearchParams.toString(), - { - method: 'post', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(newFilter), - } - ); -} +} \ No newline at end of file From 94b7cafd40583bf7c852cf6db130859c19356040 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 28 May 2024 16:04:43 +0200 Subject: [PATCH 14/15] Add newline --- src/services/explore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/explore.ts b/src/services/explore.ts index af5e3db0d0..ad1a73248d 100644 --- a/src/services/explore.ts +++ b/src/services/explore.ts @@ -55,4 +55,4 @@ export function createModifications( body: JSON.stringify(modificationList), } ); -} \ No newline at end of file +} From 7ddeb25074f98b9dd570b91ce7b5e0cb017beecc Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Tue, 4 Jun 2024 16:51:42 +0200 Subject: [PATCH 15/15] Move remaining utils functions --- package-lock.json | 7 +- package.json | 4 +- src/components/app-top-bar.jsx | 2 +- src/components/app.jsx | 8 +-- .../common/parameters-creation-dialog.tsx | 1 - .../dialogs/parameters/network-parameters.jsx | 2 +- .../network-modification-node-editor.jsx | 1 - .../network/filter-creation-panel.tsx | 1 - .../security-analysis-export-button.tsx | 6 +- .../sensitivity-analysis-result-tab.jsx | 10 ++- src/components/study-container.jsx | 1 - src/services/config-notification.js | 3 +- src/services/directory-notification.js | 7 +- src/services/study-notification.js | 3 +- src/services/study/index.js | 9 +-- src/services/study/network.js | 2 +- src/services/utils.js | 64 +------------------ 17 files changed, 33 insertions(+), 98 deletions(-) diff --git a/package-lock.json b/package-lock.json index b284e9a107..963349758f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.59.0", + "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.59.0.tgz", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -3201,8 +3201,9 @@ }, "node_modules/@gridsuite/commons-ui": { "version": "0.59.0", - "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.59.0.tgz", - "integrity": "sha512-RqQljHjIGi3P4kfHgXFIGXI3YyR6kg1n9YcpNkURgMRlwQjw5H6p3XasHIX8MJ1UuMm/+w1rbn9+lsrGNkpI9A==", + "resolved": "file:../commons-ui/gridsuite-commons-ui-0.59.0.tgz", + "integrity": "sha512-xfTfPhbRUQ2XcY+DN6l80C7iILrQ656N/rH8PFv77vDSi7Af+Dz9nlmSPydJgEAYI57T0PVnBwBnRdAVkyWp9g==", + "license": "MPL-2.0", "dependencies": { "@react-querybuilder/dnd": "^7.2.0", "@react-querybuilder/material": "^7.2.0", diff --git a/package.json b/package.json index 6e61568a52..2c86605fca 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@gridsuite/commons-ui": "0.59.0", + "@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.59.0.tgz", "@hookform/resolvers": "^3.3.4", "@mui/icons-material": "^5.15.14", "@mui/lab": "5.0.0-alpha.169", @@ -106,8 +106,8 @@ "jest-environment-jsdom": "^29.7.0", "license-checker": "^25.0.1", "prettier": "^2.8.8", - "typescript": "5.1.6", "ts-node": "^10.9.2", + "typescript": "5.1.6", "vite": "^5.2.7", "vite-plugin-eslint": "^1.8.1", "vite-plugin-svgr": "^4.2.0", diff --git a/src/components/app-top-bar.jsx b/src/components/app-top-bar.jsx index e7a6c01928..320339fb0a 100644 --- a/src/components/app-top-bar.jsx +++ b/src/components/app-top-bar.jsx @@ -12,6 +12,7 @@ import { OverflowableText, TopBar, fetchAppsMetadata, + fetchVersion, } from '@gridsuite/commons-ui'; import GridStudyLogoLight from '../images/GridStudy_logo_light.svg?react'; import GridStudyLogoDark from '../images/GridStudy_logo_dark.svg?react'; @@ -32,7 +33,6 @@ import { isNodeBuilt, isNodeReadOnly } from './graph/util/model-functions'; import { useParameterState } from './dialogs/parameters/parameters'; import { getServersInfos } from '../services/study'; import { EQUIPMENT_TYPES } from './utils/equipment-types'; -import { fetchVersion } from '../services/utils'; import { RunButtonContainer } from './run-button-container'; import { useComputationResultsCount } from '../hooks/use-computation-results-count'; diff --git a/src/components/app.jsx b/src/components/app.jsx index 5bf66386f8..853ef866d1 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -29,6 +29,9 @@ import { getPreLoginPath, initializeAuthenticationProd, useSnackMessage, + fetchAuthorizationCodeFlowFeatureFlag, + fetchDefaultParametersValues, + fetchIdpSettings, } from '@gridsuite/commons-ui'; import PageNotFound from './page-not-found'; @@ -72,11 +75,6 @@ import { fetchConfigParameter, fetchConfigParameters, } from '../services/config'; -import { - fetchAuthorizationCodeFlowFeatureFlag, - fetchDefaultParametersValues, - fetchIdpSettings, -} from '../services/utils'; import { getOptionalServices } from '../services/study'; import { changeDisplayedColumns, diff --git a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx index a9aaa9a333..52db4771c2 100644 --- a/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx +++ b/src/components/dialogs/parameters/common/parameters-creation-dialog.tsx @@ -25,7 +25,6 @@ import { createParameter } from 'services/explore'; import { UniqueNameInput } from 'components/dialogs/commons/unique-name-input'; import { ReduxState } from 'redux/reducer.type'; import { UUID } from 'crypto'; -import { fetchDirectoryElementPath } from '@gridsuite/commons-ui'; interface FormData { [NAME]: string; diff --git a/src/components/dialogs/parameters/network-parameters.jsx b/src/components/dialogs/parameters/network-parameters.jsx index ae4e443402..4e669bb472 100644 --- a/src/components/dialogs/parameters/network-parameters.jsx +++ b/src/components/dialogs/parameters/network-parameters.jsx @@ -14,7 +14,7 @@ import { import { LabelledButton, useParameterState, styles } from './parameters'; import { LineSeparator } from '../dialogUtils'; import Alert from '@mui/material/Alert'; -import { fetchDefaultParametersValues } from '../../../services/utils'; +import { fetchDefaultParametersValues } from '@gridsuite/commons-ui'; import { ParamLine, ParameterType } from './widget'; import { mergeSx } from '../../utils/functions'; diff --git a/src/components/graph/menus/network-modification-node-editor.jsx b/src/components/graph/menus/network-modification-node-editor.jsx index 686a5aacca..2b68406437 100644 --- a/src/components/graph/menus/network-modification-node-editor.jsx +++ b/src/components/graph/menus/network-modification-node-editor.jsx @@ -88,7 +88,6 @@ import ByFilterDeletionDialog from '../../dialogs/network-modifications/by-filte import { useModificationLabelComputer } from '../util/use-modification-label-computer'; import { createModifications } from '../../../services/explore'; import { areUuidsEqual } from 'components/utils/utils'; -import { fetchDirectoryElementPath } from '@gridsuite/commons-ui'; export const styles = { listContainer: (theme) => ({ diff --git a/src/components/network/filter-creation-panel.tsx b/src/components/network/filter-creation-panel.tsx index 81e075d75c..b94b876411 100644 --- a/src/components/network/filter-creation-panel.tsx +++ b/src/components/network/filter-creation-panel.tsx @@ -28,7 +28,6 @@ import { EQUIPMENT_TYPES, } from '../utils/equipment-types'; import { UUID } from 'crypto'; -import { fetchDirectoryElementPath } from '@gridsuite/commons-ui'; import CircularProgress from '@mui/material/CircularProgress'; import FolderOutlined from '@mui/icons-material/FolderOutlined'; diff --git a/src/components/results/securityanalysis/security-analysis-export-button.tsx b/src/components/results/securityanalysis/security-analysis-export-button.tsx index 28937a59ad..eb65f4e1d7 100644 --- a/src/components/results/securityanalysis/security-analysis-export-button.tsx +++ b/src/components/results/securityanalysis/security-analysis-export-button.tsx @@ -84,7 +84,11 @@ export const SecurityAnalysisExportButton: FunctionComponent< enumValueTranslations ) .then((fileBlob) => { - downloadFile(fileBlob, `${resultType}-results.zip`, FileType.ZIP); + downloadFile( + fileBlob, + `${resultType}-results.zip`, + FileType.ZIP + ); setIsCsvExportSuccessful(true); }) .catch((error) => { diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx index ee28a1fa1d..862f0562cf 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.jsx @@ -75,8 +75,8 @@ const SensitivityAnalysisResultTab = ({ studyUuid, nodeUuid }) => { initSort(nOrNkIndex ? 'valueAfter' : 'value'); /* set page to 0 to avoid being in out of range (0 to 0, but page is > 0) - for the page prop of MUI TablePagination if was not on the first page - for the prev sensiKind */ + for the page prop of MUI TablePagination if was not on the first page + for the prev sensiKind */ setPage(0); setIsCsvExportSuccessful(false); @@ -128,7 +128,11 @@ const SensitivityAnalysisResultTab = ({ studyUuid, nodeUuid }) => { }) .then((response) => { response.blob().then((blob) => { - downloadFile(blob, 'sensitivity_analyse_results.zip', FileType.ZIP); + downloadFile( + blob, + 'sensitivity_analyse_results.zip', + FileType.ZIP + ); setIsCsvExportSuccessful(true); }); }) diff --git a/src/components/study-container.jsx b/src/components/study-container.jsx index 8823a0198f..49eb45f122 100644 --- a/src/components/study-container.jsx +++ b/src/components/study-container.jsx @@ -57,7 +57,6 @@ import { invalidateLoadFlowStatus } from 'services/study/loadflow'; import { HttpStatusCode } from 'utils/http-status-code'; import { usePrevious } from './utils/utils'; import { StudyIndexationStatus } from 'redux/reducer.type'; -import { fetchDirectoryElementPath } from '@gridsuite/commons-ui'; function isWorthUpdate( studyUpdatedForce, diff --git a/src/services/config-notification.js b/src/services/config-notification.js index 50713d37e1..daa0c069ec 100644 --- a/src/services/config-notification.js +++ b/src/services/config-notification.js @@ -6,8 +6,7 @@ */ import { APP_NAME } from '../utils/config-params'; import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getUrlWithToken } from './utils'; -import { getWsBase } from '@gridsuite/commons-ui'; +import { getWsBase, getUrlWithToken } from '@gridsuite/commons-ui'; const PREFIX_CONFIG_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/config-notification'; diff --git a/src/services/directory-notification.js b/src/services/directory-notification.js index 0841ec33a0..83d4e209bc 100644 --- a/src/services/directory-notification.js +++ b/src/services/directory-notification.js @@ -6,8 +6,11 @@ */ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getUrlWithToken } from './utils'; -import { getWsBase, getUserToken } from '@gridsuite/commons-ui'; +import { + getWsBase, + getUserToken, + getUrlWithToken, +} from '@gridsuite/commons-ui'; const PREFIX_DIRECTORY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/directory-notification'; diff --git a/src/services/study-notification.js b/src/services/study-notification.js index 8699df45a0..ced54affa6 100644 --- a/src/services/study-notification.js +++ b/src/services/study-notification.js @@ -7,8 +7,7 @@ import ReconnectingWebSocket from 'reconnecting-websocket'; -import { getUrlWithToken } from './utils'; -import { getWsBase } from '@gridsuite/commons-ui'; +import { getWsBase, getUrlWithToken } from '@gridsuite/commons-ui'; const PREFIX_STUDY_NOTIFICATION_WS = import.meta.env.VITE_WS_GATEWAY + '/study-notification'; diff --git a/src/services/study/index.js b/src/services/study/index.js index 90a926bd67..21afe6f586 100644 --- a/src/services/study/index.js +++ b/src/services/study/index.js @@ -16,14 +16,7 @@ import { // created multiple circular dependencies issues, so in the meantime its other // functions are being exported as a crutch... To be removed once circular // dependencies are fixed -export { - fetchMapBoxToken, - getUrlWithToken, - fetchDefaultParametersValues, - fetchVersion, - fetchAuthorizationCodeFlowFeatureFlag, - fetchIdpSettings, -} from '../utils'; +export { fetchMapBoxToken } from '../utils'; export const PREFIX_STUDY_QUERIES = import.meta.env.VITE_API_GATEWAY + '/study'; diff --git a/src/services/study/network.js b/src/services/study/network.js index aee0611dbb..0acc9e300c 100644 --- a/src/services/study/network.js +++ b/src/services/study/network.js @@ -15,8 +15,8 @@ import { backendFetchJson, backendFetchText, getRequestParamFromList, + getUrlWithToken, } from '@gridsuite/commons-ui'; -import { getUrlWithToken } from '../utils'; /* voltage-levels */ export function getVoltageLevelSingleLineDiagram( diff --git a/src/services/utils.js b/src/services/utils.js index 9c47d53141..d4acf3daee 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -4,11 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { - fetchEnv, - fetchStudyMetadata, - getUserToken, -} from '@gridsuite/commons-ui'; +import { fetchEnv } from '@gridsuite/commons-ui'; export const FetchStatus = { SUCCEED: 'SUCCEED', @@ -17,64 +13,6 @@ export const FetchStatus = { RUNNING: 'RUNNING', }; -export function fetchIdpSettings() { - return fetch('idpSettings.json'); -} - -export function fetchAuthorizationCodeFlowFeatureFlag() { - console.info(`Fetching authorization code flow feature flag...`); - return fetchEnv() - .then((env) => - fetch(env.appsMetadataServerUrl + '/authentication.json') - ) - .then((res) => res.json()) - .then((res) => { - console.log( - `Authorization code flow is ${ - res.authorizationCodeFlowFeatureFlag - ? 'enabled' - : 'disabled' - }` - ); - return res.authorizationCodeFlowFeatureFlag; - }) - .catch((error) => { - console.error(error); - console.warn( - `Something wrong happened when retrieving authentication.json: authorization code flow will be disabled` - ); - return false; - }); -} - -export function fetchVersion() { - console.info(`Fetching global metadata...`); - return fetchEnv() - .then((env) => fetch(env.appsMetadataServerUrl + '/version.json')) - .then((response) => response.json()) - .catch((reason) => { - console.error('Error while fetching the version : ' + reason); - return reason; - }); -} - -export const fetchDefaultParametersValues = () => { - return fetchStudyMetadata().then((studyMetadata) => { - console.info( - 'fecthing default parameters values from apps-metadata file' - ); - return studyMetadata.defaultParametersValues; - }); -}; - -export function getUrlWithToken(baseUrl) { - if (baseUrl.includes('?')) { - return baseUrl + '&access_token=' + getUserToken(); - } else { - return baseUrl + '?access_token=' + getUserToken(); - } -} - export function fetchMapBoxToken() { console.info(`Fetching MapBoxToken...`); return fetchEnv().then((res) => res.mapBoxToken);