@gridsuite/commons-ui 0.41.0 → 0.43.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.
@@ -7,9 +7,9 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
7
7
  */
8
8
 
9
9
  import React, { useCallback, useEffect, useState } from 'react';
10
- import { Dialog, DialogContent, TextField, Autocomplete } from '@mui/material';
10
+ import { Autocomplete, Dialog, DialogContent, TextField } from '@mui/material';
11
11
  import PropTypes from 'prop-types';
12
- import SearchIcon from '@mui/icons-material/Search';
12
+ import { Search, SearchOff } from '@mui/icons-material';
13
13
  import { useIntl } from 'react-intl';
14
14
  var ElementSearchDialog = function ElementSearchDialog(props) {
15
15
  var intl = useIntl();
@@ -127,7 +127,9 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
127
127
  id: 'element_search/label'
128
128
  }),
129
129
  InputProps: _extends({}, params.InputProps, {
130
- startAdornment: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchIcon, {
130
+ startAdornment: /*#__PURE__*/React.createElement(React.Fragment, null, searchTermDisabled ? /*#__PURE__*/React.createElement(SearchOff, {
131
+ color: "disabled"
132
+ }) : /*#__PURE__*/React.createElement(Search, {
131
133
  color: "disabled"
132
134
  }), params.InputProps.startAdornment)
133
135
  })
@@ -0,0 +1,456 @@
1
+ /**
2
+ * Copyright (c) 2023, RTE (http://www.rte-france.com)
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v.2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ */
7
+
8
+ import React, { useCallback, useEffect, useState } from 'react';
9
+ import { Accordion, AccordionDetails, AccordionSummary, Alert, Box, Button, CircularProgress, Collapse, Dialog, DialogActions, DialogContent, DialogTitle, Fade, Grid, Stack, Tooltip, tooltipClasses, Typography, useMediaQuery, useTheme, Zoom } from '@mui/material';
10
+ import { LoadingButton } from '@mui/lab';
11
+ import { Apps, DnsOutlined, ExpandMore, Gavel, QuestionMark, Refresh, WidgetsOutlined } from '@mui/icons-material';
12
+ import { FormattedMessage } from 'react-intl';
13
+ import PropTypes from 'prop-types';
14
+ import { LogoText } from './GridLogo';
15
+ var styles = {
16
+ general: {
17
+ '.MuiAccordion-root': {
18
+ //dunno why the theme has the background as black in dark mode
19
+ bgcolor: 'unset'
20
+ }
21
+ },
22
+ mainSection: {
23
+ height: '5em'
24
+ },
25
+ logoSection: {
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ justifyContent: 'center'
29
+ },
30
+ mainInfos: {
31
+ textAlign: 'center',
32
+ marginTop: 0
33
+ },
34
+ versionField: function versionField(isUnknown) {
35
+ return isUnknown ? {
36
+ fontSize: '1.5em',
37
+ fontWeight: 'bold'
38
+ } : {
39
+ fontStyle: 'italic'
40
+ };
41
+ },
42
+ detailsSection: {
43
+ '.MuiAccordionSummary-content > .MuiSvgIcon-root': {
44
+ marginRight: '0.5rem'
45
+ }
46
+ }
47
+ };
48
+ function getGlobalVersion(fnPromise, type, setData, setLoader) {
49
+ if (fnPromise) {
50
+ console.debug('Getting', type, 'global version...');
51
+ return new Promise(function (resolve, reject) {
52
+ if (setLoader) {
53
+ setLoader(true);
54
+ }
55
+ resolve();
56
+ }).then(function () {
57
+ return fnPromise();
58
+ }).then(function (value) {
59
+ console.debug(type, 'global version is', value);
60
+ setData(value !== null && value !== void 0 ? value : null);
61
+ }, function (reason) {
62
+ console.debug(type, "global version isn't available", reason);
63
+ setData(null);
64
+ })["finally"](function () {
65
+ if (setLoader) {
66
+ setLoader(false);
67
+ }
68
+ });
69
+ } else {
70
+ console.debug('No getter for global version');
71
+ setData(null);
72
+ }
73
+ }
74
+ var moduleTypeSort = {
75
+ app: 1,
76
+ server: 10,
77
+ other: 20
78
+ };
79
+ function compareModules(c1, c2) {
80
+ //sort by type then by name
81
+ return [moduleTypeSort[c1.type] || 100] - [moduleTypeSort[c2.type] || 100] || (c1.name || '').localeCompare(c2.name || '');
82
+ }
83
+ var AboutDialog = function AboutDialog(_ref) {
84
+ var open = _ref.open,
85
+ onClose = _ref.onClose,
86
+ globalVersionPromise = _ref.globalVersionPromise,
87
+ appName = _ref.appName,
88
+ appVersion = _ref.appVersion,
89
+ appGitTag = _ref.appGitTag,
90
+ appLicense = _ref.appLicense,
91
+ additionalModulesPromise = _ref.additionalModulesPromise;
92
+ var theme = useTheme();
93
+ var _useState = useState(false),
94
+ isRefreshing = _useState[0],
95
+ setRefreshState = _useState[1];
96
+ var _useState2 = useState(false),
97
+ loadingGlobalVersion = _useState2[0],
98
+ setLoadingGlobalVersion = _useState2[1];
99
+ var _useState3 = useState(false),
100
+ showGlobalVersion = _useState3[0],
101
+ setShowGlobalVersion = _useState3[1];
102
+
103
+ /* We want to get the initial version once at first render to detect later a new deploy */
104
+ var _useState4 = useState(undefined),
105
+ initialGlobalVersion = _useState4[0],
106
+ setInitialGlobalVersion = _useState4[1];
107
+ useEffect(function () {
108
+ if (initialGlobalVersion === undefined) {
109
+ getGlobalVersion(globalVersionPromise, 'Initial', setInitialGlobalVersion, undefined);
110
+ }
111
+ }, [globalVersionPromise, initialGlobalVersion]);
112
+ var _useState5 = useState(null),
113
+ actualGlobalVersion = _useState5[0],
114
+ setActualGlobalVersion = _useState5[1];
115
+ useEffect(function () {
116
+ if (open) {
117
+ getGlobalVersion(globalVersionPromise, 'Actual', setActualGlobalVersion, function (loading) {
118
+ setLoadingGlobalVersion(loading);
119
+ setShowGlobalVersion(false);
120
+ });
121
+ }
122
+ }, [open, globalVersionPromise]);
123
+ var _useState6 = useState(false),
124
+ loadingAdditionalModules = _useState6[0],
125
+ setLoadingAdditionalModules = _useState6[1];
126
+ var _useState7 = useState(null),
127
+ modules = _useState7[0],
128
+ setModules = _useState7[1];
129
+ useEffect(function () {
130
+ if (open) {
131
+ var currentApp = {
132
+ name: "Grid" + appName,
133
+ type: 'app',
134
+ version: appVersion,
135
+ gitTag: appGitTag,
136
+ license: appLicense
137
+ };
138
+ (additionalModulesPromise ? Promise.resolve(setLoadingAdditionalModules(true)).then(function () {
139
+ return additionalModulesPromise();
140
+ }) : Promise.reject(new Error('no getter'))).then(function (values) {
141
+ return Array.isArray(values) ? values : [];
142
+ }, function (reason) {
143
+ return [];
144
+ }).then(function (values) {
145
+ setModules([currentApp].concat(values));
146
+ })["finally"](function () {
147
+ return setLoadingAdditionalModules(false);
148
+ });
149
+ }
150
+ }, [open, additionalModulesPromise, appName, appVersion, appGitTag, appLicense]);
151
+ var handleClose = useCallback(function () {
152
+ if (onClose) {
153
+ onClose();
154
+ }
155
+ }, [onClose]);
156
+ return /*#__PURE__*/React.createElement(Dialog, {
157
+ onClose: handleClose,
158
+ open: open,
159
+ fullWidth: true,
160
+ maxWidth: "md",
161
+ fullScreen: useMediaQuery(theme.breakpoints.down('md')),
162
+ sx: styles.general,
163
+ "aria-labelledby": "alert-dialog-title",
164
+ "aria-describedby": "alert-dialog-description",
165
+ TransitionProps: {
166
+ onExited: function onExited(node) {
167
+ setModules(null);
168
+ setActualGlobalVersion(null);
169
+ }
170
+ }
171
+ }, /*#__PURE__*/React.createElement(DialogTitle, {
172
+ id: "alert-dialog-title"
173
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
174
+ id: 'about-dialog/title'
175
+ }), initialGlobalVersion !== undefined && initialGlobalVersion !== null && actualGlobalVersion !== null && initialGlobalVersion !== actualGlobalVersion && /*#__PURE__*/React.createElement(Collapse, {
176
+ "in": open
177
+ }, /*#__PURE__*/React.createElement(Alert, {
178
+ severity: "warning",
179
+ variant: "outlined",
180
+ action: /*#__PURE__*/React.createElement(LoadingButton, {
181
+ color: "inherit",
182
+ size: "small",
183
+ startIcon: /*#__PURE__*/React.createElement(Refresh, {
184
+ fontSize: "small"
185
+ }),
186
+ loadingPosition: "start",
187
+ loading: isRefreshing,
188
+ onClick: function onClick() {
189
+ setRefreshState(true);
190
+ window.location.reload();
191
+ }
192
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
193
+ id: "refresh"
194
+ })),
195
+ sx: {
196
+ marginBottom: 2
197
+ }
198
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
199
+ id: "about-dialog/alert-running-old-version-msg"
200
+ }))), /*#__PURE__*/React.createElement(Box, {
201
+ sx: styles.mainSection
202
+ }, /*#__PURE__*/React.createElement(Box, {
203
+ sx: styles.logoSection
204
+ }, /*#__PURE__*/React.createElement(LogoText, {
205
+ appName: "Suite",
206
+ appColor: theme.palette.grey['500']
207
+ })), /*#__PURE__*/React.createElement(Box, {
208
+ sx: styles.mainInfos
209
+ }, /*#__PURE__*/React.createElement(Fade, {
210
+ "in": loadingGlobalVersion,
211
+ appear: true,
212
+ unmountOnExit: true,
213
+ onExited: function onExited(node) {
214
+ return setShowGlobalVersion(true);
215
+ }
216
+ }, /*#__PURE__*/React.createElement(CircularProgress, null)), showGlobalVersion && /*#__PURE__*/React.createElement(Typography, null, /*#__PURE__*/React.createElement(FormattedMessage, {
217
+ id: "about-dialog/version",
218
+ defaultMessage: "Version {version}",
219
+ values: {
220
+ version: /*#__PURE__*/React.createElement(Typography, {
221
+ component: "span",
222
+ sx: styles.versionField(!loadingGlobalVersion && actualGlobalVersion)
223
+ }, actualGlobalVersion || 'unknown')
224
+ }
225
+ }))))), /*#__PURE__*/React.createElement(DialogContent, {
226
+ id: "alert-dialog-description"
227
+ }, /*#__PURE__*/React.createElement(Box, {
228
+ sx: styles.detailsSection
229
+ }, /*#__PURE__*/React.createElement(Accordion, {
230
+ disableGutters: true,
231
+ variant: "outlined",
232
+ disabled: true,
233
+ sx: {
234
+ display: 'none'
235
+ }
236
+ }, /*#__PURE__*/React.createElement(AccordionSummary, {
237
+ expandIcon: /*#__PURE__*/React.createElement(ExpandMore, null),
238
+ "aria-controls": "panel1-content",
239
+ id: "panel1-header"
240
+ }, /*#__PURE__*/React.createElement(Gavel, {
241
+ fontSize: "small"
242
+ }), /*#__PURE__*/React.createElement(Typography, {
243
+ sx: {
244
+ width: '33%',
245
+ flexShrink: 0
246
+ }
247
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
248
+ id: "about-dialog/license"
249
+ })), /*#__PURE__*/React.createElement(Typography, {
250
+ sx: {
251
+ color: 'text.secondary'
252
+ }
253
+ }, appLicense)), /*#__PURE__*/React.createElement(AccordionDetails, null, "license app summary text")), /*#__PURE__*/React.createElement(Accordion, {
254
+ disableGutters: true,
255
+ variant: "outlined",
256
+ TransitionProps: {
257
+ unmountOnExit: true
258
+ }
259
+ }, /*#__PURE__*/React.createElement(AccordionSummary, {
260
+ expandIcon: /*#__PURE__*/React.createElement(ExpandMore, null),
261
+ "aria-controls": "panel2-content",
262
+ id: "panel2-header"
263
+ }, /*#__PURE__*/React.createElement(Apps, {
264
+ fontSize: "small"
265
+ }), /*#__PURE__*/React.createElement(FormattedMessage, {
266
+ id: "about-dialog/modules-section"
267
+ })), /*#__PURE__*/React.createElement(AccordionDetails, null, /*#__PURE__*/React.createElement(Grid, {
268
+ container: true,
269
+ sx: {
270
+ pl: 2
271
+ },
272
+ spacing: 1
273
+ }, loadingAdditionalModules ? /*#__PURE__*/React.createElement(Grid, {
274
+ item: true,
275
+ xs: true,
276
+ display: "inline-flex",
277
+ justifyContent: "center"
278
+ }, /*#__PURE__*/React.createElement(CircularProgress, {
279
+ color: "inherit"
280
+ })) : Array.isArray(modules) && /*#__PURE__*/React.createElement(React.Fragment, null, [].concat(modules).sort(compareModules).map(function (module, idx) {
281
+ return /*#__PURE__*/React.createElement(Module, {
282
+ key: "module-" + idx,
283
+ type: module.type,
284
+ name: module.name,
285
+ version: module.version,
286
+ gitTag: module.gitTag,
287
+ license: module.license
288
+ });
289
+ })) || /*#__PURE__*/React.createElement(Typography, {
290
+ color: function color(theme) {
291
+ return theme.palette.error.main;
292
+ }
293
+ }, "Error")))))), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
294
+ onClick: handleClose,
295
+ autoFocus: true
296
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
297
+ id: "close"
298
+ }))));
299
+ };
300
+ export default AboutDialog;
301
+ AboutDialog.propTypes = process.env.NODE_ENV !== "production" ? {
302
+ open: PropTypes.bool.isRequired,
303
+ onClose: PropTypes.func,
304
+ appName: PropTypes.string.isRequired,
305
+ appVersion: PropTypes.string,
306
+ appGitTag: PropTypes.string,
307
+ appLicense: PropTypes.string,
308
+ globalVersionPromise: PropTypes.func,
309
+ additionalModulesPromise: PropTypes.func
310
+ } : {};
311
+ var moduleStyles = {
312
+ icons: {
313
+ flexGrow: 0,
314
+ position: 'relative',
315
+ top: '4px',
316
+ flexShrink: 0
317
+ },
318
+ version: {
319
+ flexGrow: 0,
320
+ alignSelf: 'flex-end',
321
+ flexShrink: 0
322
+ },
323
+ tooltip: function tooltip(theme) {
324
+ var _ref2;
325
+ return _ref2 = {}, _ref2["& ." + tooltipClasses.tooltip] = {
326
+ border: '1px solid #dadde9',
327
+ boxShadow: theme.shadows[1]
328
+ }, _ref2;
329
+ },
330
+ tooltipDetails: {
331
+ display: 'grid',
332
+ gridTemplateColumns: 'max-content auto',
333
+ margin: 0,
334
+ dt: {
335
+ gridColumnStart: 1,
336
+ '&:after': {
337
+ content: '" :"'
338
+ }
339
+ },
340
+ dd: {
341
+ gridColumnStart: 2,
342
+ paddingLeft: '0.5em'
343
+ }
344
+ }
345
+ };
346
+ var ModuleTypesIcons = {
347
+ app: /*#__PURE__*/React.createElement(WidgetsOutlined, {
348
+ sx: moduleStyles.icons,
349
+ fontSize: "small",
350
+ color: "primary"
351
+ }),
352
+ server: /*#__PURE__*/React.createElement(DnsOutlined, {
353
+ sx: moduleStyles.icons,
354
+ fontSize: "small",
355
+ color: "secondary"
356
+ }),
357
+ other: /*#__PURE__*/React.createElement(QuestionMark, {
358
+ sx: moduleStyles.icons,
359
+ fontSize: "small"
360
+ })
361
+ };
362
+ function insensitiveCaseCompare(str, obj) {
363
+ return str.localeCompare(obj, undefined, {
364
+ sensitivity: 'base'
365
+ });
366
+ }
367
+ function tooltipTypeLabel(type) {
368
+ if (insensitiveCaseCompare('app', type) === 0) {
369
+ return 'about-dialog/module-tooltip-app';
370
+ } else if (insensitiveCaseCompare('server', type) === 0) {
371
+ return 'about-dialog/module-tooltip-server';
372
+ } else {
373
+ return 'about-dialog/module-tooltip-other';
374
+ }
375
+ }
376
+ var Module = function Module(_ref3) {
377
+ var type = _ref3.type,
378
+ name = _ref3.name,
379
+ version = _ref3.version,
380
+ gitTag = _ref3.gitTag,
381
+ license = _ref3.license;
382
+ return /*#__PURE__*/React.createElement(Grid, {
383
+ item: true,
384
+ xs: 12,
385
+ sm: 6,
386
+ md: 4,
387
+ sx: {
388
+ '.MuiTypography-root': {
389
+ minWidth: '3em'
390
+ }
391
+ }
392
+ }, /*#__PURE__*/React.createElement(Tooltip, {
393
+ TransitionComponent: Zoom,
394
+ enterDelay: 2500,
395
+ enterNextDelay: 350,
396
+ leaveDelay: 200,
397
+ placement: "bottom-start",
398
+ arrow: true,
399
+ sx: moduleStyles.tooltip,
400
+ title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
401
+ variant: "body1"
402
+ }, name || '<?>'), /*#__PURE__*/React.createElement(Box, {
403
+ component: "dl",
404
+ sx: moduleStyles.tooltipDetails
405
+ }, /*#__PURE__*/React.createElement(Typography, {
406
+ variant: "body2",
407
+ component: "dt"
408
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
409
+ id: "about-dialog/label-type"
410
+ })), /*#__PURE__*/React.createElement(Typography, {
411
+ variant: "body2",
412
+ component: "dd"
413
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
414
+ id: tooltipTypeLabel(type)
415
+ })), version && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
416
+ variant: "body2",
417
+ component: "dt"
418
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
419
+ id: "about-dialog/label-version"
420
+ })), /*#__PURE__*/React.createElement(Typography, {
421
+ variant: "body2",
422
+ component: "dd"
423
+ }, version)), gitTag && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
424
+ variant: "body2",
425
+ component: "dt"
426
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
427
+ id: "about-dialog/label-git-version"
428
+ })), /*#__PURE__*/React.createElement(Typography, {
429
+ variant: "body2",
430
+ component: "dd"
431
+ }, gitTag))))
432
+ }, /*#__PURE__*/React.createElement(Stack, {
433
+ direction: "row",
434
+ justifyContent: "flex-start",
435
+ alignItems: "baseline",
436
+ spacing: 1
437
+ }, ModuleTypesIcons[type] || ModuleTypesIcons['other'], /*#__PURE__*/React.createElement(Typography, {
438
+ display: "inline",
439
+ noWrap: true
440
+ }, name || '<?>'), /*#__PURE__*/React.createElement(Typography, {
441
+ variant: "caption",
442
+ color: function color(theme) {
443
+ return theme.palette.text.secondary;
444
+ },
445
+ display: "inline",
446
+ noWrap: true,
447
+ sx: moduleStyles.version
448
+ }, gitTag || version || null))));
449
+ };
450
+ Module.propTypes = process.env.NODE_ENV !== "production" ? {
451
+ type: PropTypes.string,
452
+ name: PropTypes.string,
453
+ version: PropTypes.string,
454
+ gitTag: PropTypes.string,
455
+ license: PropTypes.string
456
+ } : {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Copyright (c) 2023, RTE (http://www.rte-france.com)
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ */
7
+
8
+ import React from 'react';
9
+ import { Box, Typography } from '@mui/material';
10
+ import { BrokenImage } from '@mui/icons-material';
11
+ import { mergeSx } from '../../utils/styles';
12
+ import PropTypes from 'prop-types';
13
+ var styles = {
14
+ logo: {
15
+ flexShrink: 0,
16
+ width: 48,
17
+ height: 48,
18
+ marginBottom: '8px'
19
+ },
20
+ title: {
21
+ marginLeft: '18px'
22
+ },
23
+ clickable: {
24
+ cursor: 'pointer'
25
+ }
26
+ };
27
+ var GridLogo = function GridLogo(_ref) {
28
+ var appLogo = _ref.appLogo,
29
+ appName = _ref.appName,
30
+ appColor = _ref.appColor,
31
+ onClick = _ref.onClick;
32
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
33
+ sx: mergeSx(styles.logo, onClick && styles.clickable),
34
+ onClick: onClick
35
+ }, appLogo || /*#__PURE__*/React.createElement(BrokenImage, null)), /*#__PURE__*/React.createElement(LogoText, {
36
+ appName: appName,
37
+ appColor: appColor,
38
+ onClick: onClick,
39
+ style: styles.title
40
+ }));
41
+ };
42
+ export default GridLogo;
43
+ GridLogo.propTypes = process.env.NODE_ENV !== "production" ? {
44
+ appLogo: PropTypes.element,
45
+ appName: PropTypes.string.isRequired,
46
+ appColor: PropTypes.string.isRequired,
47
+ onClick: PropTypes.func
48
+ } : {};
49
+ export var LogoText = function LogoText(_ref2) {
50
+ var appName = _ref2.appName,
51
+ appColor = _ref2.appColor,
52
+ style = _ref2.style,
53
+ onClick = _ref2.onClick;
54
+ return /*#__PURE__*/React.createElement(Typography, {
55
+ variant: "h4",
56
+ sx: mergeSx(style, onClick && styles.clickable),
57
+ onClick: onClick
58
+ }, /*#__PURE__*/React.createElement("span", {
59
+ style: {
60
+ fontWeight: 'bold'
61
+ }
62
+ }, "Grid"), /*#__PURE__*/React.createElement("span", {
63
+ style: {
64
+ color: appColor
65
+ }
66
+ }, appName));
67
+ };
68
+ LogoText.propTypes = process.env.NODE_ENV !== "production" ? {
69
+ appName: PropTypes.string.isRequired,
70
+ appColor: PropTypes.string.isRequired,
71
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
72
+ onClick: PropTypes.func
73
+ } : {};
@@ -6,63 +6,24 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
6
6
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
7
  */
8
8
 
9
- import React, { useEffect, useRef, useState } from 'react';
9
+ import React, { useMemo, useRef, useState } from 'react';
10
10
  import { FormattedMessage } from 'react-intl';
11
- import AppBar from '@mui/material/AppBar';
12
- import ExitToAppIcon from '@mui/icons-material/ExitToApp';
11
+ import { AppBar, Box, Button, ClickAwayListener, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, MenuList, Paper, Popper, ToggleButton, ToggleButtonGroup, Toolbar, Typography } from '@mui/material';
12
+ import { Apps as AppsIcon, ArrowDropDown as ArrowDropDownIcon, ArrowDropUp as ArrowDropUpIcon, Brightness3 as Brightness3Icon, Computer as ComputerIcon, ExitToApp as ExitToAppIcon, Fullscreen as FullscreenIcon, FullscreenExit as FullscreenExitIcon, HelpOutline as HelpOutlineIcon, Person as PersonIcon, Settings as SettingsIcon, WbSunny as WbSunnyIcon } from '@mui/icons-material';
13
13
  import { darken } from '@mui/material/styles';
14
14
  import { styled } from '@mui/system';
15
- import Toolbar from '@mui/material/Toolbar';
16
- import Typography from '@mui/material/Typography';
17
- import SettingsIcon from '@mui/icons-material/Settings';
18
- import Button from '@mui/material/Button';
19
- import Menu from '@mui/material/Menu';
20
- import MenuItem from '@mui/material/MenuItem';
21
- import Box from '@mui/material/Box';
22
- import ListItemIcon from '@mui/material/ListItemIcon';
23
- import ListItemText from '@mui/material/ListItemText';
24
- import AppsIcon from '@mui/icons-material/Apps';
25
- import SearchIcon from '@mui/icons-material/Search';
26
- import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
27
- import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
28
- import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp';
29
- import PersonIcon from '@mui/icons-material/Person';
30
- import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
31
- import Brightness3Icon from '@mui/icons-material/Brightness3';
32
- import WbSunnyIcon from '@mui/icons-material/WbSunny';
33
- import ComputerIcon from '@mui/icons-material/Computer';
34
- import ToggleButton from '@mui/material/ToggleButton';
35
- import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
36
15
  import PropTypes from 'prop-types';
37
- import FullscreenIcon from '@mui/icons-material/Fullscreen';
38
16
  import FullScreen, { fullScreenSupported } from 'react-request-fullscreen';
39
- import Popper from '@mui/material/Popper';
40
- import Paper from '@mui/material/Paper';
41
- import MenuList from '@mui/material/MenuList';
42
- import ClickAwayListener from '@mui/material/ClickAwayListener';
43
- import { mergeSx } from '../../utils/styles';
44
- import ElementSearchDialog from '../ElementSearchDialog';
17
+ import GridLogo from './GridLogo';
18
+ import AboutDialog from './AboutDialog';
45
19
  var styles = {
46
20
  grow: {
47
21
  flexGrow: 1,
48
22
  display: 'flex',
49
23
  overflow: 'hidden'
50
24
  },
51
- logo: {
52
- flexShrink: 0,
53
- width: 48,
54
- height: 48,
55
- marginBottom: '8px'
56
- },
57
- menuIcon: {
58
- width: 24,
59
- height: 24
60
- },
61
- title: {
62
- marginLeft: '18px'
63
- },
64
- clickable: {
65
- cursor: 'pointer'
25
+ menuContainer: {
26
+ marginLeft: 1
66
27
  },
67
28
  link: {
68
29
  textDecoration: 'none',
@@ -162,6 +123,8 @@ var TopBar = function TopBar(_ref2) {
162
123
  var appName = _ref2.appName,
163
124
  appColor = _ref2.appColor,
164
125
  appLogo = _ref2.appLogo,
126
+ appVersion = _ref2.appVersion,
127
+ appLicense = _ref2.appLicense,
165
128
  onParametersClick = _ref2.onParametersClick,
166
129
  onLogoutClick = _ref2.onLogoutClick,
167
130
  onLogoClick = _ref2.onLogoClick,
@@ -169,21 +132,14 @@ var TopBar = function TopBar(_ref2) {
169
132
  children = _ref2.children,
170
133
  appsAndUrls = _ref2.appsAndUrls,
171
134
  onAboutClick = _ref2.onAboutClick,
135
+ globalVersionPromise = _ref2.globalVersionPromise,
136
+ additionalModulesPromise = _ref2.additionalModulesPromise,
172
137
  onThemeClick = _ref2.onThemeClick,
173
138
  theme = _ref2.theme,
174
139
  onEquipmentLabellingClick = _ref2.onEquipmentLabellingClick,
175
140
  equipmentLabelling = _ref2.equipmentLabelling,
176
- withElementsSearch = _ref2.withElementsSearch,
177
- searchDisabled = _ref2.searchDisabled,
178
- searchingLabel = _ref2.searchingLabel,
179
- onSearchTermChange = _ref2.onSearchTermChange,
180
- _onSelectionChange = _ref2.onSelectionChange,
181
- elementsFound = _ref2.elementsFound,
182
- renderElement = _ref2.renderElement,
183
141
  onLanguageClick = _ref2.onLanguageClick,
184
- language = _ref2.language,
185
- searchTermDisabled = _ref2.searchTermDisabled,
186
- searchTermDisableReason = _ref2.searchTermDisableReason;
142
+ language = _ref2.language;
187
143
  var _React$useState = React.useState(null),
188
144
  anchorElSettingsMenu = _React$useState[0],
189
145
  setAnchorElSettingsMenu = _React$useState[1];
@@ -194,12 +150,6 @@ var TopBar = function TopBar(_ref2) {
194
150
  var _useState = useState(false),
195
151
  isFullScreen = _useState[0],
196
152
  setIsFullScreen = _useState[1];
197
- var _useState2 = useState(false),
198
- isDialogSearchOpen = _useState2[0],
199
- setDialogSearchOpen = _useState2[1];
200
- var handleClickElementSearch = function handleClickElementSearch() {
201
- setDialogSearchOpen(true);
202
- };
203
153
  var handleToggleSettingsMenu = function handleToggleSettingsMenu(event) {
204
154
  setAnchorElSettingsMenu(event.currentTarget);
205
155
  };
@@ -251,26 +201,25 @@ var TopBar = function TopBar(_ref2) {
251
201
  onLanguageClick(value);
252
202
  }
253
203
  };
204
+ var _useState2 = useState(false),
205
+ isAboutDialogOpen = _useState2[0],
206
+ setAboutDialogOpen = _useState2[1];
254
207
  var onAboutClicked = function onAboutClicked() {
255
208
  setAnchorElSettingsMenu(false);
256
209
  if (onAboutClick) {
257
210
  onAboutClick();
211
+ } else {
212
+ setAboutDialogOpen(true);
258
213
  }
259
214
  };
260
- useEffect(function () {
261
- if (user && withElementsSearch && !searchDisabled) {
262
- var openSearch = function openSearch(e) {
263
- if (e.ctrlKey && e.shiftKey && (e.key === 'F' || e.key === 'f')) {
264
- e.preventDefault();
265
- setDialogSearchOpen(true);
266
- }
267
- };
268
- document.addEventListener('keydown', openSearch);
269
- return function () {
270
- return document.removeEventListener('keydown', openSearch);
271
- };
272
- }
273
- }, [user, withElementsSearch, searchDisabled]);
215
+ var logo_clickable = useMemo(function () {
216
+ return /*#__PURE__*/React.createElement(GridLogo, {
217
+ onClick: onLogoClick,
218
+ appLogo: appLogo,
219
+ appName: appName,
220
+ appColor: appColor
221
+ });
222
+ }, [onLogoClick, appLogo, appName, appColor]);
274
223
  return /*#__PURE__*/React.createElement(AppBar, {
275
224
  position: "static",
276
225
  color: "default",
@@ -281,43 +230,10 @@ var TopBar = function TopBar(_ref2) {
281
230
  onFullScreenError: function onFullScreenError(e) {
282
231
  return console.debug('full screen error : ' + e.message);
283
232
  }
284
- }), /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(Box, {
285
- sx: mergeSx(styles.logo, onLogoClick && styles.clickable),
286
- onClick: onLogoClick
287
- }, appLogo), /*#__PURE__*/React.createElement(Typography, {
288
- variant: "h4",
289
- sx: mergeSx(styles.title, onLogoClick && styles.clickable),
290
- onClick: onLogoClick
291
- }, /*#__PURE__*/React.createElement("span", {
292
- style: {
293
- fontWeight: 'bold'
294
- }
295
- }, "Grid"), /*#__PURE__*/React.createElement("span", {
296
- style: {
297
- color: appColor
298
- }
299
- }, appName)), /*#__PURE__*/React.createElement(Box, {
233
+ }), /*#__PURE__*/React.createElement(Toolbar, null, logo_clickable, /*#__PURE__*/React.createElement(Box, {
300
234
  sx: styles.grow
301
- }, children), user && withElementsSearch && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ElementSearchDialog, {
302
- open: isDialogSearchOpen,
303
- onClose: function onClose() {
304
- return setDialogSearchOpen(false);
305
- },
306
- searchingLabel: searchingLabel,
307
- onSearchTermChange: onSearchTermChange,
308
- onSelectionChange: function onSelectionChange(element) {
309
- setDialogSearchOpen(false);
310
- _onSelectionChange(element);
311
- },
312
- elementsFound: elementsFound,
313
- renderElement: renderElement,
314
- searchTermDisabled: searchTermDisabled,
315
- searchTermDisableReason: searchTermDisableReason
316
- }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
317
- color: "inherit",
318
- onClick: handleClickElementSearch,
319
- disabled: searchDisabled
320
- }, /*#__PURE__*/React.createElement(SearchIcon, null)))), user && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
235
+ }, children), user && /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(IconButton, {
236
+ "aria-label": "apps",
321
237
  "aria-controls": "apps-menu",
322
238
  "aria-haspopup": "true",
323
239
  onClick: handleClickAppsMenu,
@@ -350,7 +266,9 @@ var TopBar = function TopBar(_ref2) {
350
266
  fontWeight: 'bold'
351
267
  }
352
268
  }, item.name))));
353
- }))), user && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
269
+ }))), user && /*#__PURE__*/React.createElement(Box, {
270
+ sx: styles.menuContainerg
271
+ }, /*#__PURE__*/React.createElement(Button, {
354
272
  "aria-controls": "settings-menu",
355
273
  "aria-haspopup": "true",
356
274
  sx: styles.showHideMenu,
@@ -484,8 +402,7 @@ var TopBar = function TopBar(_ref2) {
484
402
  value: LANG_FRENCH,
485
403
  "aria-label": LANG_FRENCH,
486
404
  sx: styles.toggleButton
487
- }, FR))), /*#__PURE__*/React.createElement(StyledMenuItem, {
488
- disabled: !onParametersClick,
405
+ }, FR))), onParametersClick && /*#__PURE__*/React.createElement(StyledMenuItem, {
489
406
  onClick: onParametersClicked,
490
407
  sx: styles.borderTop
491
408
  }, /*#__PURE__*/React.createElement(CustomListItemIcon, null, /*#__PURE__*/React.createElement(SettingsIcon, {
@@ -497,7 +414,6 @@ var TopBar = function TopBar(_ref2) {
497
414
  defaultMessage: 'Settings'
498
415
  })))), /*#__PURE__*/React.createElement(StyledMenuItem, {
499
416
  sx: styles.borderBottom,
500
- disabled: !onAboutClick,
501
417
  style: {
502
418
  opacity: '1'
503
419
  },
@@ -534,7 +450,17 @@ var TopBar = function TopBar(_ref2) {
534
450
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
535
451
  id: "top-bar/logout",
536
452
  defaultMessage: 'Logout'
537
- })))))))))));
453
+ }))))))))), /*#__PURE__*/React.createElement(AboutDialog, {
454
+ open: isAboutDialogOpen,
455
+ onClose: function onClose() {
456
+ return setAboutDialogOpen(false);
457
+ },
458
+ appName: appName,
459
+ appVersion: appVersion,
460
+ appLicense: appLicense,
461
+ globalVersionPromise: globalVersionPromise,
462
+ additionalModulesPromise: additionalModulesPromise
463
+ })));
538
464
  };
539
465
  TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
540
466
  onParametersClick: PropTypes.func,
@@ -543,23 +469,19 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
543
469
  appName: PropTypes.string,
544
470
  appColor: PropTypes.string,
545
471
  appLogo: PropTypes.object,
472
+ appVersion: PropTypes.string,
473
+ appLicense: PropTypes.string,
546
474
  user: PropTypes.object,
547
475
  children: PropTypes.node,
548
476
  appsAndUrls: PropTypes.array,
549
477
  onThemeClick: PropTypes.func,
550
478
  theme: PropTypes.string,
551
479
  onAboutClick: PropTypes.func,
480
+ globalVersionPromise: PropTypes.func,
481
+ additionalModulesPromise: PropTypes.func,
552
482
  onEquipmentLabellingClick: PropTypes.func,
553
483
  equipmentLabelling: PropTypes.bool,
554
- withElementsSearch: PropTypes.bool,
555
- searchDisabled: PropTypes.bool,
556
- searchingLabel: PropTypes.string,
557
- onSearchTermChange: PropTypes.func,
558
- onSelectionChange: PropTypes.func,
559
- elementsFound: PropTypes.array,
560
484
  onLanguageClick: PropTypes.func.isRequired,
561
- language: PropTypes.string.isRequired,
562
- searchTermDisabled: PropTypes.bool,
563
- searchTermDisableReason: PropTypes.string
485
+ language: PropTypes.string.isRequired
564
486
  } : {};
565
487
  export default TopBar;
@@ -4,4 +4,6 @@
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
- export { default } from './TopBar';
7
+ export { default } from './TopBar';
8
+ export * from './GridLogo';
9
+ export { default as AboutDialog } from './AboutDialog';
@@ -16,6 +16,17 @@ var top_bar_en = {
16
16
  'top-bar/id': 'Id',
17
17
  'top-bar/name': 'Name',
18
18
  'top-bar/language': 'Language',
19
- 'top-bar/customTheme': 'Custom theme'
19
+ 'top-bar/customTheme': 'Custom theme',
20
+ 'about-dialog/title': 'About',
21
+ 'about-dialog/version': 'Version {version}',
22
+ 'about-dialog/alert-running-old-version-msg': 'Running old version.\nSave your work and refresh the application to load the latest version.',
23
+ 'about-dialog/license': 'License',
24
+ 'about-dialog/modules-section': 'Modules details',
25
+ 'about-dialog/label-version': 'Version',
26
+ 'about-dialog/label-git-version': 'Tag',
27
+ 'about-dialog/label-type': 'Type',
28
+ 'about-dialog/module-tooltip-app': 'application',
29
+ 'about-dialog/module-tooltip-server': 'server',
30
+ 'about-dialog/module-tooltip-other': 'other'
20
31
  };
21
32
  export default top_bar_en;
@@ -10,12 +10,23 @@ var top_bar_fr = {
10
10
  'top-bar/logout': 'Se déconnecter',
11
11
  'top-bar/goFullScreen': 'Plein écran',
12
12
  'top-bar/exitFullScreen': 'Quitter mode plein écran',
13
- 'top-bar/about': 'A propos',
13
+ 'top-bar/about': 'À propos',
14
14
  'top-bar/displayMode': "Mode d'affichage",
15
15
  'top-bar/equipmentLabel': 'Label des ouvrages',
16
16
  'top-bar/id': 'Id',
17
17
  'top-bar/name': 'Nom',
18
18
  'top-bar/language': 'Langue',
19
- 'top-bar/customTheme': 'Choix de theme'
19
+ 'top-bar/customTheme': 'Choix de theme',
20
+ 'about-dialog/title': 'À propos',
21
+ 'about-dialog/version': 'Version {version}',
22
+ 'about-dialog/alert-running-old-version-msg': "Ancienne version de l'application.\nVeuillez sauvegarder votre travail et rafraîchir l'application pour charger la dernière version",
23
+ 'about-dialog/license': 'Licence',
24
+ 'about-dialog/modules-section': 'Détails des modules',
25
+ 'about-dialog/label-version': 'Version',
26
+ 'about-dialog/label-git-version': 'Tag',
27
+ 'about-dialog/label-type': 'Type',
28
+ 'about-dialog/module-tooltip-app': 'application',
29
+ 'about-dialog/module-tooltip-server': 'serveur',
30
+ 'about-dialog/module-tooltip-other': 'autre'
20
31
  };
21
32
  export default top_bar_fr;
package/es/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  export { default as TreeViewFinder } from './components/TreeViewFinder';
9
9
  export { default as TopBar } from './components/TopBar';
10
+ export { default as AboutDialog } from './components/TopBar/AboutDialog';
10
11
  export { default as SnackbarProvider } from './components/SnackbarProvider';
11
12
  export { default as AuthenticationRouter } from './components/AuthenticationRouter';
12
13
  export { default as MuiVirtualizedTable } from './components/MuiVirtualizedTable';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",