From 761bc57d4015ecb3816422dd39d46dfc1c2de827 Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE <43534797+laurent-laporte-pro@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:02:31 +0200 Subject: [PATCH 1/5] fix(ui-tablemode): add missing "ST Storage" in Table Mode template (#2016) --- webapp/src/services/api/studies/tableMode/constants.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/src/services/api/studies/tableMode/constants.ts b/webapp/src/services/api/studies/tableMode/constants.ts index e75e163cc3..09ccdc82ff 100644 --- a/webapp/src/services/api/studies/tableMode/constants.ts +++ b/webapp/src/services/api/studies/tableMode/constants.ts @@ -10,6 +10,7 @@ export const TABLE_MODE_TYPES = [ LINKS, THERMALS, RENEWABLES, + ST_STORAGES, BINDING_CONSTRAINTS, ] as const; From bfcd6fac05d25858a4a27c1902c5fb959717f417 Mon Sep 17 00:00:00 2001 From: Hatim Dinia <33469289+hdinia@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:17:14 +0200 Subject: [PATCH 2/5] fix(ui-settings): prevent false duplicates on group form updates (#1998) --- .../App/Settings/Groups/dialog/GroupFormDialog/GroupForm.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/src/components/App/Settings/Groups/dialog/GroupFormDialog/GroupForm.tsx b/webapp/src/components/App/Settings/Groups/dialog/GroupFormDialog/GroupForm.tsx index e17dee147b..39e8e26ca4 100644 --- a/webapp/src/components/App/Settings/Groups/dialog/GroupFormDialog/GroupForm.tsx +++ b/webapp/src/components/App/Settings/Groups/dialog/GroupFormDialog/GroupForm.tsx @@ -115,6 +115,7 @@ function GroupForm(props: UseFormReturnPlus) { validateString(v, { existingValues: existingGroups, excludedValues: RESERVED_GROUP_NAMES, + editedValue: defaultValues?.name, // prevent false duplicates on update form }), })} /> From d0f0bf2a05a8170741b9eb88c08f6b1aa2489162 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:19:57 +0200 Subject: [PATCH 3/5] fix(ui-tablemode): unable to edit tables with old types --- .../dialogs/TableTemplateFormDialog.tsx | 2 +- .../common/fieldEditors/ListFE/index.tsx | 8 ++-- .../api/studies/tableMode/constants.ts | 45 +++++++++++-------- webapp/src/services/utils/localStorage.ts | 14 +++++- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx index 8517268e45..820852492a 100644 --- a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx +++ b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx @@ -75,7 +75,7 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) { /> { - defaultValue?: readonly TItem[]; - value?: readonly TItem[]; - options: readonly TOption[]; + defaultValue?: TItem[]; + value?: TItem[]; + options?: TOption[]; label?: string; getOptionLabel?: (option: TOption) => string; getValueLabel?: (value: TItem) => string; @@ -64,7 +64,7 @@ function ListFE(props: ListFEProps) { value, defaultValue, label, - options, + options = [], getOptionLabel = makeLabel, getValueLabel = makeLabel, optionToItem = (option: TOption) => option as unknown as TItem, diff --git a/webapp/src/services/api/studies/tableMode/constants.ts b/webapp/src/services/api/studies/tableMode/constants.ts index 09ccdc82ff..acef3d51f6 100644 --- a/webapp/src/services/api/studies/tableMode/constants.ts +++ b/webapp/src/services/api/studies/tableMode/constants.ts @@ -1,21 +1,30 @@ -const AREAS = "areas"; -const LINKS = "links"; -const THERMALS = "thermals"; -const RENEWABLES = "renewables"; -const ST_STORAGES = "st-storages"; -const BINDING_CONSTRAINTS = "binding-constraints"; +const AREA = "areas"; +const LINK = "links"; +const THERMAL = "thermals"; +const RENEWABLE = "renewables"; +const ST_STORAGE = "st-storages"; +const BINDING_CONSTRAINT = "binding-constraints"; export const TABLE_MODE_TYPES = [ - AREAS, - LINKS, - THERMALS, - RENEWABLES, - ST_STORAGES, - BINDING_CONSTRAINTS, + AREA, + LINK, + THERMAL, + RENEWABLE, + ST_STORAGE, + BINDING_CONSTRAINT, ] as const; +// Deprecated types (breaking change from v2.16.8) +export const TABLE_MODE_TYPES_ALIASES = { + area: AREA, + link: LINK, + cluster: THERMAL, + renewable: RENEWABLE, + "binding constraint": BINDING_CONSTRAINT, +}; + export const TABLE_MODE_COLUMNS_BY_TYPE = { - [AREAS]: [ + [AREA]: [ "nonDispatchablePower", "dispatchableHydroPower", "otherDispatchablePower", @@ -28,7 +37,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = { // Since v8.3 "adequacyPatchMode", ], - [LINKS]: [ + [LINK]: [ "hurdlesCost", "loopFlow", "usePhaseShifter", @@ -41,7 +50,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = { "filterSynthesis", "filterYearByYear", ], - [THERMALS]: [ + [THERMAL]: [ "group", "enabled", "unitCount", @@ -80,7 +89,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = { "efficiency", "variableOMCost", ], - [RENEWABLES]: [ + [RENEWABLE]: [ // Since v8.1 "group", "enabled", @@ -88,7 +97,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = { "unitCount", "nominalCapacity", ], - [ST_STORAGES]: [ + [ST_STORAGE]: [ // Since v8.6 "group", "injectionNominalCapacity", @@ -100,7 +109,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = { // Since v8.8 "enabled", ], - [BINDING_CONSTRAINTS]: [ + [BINDING_CONSTRAINT]: [ "enabled", "timeStep", "operator", diff --git a/webapp/src/services/utils/localStorage.ts b/webapp/src/services/utils/localStorage.ts index fa5c084c56..faa230e17a 100644 --- a/webapp/src/services/utils/localStorage.ts +++ b/webapp/src/services/utils/localStorage.ts @@ -4,6 +4,7 @@ import { UserInfo } from "../../common/types"; import { TableTemplate } from "../../components/App/Singlestudy/explore/TableModeList/utils"; import { StudiesSortConf, StudiesState } from "../../redux/ducks/studies"; import { UIState } from "../../redux/ducks/ui"; +import { TABLE_MODE_TYPES_ALIASES } from "../api/studies/tableMode/constants"; export enum StorageKey { Version = "version", @@ -46,7 +47,18 @@ function getItem(key: T): TypeFromKey[T] | null { if (serializedState === null) { return null; } - return JSON.parse(serializedState); + const res = JSON.parse(serializedState); + + // Convert deprecated types to new ones (breaking change from v2.16.8) + if (key === StorageKey.StudiesModelTableModeTemplates) { + return res.map((template: Record) => ({ + ...template, + // @ts-expect-error To ignore error TS2551 + type: TABLE_MODE_TYPES_ALIASES[template.type] ?? template.type, + })); + } + + return res; } catch (err) { return null; } From 819e62e9cb726eb359faefff10a8d3bf176e8324 Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:56:31 +0200 Subject: [PATCH 4/5] feat(ui-tablemode): translate table types in add/edit modal --- webapp/public/locales/en/main.json | 8 +++++++- webapp/public/locales/fr/main.json | 8 +++++++- .../TableModeList/dialogs/TableTemplateFormDialog.tsx | 11 ++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/webapp/public/locales/en/main.json b/webapp/public/locales/en/main.json index 788dec17c1..942d4630a9 100644 --- a/webapp/public/locales/en/main.json +++ b/webapp/public/locales/en/main.json @@ -731,5 +731,11 @@ "results.error.jobs": "Failed to retrieve study launch jobs", "results.error.outputs": "Failed to retrieve study output list", "results.noOutputs": "No outputs", - "results.question.deleteOutput": "Are you sure you want to delete the output {{outputname}}?" + "results.question.deleteOutput": "Are you sure you want to delete the output {{outputname}}?", + "tableMode.type.areas": "Areas", + "tableMode.type.links": "Links", + "tableMode.type.thermals": "Thermals", + "tableMode.type.renewables": "Renewables", + "tableMode.type.st-storages": "Short-Term Storages", + "tableMode.type.binding-constraints": "Binding Constraints" } diff --git a/webapp/public/locales/fr/main.json b/webapp/public/locales/fr/main.json index 8fc1b6c90c..5e4d02b567 100644 --- a/webapp/public/locales/fr/main.json +++ b/webapp/public/locales/fr/main.json @@ -731,5 +731,11 @@ "results.error.jobs": "Erreur lors de la récupération des tâches de lancement", "results.error.outputs": "Erreur lors de la récupération des sorties de l'étude", "results.noOutputs": "Aucune sorties", - "results.question.deleteOutput": "Êtes-vous sûr de vouloir supprimer le résultat de simulation {{outputname}} ?" + "results.question.deleteOutput": "Êtes-vous sûr de vouloir supprimer le résultat de simulation {{outputname}} ?", + "tableMode.type.areas": "Zones", + "tableMode.type.links": "Liens", + "tableMode.type.thermals": "Thermiques", + "tableMode.type.renewables": "Renouvelables", + "tableMode.type.st-storages": "Stockages court terme", + "tableMode.type.binding-constraints": "Contraintes couplantes" } diff --git a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx index 820852492a..df8b3606cb 100644 --- a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx +++ b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx @@ -30,6 +30,15 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) { [templates], ); + const typeOptions = useMemo( + () => + TABLE_MODE_TYPES.map((type) => ({ + value: type, + label: t(`tableMode.type.${type}`), + })), + [t], + ); + //////////////////////////////////////////////////////////////// // JSX //////////////////////////////////////////////////////////////// @@ -67,7 +76,7 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) { /> resetField("columns")} name="type" From 34b97eaf9e7afc000d73c73842841501059826ac Mon Sep 17 00:00:00 2001 From: Samir Kamal <1954121+skamril@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:17:40 +0200 Subject: [PATCH 5/5] fix(ui-tablemode): reset 'column' field when 'type' field change in create/update modal --- .../explore/TableModeList/dialogs/TableTemplateFormDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx index df8b3606cb..0b49e7335c 100644 --- a/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx +++ b/webapp/src/components/App/Singlestudy/explore/TableModeList/dialogs/TableTemplateFormDialog.tsx @@ -52,7 +52,7 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) { onSubmit={onSubmit} onCancel={onCancel} > - {({ control, resetField, getValues }) => ( + {({ control, setValue, getValues }) => ( resetField("columns")} + onChange={() => setValue("columns", [])} name="type" control={control} />