diff --git a/src/components/app-wrapper.jsx b/src/components/app-wrapper.jsx index 8f3ec6bc7a..d2fe1159ce 100644 --- a/src/components/app-wrapper.jsx +++ b/src/components/app-wrapper.jsx @@ -80,6 +80,8 @@ import { treeviewFinderFr, useUniqueNameValidationEn, useUniqueNameValidationFr, + csvEn, + csvFr, } from '@gridsuite/commons-ui'; import { IntlProvider } from 'react-intl'; import { BrowserRouter } from 'react-router'; @@ -418,6 +420,7 @@ const messages = { ...backend_locale_en, ...dynamic_mapping_models_en, ...csv_locale_en, + ...csvEn, ...filter_locale_en, ...menu_locale_en, ...table_locale_en, @@ -460,6 +463,7 @@ const messages = { ...backend_locale_fr, ...dynamic_mapping_models_fr, ...csv_locale_fr, + ...csvFr, ...filter_locale_fr, ...menu_locale_fr, ...table_locale_fr, diff --git a/src/components/dialogs/commons/basicModificationDialog.tsx b/src/components/dialogs/commons/basicModificationDialog.tsx index 1deace0527..6d3b7bd7f7 100644 --- a/src/components/dialogs/commons/basicModificationDialog.tsx +++ b/src/components/dialogs/commons/basicModificationDialog.tsx @@ -7,7 +7,7 @@ import { FormattedMessage } from 'react-intl'; import { Button } from '@mui/material'; -import { ModificationDialogContent, ModificationDialogContentProps } from './modification-dialog-content'; +import { ModificationDialogContent, ModificationDialogContentProps } from '@gridsuite/commons-ui'; export type BasicModificationDialogProps = Omit & { disabledSave?: boolean; diff --git a/src/components/dialogs/commons/handle-modification-form.ts b/src/components/dialogs/commons/handle-modification-form.ts deleted file mode 100644 index 5b216b2a1b..0000000000 --- a/src/components/dialogs/commons/handle-modification-form.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2023, 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 { useEffect, useState } from 'react'; - -/** - * A hook that returns a boolean indicating whether a form should be opened after a short delay. - * - * @param {boolean} isDataFetched - Whether data is fetched. - * @param {number} delay - The delay before opening the form, in milliseconds. - * - * @returns {boolean} A boolean indicating whether the form should be opened. - */ - -export const useOpenShortWaitFetching: ({ - isDataFetched, - delay, -}: { - isDataFetched: boolean; - delay: number; -}) => boolean = ({ isDataFetched, delay }) => { - // State to track whether the form should be opened or not. - const [shouldOpen, setShouldOpen] = useState(false); - - useEffect(() => { - let timeout: NodeJS.Timeout; - // If data is already available, open the form immediately. - if (isDataFetched) { - setShouldOpen(true); - } else { - // Otherwise, wait for a short delay before opening the form. - timeout = setTimeout(() => setShouldOpen(true), delay); - } - // Return a cleanup function to cancel the timeout if the data arrives before the end of the delay. - return () => clearTimeout(timeout); - }, [delay, isDataFetched]); - - return shouldOpen; -}; diff --git a/src/components/dialogs/commons/modification-dialog-content.tsx b/src/components/dialogs/commons/modification-dialog-content.tsx deleted file mode 100644 index 27ccfd8ecb..0000000000 --- a/src/components/dialogs/commons/modification-dialog-content.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (c) 2023, 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 { Grid, Dialog, DialogTitle, DialogContent, DialogActions, LinearProgress } from '@mui/material'; -import { useButtonWithTooltip } from '../../utils/inputs/input-hooks'; -import FindInPageIcon from '@mui/icons-material/FindInPage'; -import AutoStoriesOutlinedIcon from '@mui/icons-material/AutoStoriesOutlined'; -import React, { ReactNode } from 'react'; -import { UseFormSearchCopy } from './use-form-search-copy'; -import { FormattedMessage } from 'react-intl'; -import { CancelButton } from '@gridsuite/commons-ui'; -import { DialogProps } from '@mui/material/Dialog/Dialog'; - -/** - * Common parts for the Modification Dialog - * @param {String} titleId id for title translation - * @param {Object} onOpenCatalogDialog Object managing catalog - * @param {Object} searchCopy Object managing search equipments for copy - * @param {ReactElement} subtitle subtitle component to put inside DialogTitle - * @param {Boolean} isDataFetching props to display loading - * @param {ReactElement} submitButton submitButton to put in the dialog's footer - * @param {CallbackEvent} closeAndClear callback when the dialog needs to be closed and cleared - * @param {Array} dialogProps props that are forwarded to the MUI Dialog component - */ - -export type ModificationDialogContentProps = Omit & { - closeAndClear: () => void; - isDataFetching?: boolean; - titleId: string; - onOpenCatalogDialog?: () => void; - searchCopy?: UseFormSearchCopy; - submitButton: ReactNode; - subtitle?: ReactNode; -}; - -export function ModificationDialogContent({ - closeAndClear, - isDataFetching = false, - titleId, - onOpenCatalogDialog, - searchCopy, - submitButton, - subtitle, - ...dialogProps -}: Readonly) { - const catalogButton = useButtonWithTooltip({ - label: 'CatalogButtonTooltip', - handleClick: onOpenCatalogDialog ?? (() => {}), - icon: , - }); - const copyEquipmentButton = useButtonWithTooltip({ - label: 'CopyFromExisting', - handleClick: searchCopy?.handleOpenSearchDialog ?? (() => {}), - icon: , - }); - - const handleClose = (event_: React.MouseEvent, reason: string) => { - // don't close the dialog for outside click - if (reason !== 'backdropClick') { - closeAndClear(); - } - }; - - const handleCancel = () => { - closeAndClear(); - }; - - return ( - - {isDataFetching && } - - - - - - - - {onOpenCatalogDialog && ( - - {catalogButton} - - )} - {searchCopy && ( - - {copyEquipmentButton} - - )} - - {subtitle && ( - - {subtitle} - - )} - - - {dialogProps.children} - - - {submitButton} - - - ); -} diff --git a/src/components/dialogs/commons/modificationDialog.tsx b/src/components/dialogs/commons/modificationDialog.tsx deleted file mode 100644 index f47295c3dd..0000000000 --- a/src/components/dialogs/commons/modificationDialog.tsx +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2023, 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 { useCallback } from 'react'; -import { FieldErrors, FieldValues, useFormContext } from 'react-hook-form'; -import { SubmitButton } from '@gridsuite/commons-ui'; -import { ModificationDialogContent, ModificationDialogContentProps } from './modification-dialog-content'; - -/** - * Generic Modification Dialog which manage basic common behaviors with react - * hook form validation. - * @param {CallbackEvent} onClear callback when the dialog needs to be cleared - * @param {CallbackEvent} onSave callback when saving the modification - * @param {Boolean} disabledSave to control disabled prop of the validate button - * @param {CallbackEvent} onValidated callback when validation is successful - * @param {CallbackEvent} onValidationError callback when validation failed - * @param {Array} dialogProps props that are forwarded to the MUI Dialog component - */ - -export type ModificationDialogProps = Omit< - ModificationDialogContentProps, - 'closeAndClear' | 'submitButton' -> & { - disabledSave?: boolean; - onClear: () => void; - onClose?: () => void; - onSave: (modificationData: TFieldValues) => void; - onValidated?: () => void; - onValidationError?: (errors: FieldErrors) => void; -}; - -export function ModificationDialog({ - disabledSave = false, - onClear, - onClose, - onSave, - onValidated, - onValidationError, - ...dialogProps -}: Readonly>) { - const { handleSubmit } = useFormContext(); - - const closeAndClear = () => { - onClear(); - onClose?.(); - }; - - const handleValidate = (data: TFieldValues) => { - onValidated && onValidated(); - onSave(data); - // do not wait fetch response and close dialog, errors will be shown in snackbar. - closeAndClear(); - }; - - const handleScrollWhenError = useCallback(() => { - // When scrolling to the field with focus, you can end up with the label not completely displayed - // We ensure that field with focus is displayed in the middle of the dialog - // Delay focusing to ensure it happens after the validation. without timout, document.activeElement will return the validation button. - const timeoutId = setTimeout(() => { - const focusedElement = document.activeElement; - - if (focusedElement instanceof HTMLElement) { - focusedElement.scrollIntoView({ - behavior: 'smooth', - block: 'center', - }); - } - }, 0); // Delay of 0 milliseconds, effectively running at the next opportunity - - return () => clearTimeout(timeoutId); - }, []); - - const handleValidationError = (errors: FieldErrors) => { - onValidationError && onValidationError(errors); - handleScrollWhenError(); - }; - - const submitButton = ( - - ); - return ; -} diff --git a/src/components/dialogs/commons/use-form-search-copy.ts b/src/components/dialogs/commons/use-form-search-copy.ts deleted file mode 100644 index c0c84e86e5..0000000000 --- a/src/components/dialogs/commons/use-form-search-copy.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2022, 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 { useIntl } from 'react-intl'; -import { useCallback, useState } from 'react'; -import { - type EquipmentInfos, - type EquipmentType, - type ExtendedEquipmentType, - snackWithFallback, - useSnackMessage, -} from '@gridsuite/commons-ui'; -import { EQUIPMENT_INFOS_TYPES, type EQUIPMENT_TYPES } from '../../utils/equipment-types'; -import { fetchNetworkElementInfos } from '../../../services/study/network'; -import { useSelector } from 'react-redux'; -import { AppState } from '../../../redux/reducer'; - -// TODO fetchNetworkElementInfos has no type -type FetchResponse = Awaited>; - -export interface UseFormSearchCopy { - isDialogSearchOpen: boolean; - handleOpenSearchDialog: () => void; - handleSelectionChange: (element: EquipmentInfos) => Promise; - handleCloseSearchDialog: () => void; -} - -export function useFormSearchCopy( - setFormValues: (response: FetchResponse) => void, - elementType: EquipmentType | ExtendedEquipmentType | EQUIPMENT_TYPES -): UseFormSearchCopy { - const intl = useIntl(); - const { snackInfo, snackError } = useSnackMessage(); - const currentNodeUuid = useSelector((state: AppState) => state.currentTreeNode?.id); - const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); - const studyUuid = useSelector((state: AppState) => state.studyUuid); - const [isDialogSearchOpen, setIsDialogSearchOpen] = useState(false); - - const handleCloseSearchDialog = useCallback(() => { - setIsDialogSearchOpen(false); - }, []); - - const handleOpenSearchDialog = useCallback(() => { - setIsDialogSearchOpen(true); - }, []); - - const handleSelectionChange = useCallback( - (element: EquipmentInfos) => - fetchNetworkElementInfos( - studyUuid, - currentNodeUuid, - currentRootNetworkUuid, - elementType, - EQUIPMENT_INFOS_TYPES.FORM.type, - element.id, - true - ) - .then((response) => { - setFormValues(response); - snackInfo({ - messageTxt: intl.formatMessage({ id: 'EquipmentCopied' }, { equipmentId: element.id }), - }); - }) - .catch((error) => { - snackWithFallback(snackError, error, { - headerId: 'EquipmentCopyFailed', - headerValues: { equipmentId: element.id }, - }); - }) - .finally(() => handleCloseSearchDialog()), - [ - currentNodeUuid, - currentRootNetworkUuid, - elementType, - handleCloseSearchDialog, - intl, - setFormValues, - snackError, - snackInfo, - studyUuid, - ] - ); - - return { - isDialogSearchOpen, - handleOpenSearchDialog, - handleSelectionChange, - handleCloseSearchDialog, - }; -} diff --git a/src/components/dialogs/dialog-utils.ts b/src/components/dialogs/dialog-utils.ts deleted file mode 100644 index 42bd154f76..0000000000 --- a/src/components/dialogs/dialog-utils.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Copyright (c) 2022, 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 { FilledTextFieldProps, StandardTextFieldProps } from '@mui/material'; -import { - AMPERE, - KILO_AMPERE, - KILO_METER, - KILO_VOLT, - MEGA_VAR, - MEGA_VOLT_AMPERE, - MEGA_WATT, - MICRO_SIEMENS, - type MuiStyles, - OHM, - PERCENTAGE, - SIEMENS, -} from '@gridsuite/commons-ui'; - -export const styles = { - helperText: { - margin: 0, - marginTop: '4px', - }, - tooltip: { - fontSize: 18, - maxWidth: 'none', - }, - button: (theme) => ({ - justifyContent: 'flex-start', - fontSize: 'small', - marginTop: theme.spacing(1), - }), - paddingButton: (theme) => ({ - paddingLeft: theme.spacing(2), - }), - formDirectoryElements1: { - display: 'flex', - gap: '8px', - flexWrap: 'wrap', - flexDirection: 'row', - border: '2px solid lightgray', - padding: '4px', - borderRadius: '4px', - overflow: 'hidden', - }, - formDirectoryElementsError: (theme) => ({ - borderColor: theme.palette.error.main, - }), - formDirectoryElements2: { - display: 'flex', - gap: '8px', - flexWrap: 'wrap', - flexDirection: 'row', - marginTop: 0, - padding: '4px', - overflow: 'hidden', - }, - labelDirectoryElements: { - marginTop: '-10px', - }, - addDirectoryElements: { - marginTop: '-5px', - }, -} as const satisfies MuiStyles; - -export const MicroSusceptanceAdornment = { - position: 'end', - text: MICRO_SIEMENS, -}; - -export const SusceptanceAdornment = { - position: 'end', - text: SIEMENS, -}; -export const OhmAdornment = { - position: 'end', - text: OHM, -}; -export const AmpereAdornment = { - position: 'end', - text: AMPERE, -}; - -export const KiloAmpereAdornment = { - position: 'end', - text: KILO_AMPERE, -}; - -export const ActivePowerAdornment = { - position: 'end', - text: MEGA_WATT, -}; -export const ReactivePowerAdornment = { - position: 'end', - text: MEGA_VAR, -}; -export const MVAPowerAdornment = { - position: 'end', - text: MEGA_VOLT_AMPERE, -}; -export const VoltageAdornment = { - position: 'end', - text: KILO_VOLT, -}; -export const KilometerAdornment = { - position: 'end', - text: KILO_METER, -}; -export const filledTextField: FilledTextFieldProps = { - variant: 'filled', -}; - -export const standardTextField: StandardTextFieldProps = { - variant: 'standard', -}; - -export const italicFontTextField = { - style: { fontStyle: 'italic' }, -}; - -export const percentageTextField = { - position: 'end', - text: PERCENTAGE, -}; - -export function parseIntData(val: string | number, defaultValue: string | number) { - const intValue = parseInt(String(val)); - return isNaN(intValue) ? defaultValue : intValue; -} - -export function sanitizeString(val: string | null | undefined): string | null { - const trimedValue = val?.trim(); - return trimedValue === undefined || trimedValue === '' ? null : trimedValue; -} - -export const getIdOrSelf = (e: any) => e?.id ?? e; diff --git a/src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx b/src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx index 1d7c3f1844..a0ab95804e 100644 --- a/src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx +++ b/src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx @@ -12,14 +12,19 @@ import Typography from '@mui/material/Typography'; import { FormattedMessage } from 'react-intl'; import Grid from '@mui/material/Grid'; import Button from '@mui/material/Button'; -import { AutocompleteInput, CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + AutocompleteInput, + CustomFormProvider, + getIdOrSelf, + snackWithFallback, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { fetchDynamicSimulationParameters, updateDynamicSimulationParameters, } from '../../../services/study/dynamic-simulation'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { getIdOrSelf } from '../dialog-utils'; import GridItem from '../commons/grid-item'; import type { UUID } from 'node:crypto'; import { DynamicSimulationParametersInfos } from '../../../services/study/dynamic-simulation.type'; 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 162cc357a0..beef4e2aa9 100644 --- a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx +++ b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-dialog.tsx @@ -6,19 +6,23 @@ */ import { useForm } from 'react-hook-form'; -import { ModificationDialog } from '../../commons/modificationDialog'; import { yupResolver } from '@hookform/resolvers/yup'; import { useCallback, useEffect, useMemo, useState } from 'react'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../network/constants'; import { DialogProps } from '@mui/material/Dialog/Dialog'; import { DynamicSimulationEventForm } from './dynamic-simulation-event-form'; import { Event, EventProperty, EventPropertyName, PrimitiveTypes } from './types/event.type'; import yup from 'components/utils/yup-config'; import { getSchema } from './util/event-yup'; import { eventDefinitions, getEventType } from './model/event.model'; -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; -import { FetchStatus } from '../../../../services/utils'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; diff --git a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-form.tsx b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-form.tsx index edc0b23a0c..35877d01c6 100644 --- a/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-form.tsx +++ b/src/components/dialogs/dynamicsimulation/event/dynamic-simulation-event-form.tsx @@ -5,12 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Grid, TextField } from '@mui/material'; -import { filledTextField } from '../../dialog-utils'; import { Event, EventDefinition, EventPropertyName } from './types/event.type'; import { makeComponentFor } from './util/event-rhf'; import { useIntl } from 'react-intl'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; import GridItem from '../../commons/grid-item'; +import { filledTextField } from '@gridsuite/commons-ui'; export type DynamicSimulationBasicEventFormProps = { equipmentId: string; diff --git a/src/components/dialogs/equipment-id/equipment-id-selector.tsx b/src/components/dialogs/equipment-id/equipment-id-selector.tsx index 4478f23652..fdf445e662 100644 --- a/src/components/dialogs/equipment-id/equipment-id-selector.tsx +++ b/src/components/dialogs/equipment-id/equipment-id-selector.tsx @@ -6,10 +6,15 @@ */ import { useEffect, useState } from 'react'; -import { filledTextField } from '../dialog-utils'; import type { UUID } from 'node:crypto'; import { Autocomplete, Box, CircularProgress, Grid, TextField } from '@mui/material'; -import { type EquipmentType, type ExtendedEquipmentType, FieldLabel, type MuiStyles } from '@gridsuite/commons-ui'; +import { + type EquipmentType, + type ExtendedEquipmentType, + FieldLabel, + filledTextField, + type MuiStyles, +} from '@gridsuite/commons-ui'; import { FormFiller } from './formFiller.js'; import { FormattedMessage } from 'react-intl'; import { fetchEquipmentsIds } from '../../../services/study/network-map'; diff --git a/src/components/dialogs/equipment-search-dialog.tsx b/src/components/dialogs/equipment-search-dialog.tsx deleted file mode 100644 index 95598889d4..0000000000 --- a/src/components/dialogs/equipment-search-dialog.tsx +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2022, 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 { useIntl } from 'react-intl'; -import { - ElementSearchDialog, - EquipmentInfos, - EquipmentItem, - equipmentStyles, - EquipmentType, - ExtendedEquipmentType, -} from '@gridsuite/commons-ui'; -import { FC } from 'react'; -import { useSearchMatchingEquipments } from '../top-bar-equipment-seach-dialog/use-search-matching-equipments'; -import type { UUID } from 'node:crypto'; -import { useSelector } from 'react-redux'; -import { AppState } from 'redux/reducer'; -import { TextField } from '@mui/material'; -import { Search } from '@mui/icons-material'; - -interface EquipmentSearchDialogProps { - open: boolean; - onClose: () => void; - onSelectionChange: (equipment: EquipmentInfos) => void; - equipmentType: EquipmentType | ExtendedEquipmentType; - currentNodeUuid: UUID; - currentRootNetworkUuid: UUID; -} - -/** - * Dialog to search equipment with a given type - * @param {Boolean} open: Is the dialog open ? - * @param {Function} onClose: callback to call when closing the dialog - * @param {Function} onSelectionChange: callback when the selection changes - * @param {String} equipmentType: the type of equipment we want to search - * @param {String} currentNodeUuid: the node selected - * @param {String} currentRootNetworkUuid: the root network UUID - */ -const EquipmentSearchDialog: FC = ({ - open, - onClose, - onSelectionChange, - equipmentType, - currentNodeUuid, - currentRootNetworkUuid, -}) => { - const intl = useIntl(); - const studyUuid = useSelector((state: AppState) => state.studyUuid); - const { searchTerm, updateSearchTerm, equipmentsFound, isLoading } = useSearchMatchingEquipments({ - // @ts-expect-error TODO: manage null case - studyUuid: studyUuid, - nodeUuid: currentNodeUuid, - currentRootNetworkUuid: currentRootNetworkUuid, - inUpstreamBuiltParentNode: true, - equipmentType: equipmentType, - }); - - return ( - { - updateSearchTerm(''); - onSelectionChange(element); - }} - elementsFound={equipmentsFound} - renderElement={(props) => } - loading={isLoading} - getOptionLabel={(equipment) => equipment.label} - isOptionEqualToValue={(equipment1, equipment2) => equipment1.id === equipment2.id} - renderInput={(displayedValue, params) => ( - - - {params.InputProps.startAdornment} - - ), - }} - value={displayedValue} - /> - )} - /> - ); -}; - -export default EquipmentSearchDialog; diff --git a/src/components/dialogs/limits/limits-pane-utils.ts b/src/components/dialogs/limits/limits-pane-utils.ts index f2812d00c4..43c91ba86b 100644 --- a/src/components/dialogs/limits/limits-pane-utils.ts +++ b/src/components/dialogs/limits/limits-pane-utils.ts @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { sanitizeString } from '../dialog-utils'; import { APPLICABILITY_FIELD, CURRENT_LIMITS, @@ -46,6 +45,7 @@ import { LineModificationFormSchema } from '../network-modifications/line/modifi import { OperationalLimitsGroupFormSchema, TemporaryLimitFormSchema } from './operational-limits-groups-types'; import { TestContext } from 'yup'; import { APPLICABILITY } from 'components/network/constants'; +import { sanitizeString } from '@gridsuite/commons-ui'; const limitsGroupValidationSchema = () => ({ [ID]: yup.string().nonNullable().required(), diff --git a/src/components/dialogs/limits/limits-side-pane.tsx b/src/components/dialogs/limits/limits-side-pane.tsx index dbc9b84c53..f712f59854 100644 --- a/src/components/dialogs/limits/limits-side-pane.tsx +++ b/src/components/dialogs/limits/limits-side-pane.tsx @@ -7,6 +7,7 @@ import { Box, Grid } from '@mui/material'; import { FormattedMessage, useIntl } from 'react-intl'; import { + AmpereAdornment, ColumnNumeric, ColumnText, DndColumn, @@ -32,7 +33,6 @@ import { TEMPORARY_LIMIT_VALUE, TEMPORARY_LIMITS, } from 'components/utils/field-constants'; -import { AmpereAdornment } from '../dialog-utils'; import { useCallback, useEffect, useMemo } from 'react'; import { useController, useFormContext } from 'react-hook-form'; import { isNodeBuilt } from '../../graph/util/model-functions'; diff --git a/src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx b/src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx index b8509b1699..c0cb2ee3ce 100644 --- a/src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx +++ b/src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx @@ -7,9 +7,8 @@ import { useCallback, useEffect } from 'react'; import { useWatch } from 'react-hook-form'; -import { KilometerAdornment } from '../dialog-utils'; import EditIcon from '@mui/icons-material/Edit'; -import { FloatInput } from '@gridsuite/commons-ui'; +import { FloatInput, KilometerAdornment } from '@gridsuite/commons-ui'; import { IconButton } from '@mui/material'; import { SEGMENT_DISTANCE_VALUE, diff --git a/src/components/dialogs/line-types-catalog/line-type-segment-dialog.tsx b/src/components/dialogs/line-types-catalog/line-type-segment-dialog.tsx index fc76b3c6a4..dab03f7633 100644 --- a/src/components/dialogs/line-types-catalog/line-type-segment-dialog.tsx +++ b/src/components/dialogs/line-types-catalog/line-type-segment-dialog.tsx @@ -8,10 +8,9 @@ import { useCallback } from 'react'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../commons/modificationDialog'; import { useForm } from 'react-hook-form'; import { LineTypeSegmentForm } from './line-type-segment-form'; -import { CustomFormProvider } from '@gridsuite/commons-ui'; +import { CustomFormProvider, DeepNullable, ModificationDialog } from '@gridsuite/commons-ui'; import { ComputedLineCharacteristics } from './line-catalog.type'; import { SegmentSchema } from './segment-utils'; import { @@ -22,7 +21,6 @@ import { TOTAL_SUSCEPTANCE, } from '../../utils/field-constants'; import { InferType } from 'yup'; -import { DeepNullable } from '../../utils/ts-utils'; const LineTypeSegmentSchema = yup .object() diff --git a/src/components/dialogs/line-types-catalog/line-type-segment-form.tsx b/src/components/dialogs/line-types-catalog/line-type-segment-form.tsx index f6c6e9db53..0fff828477 100644 --- a/src/components/dialogs/line-types-catalog/line-type-segment-form.tsx +++ b/src/components/dialogs/line-types-catalog/line-type-segment-form.tsx @@ -9,7 +9,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { useFormContext } from 'react-hook-form'; import { Box, Grid } from '@mui/material'; import { FormattedMessage, useIntl } from 'react-intl'; -import { ExpandableInput } from '../../utils/rhf-inputs/expandable-input'; import { ReadOnlyInput } from '../../utils/rhf-inputs/read-only/read-only-input'; import { FINAL_CURRENT_LIMITS, @@ -32,6 +31,7 @@ import { calculateReactance, calculateResistance, calculateSusceptance } from '. import { CustomAGGrid, DefaultCellRenderer, + ExpandableInput, type MuiStyles, snackWithFallback, useSnackMessage, diff --git a/src/components/dialogs/line-types-catalog/line-types-catalog-selector-dialog.tsx b/src/components/dialogs/line-types-catalog/line-types-catalog-selector-dialog.tsx index fc51879802..cf006d0d99 100644 --- a/src/components/dialogs/line-types-catalog/line-types-catalog-selector-dialog.tsx +++ b/src/components/dialogs/line-types-catalog/line-types-catalog-selector-dialog.tsx @@ -6,7 +6,14 @@ */ import { useCallback, useRef, useState } from 'react'; -import { CustomFormProvider, Option, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + ModificationDialog, + Option, + snackWithFallback, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { AgGridReact } from 'ag-grid-react'; import { CATEGORIES_TABS, CurrentLimitsInfo, LineTypeInfo } from './line-catalog.type'; import { @@ -19,10 +26,8 @@ import { } from '../../utils/field-constants'; import { useForm } from 'react-hook-form'; import { getLineTypeWithLimits } from '../../../services/network-modification'; -import { ModificationDialog } from '../commons/modificationDialog'; import yup from '../../utils/yup-config'; import { yupResolver } from '@hookform/resolvers/yup'; -import { DeepNullable } from 'components/utils/ts-utils'; import LineTypesCatalogSelectorForm from './line-types-catalog-selector-form'; const formSchema = yup @@ -138,8 +143,8 @@ export default function LineTypesCatalogSelectorDialog({ ); if (filteredLimits) { - const shapeFactorValue = parseFloat(shapeFactorId); - if (!isNaN(shapeFactorValue) && shapeFactorValue !== 0) { + const shapeFactorValue = Number.parseFloat(shapeFactorId); + if (!Number.isNaN(shapeFactorValue) && shapeFactorValue !== 0) { filteredLimits.forEach((limit) => { limit.permanentLimit = Math.floor(limit.permanentLimit / shapeFactorValue); }); diff --git a/src/components/dialogs/network-modifications/balances-adjustment/balances-adjustment-dialog.tsx b/src/components/dialogs/network-modifications/balances-adjustment/balances-adjustment-dialog.tsx index 8947bae02c..87bf3156bf 100644 --- a/src/components/dialogs/network-modifications/balances-adjustment/balances-adjustment-dialog.tsx +++ b/src/components/dialogs/network-modifications/balances-adjustment/balances-adjustment-dialog.tsx @@ -4,9 +4,17 @@ * 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 { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; + import { useCallback, useEffect, useMemo, useState } from 'react'; -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { FieldErrors, useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { @@ -27,9 +35,6 @@ import { BALANCES_ADJUSTMENT_ZONES, SELECTED, } from '../../../utils/field-constants'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; -import { FetchStatus } from '../../../../services/utils'; -import { FORM_LOADING_DELAY } from '../../../network/constants'; import yup from 'components/utils/yup-config'; import { NetworkModificationDialogProps } from '../../../graph/menus/network-modifications/network-modification-menu.type'; import { diff --git a/src/components/dialogs/network-modifications/battery/battery-dialog.type.ts b/src/components/dialogs/network-modifications/battery/battery-dialog.type.ts index 9931ef163d..b4e478d1b0 100644 --- a/src/components/dialogs/network-modifications/battery/battery-dialog.type.ts +++ b/src/components/dialogs/network-modifications/battery/battery-dialog.type.ts @@ -31,7 +31,6 @@ import { TRANSIENT_REACTANCE, VOLTAGE_LEVEL, } from '../../../utils/field-constants'; -import { Property } from '../common/properties/property-utils'; import { ConnectablePositionFormInfos } from '../../connectivity/connectivity.type'; import { MinMaxReactiveLimitsFormInfos, @@ -39,6 +38,7 @@ import { } from '../../reactive-limits/reactive-limits.type'; import { ActivePowerControlInfos } from '../../active-power-control/active-power-control.type'; import { ShortCircuitFormInfos } from '../../short-circuit/short-circuit-utils'; +import { Property } from '@gridsuite/commons-ui'; export type BatteryDialogSchemaBaseForm = { [EQUIPMENT_NAME]?: string; diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.tsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.tsx index 181221daa2..c7a026f053 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-dialog.tsx @@ -6,15 +6,25 @@ */ import { useForm } from 'react-hook-form'; -import { ModificationDialog } from '../../../commons/modificationDialog'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -49,25 +59,14 @@ import { getConnectivityWithPositionEmptyFormData, getConnectivityWithPositionSchema, } from '../../../connectivity/connectivity-form-utils'; -import { sanitizeString } from '../../../dialog-utils'; -import { FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; +import { UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import { getReactiveLimitsEmptyFormData, getReactiveLimitsFormData, getReactiveLimitsValidationSchema, } from '../../../reactive-limits/reactive-limits-utils'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { createBattery } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.type'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; import { BatteryCreationDialogSchemaForm, BatteryFormInfos } from '../battery-dialog.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { getActivePowerControlEmptyFormData, getActivePowerControlSchema, @@ -81,6 +80,7 @@ import { getShortCircuitFormData, getShortCircuitFormSchema, } from '../../../short-circuit/short-circuit-utils'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; const emptyFormData = { [EQUIPMENT_ID]: '', @@ -126,6 +126,7 @@ export default function BatteryCreationDialog({ }: Readonly) { const currentNodeUuid = currentNode.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const formMethods = useForm>({ defaultValues: emptyFormData, @@ -167,7 +168,8 @@ export default function BatteryCreationDialog({ { keepDefaultValues: true } ); }; - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.BATTERY); + + const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.BATTERY, studyContext); useEffect(() => { if (editData) { @@ -279,15 +281,15 @@ export default function BatteryCreationDialog({ currentNode={currentNode} currentRootNetworkUuid={currentRootNetworkUuid} /> - - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/battery/creation/battery-creation-form.tsx b/src/components/dialogs/network-modifications/battery/creation/battery-creation-form.tsx index 66d8d3f88f..81decbbebe 100644 --- a/src/components/dialogs/network-modifications/battery/creation/battery-creation-form.tsx +++ b/src/components/dialogs/network-modifications/battery/creation/battery-creation-form.tsx @@ -5,18 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, TextInput } from '@gridsuite/commons-ui'; +import { ActivePowerAdornment, filledTextField, FloatInput, PropertiesForm, TextInput } from '@gridsuite/commons-ui'; import { EQUIPMENT_ID, EQUIPMENT_NAME, MAXIMUM_ACTIVE_POWER, MINIMUM_ACTIVE_POWER, } from 'components/utils/field-constants'; -import { ActivePowerAdornment, filledTextField } from '../../../dialog-utils'; import { Grid } from '@mui/material'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import { ReactiveLimitsForm } from '../../../reactive-limits/reactive-limits-form'; -import PropertiesForm from '../../common/properties/properties-form'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.tsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.tsx index 29993bcb8d..32f6d551a0 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-dialog.tsx @@ -8,9 +8,21 @@ import { useCallback, useEffect, useState } from 'react'; import { CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentInfosTypes, EquipmentType, + fetchNetworkElementInfos, + FetchStatus, + getConcatenatedProperties, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + modificationPropertiesSchema, + sanitizeString, snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -43,25 +55,14 @@ import { TRANSIENT_REACTANCE, VOLTAGE_LEVEL, } from 'components/utils/field-constants'; -import { sanitizeString } from '../../../dialog-utils'; import { getReactiveLimitsEmptyFormData, getReactiveLimitsFormData, getReactiveLimitsValidationSchema, } from '../../../reactive-limits/reactive-limits-utils'; import { REMOVE } from '../../../reactive-limits/reactive-capability-curve/reactive-capability-utils'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { modifyBattery } from '../../../../../services/study/network-modifications'; -import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { - emptyProperties, - getConcatenatedProperties, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, @@ -69,8 +70,6 @@ import { } from '../../../connectivity/connectivity-form-utils'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { BatteryFormInfos, BatteryModificationDialogSchemaForm } from '../battery-dialog.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; -import { FetchStatus } from '../../../../../services/utils.type'; import { toModificationOperation } from '../../../../utils/utils'; import { getActivePowerControlEmptyFormData, @@ -79,7 +78,6 @@ import { import { BatteryModificationInfos } from '../../../../../services/network-modification-types'; import BatteryModificationForm from './battery-modification-form'; import { getSetPointsEmptyFormData, getSetPointsSchema } from '../../../set-points/set-points-utils'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import { useFormWithDirtyTracking } from 'components/dialogs/commons/use-form-with-dirty-tracking'; import { @@ -87,6 +85,7 @@ import { getShortCircuitFormData, getShortCircuitFormSchema, } from '../../../short-circuit/short-circuit-utils'; +import { UUID } from 'node:crypto'; const emptyFormData = { [EQUIPMENT_NAME]: '', @@ -231,8 +230,8 @@ export default function BatteryModificationDialog({ currentNode.id, currentRootNetworkUuid, EquipmentType.BATTERY, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((value: BatteryFormInfos) => { diff --git a/src/components/dialogs/network-modifications/battery/modification/battery-modification-form.tsx b/src/components/dialogs/network-modifications/battery/modification/battery-modification-form.tsx index 27b82a039b..67a39ef8a3 100644 --- a/src/components/dialogs/network-modifications/battery/modification/battery-modification-form.tsx +++ b/src/components/dialogs/network-modifications/battery/modification/battery-modification-form.tsx @@ -12,12 +12,17 @@ import { MINIMUM_ACTIVE_POWER, REACTIVE_POWER_SET_POINT, } from 'components/utils/field-constants'; -import { ActivePowerAdornment, filledTextField, ReactivePowerAdornment } from '../../../dialog-utils'; import { Grid, TextField } from '@mui/material'; -import { FloatInput, TextInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + filledTextField, + FloatInput, + PropertiesForm, + ReactivePowerAdornment, + TextInput, +} from '@gridsuite/commons-ui'; import { ReactiveLimitsForm } from '../../../reactive-limits/reactive-limits-form'; import { FormattedMessage } from 'react-intl'; -import PropertiesForm from '../../common/properties/properties-form'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; diff --git a/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-dialog.tsx b/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-dialog.tsx index 52edb6cf39..81729d9f2b 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-dialog.tsx +++ b/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-dialog.tsx @@ -11,16 +11,17 @@ import { convertInputValue, convertOutputValue, CustomFormProvider, + DeepNullable, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + ModificationDialog, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { FC, useCallback, useEffect, useMemo } 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'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; import ModificationByAssignmentForm from './modification-by-assignment-form'; import { ASSIGNMENTS, EDITED_FIELD, EQUIPMENT_TYPE_FIELD, VALUE_FIELD } from '../../../../utils/field-constants'; import { modifyByAssignment } from '../../../../../services/study/network-modifications'; @@ -31,7 +32,6 @@ import { getDataType, } from './assignment/assignment-utils'; import { Assignment, ModificationByAssignment } from './assignment/assignment.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { useIntl } from 'react-intl'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-form.tsx b/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-form.tsx index e647b4ed2b..0810f7fff7 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-form.tsx +++ b/src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-form.tsx @@ -7,13 +7,12 @@ import { FC } from 'react'; import { ASSIGNMENTS, EQUIPMENT_TYPE_FIELD } from '../../../../utils/field-constants'; -import { ExpandableInput } from '../../../../utils/rhf-inputs/expandable-input'; import AssignmentForm from './assignment/assignment-form'; import { Box, Grid } from '@mui/material'; import { getAssignmentInitialValue } from './assignment/assignment-utils'; import { useFormContext } from 'react-hook-form'; import SelectWithConfirmationInput from '../../../commons/select-with-confirmation-input'; -import { mergeSx, unscrollableDialogStyles } from '@gridsuite/commons-ui'; +import { ExpandableInput, mergeSx, unscrollableDialogStyles } from '@gridsuite/commons-ui'; import { EQUIPMENTS_FIELDS } from './assignment/assignment-constants'; import useGetLabelEquipmentTypes from '../../../../../hooks/use-get-label-equipment-types'; import GridItem from '../../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/by-filter/by-filter-deletion/by-filter-deletion-dialog.tsx b/src/components/dialogs/network-modifications/by-filter/by-filter-deletion/by-filter-deletion-dialog.tsx index 091864b945..27706d5a68 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-filter-deletion/by-filter-deletion-dialog.tsx +++ b/src/components/dialogs/network-modifications/by-filter/by-filter-deletion/by-filter-deletion-dialog.tsx @@ -8,15 +8,19 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { FILTERS, ID, NAME, TYPE } from '../../../../utils/field-constants'; -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { FunctionComponent, useCallback, useEffect } from 'react'; -import { ModificationDialog } from '../../../commons/modificationDialog'; 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/by-formula/by-formula-dialog.jsx b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx index 53ebaee0c6..f115b27d90 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx +++ b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-dialog.jsx @@ -11,16 +11,16 @@ import { convertInputValue, convertOutputValue, CustomFormProvider, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + ModificationDialog, snackWithFallback, + useOpenShortWaitFetching, 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'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; import ByFormulaForm from './by-formula-form'; import { EDITED_FIELD, diff --git a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-form.tsx b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-form.tsx index df177ea455..3c8be48930 100644 --- a/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-form.tsx +++ b/src/components/dialogs/network-modifications/by-filter/by-formula/by-formula-form.tsx @@ -8,13 +8,12 @@ import { FunctionComponent } from 'react'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { EQUIPMENT_TYPE_FIELD, FORMULAS } from '../../../../utils/field-constants'; -import { ExpandableInput } from '../../../../utils/rhf-inputs/expandable-input'; import FormulaForm from './formula/formula-form'; import { getFormulaInitialValue } from './formula/formula-utils'; import { useFormContext } from 'react-hook-form'; import SelectWithConfirmationInput from '../../../commons/select-with-confirmation-input'; import { Box, Grid } from '@mui/material'; -import { mergeSx, unscrollableDialogStyles } from '@gridsuite/commons-ui'; +import { ExpandableInput, mergeSx, unscrollableDialogStyles } from '@gridsuite/commons-ui'; import GridItem from '../../../commons/grid-item'; interface ByFormulaFormProps {} diff --git a/src/components/dialogs/network-modifications/common/measurements/power-with-validity-form.tsx b/src/components/dialogs/network-modifications/common/measurements/power-with-validity-form.tsx index 451eea107d..009d8d0d4d 100644 --- a/src/components/dialogs/network-modifications/common/measurements/power-with-validity-form.tsx +++ b/src/components/dialogs/network-modifications/common/measurements/power-with-validity-form.tsx @@ -8,12 +8,17 @@ import Grid from '@mui/material/Grid'; import { FunctionComponent, useMemo } from 'react'; import { useIntl } from 'react-intl'; -import { convertInputValue, FieldType, FloatInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + convertInputValue, + FieldType, + FloatInput, + ReactivePowerAdornment, +} from '@gridsuite/commons-ui'; import { MeasurementProps } from './measurement.type'; import CheckboxNullableInput from '../../../../utils/rhf-inputs/boolean-nullable-input'; import GridItem from '../../../commons/grid-item'; import { VALIDITY, VALUE } from '../../../../utils/field-constants'; -import { ActivePowerAdornment, ReactivePowerAdornment } from '../../../dialog-utils'; export const PowerWithValidityForm: FunctionComponent = ({ id, field, measurement }) => { const intl = useIntl(); diff --git a/src/components/dialogs/network-modifications/common/properties/properties-form.tsx b/src/components/dialogs/network-modifications/common/properties/properties-form.tsx deleted file mode 100644 index ff941b69be..0000000000 --- a/src/components/dialogs/network-modifications/common/properties/properties-form.tsx +++ /dev/null @@ -1,105 +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 { Grid } from '@mui/material'; -import { useCallback, useEffect, useState } from 'react'; -import { ExpandableInput } from '../../../../utils/rhf-inputs/expandable-input'; -import { ADDED, ADDITIONAL_PROPERTIES, DELETION_MARK, PREVIOUS_VALUE } from '../../../../utils/field-constants'; -import PropertyForm from './property-form'; -import { fetchPredefinedProperties, initializedProperty, PredefinedProperties } from './property-utils'; -import { useFormContext, useWatch } from 'react-hook-form'; -import GridSection from '../../../commons/grid-section'; - -type PropertiesFormProps = { - id?: string; - networkElementType?: string; - isModification?: boolean; -}; - -const PropertiesForm = ({ id, networkElementType, isModification = false }: PropertiesFormProps) => { - const additionalProperties = id ? `${id}.${ADDITIONAL_PROPERTIES}` : ADDITIONAL_PROPERTIES; - const watchProps = useWatch({ - name: additionalProperties, - }); - const { getValues, setValue } = useFormContext(); - const [predefinedProperties, setPredefinedProperties] = useState({} as PredefinedProperties); - - useEffect(() => { - networkElementType && - fetchPredefinedProperties(networkElementType).then((res) => { - if (res) { - setPredefinedProperties(res); - } - }); - }, [networkElementType]); - - const getDeletionMark = useCallback( - (idx: number) => { - const properties = getValues(`${additionalProperties}`); - if (properties && typeof properties[idx] !== 'undefined') { - return watchProps && properties[idx][DELETION_MARK]; - } - return false; - }, - [getValues, watchProps, additionalProperties] - ); - - const deleteCallback = useCallback( - (idx: number) => { - let markedForDeletion = false; - const properties = getValues(`${additionalProperties}`); - if (properties && typeof properties[idx] !== 'undefined') { - markedForDeletion = properties[idx][DELETION_MARK]; - } else { - return false; - } - - let canRemoveLine = true; - if (markedForDeletion) { - // just unmark - setValue(`${additionalProperties}.${idx}.${DELETION_MARK}`, false, { shouldDirty: true }); - canRemoveLine = false; - } else { - // we should mark for deletion a property that actually exists in the network and not delete the property line straight away - if (properties[idx][PREVIOUS_VALUE] && properties[idx][ADDED] === false) { - setValue(`${additionalProperties}.${idx}.${DELETION_MARK}`, true, { shouldDirty: true }); - canRemoveLine = false; - } - } - // otherwise just delete the line - return canRemoveLine; - }, - [getValues, setValue, additionalProperties] - ); - - const modificationProperties = isModification - ? { - getDeletionMark, - deleteCallback, - watchProps, - } - : {}; - - const additionalProps = ( - - ); - - return ( - - - {additionalProps} - - ); -}; - -export default PropertiesForm; diff --git a/src/components/dialogs/network-modifications/common/properties/property-form.tsx b/src/components/dialogs/network-modifications/common/properties/property-form.tsx deleted file mode 100644 index 8d517208a6..0000000000 --- a/src/components/dialogs/network-modifications/common/properties/property-form.tsx +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2023, 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 { useMemo } from 'react'; -import { AutocompleteInput } from '@gridsuite/commons-ui'; -import { NAME, VALUE, PREVIOUS_VALUE, DELETION_MARK, ADDED } from 'components/utils/field-constants'; -import { useWatch } from 'react-hook-form'; -import { TextInput } from '@gridsuite/commons-ui'; -import { PredefinedProperties } from './property-utils'; -import { italicFontTextField } from '../../../dialog-utils'; -import GridItem from '../../../commons/grid-item'; - -type PropertyFormProps = { - name: string; - index: string; - predefinedProperties: PredefinedProperties; -}; - -const PropertyForm = ({ name, index, predefinedProperties }: PropertyFormProps) => { - const watchPropertyName = useWatch({ name: `${name}.${index}.${NAME}` }); - const watchPropertyPreviousValue = useWatch({ - name: `${name}.${index}.${PREVIOUS_VALUE}`, - }); - const watchPropertyDeletionMark = useWatch({ - name: `${name}.${index}.${DELETION_MARK}`, - }); - const watchPropertyAdded = useWatch({ - name: `${name}.${index}.${ADDED}`, - }); - - const predefinedNames = useMemo(() => { - return Object.keys(predefinedProperties ?? {}).sort(); - }, [predefinedProperties]); - - const predefinedValues = useMemo(() => { - return predefinedProperties?.[watchPropertyName]?.sort() ?? []; - }, [watchPropertyName, predefinedProperties]); - - const nameField = ( - - ); - - const nameReadOnlyField = ( - - ); - - const valueField = ( - - ); - - const valueReadOnlyField = ( - - ); - - function renderPropertyLine() { - return ( - <> - {watchPropertyDeletionMark || (watchPropertyAdded === false && watchPropertyPreviousValue) ? ( - {nameReadOnlyField} - ) : ( - {nameField} - )} - {watchPropertyDeletionMark ? ( - {valueReadOnlyField} - ) : ( - {valueField} - )} - - ); - } - - return renderPropertyLine(); -}; - -export default PropertyForm; diff --git a/src/components/dialogs/network-modifications/common/properties/property-utils.ts b/src/components/dialogs/network-modifications/common/properties/property-utils.ts deleted file mode 100644 index c2202aa856..0000000000 --- a/src/components/dialogs/network-modifications/common/properties/property-utils.ts +++ /dev/null @@ -1,203 +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 yup from 'components/utils/yup-config'; -import { - ADDED, - ADDITIONAL_PROPERTIES, - DELETION_MARK, - NAME, - PREVIOUS_VALUE, - VALUE, -} from 'components/utils/field-constants'; -import { isBlankOrEmpty } from 'components/utils/validation-functions'; -import { fetchStudyMetadata } from '@gridsuite/commons-ui'; - -export type Property = { - [NAME]: string; - [VALUE]?: string | null; - [PREVIOUS_VALUE]?: string | null; - [DELETION_MARK]: boolean; - [ADDED]: boolean; -}; - -export type Properties = { - [ADDITIONAL_PROPERTIES]?: Property[]; -}; - -export type PredefinedProperties = { - [propertyName: string]: string[]; -}; - -export type Equipment = { - properties?: Record; -}; - -export const fetchPredefinedProperties = (networkElementType: string): Promise => { - return fetchStudyMetadata().then((studyMetadata) => { - return studyMetadata.predefinedEquipmentProperties?.[networkElementType]; - }); -}; - -export const emptyProperties: Properties = { - [ADDITIONAL_PROPERTIES]: [] as Property[], -}; - -export const createPropertyModification = (name: string, value: string | null): Property => { - return { - [NAME]: name, - [VALUE]: value, - [PREVIOUS_VALUE]: value, - [DELETION_MARK]: false, - [ADDED]: true, - }; -}; - -export const initializedProperty = (): Property => { - return createPropertyModification('', null); -}; - -export const getPropertiesFromModification = (properties: Property[] | undefined | null): Properties => { - return { - [ADDITIONAL_PROPERTIES]: properties - ? properties.map((p) => { - return { - [NAME]: p[NAME], - [VALUE]: p[VALUE], - [PREVIOUS_VALUE]: p[PREVIOUS_VALUE], - [ADDED]: p[ADDED], - [DELETION_MARK]: p[DELETION_MARK], - }; - }) - : [], - }; -}; - -export const copyEquipmentPropertiesForCreation = (equipmentInfos: Equipment): Properties => { - return { - [ADDITIONAL_PROPERTIES]: equipmentInfos.properties - ? Object.entries(equipmentInfos.properties).map(([name, value]) => { - return { - [NAME]: name, - [VALUE]: value, - [PREVIOUS_VALUE]: null, - [DELETION_MARK]: false, - [ADDED]: true, - }; - }) - : [], - }; -}; - -export function getConcatenatedProperties(equipment: Equipment, getValues: (name: string) => any, id?: string): any { - // ex: current Array [ {Object { name: "p1", value: "v2", previousValue: undefined, added: true, deletionMark: false } }, {...} ] - - const path = id ? `${id}.${ADDITIONAL_PROPERTIES}` : `${ADDITIONAL_PROPERTIES}`; - const modificationProperties = getValues(path); - return mergeModificationAndEquipmentProperties(modificationProperties, equipment); -} - -/* - We first load modification properties (empty at creation but could be filled later on), then we load properties - already present on the equipment (network). If one of the equipment properties key is present in the modification - we update the previousValue of this one, it means the modification change the network property value. - If not we add it as an unmodified property. We will be able to delete it or modify its value, but not it's name. - */ -export const mergeModificationAndEquipmentProperties = ( - modificationProperties: Property[], - equipment: Equipment -): Property[] => { - const newModificationProperties = new Map(); - for (const property of modificationProperties) { - if (property.name !== null) { - newModificationProperties.set(property.name, property); - } - } - if (equipment.properties !== undefined) { - Object.entries(equipment.properties).forEach(([name, value]) => { - if (name !== null) { - let propertyToAdd; - // If the property is present in the modification and in the equipment - if (newModificationProperties.has(name)) { - const modProperty = newModificationProperties.get(name)!; - propertyToAdd = { - ...modProperty, - previousValue: value, // We set previous value of the modification to the equipment value - }; - } else { - propertyToAdd = { - [NAME]: name, - [VALUE]: null, - [PREVIOUS_VALUE]: value, - [DELETION_MARK]: false, - [ADDED]: false, - }; - } - newModificationProperties.set(name, propertyToAdd); - } - }); - } - return Array.from(newModificationProperties.values()); -}; - -export const toModificationProperties = (properties: Properties) => { - const filteredProperties = properties[ADDITIONAL_PROPERTIES]?.filter( - (p: Property) => !isBlankOrEmpty(p.value) || p[DELETION_MARK] - ); - return filteredProperties === undefined || filteredProperties?.length === 0 ? null : filteredProperties; -}; - -export const creationPropertiesSchema = yup.object({ - [ADDITIONAL_PROPERTIES]: yup - .array() - .of( - yup.object().shape({ - [NAME]: yup.string().required(), - [VALUE]: yup.string().required(), - [PREVIOUS_VALUE]: yup.string().nullable(), - [DELETION_MARK]: yup.boolean().required(), - [ADDED]: yup.boolean().required(), - }) - ) - .test('checkUniqueProperties', 'DuplicatedPropsError', (values) => checkUniquePropertyNames(values)), -}); - -export const modificationPropertiesSchema = yup.object({ - [ADDITIONAL_PROPERTIES]: yup - .array() - .of( - yup.object().shape({ - [NAME]: yup.string().required(), - [VALUE]: yup - .string() - .nullable() - .when([ADDED], { - is: (added: boolean) => added, - then: (schema) => schema.required(), - }), - [PREVIOUS_VALUE]: yup.string().nullable(), - [DELETION_MARK]: yup.boolean().required(), - [ADDED]: yup.boolean().required(), - }) - ) - .test('checkUniqueProperties', 'DuplicatedPropsError', (values) => checkUniquePropertyNames(values)), -}); - -const checkUniquePropertyNames = ( - properties: - | { - name: string; - }[] - | undefined -) => { - if (properties === undefined) { - return true; - } - const validValues = properties.filter((v) => v.name); - return validValues.length === new Set(validValues.map((v) => v.name)).size; -}; -export const getPropertyValue = (properties: Record | undefined, keyName: string): string | undefined => - properties?.[keyName]; diff --git a/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-dialog.tsx b/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-dialog.tsx index f58b9a1e4f..df0c197f62 100644 --- a/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-dialog.tsx +++ b/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-dialog.tsx @@ -8,19 +8,20 @@ import { BUS_BAR_SECTION_ID1, BUS_BAR_SECTION_ID2 } from 'components/utils/field-constants'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { yupResolver } from '@hookform/resolvers/yup'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; import { createCouplingDevice } from '../../../../../services/study/network-modifications'; import { CustomFormProvider, + DeepNullable, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, MODIFICATION_TYPES, + ModificationDialog, Option, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import yup from '../../../../utils/yup-config'; @@ -29,7 +30,6 @@ import CreateCouplingDeviceForm from './create-coupling-device-form'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import { CreateCouplingDeviceInfos } from '../../../../../services/network-modification-types'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { CreateCouplingDeviceDialogSchemaForm } from '../coupling-device-dialog.type'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-form.tsx b/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-form.tsx index f21fe38e17..e4a3281fea 100644 --- a/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-form.tsx +++ b/src/components/dialogs/network-modifications/coupling-device/modification/create-coupling-device-form.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { AutocompleteInput, Option } from '@gridsuite/commons-ui'; +import { AutocompleteInput, filledTextField, Option } from '@gridsuite/commons-ui'; import { BUS_BAR_SECTION_ID1, BUS_BAR_SECTION_ID2 } from 'components/utils/field-constants'; import GridItem from '../../../commons/grid-item'; import { getObjectId } from '../../../../utils/utils'; @@ -15,7 +15,6 @@ import PositionDiagramPane from '../../../../grid-layout/cards/diagrams/singleLi import { useCallback, useState } from 'react'; import Button from '@mui/material/Button'; import { FormattedMessage, useIntl } from 'react-intl'; -import { filledTextField } from '../../../dialog-utils'; import GridSection from '../../../commons/grid-section'; import type { UUID } from 'node:crypto'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; diff --git a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.tsx b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.tsx index d238238d4b..2b1b40c3d5 100644 --- a/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.tsx +++ b/src/components/dialogs/network-modifications/delete-attaching-line/delete-attaching-line-dialog.tsx @@ -5,9 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + NetworkModificationData, + sanitizeString, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { FORM_LOADING_DELAY } from 'components/network/constants'; import { ATTACHED_LINE_ID, LINE_TO_ATTACH_TO_1_ID, @@ -17,17 +26,12 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../dialog-utils'; import yup from 'components/utils/yup-config'; -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'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; import { UUID } from 'node:crypto'; -import { NetworkModificationData } from 'components/graph/menus/network-modifications/network-modification-menu.type'; interface DeleteAttachingLineFormData { [ATTACHED_LINE_ID]: string; diff --git a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.tsx b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.tsx index acb1ef10bf..de279d969e 100644 --- a/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.tsx +++ b/src/components/dialogs/network-modifications/delete-voltage-level-on-line/delete-voltage-level-on-line-dialog.tsx @@ -5,10 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + sanitizeString, + snackWithFallback, + useOpenShortWaitFetching, + 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'; import { LINE_TO_ATTACH_TO_1_ID, LINE_TO_ATTACH_TO_2_ID, @@ -17,12 +24,9 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../dialog-utils'; 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'; import { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; 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 31fbec45b0..b6a51dabd3 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 @@ -8,17 +8,21 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { DELETION_SPECIFIC_DATA, EQUIPMENT_ID, TYPE } from '../../../utils/field-constants'; -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect } from 'react'; -import { ModificationDialog } from '../../commons/modificationDialog'; import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import DeleteEquipmentForm from './equipment-deletion-form'; 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/equipment-deletion/equipment-deletion-form.jsx b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.jsx index 56cb62b07e..afda383e05 100644 --- a/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.jsx +++ b/src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.jsx @@ -8,8 +8,7 @@ import { Grid } from '@mui/material'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; -import { useSnackMessage, AutocompleteInput, snackWithFallback } from '@gridsuite/commons-ui'; -import { filledTextField } from 'components/dialogs/dialog-utils'; +import { useSnackMessage, AutocompleteInput, snackWithFallback, filledTextField } from '@gridsuite/commons-ui'; import { DELETION_SPECIFIC_DATA, EQUIPMENT_ID, diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.tsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.tsx index 8101c85b3b..6853adb373 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.tsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-dialog.tsx @@ -5,9 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { FORM_LOADING_DELAY } from 'components/network/constants'; import { DEFAULT_OUTAGE_RATE, FREQUENCY_RESERVE, @@ -24,15 +32,11 @@ import { import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; import yup from 'components/utils/yup-config'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; -import { ModificationDialog } from '../../commons/modificationDialog'; import GenerationDispatchForm from './generation-dispatch-form'; import { generationDispatch } from '../../../../services/study/network-modifications'; import { addSelectedFieldToRows } from 'components/utils/utils'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; import { UUID } from 'node:crypto'; -import { FetchStatus } from 'services/utils.type'; -import { DeepNullable } from '../../../utils/ts-utils'; import { GenerationDispatchModificationInfos } from '../../../../services/network-modification-types'; interface GenerationDispatchProps { diff --git a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.tsx b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.tsx index 2510f12d4f..494bc6a598 100644 --- a/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.tsx +++ b/src/components/dialogs/network-modifications/generation-dispatch/generation-dispatch-form.tsx @@ -6,14 +6,20 @@ */ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; -import { DirectoryItemsInput, ElementType, EquipmentType, FieldLabel, FloatInput } from '@gridsuite/commons-ui'; +import { + DirectoryItemsInput, + ElementType, + EquipmentType, + FieldLabel, + FloatInput, + percentageTextField, +} from '@gridsuite/commons-ui'; import { DEFAULT_OUTAGE_RATE, GENERATORS_WITH_FIXED_ACTIVE_POWER, GENERATORS_WITHOUT_OUTAGE, LOSS_COEFFICIENT, } from 'components/utils/field-constants'; -import { percentageTextField } from '../../dialog-utils'; import { Box, Grid, Typography } from '@mui/material'; import FrequencyReservePane from './frequency-reserve-pane'; import SubstationsGeneratorsOrderingPane from './substations-generators-ordering-pane'; diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.tsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.tsx index 03de3186f4..45b1196552 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.tsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-dialog.tsx @@ -8,16 +8,21 @@ import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; 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, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; -import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; +import { VARIATION_TYPES } from 'components/network/constants'; import { generatorScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import { Variations, VariationType } from '../../../../services/network-modification-types'; import { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; diff --git a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-form.tsx b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-form.tsx index 43cd02661b..444e9f4fc8 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-form.tsx +++ b/src/components/dialogs/network-modifications/generator-scaling/generator-scaling-form.tsx @@ -5,11 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { RadioInput } from '@gridsuite/commons-ui'; +import { ExpandableInput, RadioInput } from '@gridsuite/commons-ui'; import { VARIATION_MODES, VARIATION_TYPES } from 'components/network/constants'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import VariationForm from './variation/variation-form'; -import { ExpandableInput } from 'components/utils/rhf-inputs/expandable-input'; import { Grid, Theme } from '@mui/material'; import { getVariationEmptyForm } from './variation/variation-utils'; import GridItem from '../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.tsx b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.tsx index dc3ca435c6..56c7370af7 100644 --- a/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.tsx +++ b/src/components/dialogs/network-modifications/generator-scaling/variation/variation-form.tsx @@ -14,6 +14,7 @@ import { useSnackMessage, FloatInput, SelectInput, + ActivePowerAdornment, } from '@gridsuite/commons-ui'; import { FILTERS, @@ -28,7 +29,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useCallback, useEffect, useMemo } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { VARIATION_MODES, VARIATION_TYPES } from 'components/network/constants'; -import { ActivePowerAdornment } from '../../../dialog-utils'; import { IDENTIFIER_LIST } from './variation-utils'; import GridItem from '../../../commons/grid-item'; import { ItemFilterType, VariationType } from '../../../../../services/network-modification-types'; diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.tsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.tsx index 415961f7b4..f4ca7214d1 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-dialog.tsx @@ -6,15 +6,25 @@ */ import { useForm } from 'react-hook-form'; -import { ModificationDialog } from '../../../commons/modificationDialog'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; import { useCallback, useEffect } from 'react'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -59,23 +69,13 @@ import { } from '../../../connectivity/connectivity-form-utils'; import GeneratorCreationForm from './generator-creation-form'; import { getRegulatingTerminalFormData } from '../../../regulating-terminal/regulating-terminal-form-utils'; -import { sanitizeString } from '../../../dialog-utils'; -import { FORM_LOADING_DELAY, REGULATION_TYPES, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; +import { REGULATION_TYPES, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import { getReactiveLimitsEmptyFormData, getReactiveLimitsFormData, getReactiveLimitsValidationSchema, } from '../../../reactive-limits/reactive-limits-utils'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { createGenerator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils.type'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; import { getVoltageRegulationEmptyFormData, getVoltageRegulationSchema, @@ -85,7 +85,6 @@ import { getActivePowerControlSchema, } from '../../../active-power-control/active-power-control-utils'; import { GeneratorCreationInfos } from '../../../../../services/network-modification-types'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { GeneratorCreationDialogSchemaForm, GeneratorFormInfos } from '../generator-dialog.type'; import { getSetPointsEmptyFormData, getSetPointsSchema } from '../../../set-points/set-points-utils'; import { NetworkModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; @@ -95,6 +94,7 @@ import { getShortCircuitFormSchema, } from '../../../short-circuit/short-circuit-utils'; import { toReactiveCapabilityCurveChoiceForGeneratorCreation } from '../../../reactive-limits/reactive-capability-curve/reactive-capability-utils'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; const emptyFormData = { [EQUIPMENT_ID]: '', @@ -158,6 +158,7 @@ export default function GeneratorCreationDialog({ }: Readonly) { const currentNodeUuid = currentNode.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const formMethods = useForm>({ defaultValues: emptyFormData, @@ -192,7 +193,7 @@ export default function GeneratorCreationDialog({ generator?.regulatingTerminalId || generator?.regulatingTerminalConnectableId ? REGULATION_TYPES.DISTANT.id : REGULATION_TYPES.LOCAL.id, - [Q_PERCENT]: isNaN(Number(generator?.coordinatedReactiveControl?.qPercent)) + [Q_PERCENT]: Number.isNaN(Number(generator?.coordinatedReactiveControl?.qPercent)) ? null : generator?.coordinatedReactiveControl?.qPercent, ...getReactiveLimitsFormData({ @@ -219,7 +220,7 @@ export default function GeneratorCreationDialog({ ); }; - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.GENERATOR); + const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.GENERATOR, studyContext); useEffect(() => { if (editData) { @@ -360,15 +361,15 @@ export default function GeneratorCreationDialog({ currentNode={currentNode} currentRootNetworkUuid={currentRootNetworkUuid} /> - - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/generator/creation/generator-creation-form.tsx b/src/components/dialogs/network-modifications/generator/creation/generator-creation-form.tsx index 3f2037f5e1..73948e1e18 100644 --- a/src/components/dialogs/network-modifications/generator/creation/generator-creation-form.tsx +++ b/src/components/dialogs/network-modifications/generator/creation/generator-creation-form.tsx @@ -5,7 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, SelectInput, SwitchInput, TextInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + filledTextField, + FloatInput, + italicFontTextField, + MVAPowerAdornment, + PropertiesForm, + SelectInput, + SwitchInput, + TextInput, +} from '@gridsuite/commons-ui'; import { ENERGY_SOURCE, EQUIPMENT_ID, @@ -19,13 +29,11 @@ import { RATED_NOMINAL_POWER, VOLTAGE_REGULATION, } from 'components/utils/field-constants'; -import { ActivePowerAdornment, filledTextField, italicFontTextField, MVAPowerAdornment } from '../../../dialog-utils'; import { ENERGY_SOURCES } from 'components/network/constants'; import { Box, Grid } from '@mui/material'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import { ReactiveLimitsForm } from '../../../reactive-limits/reactive-limits-form'; import { SetPointsForm } from '../../../set-points/set-points-form'; -import PropertiesForm from '../../common/properties/properties-form'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; diff --git a/src/components/dialogs/network-modifications/generator/generator-dialog.type.ts b/src/components/dialogs/network-modifications/generator/generator-dialog.type.ts index 76a1b62751..e743a5adc0 100644 --- a/src/components/dialogs/network-modifications/generator/generator-dialog.type.ts +++ b/src/components/dialogs/network-modifications/generator/generator-dialog.type.ts @@ -47,7 +47,6 @@ import { VOLTAGE_REGULATION_TYPE, VOLTAGE_SET_POINT, } from '../../../utils/field-constants'; -import { Property } from '../common/properties/property-utils'; import { ConnectablePositionFormInfos } from '../../connectivity/connectivity.type'; import { MinMaxReactiveLimitsFormInfos, @@ -55,6 +54,7 @@ import { } from '../../reactive-limits/reactive-limits.type'; import { ActivePowerControlInfos } from '../../active-power-control/active-power-control.type'; import { ShortCircuitFormInfos } from '../../short-circuit/short-circuit-utils'; +import { Property } from '@gridsuite/commons-ui'; export type GeneratorDialogSchemaBaseForm = { [EQUIPMENT_NAME]?: string; diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.tsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.tsx index e5c57a7ff7..c56380f33a 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-dialog.tsx @@ -5,13 +5,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ModificationDialog } from '../../../commons/modificationDialog'; import { useCallback, useEffect, useState } from 'react'; import { CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentInfosTypes, EquipmentType, + fetchNetworkElementInfos, + FetchStatus, + getConcatenatedProperties, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + modificationPropertiesSchema, + sanitizeString, snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -55,7 +66,6 @@ import { VOLTAGE_REGULATION_TYPE, VOLTAGE_SET_POINT, } from 'components/utils/field-constants'; -import { sanitizeString } from '../../../dialog-utils'; import GeneratorModificationForm from './generator-modification-form'; import { getSetPointsEmptyFormData, getSetPointsSchema } from '../../../set-points/set-points-utils'; import { @@ -68,19 +78,8 @@ import { REMOVE, toReactiveCapabilityCurveChoiceForGeneratorModification, } from '../../../reactive-limits/reactive-capability-curve/reactive-capability-utils'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; 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.type'; -import { - emptyProperties, - getConcatenatedProperties, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, @@ -96,7 +95,6 @@ import { getActivePowerControlSchema, } from '../../../active-power-control/active-power-control-utils'; import { GeneratorModificationInfos } from '../../../../../services/network-modification-types'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { GeneratorFormInfos, GeneratorModificationDialogSchemaForm } from '../generator-dialog.type'; import { toModificationOperation } from '../../../../utils/utils'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; @@ -106,6 +104,7 @@ import { getShortCircuitFormData, getShortCircuitFormSchema, } from '../../../short-circuit/short-circuit-utils'; +import { UUID } from 'node:crypto'; const emptyFormData = { [EQUIPMENT_NAME]: '', @@ -281,8 +280,8 @@ export default function GeneratorModificationDialog({ currentNode.id, currentRootNetworkUuid, EquipmentType.GENERATOR, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((value: GeneratorFormInfos) => { diff --git a/src/components/dialogs/network-modifications/generator/modification/generator-modification-form.tsx b/src/components/dialogs/network-modifications/generator/modification/generator-modification-form.tsx index d19257b225..09ae8d2fb6 100644 --- a/src/components/dialogs/network-modifications/generator/modification/generator-modification-form.tsx +++ b/src/components/dialogs/network-modifications/generator/modification/generator-modification-form.tsx @@ -5,7 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, SelectInput, TextInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + filledTextField, + FloatInput, + MVAPowerAdornment, + PropertiesForm, + SelectInput, + TextInput, +} from '@gridsuite/commons-ui'; import { ENERGY_SOURCE, EQUIPMENT_NAME, @@ -18,12 +26,10 @@ import { RATED_NOMINAL_POWER, VOLTAGE_REGULATION, } from 'components/utils/field-constants'; -import { ActivePowerAdornment, filledTextField, MVAPowerAdornment } from '../../../dialog-utils'; import { ENERGY_SOURCES, getEnergySourceLabel } from 'components/network/constants'; import { ReactiveLimitsForm } from '../../../reactive-limits/reactive-limits-form'; import { FormattedMessage, useIntl } from 'react-intl'; import { Box, Grid, TextField } from '@mui/material'; -import PropertiesForm from '../../common/properties/properties-form'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import GridItem from '../../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-converter-station.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-converter-station.tsx index a60975f192..32d486bede 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-converter-station.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-converter-station.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, TextInput } from '@gridsuite/commons-ui'; +import { FloatInput, percentageTextField, TextInput } from '@gridsuite/commons-ui'; import { CONNECTIVITY, CONVERTER_STATION_ID, @@ -13,7 +13,6 @@ import { LOSS_FACTOR, POWER_FACTOR, } from '../../../../../utils/field-constants'; -import { percentageTextField } from '../../../../dialog-utils'; import type { UUID } from 'node:crypto'; import { ConnectivityForm } from '../../../../connectivity/connectivity-form'; import { Grid } from '@mui/material'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-hvdc-line.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-hvdc-line.tsx index 10cdb034d6..deaaf2ba49 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-hvdc-line.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-hvdc-line.tsx @@ -5,12 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, SelectInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + FloatInput, + OhmAdornment, + PropertiesForm, + SelectInput, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { ACTIVE_POWER_SETPOINT, CONVERTERS_MODE, MAX_P, NOMINAL_V, R } from '../../../../../utils/field-constants'; -import { ActivePowerAdornment, OhmAdornment, VoltageAdornment } from '../../../../dialog-utils'; import { VSC_CONVERTER_MODE, VscConverterMode } from 'components/network/constants'; import { Grid } from '@mui/material'; -import PropertiesForm from 'components/dialogs/network-modifications/common/properties/properties-form'; import GridSection from '../../../../commons/grid-section'; import GridItem from '../../../../commons/grid-item'; import { LccFormInfos } from './lcc-type'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-type.ts b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-type.ts index ecd1ab86b1..aaf609a676 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-type.ts +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-type.ts @@ -4,7 +4,6 @@ * 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 { Property } from '../../../common/properties/property-utils'; import { EQUIPMENT_TYPES } from '../../../../../utils/equipment-types'; import { ConnectablePositionInfos } from '../../../../connectivity/connectivity.type'; import { @@ -24,6 +23,7 @@ import { R, } from '../../../../../utils/field-constants'; import { LccShuntCompensatorInfos } from '../../../../../../services/network-modification-types'; +import { Property } from '@gridsuite/commons-ui'; export const LccDialogTab = { HVDC_LINE_TAB: 0, diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-utils.ts b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-utils.ts index 657984b44e..d40a3b552e 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-utils.ts +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/common/lcc-utils.ts @@ -47,11 +47,11 @@ import { creationPropertiesSchema, emptyProperties, getPropertiesFromModification, + MODIFICATION_TYPES, modificationPropertiesSchema, -} from '../../../common/properties/property-utils'; -import { MODIFICATION_TYPES } from '@gridsuite/commons-ui'; + sanitizeString, +} from '@gridsuite/commons-ui'; import { UNDEFINED_CONNECTION_DIRECTION } from '../../../../../network/constants'; -import { sanitizeString } from '../../../../dialog-utils'; import { getConnectivityWithPositionSchema } from 'components/dialogs/connectivity/connectivity-form-utils'; import { Connectivity } from 'components/dialogs/connectivity/connectivity.type'; import { diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/filters-shunt-compensator-table.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/filters-shunt-compensator-table.tsx index eafd96ab6e..14c07ad26a 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/filters-shunt-compensator-table.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/filters-shunt-compensator-table.tsx @@ -19,8 +19,7 @@ import { SHUNT_COMPENSATOR_NAME, SHUNT_COMPENSATOR_SELECTED, } from '../../../../../utils/field-constants'; -import { FloatInput, SwitchInput, TextInput } from '@gridsuite/commons-ui'; -import { ReactivePowerAdornment } from '../../../../dialog-utils'; +import { FloatInput, ReactivePowerAdornment, SwitchInput, TextInput } from '@gridsuite/commons-ui'; interface FiltersShuntCompensatorTableProps { id: string; diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog-header.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog-header.tsx index 4e29c3076d..fb719b5f45 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog-header.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog-header.tsx @@ -4,11 +4,10 @@ * 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 { TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, TextInput } from '@gridsuite/commons-ui'; import { EQUIPMENT_ID, EQUIPMENT_NAME } from '../../../../../utils/field-constants'; import { Grid } from '@mui/material'; import GridItem from '../../../../commons/grid-item'; -import { filledTextField } from '../../../../dialog-utils'; export default function LccCreationDialogHeader() { const LccIdField = ( diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog.tsx index 6a7de7bfbb..6c51044b62 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/creation/lcc-creation-dialog.tsx @@ -24,21 +24,27 @@ import { R, } from '../../../../../utils/field-constants'; import yup from '../../../../../utils/yup-config'; -import { FetchStatus } from '../../../../../../services/utils.type'; import { useForm } from 'react-hook-form'; -import { DeepNullable } from '../../../../../utils/ts-utils'; import { yupResolver } from '@hookform/resolvers/yup'; import { LccDialogTab, LccCreationInfos, LccFormInfos, ShuntCompensatorFormSchema } from '../common/lcc-type'; -import { Property, toModificationProperties } from '../../../common/properties/property-utils'; -import { useFormSearchCopy } from '../../../../commons/use-form-search-copy'; -import { CustomFormProvider, ExtendedEquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; -import { ModificationDialog } from '../../../../commons/modificationDialog'; -import EquipmentSearchDialog from '../../../../equipment-search-dialog'; +import { + CustomFormProvider, + DeepNullable, + EquipmentSearchDialog, + ExtendedEquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + Property, + sanitizeString, + snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { useCallback, useEffect, useState } from 'react'; -import { FORM_LOADING_DELAY } from '../../../../../network/constants'; import { createLcc } from '../../../../../../services/study/network-modifications'; -import { sanitizeString } from '../../../../dialog-utils'; -import { useOpenShortWaitFetching } from '../../../../commons/handle-modification-form'; import { Grid } from '@mui/material'; import LccCreationDialogHeader from './lcc-creation-dialog-header'; import LccTabs from '../common/lcc-tabs'; @@ -56,6 +62,7 @@ import { } from '../common/lcc-utils'; import { NetworkModificationDialogProps } from '../../../../../graph/menus/network-modifications/network-modification-menu.type'; import { Connectivity } from '../../../../connectivity/connectivity.type'; +import { useStudyContext } from '../../../../../../hooks/use-study-context'; export type LccCreationSchemaForm = { [EQUIPMENT_ID]: string; @@ -120,6 +127,7 @@ export function LccCreationDialog({ }: Readonly) { const currentNodeUuid = currentNode?.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const formMethods = useForm>({ defaultValues: emptyFormData, resolver: yupResolver>(formSchema), @@ -148,9 +156,13 @@ export function LccCreationDialog({ [reset] ); - const searchCopy = useFormSearchCopy((data) => { - reset(fromSearchCopyToFormValues(data), { keepDefaultValues: true }); - }, ExtendedEquipmentType.HVDC_LINE_LCC); + const searchCopy = useFormSearchCopy( + (data) => { + reset(fromSearchCopyToFormValues(data), { keepDefaultValues: true }); + }, + ExtendedEquipmentType.HVDC_LINE_LCC, + studyContext + ); useEffect(() => { if (editData) { @@ -250,14 +262,15 @@ export function LccCreationDialog({ currentRootNetworkUuid={currentRootNetworkUuid} tabIndex={tabIndex} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/filter-shunt-compensator-table-modification.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/filter-shunt-compensator-table-modification.tsx index 0474fc1bbd..eb1311268b 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/filter-shunt-compensator-table-modification.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/filter-shunt-compensator-table-modification.tsx @@ -21,8 +21,7 @@ import { SHUNT_COMPENSATOR_NAME, SHUNT_COMPENSATOR_SELECTED, } from '../../../../../utils/field-constants'; -import { FloatInput, TextInput } from '@gridsuite/commons-ui'; -import { ReactivePowerAdornment } from '../../../../dialog-utils'; +import { FloatInput, ReactivePowerAdornment, TextInput } from '@gridsuite/commons-ui'; import TextField from '@mui/material/TextField'; import CheckboxNullableInput from '../../../../../utils/rhf-inputs/boolean-nullable-input'; import { LccShuntCompensatorInfos } from '../../../../../../services/network-modification-types'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog.tsx index 6db92efb53..689ae158db 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog.tsx @@ -22,16 +22,24 @@ import { import yup from '../../../../../utils/yup-config'; import { CustomFormProvider, + DeepNullable, + EquipmentInfosTypes, ExtendedEquipmentType, + fetchNetworkElementInfos, + FetchStatus, + FORM_LOADING_DELAY, + getConcatenatedProperties, MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { LccDialogTab, LccFormInfos, LccModificationSchemaForm } from '../common/lcc-type'; import { useCallback, useEffect, useState } from 'react'; -import { useOpenShortWaitFetching } from '../../../../commons/handle-modification-form'; -import { FetchStatus } from 'services/utils.type'; import { getConcatenatedShuntCompensatorOnSideInfos, getLccConverterStationModificationData, @@ -43,20 +51,14 @@ import { getLccHvdcLineModificationSchema, } from '../common/lcc-utils'; import { modifyLcc } from 'services/study/network-modifications'; -import { sanitizeString } from 'components/dialogs/dialog-utils'; -import { getConcatenatedProperties, toModificationProperties } from '../../../common/properties/property-utils'; import { EquipmentModificationDialogProps } from '../../../../../graph/menus/network-modifications/network-modification-menu.type'; import { isNodeBuilt } from '../../../../../graph/util/model-functions'; import { EquipmentIdSelector } from '../../../../equipment-id/equipment-id-selector'; -import { fetchNetworkElementInfos } from '../../../../../../services/study/network'; -import { EQUIPMENT_INFOS_TYPES } from '../../../../../utils/equipment-types'; -import { FORM_LOADING_DELAY } from '../../../../../network/constants'; -import { ModificationDialog } from '../../../../commons/modificationDialog'; import { LccModificationForm } from './lcc-modification-form'; import { toModificationOperation } from '../../../../../utils/utils'; import { LccConverterStationModificationInfos, LccModificationInfos } from 'services/network-modification-types'; -import { DeepNullable } from '../../../../../utils/ts-utils'; import { useFormWithDirtyTracking } from 'components/dialogs/commons/use-form-with-dirty-tracking'; +import { UUID } from 'node:crypto'; const emptyFormData = { [EQUIPMENT_ID]: '', @@ -198,8 +200,8 @@ export const LccModificationDialog = ({ currentNode.id, currentRootNetworkUuid, ExtendedEquipmentType.HVDC_LINE_LCC, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((value: LccFormInfos | null) => { diff --git a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-form.tsx b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-form.tsx index 882fb0a1e8..c03edba338 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-form.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-form.tsx @@ -18,8 +18,7 @@ import { Box, Grid, TextField } from '@mui/material'; import LccHvdcLine from '../common/lcc-hvdc-line'; import LccConverterStation from '../common/lcc-converter-station'; import LccTabs from '../common/lcc-tabs'; -import { TextInput } from '@gridsuite/commons-ui'; -import { filledTextField } from '../../../../dialog-utils'; +import { filledTextField, TextInput } from '@gridsuite/commons-ui'; import GridItem from '../../../../commons/grid-item'; interface LccModificationFormProps { diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-pane.tsx b/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-pane.tsx index 2af55a6381..65e742d7ff 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-pane.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-pane.tsx @@ -6,7 +6,14 @@ */ import { FunctionComponent, useEffect } from 'react'; -import { FloatInput, SwitchInput, TextInput } from '@gridsuite/commons-ui'; +import { + FloatInput, + percentageTextField, + ReactivePowerAdornment, + SwitchInput, + TextInput, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { CONNECTIVITY, CONVERTER_STATION_ID, @@ -17,7 +24,6 @@ import { VOLTAGE, VOLTAGE_REGULATION_ON, } from '../../../../../utils/field-constants'; -import { percentageTextField, ReactivePowerAdornment, VoltageAdornment } from '../../../../dialog-utils'; import type { UUID } from 'node:crypto'; import { ConnectivityForm } from '../../../../connectivity/connectivity-form'; import { Grid, TextField } from '@mui/material'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-utils.tsx b/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-utils.tsx index a61353d085..2f2045c430 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-utils.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-utils.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { MODIFICATION_TYPES } from '@gridsuite/commons-ui'; +import { MODIFICATION_TYPES, sanitizeString } from '@gridsuite/commons-ui'; import yup from '../../../../../utils/yup-config'; import { BUS_OR_BUSBAR_SECTION, @@ -39,7 +39,6 @@ import { getReactiveLimitsSchema, } from '../../../../reactive-limits/reactive-limits-utils'; import { UNDEFINED_CONNECTION_DIRECTION } from '../../../../../network/constants'; -import { sanitizeString } from '../../../../dialog-utils'; import { toModificationOperation } from '../../../../../utils/utils'; import { VscConverterStationFormInfos, ConverterStationElementModificationInfos } from './converter-station-type'; import { ReactiveCapabilityCurvePoints } from '../../../../reactive-limits/reactive-limits.type'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/creation/vsc-creation-dialog.tsx b/src/components/dialogs/network-modifications/hvdc-line/vsc/creation/vsc-creation-dialog.tsx index 82d4c31ead..1d873eff34 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/creation/vsc-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/creation/vsc-creation-dialog.tsx @@ -7,11 +7,25 @@ import { useCallback, useEffect, useState } from 'react'; import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, ExtendedEquipmentType, + FetchStatus, + filledTextField, + FORM_LOADING_DELAY, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, snackWithFallback, TextInput, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { FieldErrors, useForm } from 'react-hook-form'; @@ -34,29 +48,14 @@ import { R, } from '../../../../../utils/field-constants'; import { Box, Grid } from '@mui/material'; -import { filledTextField, sanitizeString } from '../../../../dialog-utils'; import VscTabs from '../vsc-tabs'; import yup from 'components/utils/yup-config'; -import { FORM_LOADING_DELAY } from '../../../../../network/constants'; -import { ModificationDialog } from '../../../../commons/modificationDialog'; -import { useOpenShortWaitFetching } from '../../../../commons/handle-modification-form'; -import { FetchStatus } from '../../../../../../services/utils'; import VscCreationForm from './vsc-creation-form'; import { createVsc } from '../../../../../../services/study/network-modifications'; -import { useFormSearchCopy } from '../../../../commons/use-form-search-copy'; -import EquipmentSearchDialog from '../../../../equipment-search-dialog'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../../common/properties/property-utils'; import GridItem from '../../../../commons/grid-item'; import { VSC_CREATION_TABS } from '../vsc-utils'; import { NetworkModificationDialogProps } from '../../../../../graph/menus/network-modifications/network-modification-menu.type'; import { VscCreationInfos } from '../../../../../../services/network-modification-types'; -import { DeepNullable } from '../../../../../utils/ts-utils'; import { VscCreationDialogSchemaForm, VscFormInfos } from '../vsc-dialog.type'; import { getVscHvdcLinePaneEmptyFormData, @@ -71,6 +70,7 @@ import { getVscConverterStationEmptyFormData, getVscConverterStationSchema, } from '../converter-station/converter-station-utils'; +import { useStudyContext } from '../../../../../../hooks/use-study-context'; const formSchema = yup .object() @@ -107,6 +107,7 @@ export default function VscCreationDialog({ }: Readonly) { const currentNodeUuid = currentNode.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const [tabIndex, setTabIndex] = useState(VSC_CREATION_TABS.HVDC_LINE_TAB); const [tabIndexesWithError, setTabIndexesWithError] = useState([]); @@ -135,7 +136,7 @@ export default function VscCreationDialog({ delay: FORM_LOADING_DELAY, }); - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, ExtendedEquipmentType.HVDC_LINE_VSC); + const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, ExtendedEquipmentType.HVDC_LINE_VSC, studyContext); const generatorIdField = ( @@ -258,14 +259,15 @@ export default function VscCreationDialog({ studyUuid={studyUuid} currentRootNetworkUuid={currentRootNetworkUuid} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/hvdc-line-pane/vsc-hvdc-line-pane.tsx b/src/components/dialogs/network-modifications/hvdc-line/vsc/hvdc-line-pane/vsc-hvdc-line-pane.tsx index 94b0e69dc9..8d7d64f11d 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/hvdc-line-pane/vsc-hvdc-line-pane.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/hvdc-line-pane/vsc-hvdc-line-pane.tsx @@ -5,7 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, SelectInput, SwitchInput } from '@gridsuite/commons-ui'; +import { + ActivePowerAdornment, + FloatInput, + OhmAdornment, + PropertiesForm, + SelectInput, + SwitchInput, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { ACTIVE_POWER_SETPOINT, ANGLE_DROOP_ACTIVE_POWER_CONTROL, @@ -18,7 +26,6 @@ import { P0, R, } from '../../../../../utils/field-constants'; -import { ActivePowerAdornment, OhmAdornment, VoltageAdornment } from '../../../../dialog-utils'; import { VSC_CONVERTER_MODE } from 'components/network/constants'; import { FunctionComponent, useEffect } from 'react'; import { Grid } from '@mui/material'; @@ -26,7 +33,6 @@ import { useFormContext, useWatch } from 'react-hook-form'; import { VscModificationInfo } from 'services/network-modification-types'; import CheckboxNullableInput from '../../../../../utils/rhf-inputs/boolean-nullable-input'; import { useIntl } from 'react-intl'; -import PropertiesForm from 'components/dialogs/network-modifications/common/properties/properties-form'; import GridSection from '../../../../commons/grid-section'; import GridItem from '../../../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/modification/vsc-modification-dialog.tsx b/src/components/dialogs/network-modifications/hvdc-line/vsc/modification/vsc-modification-dialog.tsx index 7783f00226..8dafe59272 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/modification/vsc-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/modification/vsc-modification-dialog.tsx @@ -6,10 +6,7 @@ */ import { useCallback, useEffect, useState } from 'react'; -import { ModificationDialog } from '../../../../commons/modificationDialog'; import { EquipmentIdSelector } from '../../../../equipment-id/equipment-id-selector'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; -import { sanitizeString } from '../../../../dialog-utils'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'components/utils/yup-config'; import { @@ -36,7 +33,6 @@ import { REACTIVE_CAPABILITY_CURVE_TABLE, REACTIVE_LIMITS, } from '../../../../../utils/field-constants'; -import { FetchStatus } from '../../../../../../services/utils'; import { getVscHvdcLineModificationPaneSchema, getVscHvdcLineModificationTabFormData, @@ -49,27 +45,35 @@ import { getVscConverterStationModificationSchema, } from '../converter-station/converter-station-utils'; import { VscModificationForm } from './vsc-modification-from'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from 'components/network/constants'; import { modifyVsc } from 'services/study/network-modifications'; -import { fetchNetworkElementInfos } from '../../../../../../services/study/network'; import { VscModificationInfo } from 'services/network-modification-types'; import { REMOVE, setCurrentReactiveCapabilityCurveTable, setSelectedReactiveLimits, } from 'components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-utils'; -import { CustomFormProvider, ExtendedEquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; import { + CustomFormProvider, emptyProperties, + EquipmentInfosTypes, + ExtendedEquipmentType, + fetchNetworkElementInfos, + FetchStatus, + FORM_LOADING_DELAY, getConcatenatedProperties, getPropertiesFromModification, + ModificationDialog, modificationPropertiesSchema, + sanitizeString, + snackWithFallback, toModificationProperties, -} from '../../../common/properties/property-utils'; + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { isNodeBuilt } from '../../../../../graph/util/model-functions'; import { ReactiveCapabilityCurvePoints } from '../../../../reactive-limits/reactive-limits.type'; import { useFormWithDirtyTracking } from 'components/dialogs/commons/use-form-with-dirty-tracking'; +import { UUID } from 'node:crypto'; const formSchema = yup .object() @@ -166,8 +170,8 @@ const VscModificationDialog: React.FC = ({ currentNode.id, currentRootNetworkUuid, ExtendedEquipmentType.HVDC_LINE_VSC, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((value: any) => { diff --git a/src/components/dialogs/network-modifications/hvdc-line/vsc/vsc-dialog.type.ts b/src/components/dialogs/network-modifications/hvdc-line/vsc/vsc-dialog.type.ts index e2b37ce269..dfac88c215 100644 --- a/src/components/dialogs/network-modifications/hvdc-line/vsc/vsc-dialog.type.ts +++ b/src/components/dialogs/network-modifications/hvdc-line/vsc/vsc-dialog.type.ts @@ -22,8 +22,8 @@ import { P0, R, } from '../../../../utils/field-constants'; -import { Property } from '../../common/properties/property-utils'; import { VscConverterStation, VscConverterStationFormInfos } from './converter-station/converter-station-type'; +import { Property } from '@gridsuite/commons-ui'; export type VscDialogSchemaBaseForm = { [EQUIPMENT_NAME]?: string; diff --git a/src/components/dialogs/network-modifications/limit-sets/limit-sets-modification-dialog.tsx b/src/components/dialogs/network-modifications/limit-sets/limit-sets-modification-dialog.tsx index 88f22a7b00..bd6a3f0b70 100644 --- a/src/components/dialogs/network-modifications/limit-sets/limit-sets-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/limit-sets/limit-sets-modification-dialog.tsx @@ -13,16 +13,21 @@ import { TYPE, } from '../../../utils/field-constants'; import { useIntl } from 'react-intl'; -import { CustomFormProvider, ModificationType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + ModificationType, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { SubmitHandler, useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { useCallback, useEffect, useMemo } from 'react'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../network/constants'; -import { ModificationDialog } from '../../commons/modificationDialog'; import type { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; -import { FetchStatus } from 'services/utils.type'; import { LimitSetsTabularModificationForm } from './limit-sets-tabular-modification-form'; import { LIMIT_SETS_TABULAR_MODIFICATION_EQUIPMENTS } from '../tabular/tabular-modification-utils'; import { formatModification } from '../tabular/tabular-common'; diff --git a/src/components/dialogs/network-modifications/limit-sets/limit-sets-tabular-modification-form.tsx b/src/components/dialogs/network-modifications/limit-sets/limit-sets-tabular-modification-form.tsx index 7852712621..51e4786023 100644 --- a/src/components/dialogs/network-modifications/limit-sets/limit-sets-tabular-modification-form.tsx +++ b/src/components/dialogs/network-modifications/limit-sets/limit-sets-tabular-modification-form.tsx @@ -18,6 +18,7 @@ import { IntegerInput, LANG_FRENCH, type MuiStyles, + useCSVPicker, } from '@gridsuite/commons-ui'; import { AMOUNT_TEMPORARY_LIMITS, @@ -32,7 +33,6 @@ import { Alert, Button, Grid } from '@mui/material'; import Papa from 'papaparse'; import { ColDef } from 'ag-grid-community'; import GridItem from '../../commons/grid-item'; -import { useCSVPicker } from 'components/utils/inputs/input-hooks'; import { AGGRID_LOCALES } from '../../../../translations/not-intl/aggrid-locales'; import { useSelector } from 'react-redux'; import { AppState } from '../../../../redux/reducer'; diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.tsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.tsx index 1a790e07ac..3db2d94c20 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.tsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-dialog.tsx @@ -5,7 +5,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, ModificationType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + FetchStatus, + FORM_LOADING_DELAY, + GsLang, + ModificationDialog, + ModificationType, + sanitizeString, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ATTACHMENT_LINE_ID, @@ -24,9 +36,7 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../dialog-utils'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../commons/modificationDialog'; import { getConnectivityPropertiesData, getConnectivityPropertiesValidationSchema, @@ -40,8 +50,6 @@ import { getLineToAttachOrSplitFormValidationSchema, } from '../line-to-attach-or-split-form/line-to-attach-or-split-utils'; 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 { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import LineAttachToVoltageLevelIllustration from './line-attach-to-voltage-level-illustration'; @@ -49,8 +57,6 @@ import { getNewVoltageLevelOptions } from '../../../utils/utils'; import { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; import { VoltageLevel } from '../../../utils/equipment-types'; -import { DeepNullable } from '../../../utils/ts-utils'; -import { FetchStatus } from '../../../../services/utils.type'; import { AttachLineInfo, ExtendedVoltageLevelCreationInfo, @@ -97,6 +103,7 @@ interface LineAttachToVoltageLevelDialogProps { currentRootNetworkUuid: UUID; editData?: AttachLineInfo; isUpdate: boolean; + language: GsLang; editDataFetchStatus?: FetchStatus; onClose: () => void; } @@ -117,6 +124,7 @@ const LineAttachToVoltageLevelDialog = ({ currentRootNetworkUuid, editData, isUpdate, + language, editDataFetchStatus, ...dialogProps }: LineAttachToVoltageLevelDialogProps) => { @@ -430,7 +438,7 @@ const LineAttachToVoltageLevelDialog = ({ delay: FORM_LOADING_DELAY, }); return ( - + diff --git a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-form.tsx b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-form.tsx index 77fbae9c94..0fa35a9abf 100644 --- a/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-form.tsx +++ b/src/components/dialogs/network-modifications/line-attach-to-voltage-level/line-attach-to-voltage-level-form.tsx @@ -20,7 +20,7 @@ import { VOLTAGE_LEVEL, } from 'components/utils/field-constants'; import { Dispatch, SetStateAction, useCallback, useMemo, useState } from 'react'; -import { Identifiable, TextInput } from '@gridsuite/commons-ui'; +import { FetchStatus, GsLang, Identifiable, TextInput } from '@gridsuite/commons-ui'; import { ConnectivityForm } from '../../connectivity/connectivity-form'; import { Box, Button, Typography } from '@mui/material'; import { FormattedMessage } from 'react-intl'; @@ -39,7 +39,6 @@ import { LineCreationInfos, VoltageLevelCreationInfo, } from '../../../../services/network-modification-types'; -import { FetchStatus } from '../../../../services/utils.type'; interface LineAttachToVoltageLevelFormProps { studyUuid: UUID; @@ -54,6 +53,7 @@ interface LineAttachToVoltageLevelFormProps { setAttachmentPoint: Dispatch>; allVoltageLevelOptions: Identifiable[]; isUpdate: boolean; + language: GsLang; editDataFetchStatus?: FetchStatus; } @@ -70,6 +70,7 @@ const LineAttachToVoltageLevelForm = ({ setAttachmentPoint, allVoltageLevelOptions, isUpdate, + language, editDataFetchStatus, }: Readonly) => { const [lineDialogOpen, setLineDialogOpen] = useState(false); @@ -255,6 +256,7 @@ const LineAttachToVoltageLevelForm = ({ isAttachmentPointModification={true} titleId={'SpecifyAttachmentPoint'} isUpdate={isUpdate} + language={language} editDataFetchStatus={editDataFetchStatus} /> )} @@ -268,6 +270,7 @@ const LineAttachToVoltageLevelForm = ({ onCreateVoltageLevel={onVoltageLevelCreationDo} editData={isVoltageLevelEdit && voltageLevelToEdit ? (voltageLevelToEdit as any) : undefined} isUpdate={isUpdate} + language={language} editDataFetchStatus={editDataFetchStatus} /> )} diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.tsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.tsx index 618cac45c7..864ec53dba 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.tsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-dialog.tsx @@ -5,7 +5,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, MODIFICATION_TYPES, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + FetchStatus, + FORM_LOADING_DELAY, + GsLang, + MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { BUS_OR_BUSBAR_SECTION, @@ -24,9 +36,7 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../dialog-utils'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../commons/modificationDialog'; import { getConnectivityData, getConnectivityWithoutPositionEmptyFormData, @@ -41,15 +51,11 @@ import { getLineToAttachOrSplitFormValidationSchema, } from '../line-to-attach-or-split-form/line-to-attach-or-split-utils'; 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.type'; import { fetchVoltageLevelsListInfos } from '../../../../services/study/network'; import { getNewVoltageLevelOptions } from '../../../utils/utils'; import { UUID } from 'node:crypto'; import { VoltageLevelFormInfos } from '../voltage-level/voltage-level.type'; -import { DeepNullable } from '../../../utils/ts-utils'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; import { VoltageLevelCreationInfo } from '../../../../services/network-modification-types'; import { VoltageLevel } from '../../../utils/equipment-types'; @@ -114,6 +120,7 @@ interface LineSplitWithVoltageLevelDialogProps { currentRootNetworkUuid: UUID; editData?: LineSplitEditData; isUpdate: boolean; + language: GsLang; editDataFetchStatus?: FetchStatus; onClose: () => void; } @@ -134,6 +141,7 @@ const LineSplitWithVoltageLevelDialog = ({ currentRootNetworkUuid, editData, isUpdate, + language, editDataFetchStatus, ...dialogProps }: LineSplitWithVoltageLevelDialogProps) => { @@ -332,7 +340,7 @@ const LineSplitWithVoltageLevelDialog = ({ delay: FORM_LOADING_DELAY, }); return ( - + diff --git a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-form.tsx b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-form.tsx index a190692365..87f03007ff 100644 --- a/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-form.tsx +++ b/src/components/dialogs/network-modifications/line-split-with-voltage-level/line-split-with-voltage-level-form.tsx @@ -10,7 +10,7 @@ import { LINE1_ID, LINE1_NAME, LINE2_ID, LINE2_NAME } from 'components/utils/fie import { useMemo, useState } from 'react'; import AddIcon from '@mui/icons-material/ControlPoint'; import EditIcon from '@mui/icons-material/Edit'; -import { Identifiable, Option, TextInput } from '@gridsuite/commons-ui'; +import { FetchStatus, GsLang, Identifiable, Option, TextInput } from '@gridsuite/commons-ui'; import { ConnectivityForm } from '../../connectivity/connectivity-form'; import { Button, Typography } from '@mui/material'; import { FormattedMessage } from 'react-intl'; @@ -23,7 +23,6 @@ import GridItem from '../../commons/grid-item'; import { UUID } from 'node:crypto'; import { VoltageLevelFormInfos } from '../voltage-level/voltage-level.type'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; -import { FetchStatus } from '../../../../services/utils.type'; import { VoltageLevelCreationInfo } from '../../../../services/network-modification-types'; export interface ExtendedVoltageLevelFormInfos extends VoltageLevelFormInfos { @@ -41,6 +40,7 @@ interface LineSplitWithVoltageLevelFormProps { onVoltageLevelChange?: () => void; allVoltageLevelOptions: Identifiable[]; isUpdate: boolean; + language: GsLang; editDataFetchStatus?: FetchStatus; } @@ -52,6 +52,7 @@ const LineSplitWithVoltageLevelForm = ({ voltageLevelToEdit, allVoltageLevelOptions, isUpdate, + language, editDataFetchStatus, }: LineSplitWithVoltageLevelFormProps) => { const [voltageLevelDialogOpen, setVoltageLevelDialogOpen] = useState(false); @@ -144,6 +145,7 @@ const LineSplitWithVoltageLevelForm = ({ onCreateVoltageLevel={onVoltageLevelCreationDo} editData={isVoltageLevelEdit ? (voltageLevelToEdit as any) : null} isUpdate={isUpdate} + language={language} editDataFetchStatus={editDataFetchStatus} /> )} diff --git a/src/components/dialogs/network-modifications/line/characteristics-pane/line-characteristics-pane.tsx b/src/components/dialogs/network-modifications/line/characteristics-pane/line-characteristics-pane.tsx index 01da6703e3..c92f097b69 100644 --- a/src/components/dialogs/network-modifications/line/characteristics-pane/line-characteristics-pane.tsx +++ b/src/components/dialogs/network-modifications/line/characteristics-pane/line-characteristics-pane.tsx @@ -6,8 +6,14 @@ */ import { Grid } from '@mui/material'; -import { MicroSusceptanceAdornment, OhmAdornment } from '../../../dialog-utils'; -import { convertInputValue, FieldType, FloatInput } from '@gridsuite/commons-ui'; +import { + convertInputValue, + FieldType, + FloatInput, + MicroSusceptanceAdornment, + OhmAdornment, + PropertiesForm, +} from '@gridsuite/commons-ui'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import { B1, @@ -20,7 +26,6 @@ import { R, X, } from 'components/utils/field-constants'; -import PropertiesForm from '../../common/properties/properties-form'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import GridSection from '../../../commons/grid-section'; import GridItem from '../../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.tsx b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.tsx index b6a123aa2f..72eca74e27 100644 --- a/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/line/creation/line-creation-dialog.tsx @@ -8,12 +8,25 @@ import { convertInputValue, convertOutputValue, + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + emptyProperties, + EquipmentSearchDialog, EquipmentType, + FetchStatus, FieldType, + filledTextField, + FORM_LOADING_DELAY, + getPropertiesFromModification, + ModificationDialog, ModificationType, + sanitizeString, snackWithFallback, TextInput, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -46,13 +59,10 @@ import { VOLTAGE_LEVEL, X, } from 'components/utils/field-constants'; -import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useCallback, useEffect, useState } from 'react'; import { FieldErrors, useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; -import { APPLICABILITY, FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; +import { APPLICABILITY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { getConnectivityFormData } from '../../../connectivity/connectivity-form-utils'; import LineCharacteristicsPane from '../characteristics-pane/line-characteristics-pane'; import { @@ -73,19 +83,8 @@ import { sanitizeLimitsGroups, } from '../../../limits/limits-pane-utils'; import LineDialogTabs from '../line-dialog-tabs'; -import { filledTextField, sanitizeString } from 'components/dialogs/dialog-utils'; -import EquipmentSearchDialog from 'components/dialogs/equipment-search-dialog'; -import { useFormSearchCopy } from 'components/dialogs/commons/use-form-search-copy'; import LineTypeSegmentDialog from '../../../line-types-catalog/line-type-segment-dialog'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { createLine } from '../../../../../services/study/network-modifications'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; import GridItem from '../../../commons/grid-item'; import { formatCompleteCurrentLimit } from '../../../../utils/utils'; import { LimitsPane } from '../../../limits/limits-pane'; @@ -95,6 +94,7 @@ import { ComputedLineCharacteristics, CurrentLimitsInfo } from '../../../line-ty import { LineCreationFormSchema, LineFormInfos } from './line-creation-type'; import { OperationalLimitsGroupFormSchema } from '../../../limits/operational-limits-groups-types'; import { NetworkModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; const emptyFormData: any = { ...getHeaderEmptyFormData(), @@ -134,6 +134,7 @@ const LineCreationDialog = ({ }: Readonly) => { const currentNodeUuid = currentNode?.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const [tabIndex, setTabIndex] = useState(LineCreationDialogTab.CHARACTERISTICS_TAB); const [tabIndexesWithError, setTabIndexesWithError] = useState([]); @@ -259,7 +260,7 @@ const LineCreationDialog = ({ [reset] ); - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EQUIPMENT_TYPES.LINE); + const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.LINE, studyContext); useEffect(() => { if (editData) { @@ -442,15 +443,15 @@ const LineCreationDialog = ({ - - + {studyContext && ( + + )} { diff --git a/src/components/dialogs/network-modifications/line/modification/line-modification-type.ts b/src/components/dialogs/network-modifications/line/modification/line-modification-type.ts index b8f4883b9a..c6223aa794 100644 --- a/src/components/dialogs/network-modifications/line/modification/line-modification-type.ts +++ b/src/components/dialogs/network-modifications/line/modification/line-modification-type.ts @@ -15,7 +15,7 @@ import { LIMITS, STATE_ESTIMATION, } from '../../../../utils/field-constants'; -import { Property } from '../../common/properties/property-utils'; +import { Property } from '@gridsuite/commons-ui'; export interface LineCharacteristics { r: number | null; diff --git a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.tsx b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.tsx index 52b40041b5..fc7f67b677 100644 --- a/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.tsx +++ b/src/components/dialogs/network-modifications/lines-attach-to-split-lines/lines-attach-to-split-lines-dialog.tsx @@ -5,9 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + sanitizeString, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { sanitizeString } from 'components/dialogs/dialog-utils'; import { ATTACHED_LINE_ID, BUS_BAR_SECTION_ID, @@ -26,22 +35,16 @@ import { import yup from 'components/utils/yup-config'; import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; - import LinesAttachToSplitLinesForm from './lines-attach-to-split-lines-form'; import { getConnectivityData, getConnectivityPropertiesValidationSchema, getConnectivityWithoutPositionEmptyFormData, } from '../../connectivity/connectivity-form-utils'; -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.type'; import LineAttachToSplitLinesIllustration from './lines-attach-to-split-lines-illustration'; import type { CurrentTreeNode } from '../../../graph/tree-node.type'; import { UUID } from 'node:crypto'; -import { DeepNullable } from '../../../utils/ts-utils'; import { LinesAttachToSplitLinesInfo } from '../../../../services/network-modification-types'; interface LinesAttachToSplitLinesProps { diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.tsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.tsx index 8310faa299..6f9b3d25f0 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.tsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-dialog.tsx @@ -8,16 +8,21 @@ import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; 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, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import { getVariationsSchema } from './variation/variation-utils'; -import { FORM_LOADING_DELAY, VARIATION_TYPES } from 'components/network/constants'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; +import { VARIATION_TYPES } from 'components/network/constants'; import { loadScaling } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import { UUID } from 'node:crypto'; import { Variations, VariationType } from '../../../../services/network-modification-types'; import { CurrentTreeNode } from '../../../graph/tree-node.type'; diff --git a/src/components/dialogs/network-modifications/load-scaling/load-scaling-form.tsx b/src/components/dialogs/network-modifications/load-scaling/load-scaling-form.tsx index 9ee107e7e5..9cbde85dcb 100644 --- a/src/components/dialogs/network-modifications/load-scaling/load-scaling-form.tsx +++ b/src/components/dialogs/network-modifications/load-scaling/load-scaling-form.tsx @@ -5,11 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { RadioInput } from '@gridsuite/commons-ui'; +import { ExpandableInput, RadioInput } from '@gridsuite/commons-ui'; import { ACTIVE_VARIATION_MODES, VARIATION_TYPES } from 'components/network/constants'; import { VARIATION_TYPE, VARIATIONS } from 'components/utils/field-constants'; import VariationForm from './variation/variation-form'; -import { ExpandableInput } from 'components/utils/rhf-inputs/expandable-input'; import { Grid, Theme } from '@mui/material'; import { getVariationEmptyForm } from './variation/variation-utils'; import GridItem from '../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.tsx b/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.tsx index d3e7dfb8e8..0ab816c47f 100644 --- a/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.tsx +++ b/src/components/dialogs/network-modifications/load-scaling/variation/variation-form.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { DirectoryItemsInput, SelectInput, FloatInput, ElementType } from '@gridsuite/commons-ui'; +import { DirectoryItemsInput, SelectInput, FloatInput, ElementType, ActivePowerAdornment } from '@gridsuite/commons-ui'; import { FILTERS, REACTIVE_VARIATION_MODE, @@ -17,7 +17,6 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useCallback } from 'react'; import { useWatch } from 'react-hook-form'; import { ACTIVE_VARIATION_MODES, REACTIVE_VARIATION_MODES, VARIATION_TYPES } from 'components/network/constants'; -import { ActivePowerAdornment } from '../../../dialog-utils'; import { IDENTIFIER_LIST } from './variation-utils'; import GridItem from '../../../commons/grid-item'; import { ItemFilterType, VariationType } from '../../../../../services/network-modification-types'; diff --git a/src/components/dialogs/network-modifications/load/common/load-dialog-header.tsx b/src/components/dialogs/network-modifications/load/common/load-dialog-header.tsx index 31e3fc79b3..fc0e12082c 100644 --- a/src/components/dialogs/network-modifications/load/common/load-dialog-header.tsx +++ b/src/components/dialogs/network-modifications/load/common/load-dialog-header.tsx @@ -8,9 +8,8 @@ import React from 'react'; import { EQUIPMENT_ID, EQUIPMENT_NAME, LOAD_TYPE } from 'components/utils/field-constants'; import { Box, Grid, TextField } from '@mui/material'; -import { filledTextField } from 'components/dialogs/dialog-utils'; import { getLoadTypeLabel, LOAD_TYPES } from 'components/network/constants'; -import { SelectInput, TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, SelectInput, TextInput } from '@gridsuite/commons-ui'; import GridItem from '../../../commons/grid-item'; import { useIntl } from 'react-intl'; import LoadDialogTabs from './load-dialog-tabs'; diff --git a/src/components/dialogs/network-modifications/load/common/load-dialog-tabs-content.tsx b/src/components/dialogs/network-modifications/load/common/load-dialog-tabs-content.tsx index 4373bce2cf..f42ecd0e3a 100644 --- a/src/components/dialogs/network-modifications/load/common/load-dialog-tabs-content.tsx +++ b/src/components/dialogs/network-modifications/load/common/load-dialog-tabs-content.tsx @@ -8,7 +8,6 @@ import { Box } from '@mui/material'; import { ConnectivityForm } from 'components/dialogs/connectivity/connectivity-form'; import { SetPointsForm } from 'components/dialogs/set-points/set-points-form'; -import PropertiesForm from '../../common/properties/properties-form'; import { LoadDialogTab } from './load-utils'; import { PowerMeasurementsForm } from '../../common/measurements/power-measurements-form'; import GridSection from 'components/dialogs/commons/grid-section'; @@ -16,7 +15,7 @@ import React from 'react'; import type { UUID } from 'node:crypto'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; import { LoadFormInfos } from './load.type'; -import { Identifiable } from '@gridsuite/commons-ui'; +import { Identifiable, PropertiesForm } from '@gridsuite/commons-ui'; interface LoadDialogTabsContentProps { studyUuid: UUID; diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.tsx b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.tsx index b3df616cac..da8db704f6 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/load/creation/load-creation-dialog.tsx @@ -5,7 +5,25 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, EquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, + CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, + EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + getPropertiesFromModification, + ModificationDialog, + sanitizeString, + snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { ACTIVE_POWER_SETPOINT, @@ -18,36 +36,22 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect, useState } from 'react'; import { FieldErrors, useForm } from 'react-hook-form'; -import { sanitizeString } from '../../../dialog-utils'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; -import { FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION, UNDEFINED_LOAD_TYPE } from 'components/network/constants'; +import { UNDEFINED_CONNECTION_DIRECTION, UNDEFINED_LOAD_TYPE } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, getConnectivityWithPositionSchema, } from '../../../connectivity/connectivity-form-utils'; -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 { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { LoadCreationInfos, LoadCreationSchemaForm } from './load-creation.type'; -import { FetchStatus } from '../../../../../services/utils.type'; import { NetworkModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import LoadDialogHeader from '../common/load-dialog-header'; import { LoadDialogTab } from '../common/load-utils'; import LoadDialogTabsContent from '../common/load-dialog-tabs-content'; import { LoadFormInfos } from '../common/load.type'; import useVoltageLevelsListInfos from 'hooks/use-voltage-levels-list-infos'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; /** * Dialog to create a load in the network @@ -98,6 +102,7 @@ export function LoadCreationDialog({ const { snackError } = useSnackMessage(); const [tabIndexesWithError, setTabIndexesWithError] = useState([]); const [tabIndex, setTabIndex] = useState(LoadDialogTab.CONNECTIVITY_TAB); + const studyContext = useStudyContext(); const voltageLevelOptions = useVoltageLevelsListInfos(studyUuid, currentNode?.id, currentRootNetworkUuid); const formMethods = useForm>({ @@ -148,9 +153,13 @@ export function LoadCreationDialog({ [reset] ); - const searchCopy = useFormSearchCopy((data) => { - reset(fromSearchCopyToFormValues(data), { keepDefaultValues: true }); - }, EQUIPMENT_TYPES.LOAD); + const searchCopy = useFormSearchCopy( + (data) => { + reset(fromSearchCopyToFormValues(data), { keepDefaultValues: true }); + }, + EquipmentType.LOAD, + studyContext + ); useEffect(() => { if (editData) { @@ -236,14 +245,15 @@ export function LoadCreationDialog({ tabIndex={tabIndex} voltageLevelOptions={voltageLevelOptions} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/load/creation/load-creation.type.ts b/src/components/dialogs/network-modifications/load/creation/load-creation.type.ts index 4632feb51c..a2534684a5 100644 --- a/src/components/dialogs/network-modifications/load/creation/load-creation.type.ts +++ b/src/components/dialogs/network-modifications/load/creation/load-creation.type.ts @@ -22,7 +22,7 @@ import { REACTIVE_POWER_SET_POINT, VOLTAGE_LEVEL, } from '../../../../utils/field-constants'; -import { Property } from '../../common/properties/property-utils'; +import { Property } from '@gridsuite/commons-ui'; export type LoadCreationSchemaForm = { [EQUIPMENT_ID]: string; diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.tsx b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.tsx index c7db3be7cf..f350f24168 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/load/modification/load-modification-dialog.tsx @@ -5,10 +5,26 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, EquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentInfosTypes, + EquipmentType, + fetchNetworkElementInfos, + FetchStatus, + FORM_LOADING_DELAY, + getConcatenatedProperties, + getPropertiesFromModification, + ModificationDialog, + modificationPropertiesSchema, + sanitizeString, + snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, + 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'; import { ACTIVE_POWER_SETPOINT, ADDITIONAL_PROPERTIES, @@ -31,21 +47,9 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect, useState } from 'react'; import { FieldErrors } from 'react-hook-form'; -import { sanitizeString } from '../../../dialog-utils'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; import { modifyLoad } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; -import { - emptyProperties, - getConcatenatedProperties, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; -import { fetchNetworkElementInfos } from '../../../../../services/study/network'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, @@ -63,10 +67,10 @@ import { LoadModificationInfos, LoadModificationSchemaForm } from './load-modifi import LoadDialogHeader from '../common/load-dialog-header'; import LoadDialogTabsContent from '../common/load-dialog-tabs-content'; import { LoadFormInfos } from '../common/load.type'; -import { DeepNullable } from 'components/utils/ts-utils'; import { getSetPointsEmptyFormData, getSetPointsSchema } from 'components/dialogs/set-points/set-points-utils'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import { useFormWithDirtyTracking } from 'components/dialogs/commons/use-form-with-dirty-tracking'; +import { UUID } from 'node:crypto'; const emptyFormData = { [EQUIPMENT_NAME]: '', @@ -163,8 +167,8 @@ export default function LoadModificationDialog({ currentNodeUuid, currentRootNetworkUuid, EquipmentType.LOAD, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((load: LoadFormInfos) => { diff --git a/src/components/dialogs/network-modifications/load/modification/load-modification.type.ts b/src/components/dialogs/network-modifications/load/modification/load-modification.type.ts index 9f37be6946..8aeb8c3114 100644 --- a/src/components/dialogs/network-modifications/load/modification/load-modification.type.ts +++ b/src/components/dialogs/network-modifications/load/modification/load-modification.type.ts @@ -26,7 +26,7 @@ import { VOLTAGE_LEVEL, } from '../../../../utils/field-constants'; import { MeasurementInfo } from '../../common/measurements/measurement.type'; -import { Property } from '../../common/properties/property-utils'; +import { Property } from '@gridsuite/commons-ui'; export type LoadModificationSchemaForm = { [EQUIPMENT_NAME]?: string; diff --git a/src/components/dialogs/network-modifications/shunt-compensator/characteristics-pane/characteristics-form.tsx b/src/components/dialogs/network-modifications/shunt-compensator/characteristics-pane/characteristics-form.tsx index aefb639aa5..8de12850ad 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/characteristics-pane/characteristics-form.tsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/characteristics-pane/characteristics-form.tsx @@ -18,8 +18,14 @@ import { } from 'components/utils/field-constants'; import { Box, Grid } from '@mui/material'; import { useFormContext, useWatch } from 'react-hook-form'; -import { FloatInput, IntegerInput, RadioInput, SelectInput } from '@gridsuite/commons-ui'; -import { ReactivePowerAdornment, SusceptanceAdornment } from '../../../dialog-utils'; +import { + FloatInput, + IntegerInput, + RadioInput, + ReactivePowerAdornment, + SelectInput, + SusceptanceAdornment, +} from '@gridsuite/commons-ui'; import { useCallback, useEffect, useMemo } from 'react'; import { useIntl } from 'react-intl'; import { SHUNT_COMPENSATOR_TYPES } from '../../../../network/constants'; diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.tsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.tsx index 22f9efda2e..28903ad937 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog.tsx @@ -6,14 +6,26 @@ */ import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + getPropertiesFromModification, MODIFICATION_TYPES, + ModificationDialog, + sanitizeString, snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { BUS_OR_BUSBAR_SECTION, CHARACTERISTICS_CHOICE, @@ -35,12 +47,8 @@ import { } from 'components/utils/field-constants'; import { useCallback, useEffect } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../../dialog-utils'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; -import { FORM_LOADING_DELAY, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; +import { UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, @@ -54,18 +62,10 @@ 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, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; import { NetworkModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import { ShuntCompensatorCreationDialogSchemaForm, ShuntCompensatorFormInfos } from '../shunt-compensator-dialog.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { ShuntCompensatorCreationInfos } from '../../../../../services/network-modification-types'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; const emptyFormData = { [EQUIPMENT_ID]: '', @@ -111,7 +111,7 @@ export default function ShuntCompensatorCreationDialog({ ...dialogProps }: Readonly) { const currentNodeUuid = currentNode?.id; - + const studyContext = useStudyContext(); const { snackError, snackWarning } = useSnackMessage(); const formMethods = useForm>({ @@ -153,7 +153,7 @@ export default function ShuntCompensatorCreationDialog({ [reset, snackWarning] ); - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.SHUNT_COMPENSATOR); + const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.SHUNT_COMPENSATOR, studyContext); useEffect(() => { if (editData) { @@ -250,14 +250,15 @@ export default function ShuntCompensatorCreationDialog({ currentNode={currentNode} currentRootNetworkUuid={currentRootNetworkUuid} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-form.tsx b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-form.tsx index 86b4b65268..8b2d3635ef 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-form.tsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-form.tsx @@ -7,12 +7,8 @@ import { Grid } from '@mui/material'; import { EQUIPMENT_ID, EQUIPMENT_NAME } from 'components/utils/field-constants'; - -import { filledTextField } from '../../../dialog-utils'; - -import { TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, PropertiesForm, TextInput } from '@gridsuite/commons-ui'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; -import PropertiesForm from '../../common/properties/properties-form'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; import type { UUID } from 'node:crypto'; 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 44e4ea506f..44c47c4b6d 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,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + emptyProperties, + EquipmentInfosTypes, + EquipmentType, + fetchNetworkElementInfos, + FetchStatus, + FORM_LOADING_DELAY, + getConcatenatedProperties, + getPropertiesFromModification, + ModificationDialog, + modificationPropertiesSchema, + sanitizeString, + snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { ADDITIONAL_PROPERTIES, BUS_OR_BUSBAR_SECTION, @@ -33,23 +50,11 @@ import { import yup from '../../../../utils/yup-config'; import { yupResolver } from '@hookform/resolvers/yup'; import { useCallback, useEffect, useState } from 'react'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import ShuntCompensatorModificationForm from './shunt-compensator-modification-form'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; -import { sanitizeString } from '../../../dialog-utils'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; +import { EQUIPMENT_TYPES } from '../../../../utils/equipment-types'; 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, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; + import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, @@ -166,8 +171,8 @@ const ShuntCompensatorModificationDialog = ({ studyUuid, currentNode?.id, currentRootNetworkUuid, - EQUIPMENT_TYPES.SHUNT_COMPENSATOR, - EQUIPMENT_INFOS_TYPES.FORM.type, + EquipmentType.SHUNT_COMPENSATOR, + EquipmentInfosTypes.FORM, equipmentId, true ) diff --git a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-form.jsx b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-form.jsx index d3160396b7..890604cb8b 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-form.jsx +++ b/src/components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-form.jsx @@ -5,11 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, PropertiesForm, TextInput } from '@gridsuite/commons-ui'; import { EQUIPMENT_NAME } from '../../../../utils/field-constants'; -import { filledTextField } from '../../../dialog-utils'; import { Grid, TextField } from '@mui/material'; -import PropertiesForm from '../../common/properties/properties-form'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; diff --git a/src/components/dialogs/network-modifications/shunt-compensator/shunt-compensator-dialog.type.ts b/src/components/dialogs/network-modifications/shunt-compensator/shunt-compensator-dialog.type.ts index 23d8dd9769..8c7597938c 100644 --- a/src/components/dialogs/network-modifications/shunt-compensator/shunt-compensator-dialog.type.ts +++ b/src/components/dialogs/network-modifications/shunt-compensator/shunt-compensator-dialog.type.ts @@ -25,8 +25,8 @@ import { SWITCHED_ON_SUSCEPTANCE, VOLTAGE_LEVEL, } from '../../../utils/field-constants'; -import { Property } from '../common/properties/property-utils'; import { ConnectablePositionFormInfos } from '../../connectivity/connectivity.type'; +import { Property } from '@gridsuite/commons-ui'; export type ShuntCompensatorDialogSchemaBaseForm = { [EQUIPMENT_NAME]?: string; diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/set-points-limits-form.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/set-points-limits-form.tsx index 3ae450fbd1..7988a18e55 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/set-points-limits-form.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/set-points-limits-form.tsx @@ -20,8 +20,13 @@ import { VOLTAGE_REGULATION_TYPE, VOLTAGE_SET_POINT, } from 'components/utils/field-constants'; -import { FloatInput, SelectInput } from '@gridsuite/commons-ui'; -import { ReactivePowerAdornment, SusceptanceAdornment, VoltageAdornment } from '../../../dialog-utils'; +import { + FloatInput, + ReactivePowerAdornment, + SelectInput, + SusceptanceAdornment, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { useWatch } from 'react-hook-form'; import { FunctionComponent } from 'react'; import type { UUID } from 'node:crypto'; diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form.tsx index 3d22e530e4..98848a2e33 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/standby-automaton-form.tsx @@ -17,8 +17,7 @@ import { VOLTAGE_REGULATION_MODE, VOLTAGE_REGULATION_MODES, } from 'components/utils/field-constants'; -import { CheckboxInput, FloatInput, SwitchInput } from '@gridsuite/commons-ui'; -import { VoltageAdornment } from '../../../dialog-utils'; +import { CheckboxInput, FloatInput, SwitchInput, VoltageAdornment } from '@gridsuite/commons-ui'; import { useEffect, useMemo, useState } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { FormattedMessage, useIntl } from 'react-intl'; diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx index b368cee421..f636dfc49e 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog.tsx @@ -5,9 +5,27 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, EquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, + CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, + EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, + getPropertiesFromModification, + ModificationDialog, + Property, + sanitizeString, + snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import { ADD_STAND_BY_AUTOMATON, ADDITIONAL_PROPERTIES, @@ -44,30 +62,16 @@ import { VOLTAGE_REGULATION_TYPE, VOLTAGE_SET_POINT, } from 'components/utils/field-constants'; -import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { FC, useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { sanitizeString } from '../../../dialog-utils'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; -import { FORM_LOADING_DELAY, REGULATION_TYPES, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; +import { REGULATION_TYPES, UNDEFINED_CONNECTION_DIRECTION } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { getConnectivityFormData, getConnectivityWithPositionEmptyFormData, getConnectivityWithPositionSchema, } from '../../../connectivity/connectivity-form-utils'; import { createStaticVarCompensator } from '../../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../../services/utils'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - Property, - toModificationProperties, -} from '../../common/properties/property-utils'; import StaticVarCompensatorCreationDialogTabs from './static-var-compensator-creation-dialog-tabs'; import { Grid } from '@mui/material'; import StaticVarCompensatorCreationForm from './static-var-compensator-creation-form'; @@ -82,8 +86,8 @@ import { getStandbyAutomatonFormData, getStandbyAutomatonFormValidationSchema, } from './standby-automaton-form-utils'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { StaticVarCompensatorCreationDialogTab } from './static-var-compensator-creation-utils'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; export type StaticVarCompensatorCreationSchemaForm = { [EQUIPMENT_ID]: string; @@ -169,7 +173,7 @@ const StaticVarCompensatorCreationDialog: FC = ({ ...dialogProps }) => { const currentNodeUuid = currentNode?.id; - + const studyContext = useStudyContext(); const { snackError } = useSnackMessage(); const formMethods = useForm>({ @@ -286,7 +290,11 @@ const StaticVarCompensatorCreationDialog: FC = ({ [reset] ); - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EQUIPMENT_TYPES.STATIC_VAR_COMPENSATOR); + const searchCopy = useFormSearchCopy( + fromSearchCopyToFormValues, + EquipmentType.STATIC_VAR_COMPENSATOR, + studyContext + ); useEffect(() => { if (editData) { @@ -464,14 +472,15 @@ const StaticVarCompensatorCreationDialog: FC = ({ currentRootNetworkUuid={currentRootNetworkUuid} tabIndex={tabIndex} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.tsx index 1186f266f4..c63d6447e5 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.tsx @@ -8,7 +8,6 @@ import { FunctionComponent } from 'react'; import { ConnectivityForm } from '../../../connectivity/connectivity-form'; -import PropertiesForm from '../../common/properties/properties-form'; import { Box, Grid } from '@mui/material'; import { StandbyAutomatonForm } from './standby-automaton-form'; import { SetPointsLimitsForm } from './set-points-limits-form'; @@ -17,6 +16,7 @@ import type { UUID } from 'node:crypto'; import GridItem from '../../../commons/grid-item'; import { StaticVarCompensatorCreationDialogTab } from './static-var-compensator-creation-utils'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; +import { PropertiesForm } from '@gridsuite/commons-ui'; export interface StaticVarCompensatorCreationFormProps { studyUuid: UUID; diff --git a/src/components/dialogs/network-modifications/static-var-compensator/creation/susceptance-area.tsx b/src/components/dialogs/network-modifications/static-var-compensator/creation/susceptance-area.tsx index 07a16c9223..7905ff6225 100644 --- a/src/components/dialogs/network-modifications/static-var-compensator/creation/susceptance-area.tsx +++ b/src/components/dialogs/network-modifications/static-var-compensator/creation/susceptance-area.tsx @@ -22,8 +22,7 @@ import { Q0, SETPOINTS_LIMITS, } from 'components/utils/field-constants'; -import { FloatInput } from '@gridsuite/commons-ui'; -import { ReactivePowerAdornment, SusceptanceAdornment } from '../../../dialog-utils'; +import { FloatInput, ReactivePowerAdornment, SusceptanceAdornment } from '@gridsuite/commons-ui'; import { useEffect } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { InputAdornment, Grid, TextField } from '@mui/material'; diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.tsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.tsx deleted file mode 100644 index ffc22305a2..0000000000 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.tsx +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Copyright (c) 2023, 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 { useForm } from 'react-hook-form'; -import { ModificationDialog } from '../../../commons/modificationDialog'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; -import { useCallback, useEffect } from 'react'; -import { - CustomFormProvider, - EquipmentType, - fetchDefaultCountry, - snackWithFallback, - useSnackMessage, -} from '@gridsuite/commons-ui'; -import { yupResolver } from '@hookform/resolvers/yup'; -import yup from 'components/utils/yup-config'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; -import { ADDITIONAL_PROPERTIES, COUNTRY, EQUIPMENT_ID, EQUIPMENT_NAME } from 'components/utils/field-constants'; -import SubstationCreationForm from './substation-creation-form'; -import { sanitizeString } from '../../../dialog-utils'; -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, - getPropertiesFromModification, - Property, - toModificationProperties, -} from '../../common/properties/property-utils'; -import { UUID } from 'node:crypto'; -import { CurrentTreeNode } from '../../../../graph/tree-node.type'; -import { DeepNullable } from 'components/utils/ts-utils'; -import { SubstationInfos } from '../substation-dialog.type'; - -const formSchema = yup - .object() - .shape({ - [EQUIPMENT_ID]: yup.string().required(), - [EQUIPMENT_NAME]: yup.string().nullable(), - [COUNTRY]: yup.string().nullable(), - }) - .concat(creationPropertiesSchema); - -export type SubstationCreationFormData = yup.InferType; - -const emptyFormData: SubstationCreationFormData = { - [EQUIPMENT_ID]: '', - [EQUIPMENT_NAME]: '', - [COUNTRY]: null, - [ADDITIONAL_PROPERTIES]: [], -}; - -interface SubstationCreationEditData { - uuid?: UUID; - equipmentId: string; - equipmentName?: string; - country: string | null; - properties?: Property[] | null; -} - -interface SubstationCreationDialogProps { - studyUuid: UUID; - currentNode: CurrentTreeNode; - currentRootNetworkUuid: UUID; - isUpdate: boolean; - editDataFetchStatus?: string; - editData?: SubstationCreationEditData; -} - -/** - * Dialog to create a substation in the network - * @param editData the data to edit - * @param currentNode The node we are currently working on - * @param studyUuid the study we are currently working on - * @param currentRootNetworkUuid The root network we are currently working on - * @param isUpdate check if edition form - * @param editDataFetchStatus indicates the status of fetching EditData - * @param dialogProps props that are forwarded to the generic ModificationDialog component - */ -const SubstationCreationDialog = ({ - editData, - currentNode, - studyUuid, - currentRootNetworkUuid, - isUpdate, - editDataFetchStatus, - ...dialogProps -}: SubstationCreationDialogProps) => { - const currentNodeUuid = currentNode?.id; - const { snackError } = useSnackMessage(); - - const formMethods = useForm>({ - defaultValues: emptyFormData, - resolver: yupResolver>(formSchema), - }); - - const { reset, getValues } = formMethods; - - const fromSearchCopyToFormValues = (substation: SubstationInfos) => { - reset( - { - [EQUIPMENT_ID]: substation.id + '(1)', - [EQUIPMENT_NAME]: substation.name ?? '', - [COUNTRY]: substation.country, - ...copyEquipmentPropertiesForCreation(substation), - }, - { keepDefaultValues: true } - ); - }; - - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EquipmentType.SUBSTATION); - - useEffect(() => { - if (editData) { - reset({ - [EQUIPMENT_ID]: editData.equipmentId, - [EQUIPMENT_NAME]: editData.equipmentName ?? '', - [COUNTRY]: editData.country, - ...getPropertiesFromModification(editData.properties), - }); - } - }, [reset, editData]); - - // We set the default country only in creation mode - useEffect(() => { - if (!isUpdate) { - fetchDefaultCountry().then((country) => { - if (country) { - reset({ - ...getValues(), - [COUNTRY]: country, - }); - } - }); - } - }, [reset, getValues, isUpdate]); - - const clear = useCallback(() => { - reset(emptyFormData); - }, [reset]); - - const onSubmit = useCallback( - (substation: SubstationCreationFormData) => { - createSubstation({ - studyUuid: studyUuid, - nodeUuid: currentNodeUuid, - substationId: substation[EQUIPMENT_ID], - substationName: sanitizeString(substation[EQUIPMENT_NAME]), - country: substation[COUNTRY] ?? null, - isUpdate: !!editData, - modificationUuid: editData ? editData.uuid : undefined, - properties: toModificationProperties(substation), - }).catch((error) => { - snackWithFallback(snackError, error, { headerId: 'SubstationCreationError' }); - }); - }, - [currentNodeUuid, editData, snackError, studyUuid] - ); - - const open = useOpenShortWaitFetching({ - isDataFetched: - !isUpdate || editDataFetchStatus === FetchStatus.SUCCEED || editDataFetchStatus === FetchStatus.FAILED, - delay: FORM_LOADING_DELAY, - }); - - return ( - - - - - - - ); -}; - -export default SubstationCreationDialog; diff --git a/src/components/dialogs/network-modifications/substation/creation/substation-creation-form.tsx b/src/components/dialogs/network-modifications/substation/creation/substation-creation-form.tsx deleted file mode 100644 index b3fabe90a6..0000000000 --- a/src/components/dialogs/network-modifications/substation/creation/substation-creation-form.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2023, 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 { Grid } from '@mui/material'; -import { filledTextField } from '../../../dialog-utils'; -import { TextInput } from '@gridsuite/commons-ui'; -import { COUNTRY, EQUIPMENT_ID, EQUIPMENT_NAME } from 'components/utils/field-constants'; -import CountrySelectionInput from 'components/utils/rhf-inputs/country-selection-input'; -import PropertiesForm from '../../common/properties/properties-form'; -import GridItem from '../../../commons/grid-item'; - -const SubstationCreationForm = () => { - const substationIdField = ; - - const substationNameField = ; - - const substationCountryField = ( - - ); - - return ( - <> - - {substationIdField} - {substationNameField} - {substationCountryField} - - - - ); -}; - -export default SubstationCreationForm; diff --git a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.tsx b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.tsx index 5e09149392..ef475692b7 100644 --- a/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/substation/modification/substation-modification-dialog.tsx @@ -5,35 +5,39 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ModificationDialog } from '../../../commons/modificationDialog'; import { useCallback, useEffect, useState } from 'react'; -import { CustomFormProvider, EquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; -import { yupResolver } from '@hookform/resolvers/yup'; -import yup from 'components/utils/yup-config'; -import { ADDITIONAL_PROPERTIES, COUNTRY, EQUIPMENT_NAME } from 'components/utils/field-constants'; -import SubstationModificationForm from './substation-modification-form'; -import { sanitizeString } from '../../../dialog-utils'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from 'components/network/constants'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipment-types'; -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 { + CustomFormProvider, + DeepNullable, + EquipmentInfosTypes, + EquipmentType, + fetchNetworkElementInfos, + FetchStatus, + FORM_LOADING_DELAY, getConcatenatedProperties, getPropertiesFromModification, + GsLang, + ModificationDialog, modificationPropertiesSchema, Property, + sanitizeString, + snackWithFallback, + SubstationInfos, toModificationProperties, -} from '../../common/properties/property-utils'; + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; +import { yupResolver } from '@hookform/resolvers/yup'; +import yup from 'components/utils/yup-config'; +import { ADDITIONAL_PROPERTIES, COUNTRY, EQUIPMENT_NAME } from 'components/utils/field-constants'; +import SubstationModificationForm from './substation-modification-form'; +import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; +import { modifySubstation } from '../../../../../services/study/network-modifications'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../../../graph/tree-node.type'; import { AttributeModification } from 'services/network-modification-types'; import { useForm } from 'react-hook-form'; -import { DeepNullable } from '../../../../utils/ts-utils'; -import { SubstationInfos } from '../substation-dialog.type'; const formSchema = yup .object() @@ -64,6 +68,7 @@ interface SubstationModificationDialogProps { currentNode: CurrentTreeNode; currentRootNetworkUuid: UUID; isUpdate: boolean; + language: GsLang; editDataFetchStatus?: string; editData?: SubstationModificationEditData; defaultIdValue?: string; @@ -87,6 +92,7 @@ const SubstationModificationDialog = ({ currentRootNetworkUuid, studyUuid, isUpdate, + language, editDataFetchStatus, ...dialogProps }: SubstationModificationDialogProps) => { @@ -127,9 +133,9 @@ const SubstationModificationDialog = ({ studyUuid, currentNodeUuid, currentRootNetworkUuid, - EQUIPMENT_TYPES.SUBSTATION, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentType.SUBSTATION, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((substation: SubstationInfos) => { @@ -197,6 +203,7 @@ const SubstationModificationDialog = ({ removeOptional={true} isNodeBuilt={isNodeBuilt(currentNode)} isUpdate={isUpdate} + language={language} > ; -} diff --git a/src/components/dialogs/network-modifications/tabular/generation/generate-prefilled-model-dialog.tsx b/src/components/dialogs/network-modifications/tabular/generation/generate-prefilled-model-dialog.tsx index 3ed98981ae..316038ff1b 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/generate-prefilled-model-dialog.tsx +++ b/src/components/dialogs/network-modifications/tabular/generation/generate-prefilled-model-dialog.tsx @@ -13,6 +13,7 @@ import { ElementType, ErrorInput, FieldErrorAlert, + ModificationDialogContent, SwitchInput, } from '@gridsuite/commons-ui'; import { getPrefilledColumnGroups, PrefilledColumnGroup } from './prefillable-columns-config'; @@ -30,7 +31,6 @@ import { styles, USE_CURRENT_GRID_STATE, } from './utils'; -import { ModificationDialogContent } from 'components/dialogs/commons/modification-dialog-content'; export default function GeneratePrefilledModelDialog({ open, diff --git a/src/components/dialogs/network-modifications/tabular/generation/use-prefilled-model-generator.ts b/src/components/dialogs/network-modifications/tabular/generation/use-prefilled-model-generator.ts index a764bb0c5b..0f9743d325 100644 --- a/src/components/dialogs/network-modifications/tabular/generation/use-prefilled-model-generator.ts +++ b/src/components/dialogs/network-modifications/tabular/generation/use-prefilled-model-generator.ts @@ -7,7 +7,13 @@ import { useCallback, useMemo } from 'react'; import { useSelector } from 'react-redux'; -import { LANG_FRENCH, useSnackMessage, snackWithFallback, Identifiable } from '@gridsuite/commons-ui'; +import { + LANG_FRENCH, + useSnackMessage, + snackWithFallback, + Identifiable, + EquipmentInfosTypes, +} from '@gridsuite/commons-ui'; import { AppState } from 'redux/reducer'; import { EQUIPMENT_ID } from 'components/utils/field-constants'; import { isFieldTypeOk, TabularField, PredefinedEquipmentProperties } from '../tabular-common'; @@ -15,7 +21,7 @@ import { getNetworkElementsInfosByGlobalFilter } from 'services/study/filter'; import { fetchNetworkElementsInfos } from 'services/study/network'; import type { UUID } from 'node:crypto'; import { getPrefilledColumnGroups } from './prefillable-columns-config'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipment-types'; +import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { mapPrefilledEquipments, PrefilledModelGenerationParams } from './utils'; import { TABULAR_MODIFICATION_FIELDS } from '../tabular-modification-utils'; @@ -53,7 +59,7 @@ export const usePrefilledModelGenerator = (props: UsePrefilledModelGeneratorProp currentRootNetworkUuid, [], equipmentType, - EQUIPMENT_INFOS_TYPES.FORM.type, + EquipmentInfosTypes.FORM, true ); return mapPrefilledEquipments(equipmentType, equipments) ?? []; @@ -84,7 +90,7 @@ export const usePrefilledModelGenerator = (props: UsePrefilledModelGeneratorProp currentRootNetworkUuid, equipmentType, globalFilter, - EQUIPMENT_INFOS_TYPES.FORM.type + EquipmentInfosTypes.FORM ); return mapPrefilledEquipments(equipmentType, equipments) ?? []; diff --git a/src/components/dialogs/network-modifications/tabular/properties/define-properties-dialog.tsx b/src/components/dialogs/network-modifications/tabular/properties/define-properties-dialog.tsx index 8151ecdd34..ea0384b8b7 100644 --- a/src/components/dialogs/network-modifications/tabular/properties/define-properties-dialog.tsx +++ b/src/components/dialogs/network-modifications/tabular/properties/define-properties-dialog.tsx @@ -11,13 +11,13 @@ import { CustomFormProvider, type EquipmentType, equipmentTypesForPredefinedPropertiesMapper, + ModificationDialog, type MuiStyles, type UseStateBooleanReturn, } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import PropertiesForm from './properties-form'; import { propertiesSchema, diff --git a/src/components/dialogs/network-modifications/tabular/properties/properties-form.tsx b/src/components/dialogs/network-modifications/tabular/properties/properties-form.tsx index 4a084a211c..a25597dff1 100644 --- a/src/components/dialogs/network-modifications/tabular/properties/properties-form.tsx +++ b/src/components/dialogs/network-modifications/tabular/properties/properties-form.tsx @@ -5,12 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Grid } from '@mui/material'; -import { ExpandableInput } from '../../../../utils/rhf-inputs/expandable-input'; import { TABULAR_PROPERTIES, PREDEFINED } from '../../../../utils/field-constants'; import PropertyForm from './property-form'; import { initializedProperty } from './property-utils'; import { useCallback } from 'react'; import { useFormContext } from 'react-hook-form'; +import { ExpandableInput } from '@gridsuite/commons-ui'; const PropertiesForm = () => { const { getValues } = useFormContext(); diff --git a/src/components/dialogs/network-modifications/tabular/properties/property-form.tsx b/src/components/dialogs/network-modifications/tabular/properties/property-form.tsx index 299cf1b7cc..2eabf3f767 100644 --- a/src/components/dialogs/network-modifications/tabular/properties/property-form.tsx +++ b/src/components/dialogs/network-modifications/tabular/properties/property-form.tsx @@ -6,10 +6,9 @@ */ import { NAME, PREDEFINED, SELECTED } from 'components/utils/field-constants'; -import { CheckboxInput, TextInput } from '@gridsuite/commons-ui'; +import { CheckboxInput, italicFontTextField, TextInput } from '@gridsuite/commons-ui'; import GridItem from '../../../commons/grid-item'; import { useWatch } from 'react-hook-form'; -import { italicFontTextField } from '../../../dialog-utils'; type PropertyFormProps = { name: string; diff --git a/src/components/dialogs/network-modifications/tabular/tabular-common.ts b/src/components/dialogs/network-modifications/tabular/tabular-common.ts index 2476d89575..a220e8ed0d 100644 --- a/src/components/dialogs/network-modifications/tabular/tabular-common.ts +++ b/src/components/dialogs/network-modifications/tabular/tabular-common.ts @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { ReactiveCapabilityCurvePoints } from 'components/dialogs/reactive-limits/reactive-limits.type'; -import { createPropertyModification, Property } from '../common/properties/property-utils'; import { propertiesSchema, PROPERTY_CSV_COLUMN_PREFIX, TabularProperty } from './properties/property-utils'; import { CSV_FILENAME, @@ -27,11 +26,13 @@ import { import { BOOLEAN, ENUM, NUMBER } from '../../../network/constants'; import { IntlShape } from 'react-intl'; import { + createPropertyModification, EquipmentType, equipmentTypesForPredefinedPropertiesMapper, LANG_FRENCH, ModificationType, PredefinedProperties, + Property, } from '@gridsuite/commons-ui'; import yup from 'components/utils/yup-config'; import type { UUID } from 'node:crypto'; diff --git a/src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx b/src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx index 4088377b03..21e187e914 100644 --- a/src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx +++ b/src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx @@ -6,15 +6,20 @@ */ import { yupResolver } from '@hookform/resolvers/yup'; -import { CustomFormProvider, ModificationType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + FetchStatus, + FORM_LOADING_DELAY, + ModificationDialog, + ModificationType, + snackWithFallback, + useOpenShortWaitFetching, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { useCallback, useEffect, useMemo } from 'react'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form.js'; -import { FORM_LOADING_DELAY } from 'components/network/constants.js'; import { TABULAR_PROPERTIES, MODIFICATIONS_TABLE, CSV_FILENAME, TYPE } from 'components/utils/field-constants.js'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog.js'; import { createTabularModification } from 'services/study/network-modifications.js'; -import { FetchStatus } from 'services/utils.type'; import { convertGeneratorOrBatteryModificationFromBackToFront, convertInputValues, diff --git a/src/components/dialogs/network-modifications/tabular/tabular-form.tsx b/src/components/dialogs/network-modifications/tabular/tabular-form.tsx index 5a9d6c7004..dbd5b99602 100644 --- a/src/components/dialogs/network-modifications/tabular/tabular-form.tsx +++ b/src/components/dialogs/network-modifications/tabular/tabular-form.tsx @@ -21,6 +21,7 @@ import { LANG_FRENCH, type MuiStyles, type TreeViewFinderNodeProps, + useCSVPicker, useSnackMessage, useStateBoolean, } from '@gridsuite/commons-ui'; @@ -36,7 +37,6 @@ import CsvDownloader from 'react-csv-downloader'; import { Alert, Button, Grid } from '@mui/material'; import Papa from 'papaparse'; import GridItem from '../../commons/grid-item'; -import { useCSVPicker } from 'components/utils/inputs/input-hooks'; import { AGGRID_LOCALES } from '../../../../translations/not-intl/aggrid-locales'; import { useSelector } from 'react-redux'; import { AppState } from '../../../../redux/reducer'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/characteristics-pane/two-windings-transformer-characteristics-pane.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/characteristics-pane/two-windings-transformer-characteristics-pane.jsx index 7ad2e2f2c2..a79c6187ae 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/characteristics-pane/two-windings-transformer-characteristics-pane.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/characteristics-pane/two-windings-transformer-characteristics-pane.jsx @@ -7,10 +7,17 @@ import { Grid } from '@mui/material'; import { FormattedMessage } from 'react-intl'; -import { MicroSusceptanceAdornment, MVAPowerAdornment, OhmAdornment, VoltageAdornment } from '../../../dialog-utils'; -import { convertInputValue, FieldType, FloatInput } from '@gridsuite/commons-ui'; +import { + convertInputValue, + FieldType, + FloatInput, + MicroSusceptanceAdornment, + MVAPowerAdornment, + OhmAdornment, + PropertiesForm, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { B, CHARACTERISTICS, G, R, RATED_S, RATED_U1, RATED_U2, X } from 'components/utils/field-constants'; -import PropertiesForm from '../../common/properties/properties-form'; import GridSection from '../../../commons/grid-section'; import GridItem from '../../../commons/grid-item'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog-header.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog-header.jsx index 08472eb020..cfd418ccd4 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog-header.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog-header.jsx @@ -13,8 +13,7 @@ import { PHASE_TAP_CHANGER, RATIO_TAP_CHANGER, } from 'components/utils/field-constants'; -import { filledTextField } from '../../../dialog-utils'; -import { TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, TextInput } from '@gridsuite/commons-ui'; import { SwitchInput } from '@gridsuite/commons-ui'; import GridItem from '../../../commons/grid-item'; 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 ebe21e7821..e5ef9e5aac 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 @@ -8,9 +8,21 @@ import { convertInputValue, convertOutputValue, + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + emptyProperties, + EquipmentSearchDialog, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + getPropertiesFromModification, + ModificationDialog, + sanitizeString, snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -60,12 +72,7 @@ import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { FetchStatus } from '../../../../../services/utils'; -import { sanitizeString } from '../../../dialog-utils'; -import EquipmentSearchDialog from '../../../equipment-search-dialog'; -import { useFormSearchCopy } from '../../../commons/use-form-search-copy'; import { - FORM_LOADING_DELAY, PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES, @@ -73,7 +80,6 @@ import { UNDEFINED_CONNECTION_DIRECTION, } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { getConnectivityFormData } from '../../../connectivity/connectivity-form-utils'; import { getPhaseTapChangerEmptyFormData, @@ -98,18 +104,11 @@ import { getLimitsValidationSchema, sanitizeLimitsGroups, } from '../../../limits/limits-pane-utils'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import TwoWindingsTransformerCreationDialogHeader from './two-windings-transformer-creation-dialog-header'; import { addSelectedFieldToRows, computeHighTapPosition, formatCompleteCurrentLimit } from 'components/utils/utils'; import { createTwoWindingsTransformer } from '../../../../../services/study/network-modifications'; -import { - copyEquipmentPropertiesForCreation, - creationPropertiesSchema, - emptyProperties, - getPropertiesFromModification, - toModificationProperties, -} from '../../common/properties/property-utils'; import { TwoWindingsTransformerCreationDialogTab } from '../two-windings-transformer-utils'; +import { useStudyContext } from '../../../../../hooks/use-study-context.ts'; /** * Dialog to create a two windings transformer in the network @@ -156,6 +155,7 @@ const TwoWindingsTransformerCreationDialog = ({ }) => { const currentNodeUuid = currentNode?.id; const { snackError } = useSnackMessage(); + const studyContext = useStudyContext(); const formMethods = useForm({ defaultValues: emptyFormData, @@ -390,7 +390,11 @@ const TwoWindingsTransformerCreationDialog = ({ [reset] ); - const searchCopy = useFormSearchCopy(fromSearchCopyToFormValues, EQUIPMENT_TYPES.TWO_WINDINGS_TRANSFORMER); + const searchCopy = useFormSearchCopy( + fromSearchCopyToFormValues, + EQUIPMENT_TYPES.TWO_WINDINGS_TRANSFORMER, + studyContext + ); useEffect(() => { if (editData) { @@ -642,15 +646,15 @@ const TwoWindingsTransformerCreationDialog = ({ currentRootNetworkUuid={currentRootNetworkUuid} tabIndex={tabIndex} /> - - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog-header.jsx b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog-header.jsx index 4d01e99e55..2405cfc79f 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog-header.jsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/modification/two-windings-transformer-modification-dialog-header.jsx @@ -7,8 +7,7 @@ import { Grid, TextField } from '@mui/material'; import { ENABLED, EQUIPMENT_NAME, RATIO_TAP_CHANGER, PHASE_TAP_CHANGER } from 'components/utils/field-constants'; -import { filledTextField } from '../../../dialog-utils'; -import { SwitchInput, TextInput } from '@gridsuite/commons-ui'; +import { filledTextField, SwitchInput, TextInput } from '@gridsuite/commons-ui'; import GridItem from '../../../commons/grid-item'; const TwoWindingsTransformerModificationDialogHeader = ({ equipmentToModify, equipmentId }) => { 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 272d348301..8780144d2f 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 @@ -9,9 +9,21 @@ import { convertInputValue, convertOutputValue, CustomFormProvider, + emptyProperties, + EquipmentInfosTypes, EquipmentType, + fetchNetworkElementInfos, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + getConcatenatedProperties, + getPropertiesFromModification, + ModificationDialog, + modificationPropertiesSchema, + sanitizeString, snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; @@ -73,15 +85,8 @@ import { } from 'components/utils/field-constants'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState } from 'react'; -import { sanitizeString } from '../../../dialog-utils'; -import { - FORM_LOADING_DELAY, - PHASE_REGULATION_MODES, - RATIO_REGULATION_MODES, - REGULATION_TYPES, -} from 'components/network/constants'; +import { PHASE_REGULATION_MODES, RATIO_REGULATION_MODES, REGULATION_TYPES } from 'components/network/constants'; import yup from 'components/utils/yup-config'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import TwoWindingsTransformerModificationDialogTabs from './two-windings-transformer-modification-dialog-tabs'; import TwoWindingsTransformerCharacteristicsPane from '../characteristics-pane/two-windings-transformer-characteristics-pane'; import { @@ -99,7 +104,6 @@ import { getLimitsValidationSchema, getOpLimitsGroupInfosFromBranchModification, } from '../../../limits/limits-pane-utils'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; import TwoWindingsTransformerModificationDialogHeader from './two-windings-transformer-modification-dialog-header'; import { addSelectedFieldToRows, @@ -107,7 +111,6 @@ import { computeHighTapPosition, toModificationOperation, } from '../../../../utils/utils'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import { getComputedPhaseTapChangerRegulationMode, @@ -126,15 +129,6 @@ import { import { isNodeBuilt } from 'components/graph/util/model-functions'; import RatioTapChangerPane from '../tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane'; import PhaseTapChangerPane from '../tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane'; -import { fetchNetworkElementInfos } from '../../../../../services/study/network'; -import { FetchStatus } from '../../../../../services/utils'; -import { - emptyProperties, - getConcatenatedProperties, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; import useVoltageLevelsListInfos from '../../../../../hooks/use-voltage-levels-list-infos'; import { BranchConnectivityForm } from '../../../connectivity/branch-connectivity-form'; import { @@ -648,7 +642,7 @@ const TwoWindingsTransformerModificationDialog = ({ currentNodeUuid, currentRootNetworkUuid, EquipmentType.TWO_WINDINGS_TRANSFORMER, - EQUIPMENT_INFOS_TYPES.FORM.type, + EquipmentInfosTypes.FORM, equipmentId, true ) diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/import-rule-dialog.tsx b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/import-rule-dialog.tsx index ee707da81b..63883c093c 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/import-rule-dialog.tsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/import-rule-dialog.tsx @@ -8,9 +8,8 @@ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid } from '@mui/material'; import { useMemo } from 'react'; import { FormattedMessage } from 'react-intl'; -import { useCSVPicker } from 'components/utils/inputs/input-hooks'; import CsvDownloader from 'react-csv-downloader'; -import { CancelButton, LANG_FRENCH, MAX_ROWS_NUMBER } from '@gridsuite/commons-ui'; +import { CancelButton, LANG_FRENCH, MAX_ROWS_NUMBER, useCSVPicker } from '@gridsuite/commons-ui'; import { useSelector } from 'react-redux'; import { PHASE_TAP, RuleType } from '../two-windings-transformer.types'; import { AppState } from 'redux/reducer'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-steps.tsx b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-steps.tsx index 14f3986940..247b4337b8 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-steps.tsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane-steps.tsx @@ -18,8 +18,7 @@ import { import { useMemo } from 'react'; import { useIntl } from 'react-intl'; import TapChangerSteps from '../tap-changer-steps'; -import { parseIntData } from '../../../../dialog-utils'; -import { DndColumn, DndColumnType } from '@gridsuite/commons-ui'; +import { DndColumn, DndColumnType, parseIntData } from '@gridsuite/commons-ui'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; import { PHASE_TAP, PhaseTapChangerData } from '../../two-windings-transformer.types'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane.tsx b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane.tsx index c07238558f..23b06b7842 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane.tsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/phase-tap-changer-pane/phase-tap-changer-pane.tsx @@ -17,9 +17,8 @@ import { } from 'components/utils/field-constants'; import { useWatch } from 'react-hook-form'; import { useIntl } from 'react-intl'; -import { ActivePowerAdornment, AmpereAdornment } from '../../../../dialog-utils'; import { PHASE_REGULATION_MODES } from 'components/network/constants'; -import { FloatInput, SelectInput } from '@gridsuite/commons-ui'; +import { ActivePowerAdornment, AmpereAdornment, FloatInput, SelectInput } from '@gridsuite/commons-ui'; import PhaseTapChangerPaneSteps from './phase-tap-changer-pane-steps'; import { getComputedPhaseTapChangerRegulationMode, diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-steps.tsx b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-steps.tsx index 345bb7c970..3c67df0508 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-steps.tsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane-steps.tsx @@ -16,8 +16,7 @@ import { } from 'components/utils/field-constants'; import { useMemo } from 'react'; import { useIntl } from 'react-intl'; -import { parseIntData } from '../../../../dialog-utils'; -import { DndColumn, DndColumnType } from '@gridsuite/commons-ui'; +import { DndColumn, DndColumnType, parseIntData } from '@gridsuite/commons-ui'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; import TapChangerSteps from '../tap-changer-steps'; import { RATIO_TAP, RatioTapChangerData } from '../../two-windings-transformer.types'; diff --git a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane.tsx b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane.tsx index cbe8640b06..6eda483d3f 100644 --- a/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane.tsx +++ b/src/components/dialogs/network-modifications/two-windings-transformer/tap-changer-pane/ratio-tap-changer-pane/ratio-tap-changer-pane.tsx @@ -21,8 +21,7 @@ import { import { useCallback, useEffect, useMemo } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { useIntl } from 'react-intl'; -import { VoltageAdornment } from '../../../../dialog-utils'; -import { FloatInput, Identifiable, SelectInput, SwitchInput } from '@gridsuite/commons-ui'; +import { FloatInput, Identifiable, SelectInput, SwitchInput, VoltageAdornment } from '@gridsuite/commons-ui'; import RatioTapChangerPaneSteps from './ratio-tap-changer-pane-steps'; import { RATIO_REGULATION_MODES } from 'components/network/constants'; import CheckboxNullableInput from 'components/utils/rhf-inputs/boolean-nullable-input'; 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 aa0e916c7f..ccfaed0664 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 @@ -12,12 +12,13 @@ import { CsvExport, CustomAGGrid, DefaultCellRenderer, + FetchStatus, + FORM_LOADING_DELAY, type MuiStyles, + useOpenShortWaitFetching, } from '@gridsuite/commons-ui'; import { FormattedMessage, useIntl } from 'react-intl'; import { Box, Grid, Tab, Tabs, Typography } from '@mui/material'; -import { useOpenShortWaitFetching } from '../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../network/constants'; import { ANGLE, CONNECT, @@ -31,7 +32,6 @@ import { VOLTAGE_SET_POINT, } from '../../../utils/field-constants'; import { AgGridReact } from 'ag-grid-react'; -import { FetchStatus } from '../../../../services/utils.type'; import type { ColDef, RowDataUpdatedEvent } from 'ag-grid-community'; import { suppressEventsToPreventEditMode } from '../../commons/utils'; import { AGGRID_LOCALES } from '../../../../translations/not-intl/aggrid-locales'; diff --git a/src/components/dialogs/network-modifications/voltage-level/coupling-omnibus/coupling-omnibus-form.tsx b/src/components/dialogs/network-modifications/voltage-level/coupling-omnibus/coupling-omnibus-form.tsx index 5d4c174cb5..d22023d6a0 100644 --- a/src/components/dialogs/network-modifications/voltage-level/coupling-omnibus/coupling-omnibus-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/coupling-omnibus/coupling-omnibus-form.tsx @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ExpandableInput } from 'components/utils/rhf-inputs/expandable-input'; import { BUS_BAR_COUNT, BUS_BAR_SECTION_ID1, @@ -18,6 +17,7 @@ import { CouplingOmnibusCreation } from './coupling-omnibus-creation'; import { useEffect, useMemo } from 'react'; import { useFormContext, useWatch } from 'react-hook-form'; import { buildNewBusbarSections } from 'components/utils/utils'; +import { ExpandableInput } from '@gridsuite/commons-ui'; export const CouplingOmnibusForm = () => { const { setValue } = useFormContext(); diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.tsx index c16d7e6b5a..89b451c649 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.tsx @@ -8,17 +8,30 @@ import { convertInputValue, convertOutputValue, + copyEquipmentPropertiesForCreation, + creationPropertiesSchema, CustomFormProvider, + DeepNullable, + emptyProperties, + EquipmentSearchDialog, EquipmentType, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + getPropertiesFromModification, + GsLang, MODIFICATION_TYPES, + ModificationDialog, + Properties, + Property, + sanitizeString, snackWithFallback, + toModificationProperties, + useFormSearchCopy, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; -import { sanitizeString } from 'components/dialogs/dialog-utils'; -import EquipmentSearchDialog from 'components/dialogs/equipment-search-dialog'; -import { useFormSearchCopy } from 'components/dialogs/commons/use-form-search-copy'; import { ADD_SUBSTATION_CREATION, ADDITIONAL_PROPERTIES, @@ -50,24 +63,10 @@ import { import yup from 'components/utils/yup-config'; import { FC, useCallback, useEffect, useMemo } from 'react'; import { useForm } from 'react-hook-form'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import VoltageLevelCreationForm from './voltage-level-creation-form'; -import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import { useIntl } from 'react-intl'; -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, - emptyProperties, - getPropertiesFromModification, - Properties, - Property, - toModificationProperties, -} from '../../common/properties/property-utils'; import { UUID } from 'node:crypto'; import { AttachedSubstationCreationInfo, @@ -75,8 +74,8 @@ import { VoltageLevelCreationInfo, } from '../../../../../services/network-modification-types'; import { CurrentTreeNode } from '../../../../graph/tree-node.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { CreateCouplingDeviceDialogSchemaForm } from '../../coupling-device/coupling-device-dialog.type'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; export type SwitchKindFormData = { [SWITCH_KIND]: string }; @@ -111,6 +110,7 @@ interface VoltageLevelCreationDialogProps { studyUuid: string; currentRootNetworkUuid: UUID; isUpdate?: boolean; + language: GsLang; editDataFetchStatus?: string; onCreateVoltageLevel?: (data: VoltageLevelCreationInfo) => Promise; isAttachmentPointModification?: boolean; @@ -272,6 +272,7 @@ const VoltageLevelCreationDialog: FC = ({ studyUuid, currentRootNetworkUuid, isUpdate, + language, editDataFetchStatus, onCreateVoltageLevel = createVoltageLevel, isAttachmentPointModification = false, @@ -280,6 +281,7 @@ const VoltageLevelCreationDialog: FC = ({ }) => { const currentNodeUuid = currentNode.id; const { snackError, snackWarning } = useSnackMessage(); + const studyContext = useStudyContext(); const defaultValues = useMemo((): VoltageLevelCreationFormData => { if (isAttachmentPointModification) { @@ -424,7 +426,7 @@ const VoltageLevelCreationDialog: FC = ({ }; }, [subscribe, trigger, getValues]); - const searchCopy = useFormSearchCopy(fromExternalDataToFormValues, EQUIPMENT_TYPES.VOLTAGE_LEVEL); + const searchCopy = useFormSearchCopy(fromExternalDataToFormValues, EquipmentType.VOLTAGE_LEVEL, studyContext); useEffect(() => { if (editData) { @@ -488,7 +490,7 @@ const VoltageLevelCreationDialog: FC = ({ }); return ( - + = ({ studyUuid={studyUuid as UUID} currentRootNetworkUuid={currentRootNetworkUuid} /> - + {studyContext && ( + + )} ); diff --git a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-form.tsx b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-form.tsx index 3755df24ba..be87470bca 100644 --- a/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-form.tsx @@ -24,27 +24,28 @@ import { SUBSTATION_NAME, } from 'components/utils/field-constants'; import React, { useCallback, useEffect, useState } from 'react'; -import { KiloAmpereAdornment, VoltageAdornment } from 'components/dialogs/dialog-utils'; import { AutocompleteInput, + CountrySelectionInput, EquipmentType, fetchDefaultCountry, FloatInput, IntegerInput, + KiloAmpereAdornment, + PropertiesForm, TextInput, + VoltageAdornment, } from '@gridsuite/commons-ui'; import { Box, Grid, Paper, Tooltip } from '@mui/material'; import { CouplingOmnibusForm } from '../coupling-omnibus/coupling-omnibus-form'; import { SwitchesBetweenSections } from '../switches-between-sections/switches-between-sections'; import { fetchEquipmentsIds } from '../../../../../services/study/network-map'; -import PropertiesForm from '../../common/properties/properties-form'; import { useFormContext, useWatch } from 'react-hook-form'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; import IconButton from '@mui/material/IconButton'; import { useIntl } from 'react-intl'; -import CountrySelectionInput from '../../../../utils/rhf-inputs/country-selection-input'; import DeleteIcon from '@mui/icons-material/Delete'; import LineSeparator from '../../../commons/line-separator'; import { UUID } from 'node:crypto'; diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx index 4f29b979b1..b6b063a694 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ModificationDialog } from '../../../commons/modificationDialog'; import { useCallback, useEffect, useState } from 'react'; import VoltageLevelModificationForm from './voltage-level-modification-form'; import { @@ -24,26 +23,25 @@ import { convertInputValue, convertOutputValue, CustomFormProvider, + emptyProperties, + EquipmentInfosTypes, EquipmentType, + EquipmentWithProperties, + fetchNetworkElementInfos, + FetchStatus, FieldType, + FORM_LOADING_DELAY, + getConcatenatedProperties, + getPropertiesFromModification, + ModificationDialog, + modificationPropertiesSchema, snackWithFallback, + toModificationProperties, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from 'components/network/constants'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; 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, - Equipment, - getConcatenatedProperties, - getPropertiesFromModification, - modificationPropertiesSchema, - toModificationProperties, -} from '../../common/properties/property-utils'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { useFormWithDirtyTracking } from 'components/dialogs/commons/use-form-with-dirty-tracking'; import { UUID } from 'node:crypto'; @@ -128,6 +126,7 @@ const formSchema = yup .min(0, 'ShortCircuitCurrentLimitMustBeGreaterOrEqualToZero'), }) .concat(modificationPropertiesSchema); + const VoltageLevelModificationDialog = ({ editData, // contains data when we try to edit an existing hypothesis from the current node's list defaultIdValue, // Used to pre-select an equipmentId when calling this dialog from the network map @@ -195,8 +194,8 @@ const VoltageLevelModificationDialog = ({ currentNodeUuid, currentRootNetworkUuid, EquipmentType.VOLTAGE_LEVEL, - EQUIPMENT_INFOS_TYPES.FORM.type, - equipmentId, + EquipmentInfosTypes.FORM, + equipmentId as UUID, true ) .then((voltageLevel: VoltageLevelFormData) => { @@ -218,7 +217,7 @@ const VoltageLevelModificationDialog = ({ (formValues) => ({ ...formValues, [ADDITIONAL_PROPERTIES]: getConcatenatedProperties( - voltageLevel as Equipment, + voltageLevel as EquipmentWithProperties, getValues ), [SUBSTATION_ID]: voltageLevel?.substationId, diff --git a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx index 09ce106af8..132dbb08e9 100644 --- a/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx @@ -18,13 +18,19 @@ import { NOMINAL_V, SUBSTATION_ID, } from 'components/utils/field-constants'; -import { AutocompleteInput, FloatInput, TextInput } from '@gridsuite/commons-ui'; -import { filledTextField, KiloAmpereAdornment, VoltageAdornment } from '../../../dialog-utils'; +import { + AutocompleteInput, + filledTextField, + FloatInput, + KiloAmpereAdornment, + Properties, + PropertiesForm, + TextInput, + VoltageAdornment, +} from '@gridsuite/commons-ui'; import { TextField, Grid } from '@mui/material'; -import PropertiesForm from '../../common/properties/properties-form'; import GridItem from '../../../commons/grid-item'; import GridSection from '../../../commons/grid-section'; -import { Properties } from '../../common/properties/property-utils'; interface VoltageLevelFormData { [NAME]?: string; diff --git a/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-dialog.tsx index b9b612ca54..1364a1e8e4 100644 --- a/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-dialog.tsx @@ -7,20 +7,21 @@ import { CustomFormProvider, + DeepNullable, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, Identifiable, MODIFICATION_TYPES, + ModificationDialog, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { useCallback, useEffect, useMemo, useState } from 'react'; -import { FetchStatus } from '../../../../../services/utils'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import yup from '../../../../utils/yup-config'; import { @@ -41,7 +42,6 @@ import { MoveVoltageLevelFeederBaysInfos, } from '../../../../../services/network-modification-types'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { FeederBays, FeederBaysFormInfos } from './move-voltage-level-feeder-bays.type'; import { moveVoltageLevelFeederBays } from '../../../../../services/study/network-modifications'; import { diff --git a/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-form.tsx b/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-form.tsx index 283332c2ae..3d0c4e2cae 100644 --- a/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-form.tsx @@ -8,11 +8,10 @@ import { useCallback, useMemo, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { CurrentTreeNode } from '../../../../graph/tree-node.type'; import { Box, Grid, TextField, Tooltip } from '@mui/material'; -import { filledTextField } from '../../../dialog-utils'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { useFormContext } from 'react-hook-form'; import HeaderWithTooltip from '../topology-modification/header-with-tooltip'; -import { AutocompleteInput, CustomAGGrid, TextInput } from '@gridsuite/commons-ui'; +import { AutocompleteInput, CustomAGGrid, filledTextField, TextInput } from '@gridsuite/commons-ui'; import { BUSBAR_SECTION_ID, BUSBAR_SECTION_IDS, diff --git a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx index c54e6d6da0..9ccdc45e66 100644 --- a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog.tsx @@ -6,17 +6,20 @@ */ import { CustomFormProvider, + DeepNullable, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, MODIFICATION_TYPES, + ModificationDialog, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import { useCallback, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; -import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modification-form'; -import { FORM_LOADING_DELAY, POSITION_NEW_SECTION_SIDE } from 'components/network/constants'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; +import { POSITION_NEW_SECTION_SIDE } from 'components/network/constants'; import { isNodeBuilt } from 'components/graph/util/model-functions'; import { yupResolver } from '@hookform/resolvers/yup'; import { @@ -32,14 +35,12 @@ import { SWITCHES_BEFORE_SECTIONS, } from '../../../../utils/field-constants'; import yup from '../../../../utils/yup-config'; -import { FetchStatus } from 'services/utils'; import { EquipmentIdSelector } from 'components/dialogs/equipment-id/equipment-id-selector'; import { CreateVoltageLevelSectionForm } from './create-voltage-level-section-form'; import { BusBarSections, CreateVoltageLevelSectionDialogSchemaForm } from './voltage-level-section.type'; import { CreateVoltageLevelSectionInfos } from '../../../../../services/network-modification-types'; import { createVoltageLevelSection } from '../../../../../services/study/network-modifications'; import { fetchVoltageLevelBusBarSectionsInfos } from '../../../../../services/study/network'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { BusBarSectionsInfos } from '../../../../../services/study/network-map.type'; const getBusBarIndexValue = ({ busbarIndex, allBusbars }: { busbarIndex: string | null; allBusbars: boolean }) => { diff --git a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx index b9855285c7..ed0b81dcf4 100644 --- a/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/section/create-voltage-level-section-form.tsx @@ -17,10 +17,9 @@ import { SWITCHES_BEFORE_SECTIONS, } from '../../../../utils/field-constants'; import { Box, Button, Grid, Slider, TextField, Tooltip, Typography } from '@mui/material'; -import { filledTextField } from '../../../dialog-utils'; import { FormattedMessage, useIntl } from 'react-intl'; import { CurrentTreeNode } from 'components/graph/tree-node.type'; -import { AutocompleteInput, Option, SelectInput, SwitchInput } from '@gridsuite/commons-ui'; +import { AutocompleteInput, filledTextField, Option, SelectInput, SwitchInput } from '@gridsuite/commons-ui'; import GridSection from '../../../commons/grid-section'; import { isNodeBuilt } from 'components/graph/util/model-functions'; import { InfoOutlined } from '@mui/icons-material'; diff --git a/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-dialog.tsx index e9fb7f08f0..60029677d0 100644 --- a/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-dialog.tsx @@ -11,9 +11,14 @@ import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { CustomFormProvider, + DeepNullable, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, MODIFICATION_TYPES, + ModificationDialog, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import yup from '../../../../utils/yup-config'; @@ -21,14 +26,9 @@ import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { EquipmentModificationDialogProps } from '../../../../graph/menus/network-modifications/network-modification-menu.type'; import { CreateVoltageLevelTopologyDialogSchemaForm } from './create-voltage-level-topology-dialog.type'; import CreateVoltageLevelTopologyForm from './create-voltage-level-topology-form'; -import { DeepNullable } from '../../../../utils/ts-utils'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; -import { ModificationDialog } from '../../../commons/modificationDialog'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; import { createVoltageLevelTopology } from '../../../../../services/study/network-modifications'; import { CreateVoltageLevelTopologyInfos } from '../../../../../services/network-modification-types'; -import { FetchStatus } from '../../../../../services/utils'; import { useIntl } from 'react-intl'; const emptyFormData = { diff --git a/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-form.tsx b/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-form.tsx index 5193ac1215..b023e018a7 100644 --- a/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/topology-creation/create-voltage-level-topology-form.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { IntegerInput } from '@gridsuite/commons-ui'; +import { filledTextField, IntegerInput } from '@gridsuite/commons-ui'; import { SECTION_COUNT } from 'components/utils/field-constants'; import GridItem from '../../../commons/grid-item'; import { Box, Grid, TextField, Tooltip } from '@mui/material'; @@ -14,7 +14,6 @@ import PositionDiagramPane from '../../../../grid-layout/cards/diagrams/singleLi import { useCallback, useMemo, useState } from 'react'; import Button from '@mui/material/Button'; import { FormattedMessage, useIntl } from 'react-intl'; -import { filledTextField } from '../../../dialog-utils'; import type { UUID } from 'node:crypto'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import { CurrentTreeNode } from '../../../../graph/tree-node.type'; diff --git a/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-dialog.tsx b/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-dialog.tsx index 58bc8986b6..27dbe115a0 100644 --- a/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-dialog.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-dialog.tsx @@ -8,18 +8,18 @@ import { CustomFormProvider, EquipmentType, + FetchStatus, + FORM_LOADING_DELAY, MODIFICATION_TYPES, + ModificationDialog, ModificationType, snackWithFallback, + useOpenShortWaitFetching, useSnackMessage, } from '@gridsuite/commons-ui'; import { useCallback, useEffect, useMemo, useState } from 'react'; -import { FetchStatus } from '../../../../../services/utils'; import { yupResolver } from '@hookform/resolvers/yup'; -import { useOpenShortWaitFetching } from '../../../commons/handle-modification-form'; -import { FORM_LOADING_DELAY } from '../../../../network/constants'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; -import { ModificationDialog } from '../../../commons/modificationDialog'; import { EquipmentIdSelector } from '../../../equipment-id/equipment-id-selector'; import yup from '../../../../utils/yup-config'; import { diff --git a/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-form.tsx b/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-form.tsx index 4deb89c8e1..253ef9159b 100644 --- a/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-form.tsx +++ b/src/components/dialogs/network-modifications/voltage-level/topology-modification/voltage-level-topology-modification-form.tsx @@ -14,8 +14,7 @@ import { SWITCH_ID, TOPOLOGY_MODIFICATION_TABLE, } from '../../../../utils/field-constants'; -import { CustomAGGrid } from '@gridsuite/commons-ui'; -import { filledTextField } from '../../../dialog-utils'; +import { CustomAGGrid, filledTextField } from '@gridsuite/commons-ui'; import HeaderWithTooltip from './header-with-tooltip'; import { isNodeBuilt } from '../../../../graph/util/model-functions'; import ConnectionCellRenderer from './connection-cell-render'; diff --git a/src/components/dialogs/parameters/dynamicsimulation/mapping-parameters.tsx b/src/components/dialogs/parameters/dynamicsimulation/mapping-parameters.tsx index 6d489bd48c..694a49c232 100644 --- a/src/components/dialogs/parameters/dynamicsimulation/mapping-parameters.tsx +++ b/src/components/dialogs/parameters/dynamicsimulation/mapping-parameters.tsx @@ -8,8 +8,7 @@ import { Grid } from '@mui/material'; import { DefParam, makeComponents, TYPES } from '../util/make-component-utils'; import { FunctionComponent, useMemo } from 'react'; -import { getIdOrSelf } from '../../dialog-utils'; -import { AutocompleteInput } from '@gridsuite/commons-ui'; +import { AutocompleteInput, getIdOrSelf } from '@gridsuite/commons-ui'; import { MappingInfos } from 'services/study/dynamic-simulation.type'; import { MAPPING } from './dynamic-simulation-utils'; diff --git a/src/components/dialogs/percentage-area/percentage-area.tsx b/src/components/dialogs/percentage-area/percentage-area.tsx index 09f2b10475..90b5cafb97 100644 --- a/src/components/dialogs/percentage-area/percentage-area.tsx +++ b/src/components/dialogs/percentage-area/percentage-area.tsx @@ -6,12 +6,11 @@ */ import { Grid, Typography } from '@mui/material'; -import { percentageTextField, standardTextField } from '../dialog-utils'; import { LEFT_SIDE_PERCENTAGE, RIGHT_SIDE_PERCENTAGE, SLIDER_PERCENTAGE } from 'components/utils/field-constants'; import { useFormContext } from 'react-hook-form'; import { formatPercentageValue, isValidPercentage, sanitizePercentageValue } from './percentage-area-utils'; import { FormattedMessage } from 'react-intl'; -import { Input, SliderInput, TextInput } from '@gridsuite/commons-ui'; +import { Input, percentageTextField, SliderInput, standardTextField, TextInput } from '@gridsuite/commons-ui'; /** * Component to handle a 'percentage area' (slider , left and right percentage fields) diff --git a/src/components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-curve-row-form.tsx b/src/components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-curve-row-form.tsx index 390c2cbb86..d74a2bbbad 100644 --- a/src/components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-curve-row-form.tsx +++ b/src/components/dialogs/reactive-limits/reactive-capability-curve/reactive-capability-curve-row-form.tsx @@ -5,9 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput } from '@gridsuite/commons-ui'; +import { ActivePowerAdornment, FloatInput, ReactivePowerAdornment } from '@gridsuite/commons-ui'; import { MAX_Q, MIN_Q, P, REACTIVE_CAPABILITY_CURVE_TABLE, REACTIVE_LIMITS } from 'components/utils/field-constants'; -import { ActivePowerAdornment, ReactivePowerAdornment } from '../../dialog-utils'; import GridItem from '../../commons/grid-item'; import { useCallback } from 'react'; import { useFormContext } from 'react-hook-form'; diff --git a/src/components/dialogs/reactive-limits/reactive-limits-form.tsx b/src/components/dialogs/reactive-limits/reactive-limits-form.tsx index c2217985c9..ec627a6ef0 100644 --- a/src/components/dialogs/reactive-limits/reactive-limits-form.tsx +++ b/src/components/dialogs/reactive-limits/reactive-limits-form.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, RadioInput } from '@gridsuite/commons-ui'; +import { FloatInput, RadioInput, ReactivePowerAdornment } from '@gridsuite/commons-ui'; import { MAXIMUM_REACTIVE_POWER, MINIMUM_REACTIVE_POWER, @@ -14,7 +14,6 @@ import { REACTIVE_LIMITS, } from 'components/utils/field-constants'; import { REACTIVE_LIMIT_TYPES } from 'components/network/constants'; -import { ReactivePowerAdornment } from '../dialog-utils'; import { useWatch } from 'react-hook-form'; import Grid from '@mui/material/Grid'; import GridItem from '../commons/grid-item'; diff --git a/src/components/dialogs/root-network/root-network-dialog.tsx b/src/components/dialogs/root-network/root-network-dialog.tsx index 035002d675..0fe31db863 100644 --- a/src/components/dialogs/root-network/root-network-dialog.tsx +++ b/src/components/dialogs/root-network/root-network-dialog.tsx @@ -11,6 +11,7 @@ import { FieldConstants, isObjectEmpty, MAX_CHAR_DESCRIPTION, + ModificationDialog, Parameter, TreeViewFinderNodeProps, } from '@gridsuite/commons-ui'; @@ -22,7 +23,6 @@ import { yupResolver } from '@hookform/resolvers/yup'; import yup from '../../utils/yup-config'; import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; -import { ModificationDialog } from '../commons/modificationDialog'; import { checkRootNetworkNameExistence, checkRootNetworkTagExistence } from 'services/root-network'; import { RootNetworkCaseSelection } from './root-network-case-selection'; import { UniqueCheckNameInput } from 'components/graph/menus/unique-check-name-input'; diff --git a/src/components/dialogs/set-points/set-points-form.tsx b/src/components/dialogs/set-points/set-points-form.tsx index e1d31b2aca..9962d123d6 100644 --- a/src/components/dialogs/set-points/set-points-form.tsx +++ b/src/components/dialogs/set-points/set-points-form.tsx @@ -5,9 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { ActivePowerAdornment, ReactivePowerAdornment } from '../dialog-utils'; import { Grid } from '@mui/material'; -import { FloatInput } from '@gridsuite/commons-ui'; +import { ActivePowerAdornment, FloatInput, ReactivePowerAdornment } from '@gridsuite/commons-ui'; import { ACTIVE_POWER_SET_POINT, REACTIVE_POWER_SET_POINT } from 'components/utils/field-constants'; import GridItem from '../commons/grid-item'; import GridSection from '../commons/grid-section'; diff --git a/src/components/dialogs/short-circuit/short-circuit-form.tsx b/src/components/dialogs/short-circuit/short-circuit-form.tsx index def916e8cb..cc31148548 100644 --- a/src/components/dialogs/short-circuit/short-circuit-form.tsx +++ b/src/components/dialogs/short-circuit/short-circuit-form.tsx @@ -6,9 +6,8 @@ */ import GridItem from '../commons/grid-item'; import { Grid } from '@mui/material'; -import { FloatInput } from '@gridsuite/commons-ui'; +import { FloatInput, OhmAdornment } from '@gridsuite/commons-ui'; import { TRANSFORMER_REACTANCE, TRANSIENT_REACTANCE } from '../../utils/field-constants'; -import { OhmAdornment } from '../dialog-utils'; import { ShortCircuitInfos } from './short-circuit.type'; export interface ShortCircuitFormProps { diff --git a/src/components/dialogs/voltage-regulation/voltage-regulation-form.tsx b/src/components/dialogs/voltage-regulation/voltage-regulation-form.tsx index a735098bd6..b9675f5624 100644 --- a/src/components/dialogs/voltage-regulation/voltage-regulation-form.tsx +++ b/src/components/dialogs/voltage-regulation/voltage-regulation-form.tsx @@ -5,11 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FloatInput, Identifiable, SelectInput } from '@gridsuite/commons-ui'; +import { FloatInput, Identifiable, percentageTextField, SelectInput, VoltageAdornment } from '@gridsuite/commons-ui'; import { REGULATION_TYPES } from 'components/network/constants'; import { Q_PERCENT, VOLTAGE_REGULATION_TYPE, VOLTAGE_SET_POINT } from 'components/utils/field-constants'; import { useMemo } from 'react'; -import { percentageTextField, VoltageAdornment } from '../dialog-utils'; import { RegulatingTerminalForm } from '../regulating-terminal/regulating-terminal-form'; import { Box, Grid } from '@mui/material'; import { FormattedMessage, useIntl } from 'react-intl'; diff --git a/src/components/graph/menus/network-modifications/network-modification-menu.type.ts b/src/components/graph/menus/network-modifications/network-modification-menu.type.ts index 5c851d9440..5c84ac90f7 100644 --- a/src/components/graph/menus/network-modifications/network-modification-menu.type.ts +++ b/src/components/graph/menus/network-modifications/network-modification-menu.type.ts @@ -7,8 +7,8 @@ import type { UUID } from 'node:crypto'; import { CurrentTreeNode } from '../../tree-node.type'; -import { FetchStatus } from '../../../../services/utils.type'; import { JSX } from 'react'; +import { FetchStatus } from '@gridsuite/commons-ui'; export interface RootNetworkMetadata { rootNetworkUuid: UUID; @@ -73,12 +73,6 @@ export interface MenuDefinitionWithoutSubItem extends MenuDefinitionBase { export type MenuDefinition = MenuDefinitionWithSubItem | MenuDefinitionWithoutSubItem; -export interface NetworkModificationData { - uuid: UUID; - type: string; - [key: string]: any; -} - export interface MenuSection { id: string; label?: string; diff --git a/src/components/graph/menus/network-modifications/network-modification-node-dialog.tsx b/src/components/graph/menus/network-modifications/network-modification-node-dialog.tsx index 25413b3bc6..6529aa05c5 100644 --- a/src/components/graph/menus/network-modifications/network-modification-node-dialog.tsx +++ b/src/components/graph/menus/network-modifications/network-modification-node-dialog.tsx @@ -9,6 +9,7 @@ import { CustomFormProvider, DescriptionField, isObjectEmpty, + ModificationDialog, snackWithFallback, useSnackMessage, } from '@gridsuite/commons-ui'; @@ -18,7 +19,6 @@ import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import { UniqueCheckNameInput } from 'components/graph/menus/unique-check-name-input'; import { isNodeExists } from 'services/study'; import { NAME, DESCRIPTION } from 'components/utils/field-constants'; diff --git a/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx b/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx index a5b389d82f..e0b73cc6d7 100644 --- a/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx +++ b/src/components/graph/menus/network-modifications/network-modification-node-editor.tsx @@ -8,14 +8,20 @@ import { ElementSaveDialog, ElementType, + FetchStatus, IElementCreationDialog, IElementUpdateDialog, MODIFICATION_TYPES, + NetworkModificationData, ModificationType, NetworkModificationMetadata, + PARAM_LANGUAGE, + removeNullFields, snackWithFallback, + SubstationCreationDialog, usePrevious, useSnackMessage, + fetchNetworkModification, } from '@gridsuite/commons-ui'; import AddIcon from '@mui/icons-material/Add'; import ContentCopyIcon from '@mui/icons-material/ContentCopy'; @@ -45,7 +51,6 @@ import { LoadCreationDialog } from '../../../dialogs/network-modifications/load/ import LoadModificationDialog from 'components/dialogs/network-modifications/load/modification/load-modification-dialog'; import ShuntCompensatorCreationDialog from 'components/dialogs/network-modifications/shunt-compensator/creation/shunt-compensator-creation-dialog'; import ShuntCompensatorModificationDialog from 'components/dialogs/network-modifications/shunt-compensator/modification/shunt-compensator-modification-dialog'; -import SubstationCreationDialog from 'components/dialogs/network-modifications/substation/creation/substation-creation-dialog'; import SubstationModificationDialog from 'components/dialogs/network-modifications/substation/modification/substation-modification-dialog'; import { TabularModificationType } from 'components/dialogs/network-modifications/tabular/tabular-common'; import { TabularDialog } from 'components/dialogs/network-modifications/tabular/tabular-dialog'; @@ -69,7 +74,6 @@ import RestoreModificationDialog from 'components/dialogs/restore-modification-d import type { UUID } from 'node:crypto'; import { AppState } from 'redux/reducer'; import { createCompositeModifications, updateCompositeModifications } from '../../../../services/explore'; -import { fetchNetworkModification } from '../../../../services/network-modification'; import { copyOrMoveModifications } from '../../../../services/study'; import { changeNetworkModificationOrder, @@ -77,7 +81,6 @@ import { fetchNetworkModifications, stashModifications, } from '../../../../services/study/network-modifications'; -import { FetchStatus } from '../../../../services/utils'; import { ExcludedNetworkModifications, MenuDefinitionSubItem, @@ -85,7 +88,6 @@ import { MenuSection, NetworkModificationCopyInfos, NetworkModificationCopyType, - NetworkModificationData, } from './network-modification-menu.type'; import StaticVarCompensatorCreationDialog from '../../../dialogs/network-modifications/static-var-compensator/creation/static-var-compensator-creation-dialog'; import ModificationByAssignmentDialog from '../../../dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-dialog'; @@ -95,6 +97,7 @@ import { LccCreationDialog } from '../../../dialogs/network-modifications/hvdc-l import { styles } from './network-modification-node-editor-utils'; import NetworkModificationsTable from './network-modifications-table'; import { CellClickedEvent, RowDragEndEvent, RowDragEnterEvent } from 'ag-grid-community'; +import { useStudyContext } from '../../../../hooks/use-study-context'; import { isModificationsDeleteFinishedNotification, isModificationsUpdateFinishedNotification, @@ -115,6 +118,7 @@ import CreateVoltageLevelTopologyDialog from '../../../dialogs/network-modificat import { NodeType } from 'components/graph/tree-node.type'; import { LimitSetsModificationDialog } from '../../../dialogs/network-modifications/limit-sets/limit-sets-modification-dialog'; import { EQUIPMENT_TYPES } from '../../../utils/equipment-types'; +import { useParameterState } from '../../../dialogs/parameters/use-parameters-state'; import CreateVoltageLevelSectionDialog from '../../../dialogs/network-modifications/voltage-level/section/create-voltage-level-section-dialog'; import MoveVoltageLevelFeederBaysDialog from '../../../dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-dialog'; import { useCopiedNetworkModifications } from 'hooks/copy-paste/use-copied-network-modifications'; @@ -149,6 +153,7 @@ const NetworkModificationNodeEditor = () => { const currentNode = useSelector((state: AppState) => state.currentTreeNode); const isRootNode = currentNode?.type === NodeType.ROOT; const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); + const [languageLocal] = useParameterState(PARAM_LANGUAGE); const currentNodeIdRef = useRef(null); // initial empty to get first update const [pendingState, setPendingState] = useState(false); @@ -177,6 +182,8 @@ const NetworkModificationNodeEditor = () => { const copyInfosRef = useRef(null); copyInfosRef.current = copyInfos; + const studyContext = useStudyContext(); + useEffect(() => { //If the tab is closed we want to invalidate the copy on all tabs because we won't able to track the node modification window.addEventListener('beforeunload', () => { @@ -210,6 +217,21 @@ const NetworkModificationNodeEditor = () => { editData={editData} isUpdate={isUpdate} editDataFetchStatus={editDataFetchStatus} + language={languageLocal} + /> + ); + } + + function modificationWithStudyContext(Dialog: React.FC) { + return ( + ); } @@ -268,7 +290,7 @@ const NetworkModificationNodeEditor = () => { { id: MODIFICATION_TYPES.SUBSTATION_CREATION.type, label: 'menu.create', - action: () => withDefaultParams(SubstationCreationDialog), + action: () => modificationWithStudyContext(SubstationCreationDialog), }, { id: MODIFICATION_TYPES.SUBSTATION_MODIFICATION.type, @@ -1012,22 +1034,6 @@ const NetworkModificationNodeEditor = () => { } }, [copyInfos, studyUuid, currentNode?.id, networkModificationsToCopy, cleanClipboard, snackError]); - const removeNullFields = useCallback((data: NetworkModificationData) => { - let dataTemp = data; - if (dataTemp) { - Object.keys(dataTemp).forEach((key) => { - if (dataTemp[key] && dataTemp[key] !== null && typeof dataTemp[key] === 'object') { - dataTemp[key] = removeNullFields(dataTemp[key]); - } - - if (dataTemp[key] === null) { - delete dataTemp[key]; - } - }); - } - return dataTemp; - }, []); - const doEditModification = useCallback( (modificationUuid: UUID, modificationType: ModificationType) => { setIsUpdate(true); @@ -1046,11 +1052,13 @@ const NetworkModificationNodeEditor = () => { }); }) .catch((error) => { - snackWithFallback(snackError, error); + snackWithFallback(snackError, error, { + headerId: 'ModificationReadError', + }); setEditDataFetchStatus(FetchStatus.FAILED); }); }, - [removeNullFields, snackError] + [snackError] ); const onItemClick = (id: string) => { diff --git a/src/components/graph/menus/node-name-edit-dialog.tsx b/src/components/graph/menus/node-name-edit-dialog.tsx index e8ecc50dd7..c629113fd8 100644 --- a/src/components/graph/menus/node-name-edit-dialog.tsx +++ b/src/components/graph/menus/node-name-edit-dialog.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomFormProvider, isObjectEmpty } from '@gridsuite/commons-ui'; +import { CustomFormProvider, isObjectEmpty, ModificationDialog } from '@gridsuite/commons-ui'; import { useCallback, useEffect } from 'react'; import { Grid } from '@mui/material'; import { NAME } from '../../utils/field-constants'; @@ -16,7 +16,6 @@ import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; import { UniqueCheckNameInput } from 'components/graph/menus/unique-check-name-input'; import { isNodeExists } from 'services/study'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; export interface FormData { [NAME]: string; diff --git a/src/components/graph/nodes/network-modification-node.tsx b/src/components/graph/nodes/network-modification-node.tsx index 244e8eb802..27ede2ce7e 100644 --- a/src/components/graph/nodes/network-modification-node.tsx +++ b/src/components/graph/nodes/network-modification-node.tsx @@ -9,7 +9,7 @@ import { NodeProps, Position } from '@xyflow/react'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; import { useSelector } from 'react-redux'; import Box from '@mui/material/Box'; -import { copyToClipboard, LIGHT_THEME, type MuiStyles, useSnackMessage } from '@gridsuite/commons-ui'; +import { copyToClipboard, LIGHT_THEME, type MuiStyles, TOOLTIP_DELAY, useSnackMessage } from '@gridsuite/commons-ui'; import { getLocalStorageTheme } from '../../../redux/session-storage/local-storage'; import { BUILD_STATUS } from '../../network/constants'; import { AppState } from 'redux/reducer'; @@ -24,7 +24,6 @@ import { BuildButton } from './build-button'; import { Tooltip, Typography } from '@mui/material'; import { useIntl } from 'react-intl'; import { useCallback, useMemo } from 'react'; -import { TOOLTIP_DELAY } from 'utils/UIconstants'; import ForwardRefBox from 'components/utils/forwardRefBox'; import ContentCopyIcon from '@mui/icons-material/ContentCopy'; diff --git a/src/components/graph/util/tree-control-button.tsx b/src/components/graph/util/tree-control-button.tsx index 823c711755..dfb16758cf 100644 --- a/src/components/graph/util/tree-control-button.tsx +++ b/src/components/graph/util/tree-control-button.tsx @@ -9,7 +9,7 @@ import { Tooltip } from '@mui/material'; import React from 'react'; import { ControlButton } from '@xyflow/react'; import { useIntl } from 'react-intl'; -import { TOOLTIP_DELAY } from '../../../utils/UIconstants'; +import { TOOLTIP_DELAY } from '@gridsuite/commons-ui'; const TreeControlButton = ({ onClick, diff --git a/src/components/grid-layout/cards/diagrams/networkAreaDiagram/diagram-controls.tsx b/src/components/grid-layout/cards/diagrams/networkAreaDiagram/diagram-controls.tsx index 3946a528c6..c030638401 100644 --- a/src/components/grid-layout/cards/diagrams/networkAreaDiagram/diagram-controls.tsx +++ b/src/components/grid-layout/cards/diagrams/networkAreaDiagram/diagram-controls.tsx @@ -6,7 +6,6 @@ */ import { useCallback, useState } from 'react'; -import { useSelector } from 'react-redux'; import Box from '@mui/material/Box'; import Divider from '@mui/material/Divider'; import { @@ -15,7 +14,10 @@ import { ElementSaveDialog, ElementType, type EquipmentInfos, + EquipmentInfosTypes, + EquipmentSearchDialog, EquipmentType, + fetchNetworkElementInfos, type IElementCreationDialog, type IElementUpdateDialog, type MuiStyles, @@ -31,14 +33,12 @@ import SpeakerNotesOutlinedIcon from '@mui/icons-material/SpeakerNotesOutlined'; import SearchIcon from '@mui/icons-material/Search'; import AddLocationAltOutlinedIcon from '@mui/icons-material/AddLocationAltOutlined'; import { Tooltip } from '@mui/material'; -import { AppState } from 'redux/reducer'; import { FormattedMessage, useIntl } from 'react-intl'; import type { UUID } from 'node:crypto'; import { AddLocationOutlined } from '@mui/icons-material'; -import EquipmentSearchDialog from 'components/dialogs/equipment-search-dialog'; -import { fetchNetworkElementInfos } from 'services/study/network'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from 'components/utils/equipment-types'; +import { EQUIPMENT_TYPES } from 'components/utils/equipment-types'; import VoltageLevelSearchMenu from './voltage-level-search-menu'; +import { useStudyContext } from '../../../../../hooks/use-study-context'; const styles = { actionIcon: (theme) => ({ @@ -111,9 +111,7 @@ const DiagramControls: React.FC = ({ const [isSaveDialogOpen, setIsSaveDialogOpen] = useState(false); const [isLoadSelectorOpen, setIsLoadSelectorOpen] = useState(false); const [isFilterSelectorOpen, setIsFilterSelectorOpen] = useState(false); - const studyUuid = useSelector((state: AppState) => state.studyUuid); - const currentNodeUuid = useSelector((state: AppState) => state.currentTreeNode?.id ?? null); - const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); + const studyContext = useStudyContext(); const handleCloseSaveDialog = () => { setIsSaveDialogOpen(false); @@ -219,16 +217,16 @@ const DiagramControls: React.FC = ({ const onSelectionChange = useCallback( (equipment: EquipmentInfos) => { handleCloseSearchDialog(); - if (!currentNodeUuid || !currentRootNetworkUuid) { + if (!studyContext) { return; } fetchNetworkElementInfos( - studyUuid, - currentNodeUuid, - currentRootNetworkUuid, + studyContext.studyId, + studyContext.nodeId, + studyContext.rootNetworkId, equipment.type, - EQUIPMENT_INFOS_TYPES.LIST.type, - equipment.id, + EquipmentInfosTypes.LIST, + equipment.id as UUID, false ) .then(() => { @@ -241,10 +239,10 @@ const DiagramControls: React.FC = ({ }); }); }, - [handleCloseSearchDialog, currentNodeUuid, currentRootNetworkUuid, studyUuid, onAddVoltageLevel, snackWarning] + [handleCloseSearchDialog, onAddVoltageLevel, snackWarning, studyContext] ); function renderSearchEquipment() { - if (!currentRootNetworkUuid || !currentNodeUuid) { + if (!studyContext) { return; } return ( @@ -253,8 +251,7 @@ const DiagramControls: React.FC = ({ onClose={handleCloseSearchDialog} equipmentType={EquipmentType.VOLTAGE_LEVEL} onSelectionChange={onSelectionChange} - currentNodeUuid={currentNodeUuid} - currentRootNetworkUuid={currentRootNetworkUuid} + studyContext={studyContext} /> ); } @@ -353,11 +350,11 @@ const DiagramControls: React.FC = ({ - {studyUuid && ( + {studyContext && ( <> {isSaveDialogOpen && ( { diff --git a/src/components/menus/bus-menu.tsx b/src/components/menus/bus-menu.tsx index 08cc411566..ef2538f536 100644 --- a/src/components/menus/bus-menu.tsx +++ b/src/components/menus/bus-menu.tsx @@ -14,7 +14,7 @@ import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; import { useIsAnyNodeBuilding } from 'components/utils/is-any-node-building-hook'; import { RunningStatus } from 'components/utils/running-status'; -import { convertToEquipmentType, EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../utils/equipment-types'; +import { convertToEquipmentType, EQUIPMENT_TYPES } from '../utils/equipment-types'; import { getEventType } from '../dialogs/dynamicsimulation/event/model/event.model'; import DynamicSimulationEventMenuItem from './dynamic-simulation/dynamic-simulation-event-menu-item'; import { useOptionalServiceStatus } from '../../hooks/use-optional-service-status'; @@ -24,13 +24,15 @@ import { tripEquipment } from '../../services/study/network-modifications'; import { ComputingType, CustomMenuItem, - type EquipmentType, + EquipmentInfosTypes, + EquipmentType, + fetchNetworkElementInfos, type MuiStyles, PARAM_DEVELOPER_MODE, snackWithFallback, useSnackMessage, } from '@gridsuite/commons-ui'; -import { fetchNetworkElementInfos } from '../../services/study/network'; +import { UUID } from 'node:crypto'; import { useParameterState } from 'components/dialogs/parameters/use-parameters-state'; interface BusMenuProps { @@ -93,9 +95,9 @@ export const BusMenu: FunctionComponent = ({ studyUuid, currentNode?.id, currentRootNetworkUuid, - EQUIPMENT_TYPES.BUSBAR_SECTION, - EQUIPMENT_INFOS_TYPES.OPERATING_STATUS.type, - busId, + EquipmentType.BUSBAR_SECTION, + EquipmentInfosTypes.OPERATING_STATUS, + busId as UUID, false ).then((value: EquipmentInfo | null) => { if (value) { diff --git a/src/components/menus/operating-status-menu.tsx b/src/components/menus/operating-status-menu.tsx index 4803e3df66..777654e862 100644 --- a/src/components/menus/operating-status-menu.tsx +++ b/src/components/menus/operating-status-menu.tsx @@ -29,18 +29,18 @@ import { snackWithFallback, useSnackMessage, PARAM_DEVELOPER_MODE, + fetchNetworkElementInfos, + EquipmentInfosTypes, } from '@gridsuite/commons-ui'; import { isNodeBuilt, isNodeReadOnly } from '../graph/util/model-functions'; import { useIsAnyNodeBuilding } from '../utils/is-any-node-building-hook'; import { BRANCH_SIDE } from '../network/constants'; -import { EQUIPMENT_INFOS_TYPES } from '../utils/equipment-types'; import { energiseEquipmentEnd, lockoutEquipment, switchOnEquipment, tripEquipment, } from '../../services/study/network-modifications'; -import { fetchNetworkElementInfos } from '../../services/study/network'; import { getEventType } from '../dialogs/dynamicsimulation/event/model/event.model'; import { EQUIPMENT_TYPE_LABEL_KEYS } from '../graph/util/model-constants'; import DynamicSimulationEventMenuItem from './dynamic-simulation/dynamic-simulation-event-menu-item'; @@ -120,8 +120,8 @@ const withOperatingStatusMenu = currentNode?.id, currentRootNetworkUuid, equipmentType, - EQUIPMENT_INFOS_TYPES.OPERATING_STATUS.type, - equipment.id, + EquipmentInfosTypes.OPERATING_STATUS, + equipment.id as UUID, false ).then((value) => { if (value) { diff --git a/src/components/network/constants.ts b/src/components/network/constants.ts index b5e52cf3d2..ae770c7789 100644 --- a/src/components/network/constants.ts +++ b/src/components/network/constants.ts @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const FORM_LOADING_DELAY = 200; export const RESULTS_LOADING_DELAY = 500; // Relevant LoadType Powsybl enum values diff --git a/src/components/network/network-map-panel.tsx b/src/components/network/network-map-panel.tsx index 537d5177b9..7372eab86f 100644 --- a/src/components/network/network-map-panel.tsx +++ b/src/components/network/network-map-panel.tsx @@ -41,6 +41,7 @@ import { type MuiStyles, NotificationsUrlKeys, snackWithFallback, + StudyContext, useNotificationsListener, useSnackMessage, useStateBoolean, @@ -156,6 +157,17 @@ export const NetworkMapPanel = memo(function NetworkMapPanel({ return rootNode?.id; }, [treeModel]); + const studyContext: StudyContext | undefined = useMemo(() => { + if (studyUuid && currentNode.id && currentRootNetworkUuid) { + return { + studyId: studyUuid, + nodeId: currentNode.id, + rootNetworkId: currentRootNetworkUuid, + useNameParam: useName, + }; + } + }, [currentNode.id, currentRootNetworkUuid, studyUuid, useName]); + const dispatch = useDispatch(); const { showInSpreadsheet, openSLD } = useWorkspacePanelActions(); @@ -1222,12 +1234,13 @@ export const NetworkMapPanel = memo(function NetworkMapPanel({ {choiceVoltageLevelsSubstationId && renderVoltageLevelChoice()} )} - {studyUuid && ( + {studyContext && ( )} diff --git a/src/components/network/selection-creation-panel/selection-creation-panel-form.tsx b/src/components/network/selection-creation-panel/selection-creation-panel-form.tsx index c532622e02..b2db6f76fc 100644 --- a/src/components/network/selection-creation-panel/selection-creation-panel-form.tsx +++ b/src/components/network/selection-creation-panel/selection-creation-panel-form.tsx @@ -4,7 +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 { SelectInput, TextInput } from '@gridsuite/commons-ui'; +import { Nullable, SelectInput, TextInput } from '@gridsuite/commons-ui'; import { Grid } from '@mui/material'; import { NAME, SELECTION_TYPE } from 'components/utils/field-constants'; @@ -13,7 +13,6 @@ import { useWatch } from 'react-hook-form'; import { ContingencyFilterCreationFields } from './contingency-filter-creation/contingency-filter-creation-fields'; import { SELECTION_TYPES, selectionTypeToLabel } from './selection-types'; import { SelectionCreationPaneFields } from './selection-creation-schema'; -import { Nullable } from 'components/utils/ts-utils'; import GridSection from '../../dialogs/commons/grid-section'; interface SelectionCreationPanelFormProps { diff --git a/src/components/network/selection-creation-panel/selection-creation-panel-submit-button.tsx b/src/components/network/selection-creation-panel/selection-creation-panel-submit-button.tsx index f6a3643919..01b1a55492 100644 --- a/src/components/network/selection-creation-panel/selection-creation-panel-submit-button.tsx +++ b/src/components/network/selection-creation-panel/selection-creation-panel-submit-button.tsx @@ -10,7 +10,7 @@ import { useFormContext, useWatch } from 'react-hook-form'; import { FormattedMessage } from 'react-intl'; import { SELECTION_TYPES } from './selection-types'; import { SelectionCreationPaneFields } from './selection-creation-schema'; -import { Nullable } from 'components/utils/ts-utils'; +import { Nullable } from '@gridsuite/commons-ui'; interface SelectionCreationPanelSubmitButtonProps { handleValidate: (formData: SelectionCreationPaneFields) => void; diff --git a/src/components/network/selection-creation-panel/selection-creation-panel.tsx b/src/components/network/selection-creation-panel/selection-creation-panel.tsx index 17a07a8a84..b55931bbfd 100644 --- a/src/components/network/selection-creation-panel/selection-creation-panel.tsx +++ b/src/components/network/selection-creation-panel/selection-creation-panel.tsx @@ -13,6 +13,7 @@ import { EquipmentType, fetchDirectoryElementPath, Identifiable, + Nullable, } from '@gridsuite/commons-ui'; import { yupResolver } from '@hookform/resolvers/yup'; import { useForm } from 'react-hook-form'; @@ -29,7 +30,6 @@ import { useSelector } from 'react-redux'; import { useSaveMap } from './use-save-map'; import { SelectionCreationPanelSubmitButton } from './selection-creation-panel-submit-button'; import { SELECTION_TYPES } from './selection-types'; -import { Nullable } from 'components/utils/ts-utils'; import { AppState } from 'redux/reducer'; import { SelectionCreationPanelForm } from './selection-creation-panel-form'; import { diff --git a/src/components/results/sensitivity-analysis/sensitivity-analysis-result.tsx b/src/components/results/sensitivity-analysis/sensitivity-analysis-result.tsx index c45ee72d3b..82f6afc46f 100644 --- a/src/components/results/sensitivity-analysis/sensitivity-analysis-result.tsx +++ b/src/components/results/sensitivity-analysis/sensitivity-analysis-result.tsx @@ -7,10 +7,15 @@ import { useIntl } from 'react-intl'; import { useCallback, useMemo, useRef } from 'react'; -import { TOOLTIP_DELAY } from 'utils/UIconstants'; import { getNoRowsMessage, getRows, useIntlResultStatusMessages } from '../../utils/aggrid-rows-handler'; import { useSelector } from 'react-redux'; -import { ComputingType, CustomAGGrid, CustomAGGridProps, DefaultCellRenderer } from '@gridsuite/commons-ui'; +import { + ComputingType, + CustomAGGrid, + CustomAGGridProps, + DefaultCellRenderer, + TOOLTIP_DELAY, +} from '@gridsuite/commons-ui'; import { useOpenLoaderShortWait } from '../../dialogs/commons/handle-loader'; import { RunningStatus } from '../../utils/running-status'; import { RESULTS_LOADING_DELAY } from '../../network/constants'; diff --git a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-empty-spreadsheet-dialog.tsx b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-empty-spreadsheet-dialog.tsx index e72adae0a3..e7134fefc7 100644 --- a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-empty-spreadsheet-dialog.tsx +++ b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-empty-spreadsheet-dialog.tsx @@ -7,7 +7,14 @@ import { useCallback, useEffect, useMemo } from 'react'; import { Grid } from '@mui/material'; -import { CustomFormProvider, SelectInput, TextInput, useSnackMessage } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + ModificationDialog, + ModificationDialogProps, + SelectInput, + TextInput, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { useDispatch, useSelector } from 'react-redux'; @@ -15,7 +22,6 @@ import { EQUIPMENT_TYPE_FIELD } from 'components/utils/field-constants'; import { AppState } from 'redux/reducer'; import type { UUID } from 'node:crypto'; import { dialogStyles } from '../styles/styles'; -import { ModificationDialog, type ModificationDialogProps } from 'components/dialogs/commons/modificationDialog'; import { type EmptySpreadsheetForm, getEmptySpreadsheetFormSchema, diff --git a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheet-from-model-dialog.tsx b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheet-from-model-dialog.tsx index 02c5d5014a..dc03da3044 100644 --- a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheet-from-model-dialog.tsx +++ b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheet-from-model-dialog.tsx @@ -11,6 +11,7 @@ import { CustomFormProvider, DirectoryItemsInput, ElementType, + ModificationDialog, snackWithFallback, TextInput, useSnackMessage, @@ -28,7 +29,6 @@ import { import { addNewSpreadsheet } from './add-spreadsheet-utils'; import { getSpreadsheetModel } from 'services/study-config'; import type { UUID } from 'node:crypto'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import { dialogStyles } from '../styles/styles'; import type { DialogComponentProps } from '../types'; import { useNodeAliases } from '../../hooks/use-node-aliases'; diff --git a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheets-from-collection-dialog.tsx b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheets-from-collection-dialog.tsx index 80622138e8..4bf9ab78bc 100644 --- a/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheets-from-collection-dialog.tsx +++ b/src/components/spreadsheet-view/add-spreadsheet/dialogs/add-spreadsheets-from-collection-dialog.tsx @@ -11,6 +11,7 @@ import { CustomFormProvider, DirectoryItemsInput, ElementType, + ModificationDialog, PopupConfirmationDialog, RadioInput, snackWithFallback, @@ -24,7 +25,6 @@ import { useIntl } from 'react-intl'; import { updateStudySpreadsheetConfigCollection } from 'services/study/study-config'; import { initTableDefinitions } from 'redux/actions'; import type { UUID } from 'node:crypto'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import { dialogStyles } from '../styles/styles'; import { SpreadsheetCollectionDto } from 'components/spreadsheet-view/types/spreadsheet.type'; import { diff --git a/src/components/spreadsheet-view/hooks/use-fetch-equipment.ts b/src/components/spreadsheet-view/hooks/use-fetch-equipment.ts index eedda319d9..0e19bf37b9 100644 --- a/src/components/spreadsheet-view/hooks/use-fetch-equipment.ts +++ b/src/components/spreadsheet-view/hooks/use-fetch-equipment.ts @@ -11,10 +11,9 @@ import type { UUID } from 'node:crypto'; import { useDispatch, useSelector } from 'react-redux'; import { type AppState } from '../../../redux/reducer'; import { loadEquipments, setSpreadsheetFetching } from '../../../redux/actions'; -import { snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { EquipmentInfosTypes, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; import { fetchNetworkElementsInfos } from '../../../services/study/network'; import { mapSpreadsheetEquipments } from '../../../utils/spreadsheet-equipments-mapper'; -import { EQUIPMENT_INFOS_TYPES } from '../../utils/equipment-types'; export function useFetchEquipment() { const dispatch = useDispatch(); @@ -36,7 +35,7 @@ export function useFetchEquipment() { currentRootNetworkUuid, [], type, - EQUIPMENT_INFOS_TYPES.TAB.type + EquipmentInfosTypes.TAB ); fetcherPromises.push(promise); promise diff --git a/src/components/spreadsheet-view/spreadsheet-tabs/rename-tab-dialog.tsx b/src/components/spreadsheet-view/spreadsheet-tabs/rename-tab-dialog.tsx index 22d805a896..44edb6f8e4 100644 --- a/src/components/spreadsheet-view/spreadsheet-tabs/rename-tab-dialog.tsx +++ b/src/components/spreadsheet-view/spreadsheet-tabs/rename-tab-dialog.tsx @@ -8,13 +8,12 @@ import React from 'react'; import { useIntl } from 'react-intl'; import { Grid } from '@mui/material'; -import { CustomFormProvider, TextInput } from '@gridsuite/commons-ui'; +import { CustomFormProvider, ModificationDialog, TextInput } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import * as yup from 'yup'; import { SpreadsheetTabDefinition } from '../types/spreadsheet.type'; import type { UUID } from 'node:crypto'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; interface RenameTabDialogProps { open: boolean; diff --git a/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/hooks/use-equipment-modification.tsx b/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/hooks/use-equipment-modification.tsx index 678544021b..adc5f04fad 100644 --- a/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/hooks/use-equipment-modification.tsx +++ b/src/components/spreadsheet-view/spreadsheet/spreadsheet-content/hooks/use-equipment-modification.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { FetchStatus } from '@gridsuite/commons-ui'; +import { FetchStatus, PARAM_LANGUAGE } from '@gridsuite/commons-ui'; import BatteryModificationDialog from 'components/dialogs/network-modifications/battery/modification/battery-modification-dialog'; import GeneratorModificationDialog from 'components/dialogs/network-modifications/generator/modification/generator-modification-dialog'; import LineModificationDialog from 'components/dialogs/network-modifications/line/modification/line-modification-dialog'; @@ -18,6 +18,7 @@ import { type FunctionComponent, type ReactElement, useCallback, useMemo, useSta import { useSelector } from 'react-redux'; import { type AppState } from 'redux/reducer'; import { type EditableEquipmentType, SpreadsheetEquipmentType } from '../../../types/spreadsheet.type'; +import { useParameterState } from 'components/dialogs/parameters/use-parameters-state'; export type UseEquipmentModificationProps = { equipmentType: SpreadsheetEquipmentType; @@ -40,7 +41,7 @@ function isEditableEquipmentType(type: SpreadsheetEquipmentType): type is Editab export function useEquipmentModification({ equipmentType }: Readonly) { const [modificationDialog, setModificationDialog] = useState(null); - + const [languageLocal] = useParameterState(PARAM_LANGUAGE); const currentNode = useSelector((state: AppState) => state.currentTreeNode); const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); const studyUuid = useSelector((state: AppState) => state.studyUuid); @@ -56,9 +57,10 @@ export function useEquipmentModification({ equipmentType }: Readonly ), - [currentNode, studyUuid, currentRootNetworkUuid] + [currentNode, studyUuid, currentRootNetworkUuid, languageLocal] ); const getDialogForEquipment = useCallback( diff --git a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/formula-search-replace.tsx b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/formula-search-replace.tsx index aeda12f9a4..5c0b623df7 100644 --- a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/formula-search-replace.tsx +++ b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/formula-search-replace.tsx @@ -10,10 +10,10 @@ import FindReplaceIcon from '@mui/icons-material/FindReplace'; import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'; import { useIntl } from 'react-intl'; import { useFormContext } from 'react-hook-form'; -import { useButtonWithTooltip } from '../../../../utils/inputs/input-hooks'; import { COLUMNS_MODEL, COLUMN_FORMULA } from './spreadsheet-model-global-editor.utils'; import { QuickSearch } from 'components/report-viewer/QuickSearch'; import { useFormulaSearch } from './formula-search-context'; +import { useButtonWithTooltip } from '@gridsuite/commons-ui'; export default function FormulaSearchReplace() { const intl = useIntl(); diff --git a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/spreadsheet-model-global-editor-dialog.tsx b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/spreadsheet-model-global-editor-dialog.tsx index 9a324bf343..ccc2d7448e 100644 --- a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/spreadsheet-model-global-editor-dialog.tsx +++ b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/global-model-editor/spreadsheet-model-global-editor-dialog.tsx @@ -7,10 +7,14 @@ import { useEffect } from 'react'; import { Grid } from '@mui/material'; -import { CustomFormProvider, type MuiStyles, type UseStateBooleanReturn } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + ModificationDialog, + type MuiStyles, + type UseStateBooleanReturn, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import { SpreadsheetModelGlobalEditorTable } from './spreadsheet-model-global-editor-table'; import FormulaSearchReplace from './formula-search-replace'; import { FormulaSearchProvider } from './formula-search-context'; diff --git a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/nodes-config/nodes-config-dialog.tsx b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/nodes-config/nodes-config-dialog.tsx index 007c3e6380..f1584feb5a 100644 --- a/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/nodes-config/nodes-config-dialog.tsx +++ b/src/components/spreadsheet-view/spreadsheet/spreadsheet-toolbar/nodes-config/nodes-config-dialog.tsx @@ -7,14 +7,18 @@ import { useEffect, useMemo } from 'react'; import { Grid } from '@mui/material'; -import { CustomFormProvider, type MuiStyles, type UseStateBooleanReturn } from '@gridsuite/commons-ui'; +import { + CustomFormProvider, + ModificationDialog, + type MuiStyles, + type UseStateBooleanReturn, +} from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { useSelector } from 'react-redux'; import { AppState } from 'redux/reducer'; import NodeConfigTable from './node-config-table'; import type { UUID } from 'node:crypto'; -import { ModificationDialog } from 'components/dialogs/commons/modificationDialog'; import { NodeAlias } from '../../../types/node-alias.type'; import { CurrentTreeNode } from '../../../../graph/tree-node.type'; import { initialNodesForm, NODES_ALIASES, NodesForm, nodesFormSchema } from './nodes-config-dialog.utils'; diff --git a/src/components/tooltips/generic-equipment-popover.tsx b/src/components/tooltips/generic-equipment-popover.tsx index 805940de89..e08205fff4 100644 --- a/src/components/tooltips/generic-equipment-popover.tsx +++ b/src/components/tooltips/generic-equipment-popover.tsx @@ -9,9 +9,7 @@ import { useState, useEffect, useCallback, ReactNode } from 'react'; import { Popover, Typography, Card, CardHeader, CardContent } from '@mui/material'; import { useSelector } from 'react-redux'; import { RunningStatus } from '../utils/running-status'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; -import { fetchNetworkElementInfos } from '../../services/study/network'; -import { EquipmentType, useDebounce } from '@gridsuite/commons-ui'; +import { EquipmentInfosTypes, EquipmentType, fetchNetworkElementInfos, useDebounce } from '@gridsuite/commons-ui'; import { AppState } from 'redux/reducer'; import { UUID } from 'node:crypto'; import { GenericEquipmentInfos } from './equipment-popover-type'; @@ -59,8 +57,8 @@ const GenericEquipmentPopover: React.FC = ({ currentNodeId, currentRootNetworkUuid, equipmentType, - EQUIPMENT_INFOS_TYPES.TOOLTIP.type, - equipmentId, + EquipmentInfosTypes.TOOLTIP, + equipmentId as UUID, true ).then((value) => { setEquipmentInfo(value); diff --git a/src/components/tooltips/load/load-popover-content.tsx b/src/components/tooltips/load/load-popover-content.tsx index 0700436cae..bed1487d21 100644 --- a/src/components/tooltips/load/load-popover-content.tsx +++ b/src/components/tooltips/load/load-popover-content.tsx @@ -9,7 +9,7 @@ import { Grid, Table, TableBody, TableContainer, TableRow } from '@mui/material' import { CellRender } from '../cell-render'; import { formatValue, styles } from '../generic-equipment-popover-utils'; import { LoadEquipmentInfos } from '../equipment-popover-type'; -import { getPropertyValue } from 'components/dialogs/network-modifications/common/properties/property-utils'; +import { getPropertyValue } from '@gridsuite/commons-ui'; interface LoadPopoverContentProps { equipmentInfos: LoadEquipmentInfos; } diff --git a/src/components/top-bar-equipment-seach-dialog/top-bar-equipment-search-dialog.tsx b/src/components/top-bar-equipment-seach-dialog/top-bar-equipment-search-dialog.tsx index 96acf5ebc4..9249f05717 100644 --- a/src/components/top-bar-equipment-seach-dialog/top-bar-equipment-search-dialog.tsx +++ b/src/components/top-bar-equipment-seach-dialog/top-bar-equipment-search-dialog.tsx @@ -4,15 +4,17 @@ * 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 { useSelector } from 'react-redux'; -import { AppState } from 'redux/reducer'; + import { ElementSearchDialog, EquipmentInfos, + EquipmentInfosTypes, EquipmentItem, equipmentStyles, EquipmentType, ExtendedEquipmentType, + fetchNetworkElementInfos, + StudyContext, TagRendererProps, useSnackMessage, } from '@gridsuite/commons-ui'; @@ -26,11 +28,11 @@ import { addToLocalStorageSearchEquipmentHistory, excludeElementFromCurrentSearchHistory, } from 'redux/session-storage/search-equipment-history'; -import { fetchNetworkElementInfos } from 'services/study/network'; -import { EQUIPMENT_INFOS_TYPES } from 'components/utils/equipment-types'; import { TopBarEquipmentSearchInput } from './top-bar-equipment-search-input'; +import { UUID } from 'node:crypto'; interface TopBarEquipmentSearchDialogProps { + studyContext: StudyContext; showVoltageLevelDiagram: (element: EquipmentInfos) => void; isDialogSearchOpen: boolean; setIsDialogSearchOpen: React.Dispatch>; @@ -41,6 +43,7 @@ interface TopBarEquipmentSearchDialogProps { export const TopBarEquipmentSearchDialog: FunctionComponent = (props) => { const { + studyContext, isDialogSearchOpen, setIsDialogSearchOpen, showVoltageLevelDiagram, @@ -49,19 +52,10 @@ export const TopBarEquipmentSearchDialog: FunctionComponent state.studyUuid); - const currentNode = useSelector((state: AppState) => state.currentTreeNode); - const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); const [equipmentTypeFilter, setEquipmentTypeFilter] = useState(null); const { searchTerm, updateSearchTerm, equipmentsFound, isLoading } = useTopBarSearchMatchingEquipment({ - // @ts-expect-error TODO: manage null case - studyUuid: studyUuid, - // @ts-expect-error TODO: manage null case - nodeUuid: currentNode?.id, - // @ts-expect-error TODO: manage null case - - currentRootNetworkUuid, + studyContext, equipmentType: equipmentTypeFilter ?? undefined, }); const disabledSearchReason = useDisabledSearchReason(); @@ -82,26 +76,21 @@ export const TopBarEquipmentSearchDialog: FunctionComponent { closeDialog(); updateSearchTerm(''); - // @ts-expect-error TODO: manage null case - addToLocalStorageSearchEquipmentHistory(studyUuid, equipment); + addToLocalStorageSearchEquipmentHistory(studyContext.studyId, equipment); fetchNetworkElementInfos( - studyUuid, - currentNode?.id, - currentRootNetworkUuid, + studyContext.studyId, + studyContext.nodeId, + studyContext.rootNetworkId, equipment.type, - EQUIPMENT_INFOS_TYPES.LIST.type, - equipment.id, + EquipmentInfosTypes.LIST, + equipment.id as UUID, false ) .then(() => { showVoltageLevelDiagram(equipment); }) .catch(() => { - excludeElementFromCurrentSearchHistory( - // @ts-expect-error TODO: manage null case - studyUuid, - equipment - ); + excludeElementFromCurrentSearchHistory(studyContext.studyId, equipment); updateSearchTerm(''); snackWarning({ messageId: 'NetworkEquipmentNotFound', @@ -109,15 +98,7 @@ export const TopBarEquipmentSearchDialog: FunctionComponent { - const { studyUuid, nodeUuid, currentRootNetworkUuid, inUpstreamBuiltParentNode, equipmentType } = props; - - const { getUseNameParameterKey, getNameOrId } = useNameOrId(); - - const fetchElements: (newSearchTerm: string) => Promise = useCallback( - (newSearchTerm) => - searchEquipmentsInfos( - studyUuid, - nodeUuid, - currentRootNetworkUuid, - newSearchTerm, - getUseNameParameterKey, - inUpstreamBuiltParentNode, - equipmentType - ), - [equipmentType, getUseNameParameterKey, inUpstreamBuiltParentNode, nodeUuid, studyUuid, currentRootNetworkUuid] - ); - - const { elementsFound, isLoading, searchTerm, updateSearchTerm } = useElementSearch({ - fetchElements, - }); - - const equipmentsFound = useMemo( - () => getEquipmentsInfosForSearchBar(elementsFound, getNameOrId), - [elementsFound, getNameOrId] - ); - - useEffect(() => { - updateSearchTerm(searchTerm?.trim()); - }, [searchTerm, equipmentType, updateSearchTerm]); - - return { - searchTerm, - updateSearchTerm, - equipmentsFound, - isLoading, - }; -}; diff --git a/src/components/top-bar-equipment-seach-dialog/use-top-bar-search-matching-equipments.tsx b/src/components/top-bar-equipment-seach-dialog/use-top-bar-search-matching-equipments.tsx index 72ac49192c..d52225ec10 100644 --- a/src/components/top-bar-equipment-seach-dialog/use-top-bar-search-matching-equipments.tsx +++ b/src/components/top-bar-equipment-seach-dialog/use-top-bar-search-matching-equipments.tsx @@ -4,25 +4,20 @@ * 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 type { UUID } from 'node:crypto'; -import { useSearchMatchingEquipments } from './use-search-matching-equipments'; + import { useMemo } from 'react'; import { getLocalStorageSearchEquipmentHistory } from 'redux/session-storage/search-equipment-history'; -import { EquipmentType, ExtendedEquipmentType } from '@gridsuite/commons-ui'; +import { EquipmentType, ExtendedEquipmentType, StudyContext, useSearchMatchingEquipments } from '@gridsuite/commons-ui'; interface UseTopBarSearchMatchingEquipmentProps { - studyUuid: UUID; - nodeUuid: UUID; - currentRootNetworkUuid: UUID; + studyContext: StudyContext; equipmentType?: EquipmentType | ExtendedEquipmentType; } export const useTopBarSearchMatchingEquipment = (props: UseTopBarSearchMatchingEquipmentProps) => { - const { nodeUuid, studyUuid, currentRootNetworkUuid, equipmentType } = props; + const { studyContext, equipmentType } = props; const { equipmentsFound, searchTerm, ...otherStates } = useSearchMatchingEquipments({ - studyUuid: studyUuid, - nodeUuid: nodeUuid, - currentRootNetworkUuid: currentRootNetworkUuid, + studyContext: studyContext, equipmentType: equipmentType ?? undefined, }); @@ -31,9 +26,9 @@ export const useTopBarSearchMatchingEquipment = (props: UseTopBarSearchMatchingE if (searchTerm.length > 0 || equipmentType !== undefined) { return equipmentsFound; } else { - return getLocalStorageSearchEquipmentHistory(studyUuid); //elements from localstorage + return getLocalStorageSearchEquipmentHistory(studyContext.studyId); //elements from localstorage } - }, [searchTerm, equipmentType, equipmentsFound, studyUuid]); + }, [searchTerm, equipmentType, equipmentsFound, studyContext.studyId]); return { ...otherStates, diff --git a/src/components/utils/equipment-types.ts b/src/components/utils/equipment-types.ts index 066accbf2d..1549b8e940 100644 --- a/src/components/utils/equipment-types.ts +++ b/src/components/utils/equipment-types.ts @@ -7,20 +7,6 @@ import { EquipmentType, Identifiable } from '@gridsuite/commons-ui'; -type EquipmentInfosTypesStruct = { type: T }; -//TODO: rename to PascalCase -export const EQUIPMENT_INFOS_TYPES: Record = { - LIST: { type: 'LIST' }, - MAP: { type: 'MAP' }, - FORM: { type: 'FORM' }, - TAB: { type: 'TAB' }, - TOOLTIP: { type: 'TOOLTIP' }, - OPERATING_STATUS: { type: 'OPERATING_STATUS' }, -}; -export type EquipmentInfosTypes = EquipmentInfosTypesStruct< - 'LIST' | 'MAP' | 'FORM' | 'TAB' | 'TOOLTIP' | 'OPERATING_STATUS' ->; - //TODO: Compare with commons-ui's EquipmentType enum (not same order) //TODO: rename to PascalCase export enum EQUIPMENT_TYPES { diff --git a/src/components/utils/equipmentInfosHandler.ts b/src/components/utils/equipmentInfosHandler.ts index b8b365839e..c29a231881 100644 --- a/src/components/utils/equipmentInfosHandler.ts +++ b/src/components/utils/equipmentInfosHandler.ts @@ -9,23 +9,19 @@ import { useCallback } from 'react'; import { useSelector } from 'react-redux'; import { PARAM_USE_NAME } from '../../utils/config-params'; import { AppState } from 'redux/reducer'; -import { Identifiable } from '@gridsuite/commons-ui'; +import { getIdentifiableNameOrId, getUseNameKey, Identifiable } from '@gridsuite/commons-ui'; export const useNameOrId = () => { const useName = useSelector((state: AppState) => state[PARAM_USE_NAME]); const getNameOrId = useCallback( (infos?: Identifiable | null) => { - if (infos) { - const name = infos.name; - return useName && name != null && name.trim() !== '' ? name : infos?.id; - } - return ''; + return getIdentifiableNameOrId(useName, infos); }, [useName] ); const getUseNameParameterKey = useCallback(() => { - return useName ? 'name' : 'id'; + return getUseNameKey(useName); }, [useName]); return { getNameOrId, getUseNameParameterKey }; diff --git a/src/components/utils/inputs/input-hooks.tsx b/src/components/utils/inputs/input-hooks.tsx deleted file mode 100644 index 6cc357d181..0000000000 --- a/src/components/utils/inputs/input-hooks.tsx +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2022, 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 React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'; -import { FormattedMessage, useIntl } from 'react-intl'; -import { TextField, Tooltip, Button, Grid, TextFieldProps } from '@mui/material'; -import IconButton from '@mui/material/IconButton'; - -import { styles } from '../../dialogs/dialog-utils'; -import { TOOLTIP_DELAY } from '../../../utils/UIconstants'; -import { useCSVReader } from 'react-papaparse'; -import { LANG_FRENCH } from '@gridsuite/commons-ui'; - -interface UseButtonWithTooltipProps { - handleClick: React.MouseEventHandler; - label: string; - icon: ReactNode; -} - -export const useButtonWithTooltip = ({ handleClick, label, icon }: UseButtonWithTooltipProps) => { - return useMemo(() => { - return ( - } - placement="top" - arrow - enterDelay={TOOLTIP_DELAY} - enterNextDelay={TOOLTIP_DELAY} - slotProps={{ - popper: { - sx: { - '& .MuiTooltip-tooltip': styles.tooltip, - }, - }, - }} - > - - {icon} - - - ); - }, [label, handleClick, icon]); -}; - -interface UseSimpleTextValueProps { - defaultValue: string; - adornment: TextFieldProps['InputProps']; - error: boolean; - triggerReset: boolean; -} - -export const useSimpleTextValue = ({ defaultValue, adornment, error, triggerReset }: UseSimpleTextValueProps) => { - const [value, setValue] = useState(defaultValue); - - const handleChangeValue = useCallback((event: React.ChangeEvent) => { - setValue(event.target.value); - }, []); - - const field = useMemo(() => { - return ( - - ); - }, [value, handleChangeValue, adornment, error]); - - useEffect(() => setValue(defaultValue), [defaultValue, triggerReset]); - - return [value, field] as const; -}; - -interface UseCSVPickerProps { - label: string; - header: string[]; - resetTrigger: boolean; - maxTapNumber?: number; - disabled?: boolean; - language: string; -} - -export const useCSVPicker = ({ - label, - header, - resetTrigger, - maxTapNumber, - disabled = false, - language, -}: UseCSVPickerProps) => { - const intl = useIntl(); - - const { CSVReader } = useCSVReader(); - const [_acceptedFile, setAcceptedFile] = useState(); - const [fileError, setFileError] = useState(); - - const equals = (a: string[], b: string[]) => b.every((item) => a.includes(item)); - - useEffect(() => { - setAcceptedFile(undefined); - setFileError(undefined); - }, [resetTrigger]); - - // Expose a reset function to allow clearing the file manually - const resetFile = useCallback(() => { - setAcceptedFile(undefined); - setFileError(undefined); - }, []); - - const field = useMemo(() => { - return ( - <> - { - setAcceptedFile(acceptedFile); - if (results?.data.length > 0 && equals(header, results.data[0])) { - setFileError(undefined); - } else { - setFileError( - intl.formatMessage({ - id: 'InvalidRuleHeader', - }) - ); - } - - if (maxTapNumber && results.data.length > maxTapNumber) { - setFileError(intl.formatMessage({ id: 'TapPositionValueError' }, { value: maxTapNumber })); - } - }} - > - {({ getRootProps }: { getRootProps: () => any }) => ( - - - - {_acceptedFile - ? _acceptedFile.name - : intl.formatMessage({ - id: 'uploadMessage', - })} - - - )} - - - ); - }, [_acceptedFile, disabled, header, intl, label, maxTapNumber, CSVReader, language]); - - return [_acceptedFile, field, fileError, setAcceptedFile, resetFile] as const; -}; diff --git a/src/components/utils/rhf-inputs/country-selection-input.tsx b/src/components/utils/rhf-inputs/country-selection-input.tsx deleted file mode 100644 index 5955dacdde..0000000000 --- a/src/components/utils/rhf-inputs/country-selection-input.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2023, 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 { AutocompleteInput, AutocompleteInputProps } from '@gridsuite/commons-ui'; -import { useLocalizedCountries } from '../localized-countries-hook'; - -interface CountrySelectionInputProps extends Omit {} - -const CountrySelectionInput = (props: CountrySelectionInputProps) => { - const { translate, countryCodes } = useLocalizedCountries(); - - return ( - translate(countryCode as string)} - {...props} - /> - ); -}; - -export default CountrySelectionInput; diff --git a/src/components/utils/rhf-inputs/expandable-input/deletable-row.tsx b/src/components/utils/rhf-inputs/expandable-input/deletable-row.tsx deleted file mode 100644 index c6e870056e..0000000000 --- a/src/components/utils/rhf-inputs/expandable-input/deletable-row.tsx +++ /dev/null @@ -1,55 +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 { PropsWithChildren, useState } from 'react'; -import { useIntl } from 'react-intl'; -import { Grid, IconButton, Tooltip } from '@mui/material'; -import RestoreFromTrashIcon from '@mui/icons-material/RestoreFromTrash'; -import DeleteIcon from '@mui/icons-material/Delete'; - -export interface DeletableRowProps extends PropsWithChildren { - alignItems: string; - onClick: () => void; - deletionMark?: boolean | null; - disabledDeletion?: boolean | null; -} - -export function DeletableRow({ - alignItems, - onClick, - deletionMark, - disabledDeletion, - children, -}: Readonly) { - const intl = useIntl(); - const [isMouseHover, setIsMouseHover] = useState(false); - - return ( - setIsMouseHover(true)} - onMouseLeave={() => setIsMouseHover(false)} - > - {children} - - {isMouseHover && !disabledDeletion && ( - - - {deletionMark ? : } - - - )} - - - ); -} diff --git a/src/components/utils/rhf-inputs/expandable-input/expandable-input.tsx b/src/components/utils/rhf-inputs/expandable-input/expandable-input.tsx deleted file mode 100644 index 4608dd2193..0000000000 --- a/src/components/utils/rhf-inputs/expandable-input/expandable-input.tsx +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2023, 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 { useFieldArray } from 'react-hook-form'; -import { Button, Grid } from '@mui/material'; -import AddIcon from '@mui/icons-material/ControlPoint'; -import { FormattedMessage } from 'react-intl'; -import { FunctionComponent } from 'react'; -import { styles } from '../../../dialogs/dialog-utils'; -import { ErrorInput, mergeSx, MidFormError } from '@gridsuite/commons-ui'; -import { DeletableRow } from './deletable-row'; - -export interface ExpandableInputProps { - name: string; - Field: React.ComponentType; - fieldProps?: any; - addButtonLabel?: string; - initialValue?: any; - getDeletionMark?: (idx: number) => boolean | null; - deleteCallback?: (idx: number) => boolean | null; - alignItems?: string; - watchProps?: boolean; - disabled?: boolean; - disabledDeletion?: (idx: number) => boolean | null; -} - -// This component is used to display Array of objects. -// We can manage 2 states for deletion: -// - only 1 state and 1 delete icon that removes the current line -// - a second state "mark for deletion" with a second icon: the line is not removed -// and we can cancel this mark to go back to normal state. -export const ExpandableInput: FunctionComponent = ({ - name, - Field, // Used to display each object of an array - fieldProps, // Props to pass to Field - addButtonLabel, - initialValue, // Initial value to display when we add a new entry to array - getDeletionMark = null, - deleteCallback = null, - alignItems = 'stretch', // default value for a flex container - watchProps = true, - disabled = false, - disabledDeletion = null, -}) => { - const { - fields: values, - append, - remove, - } = useFieldArray({ - name: name, - }); - - return ( - - - - - {watchProps && - values.map((value, idx) => ( - { - const shouldRemove = deleteCallback ? deleteCallback(idx) : true; - if (shouldRemove) { - remove(idx); - } - }} - deletionMark={getDeletionMark?.(idx)} - disabledDeletion={disabledDeletion?.(idx)} - > - - - ))} - - - - - ); -}; diff --git a/src/components/utils/rhf-inputs/expandable-input/index.ts b/src/components/utils/rhf-inputs/expandable-input/index.ts deleted file mode 100644 index bb1bb5cc32..0000000000 --- a/src/components/utils/rhf-inputs/expandable-input/index.ts +++ /dev/null @@ -1,8 +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/. - */ - -export * from './expandable-input'; diff --git a/src/components/utils/ts-utils.ts b/src/components/utils/ts-utils.ts deleted file mode 100644 index 22926c9ded..0000000000 --- a/src/components/utils/ts-utils.ts +++ /dev/null @@ -1,18 +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/. - */ -export type Nullable = { [K in keyof T]: T[K] | null }; -export type DeepNullable = { - [K in keyof T]: DeepNullable | null; -}; - -export function notUndefined(value: T | undefined): value is T { - return value !== undefined; -} - -export function notNull(value: T | null): value is T { - return value !== null; -} diff --git a/src/components/voltage-init-result.tsx b/src/components/voltage-init-result.tsx index 5945a6ac7f..781011fc7a 100644 --- a/src/components/voltage-init-result.tsx +++ b/src/components/voltage-init-result.tsx @@ -11,7 +11,14 @@ import { useSelector } from 'react-redux'; import { FormattedMessage, IntlShape, useIntl } from 'react-intl'; import { Box, Button, LinearProgress, Stack, Typography } from '@mui/material'; import { Lens } from '@mui/icons-material'; -import { ComputingType, mergeSx, type MuiStyles, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; +import { + ComputingType, + FetchStatus, + mergeSx, + type MuiStyles, + snackWithFallback, + useSnackMessage, +} from '@gridsuite/commons-ui'; import { cloneVoltageInitModifications, getVoltageInitModifications, @@ -21,7 +28,6 @@ import CircularProgress from '@mui/material/CircularProgress'; import VoltageInitModificationDialog, { EditData, } 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 { useOpenLoaderShortWait } from './dialogs/commons/handle-loader'; import { RESULTS_LOADING_DELAY } from './network/constants'; @@ -185,12 +191,9 @@ export const VoltageInitResult: FunctionComponent = ({ if (voltageInitModification) { return ( setPreviewModificationsDialogOpen(false)} onPreviewModeSubmit={applyModifications} - // @ts-ignore editDataFetchStatus={FetchStatus.IDLE} disabledSave={autoApplyModifications} /> @@ -324,7 +327,7 @@ export const VoltageInitResult: FunctionComponent = ({ } const formatValue = (value: number, precision: number, intl: IntlShape) => { - return isNaN(value) ? intl.formatMessage({ id: 'Undefined' }) : value.toFixed(precision); + return Number.isNaN(value) ? intl.formatMessage({ id: 'Undefined' }) : value.toFixed(precision); }; const busVoltagesColumnDefs = useMemo(() => { diff --git a/src/components/workspace/core/workspace-toolbar.tsx b/src/components/workspace/core/workspace-toolbar.tsx index f2e51ada62..5382f06591 100644 --- a/src/components/workspace/core/workspace-toolbar.tsx +++ b/src/components/workspace/core/workspace-toolbar.tsx @@ -36,6 +36,7 @@ import { useSelector } from 'react-redux'; import { PanelType } from '../types/workspace.types'; import { useWorkspacePanelActions } from '../hooks/use-workspace-panel-actions'; import { selectOpenPanels } from '../../../redux/slices/workspace-selectors'; +import { useStudyContext } from '../../../hooks/use-study-context'; const styles = { container: { @@ -67,6 +68,7 @@ const styles = { export const WorkspaceToolbar = () => { const intl = useIntl(); const { openToolPanel, openSLD, openNAD, deletePanel } = useWorkspacePanelActions(); + const studyContext = useStudyContext(); const [isLoadSelectorOpen, setIsLoadSelectorOpen] = useState(false); const [isDialogSearchOpen, setIsDialogSearchOpen] = useState(false); @@ -254,14 +256,15 @@ export const WorkspaceToolbar = () => { })} multiSelect={false} /> - { + {studyContext && ( - } + )} ); }; diff --git a/src/hooks/use-equipment-dialogs.tsx b/src/hooks/use-equipment-dialogs.tsx index 121a2b063c..4cc14cc0d2 100644 --- a/src/hooks/use-equipment-dialogs.tsx +++ b/src/hooks/use-equipment-dialogs.tsx @@ -6,10 +6,17 @@ */ import { useCallback, useState } from 'react'; -import { EquipmentType, ExtendedEquipmentType, snackWithFallback, useSnackMessage } from '@gridsuite/commons-ui'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES } from '../components/utils/equipment-types'; +import { + EquipmentInfosTypes, + EquipmentType, + ExtendedEquipmentType, + fetchNetworkElementInfos, + PARAM_LANGUAGE, + snackWithFallback, + useSnackMessage, +} from '@gridsuite/commons-ui'; +import { EQUIPMENT_TYPES } from '../components/utils/equipment-types'; import { deleteEquipment } from '../services/study/network-modifications'; -import { fetchNetworkElementInfos } from '../services/study/network'; import { CurrentTreeNode } from '../components/graph/tree-node.type'; import type { UUID } from 'node:crypto'; @@ -25,6 +32,7 @@ import SubstationModificationDialog from 'components/dialogs/network-modificatio import VoltageLevelModificationDialog from 'components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog'; import VscModificationDialog from '../components/dialogs/network-modifications/hvdc-line/vsc/modification/vsc-modification-dialog'; import { LccModificationDialog } from '../components/dialogs/network-modifications/hvdc-line/lcc/modification/lcc-modification-dialog'; +import { useParameterState } from 'components/dialogs/parameters/use-parameters-state'; type EquipmentToModify = { equipmentId: string; @@ -40,7 +48,7 @@ interface UseEquipmentDialogsProps { export const useEquipmentDialogs = ({ studyUuid, currentNode, currentRootNetworkUuid }: UseEquipmentDialogsProps) => { const { snackError } = useSnackMessage(); - + const [languageLocal] = useParameterState(PARAM_LANGUAGE); // States const [equipmentToModify, setEquipmentToModify] = useState(); const [equipmentToDelete, setEquipmentToDelete] = useState(); @@ -113,9 +121,9 @@ export const useEquipmentDialogs = ({ studyUuid, currentNode, currentRootNetwork studyUuid, currentNode?.id, currentRootNetworkUuid, - EQUIPMENT_TYPES.HVDC_LINE, - EQUIPMENT_INFOS_TYPES.MAP.type, - equipmentId, + EquipmentType.HVDC_LINE, + EquipmentInfosTypes.MAP, + equipmentId as UUID, false ) .then((hvdcInfos) => { @@ -195,10 +203,11 @@ export const useEquipmentDialogs = ({ studyUuid, currentNode, currentRootNetwork onClose={closeModificationDialog} editData={undefined} editDataFetchStatus={undefined} + language={languageLocal} /> ) ); - }, [equipmentToModify, currentNode, currentRootNetworkUuid, studyUuid, closeModificationDialog]); + }, [equipmentToModify, currentNode, currentRootNetworkUuid, studyUuid, closeModificationDialog, languageLocal]); const renderDeletionDialog = useCallback(() => { if (!equipmentToDelete) { diff --git a/src/hooks/use-study-context.ts b/src/hooks/use-study-context.ts new file mode 100644 index 0000000000..c3ccb94ce6 --- /dev/null +++ b/src/hooks/use-study-context.ts @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2026, 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 { useMemo } from 'react'; +import { StudyContext } from '@gridsuite/commons-ui'; +import { useSelector } from 'react-redux'; +import { AppState } from '../redux/reducer'; +import { PARAM_USE_NAME } from '../utils/config-params'; + +export function useStudyContext() { + const studyUuid = useSelector((state: AppState) => state.studyUuid); + const currentNode = useSelector((state: AppState) => state.currentTreeNode); + const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid); + const useName = useSelector((state: AppState) => state[PARAM_USE_NAME]); + + const studyContext: StudyContext | undefined = useMemo(() => { + if (studyUuid && currentNode?.id && currentRootNetworkUuid) { + return { + studyId: studyUuid, + nodeId: currentNode.id, + rootNetworkId: currentRootNetworkUuid, + useNameParam: useName, + }; + } + }, [currentNode?.id, currentRootNetworkUuid, studyUuid, useName]); + + return studyContext; +} diff --git a/src/services/network-modification-types.ts b/src/services/network-modification-types.ts index 3cdf888bbb..a492c887a6 100644 --- a/src/services/network-modification-types.ts +++ b/src/services/network-modification-types.ts @@ -6,7 +6,6 @@ */ import type { UUID } from 'node:crypto'; -import { Property } from '../components/dialogs/network-modifications/common/properties/property-utils'; import { DataType, FieldValue, @@ -14,7 +13,7 @@ import { import { Filter } from '../components/dialogs/network-modifications/by-filter/commons/by-filter.type'; import { ConverterStationElementModificationInfos } from '../components/dialogs/network-modifications/hvdc-line/vsc/converter-station/converter-station-type'; import { ReactiveCapabilityCurvePoints } from '../components/dialogs/reactive-limits/reactive-limits.type'; -import { ModificationType, Option } from '@gridsuite/commons-ui'; +import { ModificationType, Option, Property } from '@gridsuite/commons-ui'; import { ENABLE_OLG_MODIFICATION } from '../components/utils/field-constants'; import { VARIATION_TYPES } from '../components/network/constants'; import { OperationalLimitsGroupFormSchema } from '../components/dialogs/limits/operational-limits-groups-types'; diff --git a/src/services/network-modification.ts b/src/services/network-modification.ts index 3cb84eb038..cc8ba5c7cd 100644 --- a/src/services/network-modification.ts +++ b/src/services/network-modification.ts @@ -5,21 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { backendFetch, backendFetchJson } from '@gridsuite/commons-ui'; -import type { UUID } from 'node:crypto'; +import { backendFetchJson } from '@gridsuite/commons-ui'; import { LineTypeInfo } from '../components/dialogs/line-types-catalog/line-catalog.type'; const PREFIX_NETWORK_MODIFICATION_QUERIES = import.meta.env.VITE_API_GATEWAY + '/network-modification'; -export function fetchNetworkModification(modificationUuid: UUID) { - const modificationFetchUrl = `${PREFIX_NETWORK_MODIFICATION_QUERIES}/v1/network-modifications/${encodeURIComponent( - modificationUuid - )}`; - - console.debug(modificationFetchUrl); - return backendFetch(modificationFetchUrl); -} - export function getLineTypesCatalog(): Promise { console.info(`get line types catalog`); const url = `${PREFIX_NETWORK_MODIFICATION_QUERIES}/v1/network-modifications/catalog/line_types`; diff --git a/src/services/study/index.ts b/src/services/study/index.ts index 3c20ee0732..57d61e9e60 100644 --- a/src/services/study/index.ts +++ b/src/services/study/index.ts @@ -8,15 +8,7 @@ import { getRequestParamFromList } from '../utils'; import type { UUID } from 'node:crypto'; import { COMPUTING_AND_NETWORK_MODIFICATION_TYPE } from '../../utils/report/report.constant'; -import { - backendFetch, - backendFetchJson, - backendFetchText, - ComputingType, - EquipmentType, - ExtendedEquipmentType, - Parameter, -} from '@gridsuite/commons-ui'; +import { backendFetch, backendFetchJson, backendFetchText, ComputingType, Parameter } from '@gridsuite/commons-ui'; import { NetworkModificationCopyInfos } from 'components/graph/menus/network-modifications/network-modification-menu.type'; import type { Svg } from 'components/grid-layout/cards/diagrams/diagram.type'; @@ -173,32 +165,6 @@ export function fetchSvg(svgUrl: string, fetchOptions?: RequestInit): Promise (response.status === 204 ? null : response.json())); } -export function searchEquipmentsInfos( - studyUuid: UUID, - nodeUuid: UUID, - currentRootNetworkUuid: UUID, - searchTerm: string, - getUseNameParameterKey: () => 'name' | 'id', - inUpstreamBuiltParentNode?: boolean, - equipmentType?: EquipmentType | ExtendedEquipmentType -) { - console.info("Fetching equipments infos matching with '%s' term ... ", searchTerm); - let urlSearchParams = new URLSearchParams(); - urlSearchParams.append('userInput', searchTerm); - urlSearchParams.append('fieldSelector', getUseNameParameterKey()); - if (inUpstreamBuiltParentNode !== undefined) { - urlSearchParams.append('inUpstreamBuiltParentNode', inUpstreamBuiltParentNode.toString()); - } - if (equipmentType !== undefined) { - urlSearchParams.append('equipmentType', equipmentType); - } - return backendFetchJson( - getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, nodeUuid, currentRootNetworkUuid) + - '/search?' + - urlSearchParams.toString() - ); -} - export function fetchContingencyCount( studyUuid: UUID, currentNodeUuid: UUID, diff --git a/src/services/study/network-map.ts b/src/services/study/network-map.ts index 4034589501..0a7c13542a 100644 --- a/src/services/study/network-map.ts +++ b/src/services/study/network-map.ts @@ -7,12 +7,12 @@ import { getStudyUrlWithNodeUuidAndRootNetworkUuid } from './index'; import { getQueryParamsList } from '../utils'; -import { EQUIPMENT_INFOS_TYPES } from '../../components/utils/equipment-types'; import { backendFetchJson, backendFetchText, createFilter, EquipmentInfos, + EquipmentInfosTypes, EquipmentType, ExtendedEquipmentType, Identifiable, @@ -270,7 +270,7 @@ export async function createMapContingencyList( currentRootNetworkUuid, selectedEquipmentsIds, equipmentType, - EQUIPMENT_INFOS_TYPES.LIST.type, + EquipmentInfosTypes.LIST, false, nominalVoltages ); diff --git a/src/services/study/network-map.type.ts b/src/services/study/network-map.type.ts index bfa7aae93c..75ed289e2c 100644 --- a/src/services/study/network-map.type.ts +++ b/src/services/study/network-map.type.ts @@ -5,9 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { LimitsProperty } from '../network-modification-types'; -import { Equipment } from '../../components/dialogs/network-modifications/common/properties/property-utils'; import { BusBarSections } from '../../components/dialogs/network-modifications/voltage-level/section/voltage-level-section.type'; import { ConnectablePositionInfos } from '../../components/dialogs/connectivity/connectivity.type'; +import { EquipmentWithProperties } from '@gridsuite/commons-ui'; export type SwitchInfos = { id: string; @@ -31,7 +31,7 @@ interface FeederBay { export type FeederBaysInfos = Record; -export type BranchInfos = Equipment & { +export type BranchInfos = EquipmentWithProperties & { name: string; voltageLevelId1: string; voltageLevelId2: string; diff --git a/src/services/study/network.ts b/src/services/study/network.ts index 58430dd00f..159cff5a40 100644 --- a/src/services/study/network.ts +++ b/src/services/study/network.ts @@ -11,13 +11,12 @@ import { backendFetch, backendFetchJson, backendFetchText, - EquipmentType, - ExtendedEquipmentType, + EquipmentInfosTypes, type Identifiable, } from '@gridsuite/commons-ui'; import type { MapHvdcLine, MapLine, MapSubstation, MapTieLine } from '@powsybl/network-viewer'; import { getStudyUrlWithNodeUuidAndRootNetworkUuid, PREFIX_STUDY_QUERIES, safeEncodeURIComponent } from './index'; -import { EQUIPMENT_INFOS_TYPES, EQUIPMENT_TYPES, type VoltageLevel } from '../../components/utils/equipment-types'; +import { EQUIPMENT_TYPES, type VoltageLevel } from '../../components/utils/equipment-types'; import { getQueryParamsList } from '../utils'; import { BusBarSectionsInfos, FeederBaysInfos, SwitchInfos } from './network-map.type'; import type { SpreadsheetEquipmentType } from '../../components/spreadsheet-view/types/spreadsheet.type'; @@ -211,7 +210,7 @@ export async function fetchNetworkElementsInfos { @@ -248,36 +247,6 @@ export async function fetchNetworkElementsInfos { - const fetchEquipmentTypeSchemaUrl = `${PREFIX_SCHEMAS_QUERIES}/v1/schemas/${type}/${EQUIPMENT_INFOS_TYPES.TAB.type}`; + const fetchEquipmentTypeSchemaUrl = `${PREFIX_SCHEMAS_QUERIES}/v1/schemas/${type}/${EquipmentInfosTypes.TAB}`; return backendFetchJson(fetchEquipmentTypeSchemaUrl, { method: 'get', headers: { 'Content-Type': 'application/json' }, diff --git a/src/services/utils.ts b/src/services/utils.ts index 407cddc2ac..466d6bd43c 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -7,13 +7,6 @@ import { catchErrorHandler, fetchStudyMetadata, StudyMetadata } from '@gridsuite/commons-ui'; import { getUserToken } from '../redux/user-store'; -export const FetchStatus = { - SUCCEED: 'SUCCEED', - FAILED: 'FAILED', - IDLE: 'IDLE', - RUNNING: 'RUNNING', -}; - export const MAX_INT32: number = 2147483647; type DefaultParameters = StudyMetadata['defaultParametersValues']; diff --git a/src/services/utils.type.ts b/src/services/utils.type.ts deleted file mode 100644 index 416595da7f..0000000000 --- a/src/services/utils.type.ts +++ /dev/null @@ -1,13 +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/. - */ - -export enum FetchStatus { - SUCCEED = 'SUCCEED', - FAILED = 'FAILED', - IDLE = 'IDLE', - RUNNING = 'RUNNING', -} diff --git a/src/translations/en.json b/src/translations/en.json index 979bacb615..9544185bfd 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -73,7 +73,6 @@ "geoDataLoadingFail": "An error occurred while loading geographical data.", "parameters": "Parameters", - "button.restore": "Restore", "close": "Close", "validate": "Validate", @@ -123,8 +122,6 @@ "Spreadsheet": "Spreadsheet", "Results": "Results", "ID": "ID", - "Name": "Name", - "Country": "Country", "Country1": "Country 1", "Country2": "Country 2", "Properties": "Properties", @@ -855,14 +852,8 @@ "minSusceptance": "Susceptance min", "b0": "Fixed part of susceptance", "shuntCompensatorType": "Type", - "CreateSubstation": "Create substation", - "SubstationCreationError": "Error while creating substation", - "AdditionalInformation": "Additional information", "Information": "Information", "Property": "Property", - "AddProperty": "Add property", - "PropertyName": "Property name", - "PropertyValue": "Property value", "DuplicatedPropsError": "Duplicated properties: each property must be unique", "FillAllFields": "Please fill all fields", "ModifySubstation": "Modify substation", @@ -996,7 +987,6 @@ "IncoherentPhaseRegulatingTerminalError": "The phase tap Regulating terminal value must be filled", "RatioValuesError": "The values of the ratio tap ratios must be ordered and without duplicates", "PhaseShiftValuesError": "The values of the phase tap shifts must be ordered and without duplicates", - "TapPositionValueError": "The number of taps must not exceed the value {value}", "IncoherentLowTapPositionError": "The value should match the lowest tap position generated", "IncoherentHighTapPositionError": "The value should match the highest tap position generated", @@ -1056,16 +1046,12 @@ "HighTapAlpha": "Shift angle (high tap position)", "ImportDephasingRule": "Import dephasing rule", - "GenerateSkeleton": "Generate CSV template", - "GenerateTemplateFromFilter": "Generate from filter", - "GenerateFromFilterError": "Error while generating template from filter", - "InvalidRuleHeader": "The file has an invalid header, please refer yourself to the template", - "uploadMessage": " No file selected", - "DefinePropertiesButton": "Define properties", "DefinePropertiesTitle": "Additional properties", "GenerateEmptyModel": "Generate empty model", + "GenerateSkeleton": "Generate CSV template", "GeneratePrefilledModel": "Generate prefilled model", + "GenerateFromFilterError": "Error while generating template from filter", "RestrictEquipmentList": "Restrict equipment list", "CurrentGridState": "Current grid state", "ColumnSelectionRequired": "At least one column must be selected", @@ -1085,10 +1071,6 @@ "TwoWindingsTransformerCreationError": "Error while creating a 2 windings transformer", "NewName": "New name", - "CopyFromExisting": "Copy from existing equipment", - "EquipmentCopied": "Data successfully copied from equipment {equipmentId}", - "EquipmentCopyFailed": "Equipment copy failed", - "insertNodeAbove": "Above", "insertNodeBelow": "Below", "copyNetworkModificationNode": "Copy", @@ -1203,7 +1185,6 @@ "NADOpenedInTheGrid": "The network area diagram \"{elementId}\" was opened in the image grid", "generatedNADOpenedInTheGrid": "The generated network area diagram was opened in the image grid", - "CatalogButtonTooltip": "Open catalog", "LineTypesCatalogDialogTitle": "Define line segments", "AddSegment": "Add segment", "AtLeastOneSegmentNeeded": "At least one line segment is needed", diff --git a/src/translations/fr.json b/src/translations/fr.json index 1b998ad5bc..5c2461dc0d 100644 --- a/src/translations/fr.json +++ b/src/translations/fr.json @@ -73,7 +73,6 @@ "geoDataLoadingFail": "Erreur lors du chargement des données géographiques.", "parameters": "Paramètres", - "button.restore": "Restaurer", "close": "Fermer", "validate": "Valider", @@ -123,8 +122,6 @@ "Spreadsheet": "Tableur", "Results": "Résultats", "ID": "ID", - "Name": "Nom", - "Country": "Pays", "Country1": "Pays 1", "Country2": "Pays 2", "Properties": "Propriétés", @@ -847,14 +844,8 @@ "maximumSusceptance": "Susceptance max", "minSusceptance": "Susceptance min", "shuntCompensatorType": "Type", - "CreateSubstation": "Créer un site", - "SubstationCreationError": "Erreur lors de la création d'un site", - "AdditionalInformation": "Informations complémentaires", "Information": "Information", "Property": "Propriété", - "AddProperty": "Ajouter une propriété", - "PropertyName": "Nom de la propriété", - "PropertyValue": "Valeur de la propriété", "DuplicatedPropsError": "Propriétés dupliquées : chaque propriété doit être unique", "FillAllFields": "Veuillez remplir tous les champs", "ModifySubstation": "Modifier un site", @@ -993,7 +984,6 @@ "IncoherentPhaseRegulatingTerminalError": "La valeur du Terminal distant réglé du déphaseur doit être renseignée", "RatioValuesError": "Les rapports de transformation doivent être ordonnés et sans duplication", "PhaseShiftValuesError": "Les valeurs de déphasage doivent être ordonnés et sans duplication", - "TapPositionValueError": "Le nombre de prises ne doit pas dépasser la valeur {value}", "IncoherentLowTapPositionError": "La valeur doit correspondre à la plus petite prise générée", "IncoherentHighTapPositionError": "La valeur doit correspondre à la plus grande prise générée", @@ -1053,16 +1043,12 @@ "HighTapAlpha": "Déphasage (prise max)", "ImportDephasingRule": "Importer une loi de déphasage", - "GenerateSkeleton": "Générer le modèle", - "GenerateTemplateFromFilter": "Générer depuis un filtre", - "GenerateFromFilterError": "Erreur lors de la génération du modèle depuis le filtre", - "InvalidRuleHeader": "Le fichier n'a pas le bon en-tête, veuillez vous référer au modèle", - "uploadMessage": " Aucun fichier sélectionné", - "DefinePropertiesButton": "Définir propriétés", "DefinePropertiesTitle": "Propriétés complémentaires", + "GenerateSkeleton": "Générer le modèle", "GenerateEmptyModel": "Générer un modèle vide", "GeneratePrefilledModel": "Générer un modèle pré-rempli", + "GenerateFromFilterError": "Erreur lors de la génération du modèle depuis le filtre", "RestrictEquipmentList": "Restreindre la liste des ouvrages", "CurrentGridState": "État actuel du réseau", "ColumnSelectionRequired": "Au moins une colonne doit être sélectionnée", @@ -1082,10 +1068,6 @@ "TwoWindingsTransformerCreationError": "Erreur lors de la création d'un transformateur à 2 enroulements", "NewName": "Nouveau nom", - "CopyFromExisting": "Copier depuis un ouvrage existant", - "EquipmentCopied": "Données copiées depuis l'ouvrage {equipmentId}", - "EquipmentCopyFailed": "Erreur lors de la copie de l'ouvrage", - "insertNodeAbove": "Au-dessus", "insertNodeBelow": "En-dessous", "copyNetworkModificationNode": "Copier", @@ -1203,7 +1185,6 @@ "dialog.button.leave": "Quitter", "dialog.button.launch": "Lancer", - "CatalogButtonTooltip": "Ouvrir le catalogue", "LineTypesCatalogDialogTitle": "Définir les segments de ligne", "AddSegment": "Ajouter segment", "AtLeastOneSegmentNeeded": "Au moins un segment de ligne est nécessaire", diff --git a/src/utils/UIconstants.ts b/src/utils/UIconstants.ts deleted file mode 100644 index 5f41f26c70..0000000000 --- a/src/utils/UIconstants.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) 2022, 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/. - */ - -export const SEARCH_FETCH_TIMEOUT_MILLIS = 1000; // 1 second -export const TOOLTIP_DELAY = 1000; -export const DRAWER_NODE_EDITOR_WIDTH = 630;