@gridsuite/commons-ui 0.101.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,11 @@ const styles = {
44
44
  },
45
45
  maxWidth: {
46
46
  width: "100%"
47
+ },
48
+ wrapper: {
49
+ flexGrow: 1,
50
+ overflow: "auto",
51
+ paddingLeft: 1
47
52
  }
48
53
  };
49
54
  function LoadFlowParametersContent({
@@ -53,29 +58,19 @@ function LoadFlowParametersContent({
53
58
  params,
54
59
  defaultLimitReductions
55
60
  }) {
56
- return /* @__PURE__ */ jsx(
57
- Box,
58
- {
59
- sx: {
60
- flexGrow: 1,
61
- overflow: "auto",
62
- paddingLeft: 1
63
- },
64
- children: /* @__PURE__ */ jsx(Grid, { container: true, sx: styles.container, children: /* @__PURE__ */ jsxs(Grid, { item: true, sx: styles.maxWidth, children: [
65
- /* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.GENERAL, children: /* @__PURE__ */ jsx(LoadFlowGeneralParameters, { provider: currentProvider, specificParams: specificParameters }) }),
66
- /* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.LIMIT_REDUCTIONS, children: /* @__PURE__ */ jsx(Grid, { container: true, sx: { width: "100%" }, children: currentProvider === PARAM_PROVIDER_OPENLOADFLOW ? /* @__PURE__ */ jsx(LimitReductionsTableForm, { limits: (params == null ? void 0 : params.limitReductions) ?? defaultLimitReductions }) : /* @__PURE__ */ jsx(
67
- ParameterLineSlider,
68
- {
69
- name: PARAM_LIMIT_REDUCTION,
70
- label: "LimitReduction",
71
- marks: alertThresholdMarks,
72
- minValue: MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION,
73
- maxValue: MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION
74
- }
75
- ) }) })
76
- ] }) })
77
- }
78
- );
61
+ return /* @__PURE__ */ jsx(Box, { sx: styles.wrapper, children: /* @__PURE__ */ jsx(Grid, { container: true, sx: styles.container, children: /* @__PURE__ */ jsxs(Grid, { item: true, sx: styles.maxWidth, children: [
62
+ /* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.GENERAL, children: /* @__PURE__ */ jsx(LoadFlowGeneralParameters, { provider: currentProvider, specificParams: specificParameters }) }),
63
+ /* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.LIMIT_REDUCTIONS, children: /* @__PURE__ */ jsx(Grid, { container: true, sx: { width: "100%" }, children: currentProvider === PARAM_PROVIDER_OPENLOADFLOW ? /* @__PURE__ */ jsx(LimitReductionsTableForm, { limits: (params == null ? void 0 : params.limitReductions) ?? defaultLimitReductions }) : /* @__PURE__ */ jsx(
64
+ ParameterLineSlider,
65
+ {
66
+ name: PARAM_LIMIT_REDUCTION,
67
+ label: "LimitReduction",
68
+ marks: alertThresholdMarks,
69
+ minValue: MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION,
70
+ maxValue: MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION
71
+ }
72
+ ) }) })
73
+ ] }) }) });
79
74
  }
80
75
  export {
81
76
  LoadFlowParametersContent as default
@@ -7,7 +7,7 @@ export interface ParametersEditionDialogProps {
7
7
  titleId: string;
8
8
  name: string;
9
9
  description: string | null;
10
- activeDirectory?: UUID;
10
+ activeDirectory: UUID;
11
11
  language?: string;
12
12
  user: User | null;
13
13
  enableDeveloperMode: boolean;
@@ -70,6 +70,10 @@ function LoadFlowParametersEditionDialog({
70
70
  getLoadFlowDefaultLimitReductions
71
71
  );
72
72
  const loadflowMethods = useLoadFlowParametersForm(parametersBackend, enableDeveloperMode, id, name, description);
73
+ const {
74
+ formState: { errors, dirtyFields }
75
+ } = loadflowMethods.formMethods;
76
+ const disableSave = Object.keys(errors).length > 0 || Object.keys(dirtyFields).length === 0;
73
77
  return /* @__PURE__ */ jsx(
74
78
  CustomMuiDialog,
75
79
  {
@@ -82,6 +86,7 @@ function LoadFlowParametersEditionDialog({
82
86
  titleId,
83
87
  removeOptional: true,
84
88
  language,
89
+ disabledSave: disableSave,
85
90
  children: /* @__PURE__ */ jsx(LoadFlowProvider, { children: /* @__PURE__ */ jsx(
86
91
  LoadFlowParametersForm,
87
92
  {
@@ -92,6 +97,7 @@ function LoadFlowParametersEditionDialog({
92
97
  UniqueNameInput,
93
98
  {
94
99
  name: FieldConstants.NAME,
100
+ currentName: name,
95
101
  label: "nameProperty",
96
102
  elementType: ElementType.LOADFLOW_PARAMETERS,
97
103
  activeDirectory,
@@ -1,5 +1,5 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Box, LinearProgress } from "@mui/material";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Box, Grid, LinearProgress } from "@mui/material";
3
3
  import LoadFlowParametersHeader from "./load-flow-parameters-header.js";
4
4
  import LoadFlowParametersContent from "./load-flow-parameters-content.js";
5
5
  import "react-intl";
@@ -29,6 +29,31 @@ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
29
29
  import "uuid";
30
30
  import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
31
31
  import "react-querybuilder";
32
+ const styles = {
33
+ form: {
34
+ height: "100%",
35
+ display: "flex",
36
+ position: "relative",
37
+ flexDirection: "column"
38
+ },
39
+ loadflowParameters: {
40
+ flexGrow: 1,
41
+ paddingLeft: 1,
42
+ overflow: "auto"
43
+ },
44
+ actions: {
45
+ flexGrow: 0
46
+ },
47
+ content: (theme) => ({
48
+ overflowY: "auto",
49
+ overflowX: "hidden",
50
+ maxHeight: "calc(100% - 15vh)",
51
+ paddingRight: theme.spacing(2),
52
+ paddingTop: theme.spacing(2),
53
+ paddingBottom: theme.spacing(1),
54
+ flexGrow: 1
55
+ })
56
+ };
32
57
  function LoadFlowParametersForm({
33
58
  loadflowMethods,
34
59
  renderTitleFields,
@@ -47,55 +72,31 @@ function LoadFlowParametersForm({
47
72
  defaultLimitReductions,
48
73
  paramsLoaded
49
74
  } = loadflowMethods;
50
- return /* @__PURE__ */ jsxs(CustomFormProvider, { validationSchema: formSchema, ...formMethods, removeOptional: true, children: [
75
+ return /* @__PURE__ */ jsx(CustomFormProvider, { validationSchema: formSchema, ...formMethods, removeOptional: true, children: /* @__PURE__ */ jsxs(Box, { sx: styles.form, children: [
51
76
  renderTitleFields == null ? void 0 : renderTitleFields(),
52
- /* @__PURE__ */ jsxs(
53
- Box,
54
- {
55
- sx: {
56
- height: "100%",
57
- display: "flex",
58
- position: "relative",
59
- flexDirection: "column"
60
- },
61
- children: [
62
- paramsLoaded ? /* @__PURE__ */ jsxs(
63
- Box,
64
- {
65
- sx: {
66
- height: "100%",
67
- display: "flex",
68
- position: "relative",
69
- flexDirection: "column"
70
- },
71
- children: [
72
- /* @__PURE__ */ jsx(
73
- LoadFlowParametersHeader,
74
- {
75
- selectedTab,
76
- handleTabChange,
77
- tabIndexesWithError,
78
- formattedProviders
79
- }
80
- ),
81
- /* @__PURE__ */ jsx(
82
- LoadFlowParametersContent,
83
- {
84
- selectedTab,
85
- currentProvider: currentProvider ?? "",
86
- specificParameters,
87
- params,
88
- defaultLimitReductions
89
- }
90
- )
91
- ]
92
- }
93
- ) : /* @__PURE__ */ jsx(LinearProgress, {}),
94
- renderActions == null ? void 0 : renderActions()
95
- ]
96
- }
97
- )
98
- ] });
77
+ paramsLoaded ? /* @__PURE__ */ jsxs(Box, { sx: styles.loadflowParameters, children: [
78
+ /* @__PURE__ */ jsx(
79
+ LoadFlowParametersHeader,
80
+ {
81
+ selectedTab,
82
+ handleTabChange,
83
+ tabIndexesWithError,
84
+ formattedProviders
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx(Grid, { container: true, sx: styles.content, children: /* @__PURE__ */ jsx(
88
+ LoadFlowParametersContent,
89
+ {
90
+ selectedTab,
91
+ currentProvider: currentProvider ?? "",
92
+ specificParameters,
93
+ params,
94
+ defaultLimitReductions
95
+ }
96
+ ) })
97
+ ] }) : /* @__PURE__ */ jsx(LinearProgress, {}),
98
+ renderActions && /* @__PURE__ */ jsx(Box, { sx: styles.actions, children: renderActions == null ? void 0 : renderActions() })
99
+ ] }) });
99
100
  }
100
101
  export {
101
102
  LoadFlowParametersForm
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { Dialog, DialogTitle, DialogContent, Grid, Typography, Box, DialogActions } from "@mui/material";
3
3
  import { FormattedMessage } from "react-intl";
4
- import { useState, useEffect } from "react";
4
+ import { useState, useEffect, Fragment } from "react";
5
5
  import { CancelButton } from "../inputs/reactHookForm/utils/CancelButton.js";
6
6
  import { fetchUserDetails } from "../../services/userAdmin.js";
7
7
  const styles = {
@@ -12,6 +12,7 @@ const styles = {
12
12
  usedTopography: { marginLeft: "15%" }
13
13
  };
14
14
  function UserInformationDialog({ openDialog, user, onClose }) {
15
+ var _a;
15
16
  const [userDetails, setUserDetails] = useState(void 0);
16
17
  const getUserDetails = (userName) => {
17
18
  fetchUserDetails(userName).then((response) => {
@@ -25,17 +26,23 @@ function UserInformationDialog({ openDialog, user, onClose }) {
25
26
  getUserDetails(user == null ? void 0 : user.profile.sub);
26
27
  }
27
28
  }, [openDialog, user]);
29
+ const rolesString = ((_a = user == null ? void 0 : user.profile) == null ? void 0 : _a.profile) ?? "";
30
+ const rolesList = rolesString ? rolesString.split("|").map((role) => role.trim()) : [];
28
31
  return /* @__PURE__ */ jsxs(Dialog, { open: openDialog && !!user && !!userDetails, onClose, children: [
29
32
  /* @__PURE__ */ jsx(DialogTitle, { fontWeight: "bold", sx: styles.DialogTitle, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "user-information-dialog/title" }) }),
30
33
  /* @__PURE__ */ jsxs(DialogContent, { children: [
31
34
  /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, sx: styles.DialogContent, children: [
32
35
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "user-information-dialog/role" }) }) }),
33
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(
34
- FormattedMessage,
35
- {
36
- id: (userDetails == null ? void 0 : userDetails.isAdmin) ? "user-information-dialog/role-admin" : "user-information-dialog/role-user"
37
- }
38
- ) }) }),
36
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: rolesList.length > 0 ? /* @__PURE__ */ jsx(Typography, { children: rolesList.map((role, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ index > 0 && " | ",
38
+ /* @__PURE__ */ jsx(
39
+ FormattedMessage,
40
+ {
41
+ id: `user-information-dialog/${role}`,
42
+ defaultMessage: role
43
+ }
44
+ )
45
+ ] }, role)) }) : /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(FormattedMessage, { id: "user-information-dialog/no-roles" }) }) }),
39
46
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: /* @__PURE__ */ jsx(FormattedMessage, { id: "user-information-dialog/profile" }) }) }),
40
47
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: (userDetails == null ? void 0 : userDetails.profileName) === null ? /* @__PURE__ */ jsx(FormattedMessage, { id: "user-information-dialog/no-profile" }) : /* @__PURE__ */ jsx(Typography, { children: userDetails == null ? void 0 : userDetails.profileName }) })
41
48
  ] }),
@@ -44,7 +44,7 @@ const parametersEn = {
44
44
  descLfCountries: "Countries",
45
45
  descLfAllCountries: "All countries",
46
46
  descLfCountriesToBalance: "Countries participating in balancing",
47
- editParameters: "Edit parameter",
47
+ editParameters: "Edit parameters",
48
48
  RealPercentage: "This value must be between 0 and 1",
49
49
  General: "General",
50
50
  LimitReductions: "Limit reductions",
@@ -30,8 +30,10 @@ export declare const topBarEn: {
30
30
  'about-dialog/module-tooltip-other': string;
31
31
  'user-information-dialog/title': string;
32
32
  'user-information-dialog/role': string;
33
- 'user-information-dialog/role-user': string;
34
- 'user-information-dialog/role-admin': string;
33
+ 'user-information-dialog/UTILISATEURS': string;
34
+ 'user-information-dialog/ADMIN': string;
35
+ 'user-information-dialog/ADMIN_EXPLORE': string;
36
+ 'user-information-dialog/no-roles': string;
35
37
  'user-information-dialog/profile': string;
36
38
  'user-information-dialog/no-profile': string;
37
39
  'user-information-dialog/quotas': string;
@@ -24,8 +24,10 @@ const topBarEn = {
24
24
  "about-dialog/module-tooltip-other": "other",
25
25
  "user-information-dialog/title": "User information",
26
26
  "user-information-dialog/role": "Role",
27
- "user-information-dialog/role-user": "Basic user",
28
- "user-information-dialog/role-admin": "Admin",
27
+ "user-information-dialog/UTILISATEURS": "User",
28
+ "user-information-dialog/ADMIN": "Admin",
29
+ "user-information-dialog/ADMIN_EXPLORE": "Admin Explore",
30
+ "user-information-dialog/no-roles": "No roles",
29
31
  "user-information-dialog/profile": "Profile",
30
32
  "user-information-dialog/no-profile": "No profile",
31
33
  "user-information-dialog/quotas": "User quotas",
@@ -44,7 +44,7 @@ const parametersFr = {
44
44
  descLfCountries: "Pays",
45
45
  descLfAllCountries: "Tous les pays",
46
46
  descLfCountriesToBalance: "Pays participant à la compensation",
47
- editParameters: "Éditer le paramètre",
47
+ editParameters: "Éditer les paramètres",
48
48
  RealPercentage: "Cette valeur doit être comprise entre 0 et 1",
49
49
  General: "Général",
50
50
  LimitReductions: "Abattements",
@@ -30,8 +30,10 @@ export declare const topBarFr: {
30
30
  'about-dialog/module-tooltip-other': string;
31
31
  'user-information-dialog/title': string;
32
32
  'user-information-dialog/role': string;
33
- 'user-information-dialog/role-user': string;
34
- 'user-information-dialog/role-admin': string;
33
+ 'user-information-dialog/UTILISATEURS': string;
34
+ 'user-information-dialog/ADMIN': string;
35
+ 'user-information-dialog/ADMIN_EXPLORE': string;
36
+ 'user-information-dialog/no-roles': string;
35
37
  'user-information-dialog/profile': string;
36
38
  'user-information-dialog/no-profile': string;
37
39
  'user-information-dialog/quotas': string;
@@ -24,8 +24,10 @@ const topBarFr = {
24
24
  "about-dialog/module-tooltip-other": "autre",
25
25
  "user-information-dialog/title": "Informations utilisateur",
26
26
  "user-information-dialog/role": "Rôle",
27
- "user-information-dialog/role-user": "Utilisateur simple",
28
- "user-information-dialog/role-admin": "Admin",
27
+ "user-information-dialog/UTILISATEURS": "Utilisateur",
28
+ "user-information-dialog/ADMIN": "Admin",
29
+ "user-information-dialog/ADMIN_EXPLORE": "Admin Explore",
30
+ "user-information-dialog/no-roles": "Pas de rôle",
29
31
  "user-information-dialog/profile": "Profil",
30
32
  "user-information-dialog/no-profile": "Pas de profil",
31
33
  "user-information-dialog/quotas": "Quotas",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.101.0",
3
+ "version": "0.103.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",