Skip to content

Commit

Permalink
Merge branch 'release/2.17.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed May 3, 2024
2 parents ac1d270 + 34b97ea commit d6cad7b
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 28 deletions.
8 changes: 7 additions & 1 deletion webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -748,5 +748,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"
}
8 changes: 7 additions & 1 deletion webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -748,5 +748,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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
////////////////////////////////////////////////////////////////
Expand All @@ -43,7 +52,7 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) {
onSubmit={onSubmit}
onCancel={onCancel}
>
{({ control, resetField, getValues }) => (
{({ control, setValue, getValues }) => (
<Box
sx={{
display: "flex",
Expand All @@ -67,15 +76,15 @@ function TableTemplateFormDialog(props: TableTemplateFormDialogProps) {
/>
<SelectFE
label={t("study.type")}
options={TABLE_MODE_TYPES}
options={typeOptions}
variant="outlined"
onChange={() => resetField("columns")}
onChange={() => setValue("columns", [])}
name="type"
control={control}
/>
<ListFE
label={t("study.columns")}
options={getTableColumnsForType(getValues("type"))}
options={[...getTableColumnsForType(getValues("type"))]}
getOptionLabel={startCase}
name="columns"
control={control}
Expand Down
8 changes: 4 additions & 4 deletions webapp/src/components/common/fieldEditors/ListFE/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ import {
import { makeLabel, makeListItems } from "./utils";

interface ListFEProps<TItem, TOption> {
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;
Expand All @@ -64,7 +64,7 @@ function ListFE<TItem, TOption>(props: ListFEProps<TItem, TOption>) {
value,
defaultValue,
label,
options,
options = [],
getOptionLabel = makeLabel,
getValueLabel = makeLabel,
optionToItem = (option: TOption) => option as unknown as TItem,
Expand Down
44 changes: 27 additions & 17 deletions webapp/src/services/api/studies/tableMode/constants.ts
Original file line number Diff line number Diff line change
@@ -1,20 +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,
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",
Expand All @@ -27,7 +37,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = {
// Since v8.3
"adequacyPatchMode",
],
[LINKS]: [
[LINK]: [
"hurdlesCost",
"loopFlow",
"usePhaseShifter",
Expand All @@ -40,7 +50,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = {
"filterSynthesis",
"filterYearByYear",
],
[THERMALS]: [
[THERMAL]: [
"group",
"enabled",
"unitCount",
Expand Down Expand Up @@ -79,15 +89,15 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = {
"efficiency",
"variableOMCost",
],
[RENEWABLES]: [
[RENEWABLE]: [
// Since v8.1
"group",
"enabled",
"tsInterpretation",
"unitCount",
"nominalCapacity",
],
[ST_STORAGES]: [
[ST_STORAGE]: [
// Since v8.6
"group",
"injectionNominalCapacity",
Expand All @@ -99,7 +109,7 @@ export const TABLE_MODE_COLUMNS_BY_TYPE = {
// Since v8.8
"enabled",
],
[BINDING_CONSTRAINTS]: [
[BINDING_CONSTRAINT]: [
"enabled",
"timeStep",
"operator",
Expand Down
14 changes: 13 additions & 1 deletion webapp/src/services/utils/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -46,7 +47,18 @@ function getItem<T extends StorageKey>(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<string, unknown>) => ({
...template,
// @ts-expect-error To ignore error TS2551
type: TABLE_MODE_TYPES_ALIASES[template.type] ?? template.type,
}));
}

return res;
} catch (err) {
return null;
}
Expand Down

0 comments on commit d6cad7b

Please sign in to comment.