@gridsuite/commons-ui 0.41.0 → 0.42.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.
- package/es/components/TopBar/AboutDialog.js +333 -0
- package/es/components/TopBar/GridLogo.js +73 -0
- package/es/components/TopBar/TopBar.js +39 -60
- package/es/components/TopBar/index.js +3 -1
- package/es/components/translations/top-bar-en.js +7 -1
- package/es/components/translations/top-bar-fr.js +8 -2
- package/es/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,333 @@
|
|
|
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, Typography, useMediaQuery, useTheme } 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 moduleTypeSort = {
|
|
16
|
+
app: 1,
|
|
17
|
+
server: 10,
|
|
18
|
+
other: 20
|
|
19
|
+
};
|
|
20
|
+
function compareModules(c1, c2) {
|
|
21
|
+
//sort by type then by name
|
|
22
|
+
return [moduleTypeSort[c1.type] || 100] - [moduleTypeSort[c2.type] || 100] || (c1.name || '').localeCompare(c2.name || '');
|
|
23
|
+
}
|
|
24
|
+
var AboutDialog = function AboutDialog(_ref) {
|
|
25
|
+
var open = _ref.open,
|
|
26
|
+
onClose = _ref.onClose,
|
|
27
|
+
getGlobalVersion = _ref.getGlobalVersion,
|
|
28
|
+
appName = _ref.appName,
|
|
29
|
+
appVersion = _ref.appVersion,
|
|
30
|
+
appGitTag = _ref.appGitTag,
|
|
31
|
+
appLicense = _ref.appLicense,
|
|
32
|
+
getAdditionalModules = _ref.getAdditionalModules;
|
|
33
|
+
var theme = useTheme();
|
|
34
|
+
var _useState = useState(false),
|
|
35
|
+
isRefreshing = _useState[0],
|
|
36
|
+
setRefreshState = _useState[1];
|
|
37
|
+
var _useState2 = useState(false),
|
|
38
|
+
loadingGlobalVersion = _useState2[0],
|
|
39
|
+
setLoadingGlobalVersion = _useState2[1];
|
|
40
|
+
|
|
41
|
+
/* We want to get the initial version once at first render to detect later a new deploy */
|
|
42
|
+
var _useState3 = useState(undefined),
|
|
43
|
+
startingGlobalVersion = _useState3[0],
|
|
44
|
+
setStartingGlobalVersion = _useState3[1];
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (startingGlobalVersion === undefined && getGlobalVersion) {
|
|
47
|
+
getGlobalVersion(function (value) {
|
|
48
|
+
setStartingGlobalVersion(value);
|
|
49
|
+
setActualGlobalVersion(value);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, [getGlobalVersion, startingGlobalVersion]);
|
|
53
|
+
var _useState4 = useState(null),
|
|
54
|
+
actualGlobalVersion = _useState4[0],
|
|
55
|
+
setActualGlobalVersion = _useState4[1];
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (open && getGlobalVersion) {
|
|
58
|
+
setLoadingGlobalVersion(true);
|
|
59
|
+
getGlobalVersion(function (value) {
|
|
60
|
+
setLoadingGlobalVersion(false);
|
|
61
|
+
setActualGlobalVersion(value || null);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [open, getGlobalVersion]);
|
|
65
|
+
var _useState5 = useState(false),
|
|
66
|
+
loadingAdditionalModules = _useState5[0],
|
|
67
|
+
setLoadingAdditionalModules = _useState5[1];
|
|
68
|
+
var _useState6 = useState(null),
|
|
69
|
+
modules = _useState6[0],
|
|
70
|
+
setModules = _useState6[1];
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
if (open) {
|
|
73
|
+
var currentApp = {
|
|
74
|
+
name: "Grid" + appName,
|
|
75
|
+
type: 'app',
|
|
76
|
+
version: appVersion,
|
|
77
|
+
gitTag: appGitTag,
|
|
78
|
+
license: appLicense
|
|
79
|
+
};
|
|
80
|
+
if (getAdditionalModules) {
|
|
81
|
+
setLoadingAdditionalModules(true);
|
|
82
|
+
getAdditionalModules(function (values) {
|
|
83
|
+
setLoadingAdditionalModules(false);
|
|
84
|
+
if (Array.isArray(values)) {
|
|
85
|
+
setModules([currentApp].concat(values));
|
|
86
|
+
} else {
|
|
87
|
+
setModules([currentApp]);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
setModules([currentApp]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [open, getAdditionalModules, appName, appVersion, appGitTag, appLicense]);
|
|
95
|
+
var handleClose = useCallback(function () {
|
|
96
|
+
if (onClose) {
|
|
97
|
+
onClose();
|
|
98
|
+
}
|
|
99
|
+
setModules(null);
|
|
100
|
+
setActualGlobalVersion(null);
|
|
101
|
+
}, [onClose]);
|
|
102
|
+
return /*#__PURE__*/React.createElement(Dialog, {
|
|
103
|
+
onClose: handleClose,
|
|
104
|
+
open: open,
|
|
105
|
+
fullWidth: true,
|
|
106
|
+
maxWidth: "md",
|
|
107
|
+
fullScreen: useMediaQuery(theme.breakpoints.down('md')),
|
|
108
|
+
"aria-labelledby": "alert-dialog-title",
|
|
109
|
+
"aria-describedby": "alert-dialog-description"
|
|
110
|
+
}, /*#__PURE__*/React.createElement(DialogTitle, {
|
|
111
|
+
id: "alert-dialog-title"
|
|
112
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
113
|
+
id: 'about-dialog/title'
|
|
114
|
+
})), /*#__PURE__*/React.createElement(DialogContent, {
|
|
115
|
+
dividers: true,
|
|
116
|
+
id: "alert-dialog-description"
|
|
117
|
+
}, /*#__PURE__*/React.createElement(Box, null, startingGlobalVersion !== undefined && startingGlobalVersion !== null && actualGlobalVersion !== null && startingGlobalVersion !== actualGlobalVersion && /*#__PURE__*/React.createElement(Collapse, {
|
|
118
|
+
"in": open
|
|
119
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
120
|
+
severity: "warning",
|
|
121
|
+
variant: "outlined",
|
|
122
|
+
action: /*#__PURE__*/React.createElement(LoadingButton, {
|
|
123
|
+
color: "inherit",
|
|
124
|
+
size: "small",
|
|
125
|
+
startIcon: /*#__PURE__*/React.createElement(Refresh, {
|
|
126
|
+
fontSize: "small"
|
|
127
|
+
}),
|
|
128
|
+
loadingPosition: "start",
|
|
129
|
+
loading: isRefreshing,
|
|
130
|
+
onClick: function onClick() {
|
|
131
|
+
setRefreshState(true);
|
|
132
|
+
window.location.reload();
|
|
133
|
+
}
|
|
134
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
135
|
+
id: "refresh"
|
|
136
|
+
})),
|
|
137
|
+
sx: {
|
|
138
|
+
marginBottom: 1
|
|
139
|
+
}
|
|
140
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
141
|
+
id: "about-dialog/alert-running-old-version-msg"
|
|
142
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
143
|
+
sx: {
|
|
144
|
+
display: 'flex',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
justifyContent: 'center'
|
|
147
|
+
}
|
|
148
|
+
}, /*#__PURE__*/React.createElement(LogoText, {
|
|
149
|
+
appName: "Suite",
|
|
150
|
+
appColor: theme.palette.grey['500']
|
|
151
|
+
})), /*#__PURE__*/React.createElement(Box, {
|
|
152
|
+
component: "dl",
|
|
153
|
+
sx: {
|
|
154
|
+
textAlign: 'center',
|
|
155
|
+
marginTop: 0,
|
|
156
|
+
'dt, dd': {
|
|
157
|
+
display: 'inline',
|
|
158
|
+
margin: 0
|
|
159
|
+
},
|
|
160
|
+
dt: {
|
|
161
|
+
marginRight: '0.5em',
|
|
162
|
+
'&:after': {
|
|
163
|
+
content: '" :"'
|
|
164
|
+
},
|
|
165
|
+
'&:before': {
|
|
166
|
+
content: "'\\A'",
|
|
167
|
+
whiteSpace: 'pre'
|
|
168
|
+
},
|
|
169
|
+
'&:first-child': {
|
|
170
|
+
'&:before': {
|
|
171
|
+
content: "''"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, /*#__PURE__*/React.createElement("dt", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
177
|
+
id: "about-dialog/version"
|
|
178
|
+
})), /*#__PURE__*/React.createElement("dd", null, loadingGlobalVersion ? '…' : actualGlobalVersion ? /*#__PURE__*/React.createElement("b", {
|
|
179
|
+
style: {
|
|
180
|
+
fontSize: '1.5em'
|
|
181
|
+
}
|
|
182
|
+
}, actualGlobalVersion) : /*#__PURE__*/React.createElement("i", null, "unknown")), /*#__PURE__*/React.createElement(Fade, {
|
|
183
|
+
"in": loadingGlobalVersion,
|
|
184
|
+
style: {
|
|
185
|
+
transitionDelay: '500ms'
|
|
186
|
+
},
|
|
187
|
+
unmountOnExit: true
|
|
188
|
+
}, /*#__PURE__*/React.createElement(CircularProgress, {
|
|
189
|
+
size: "1rem"
|
|
190
|
+
})))), /*#__PURE__*/React.createElement(Box, {
|
|
191
|
+
sx: {
|
|
192
|
+
'.MuiAccordion-root': {
|
|
193
|
+
//dunno why the theme has the background as black in dark mode
|
|
194
|
+
bgcolor: 'unset'
|
|
195
|
+
},
|
|
196
|
+
'.MuiAccordionSummary-content > .MuiSvgIcon-root': {
|
|
197
|
+
marginRight: '0.5rem'
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, /*#__PURE__*/React.createElement(Accordion, {
|
|
201
|
+
disableGutters: true,
|
|
202
|
+
variant: "outlined",
|
|
203
|
+
disabled: true,
|
|
204
|
+
sx: {
|
|
205
|
+
display: 'none'
|
|
206
|
+
}
|
|
207
|
+
}, /*#__PURE__*/React.createElement(AccordionSummary, {
|
|
208
|
+
expandIcon: /*#__PURE__*/React.createElement(ExpandMore, null),
|
|
209
|
+
"aria-controls": "panel1-content",
|
|
210
|
+
id: "panel1-header"
|
|
211
|
+
}, /*#__PURE__*/React.createElement(Gavel, {
|
|
212
|
+
fontSize: "small"
|
|
213
|
+
}), /*#__PURE__*/React.createElement(Typography, {
|
|
214
|
+
sx: {
|
|
215
|
+
width: '33%',
|
|
216
|
+
flexShrink: 0
|
|
217
|
+
}
|
|
218
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
219
|
+
id: "about-dialog/license"
|
|
220
|
+
})), /*#__PURE__*/React.createElement(Typography, {
|
|
221
|
+
sx: {
|
|
222
|
+
color: 'text.secondary'
|
|
223
|
+
}
|
|
224
|
+
}, appLicense)), /*#__PURE__*/React.createElement(AccordionDetails, null, "license app summary text")), /*#__PURE__*/React.createElement(Accordion, {
|
|
225
|
+
disableGutters: true,
|
|
226
|
+
variant: "outlined",
|
|
227
|
+
defaultExpanded: true,
|
|
228
|
+
TransitionProps: {
|
|
229
|
+
unmountOnExit: true
|
|
230
|
+
}
|
|
231
|
+
}, /*#__PURE__*/React.createElement(AccordionSummary, {
|
|
232
|
+
expandIcon: /*#__PURE__*/React.createElement(ExpandMore, null),
|
|
233
|
+
"aria-controls": "panel2-content",
|
|
234
|
+
id: "panel2-header"
|
|
235
|
+
}, /*#__PURE__*/React.createElement(Apps, {
|
|
236
|
+
fontSize: "small"
|
|
237
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
238
|
+
id: "about-dialog/modules-section"
|
|
239
|
+
})), /*#__PURE__*/React.createElement(AccordionDetails, null, /*#__PURE__*/React.createElement(Grid, {
|
|
240
|
+
container: true,
|
|
241
|
+
sx: {
|
|
242
|
+
pl: 2
|
|
243
|
+
},
|
|
244
|
+
spacing: 1
|
|
245
|
+
}, loadingAdditionalModules ? /*#__PURE__*/React.createElement(Grid, {
|
|
246
|
+
item: true,
|
|
247
|
+
xs: true,
|
|
248
|
+
display: "inline-flex",
|
|
249
|
+
justifyContent: "center"
|
|
250
|
+
}, /*#__PURE__*/React.createElement(CircularProgress, {
|
|
251
|
+
color: "inherit"
|
|
252
|
+
})) : Array.isArray(modules) && /*#__PURE__*/React.createElement(React.Fragment, null, [].concat(modules).sort(compareModules).map(function (module, idx) {
|
|
253
|
+
return /*#__PURE__*/React.createElement(Module, {
|
|
254
|
+
key: "module-" + idx,
|
|
255
|
+
type: module.type,
|
|
256
|
+
name: module.name,
|
|
257
|
+
version: module.gitTag || module.version,
|
|
258
|
+
license: module.license
|
|
259
|
+
});
|
|
260
|
+
})) || /*#__PURE__*/React.createElement(Typography, {
|
|
261
|
+
color: function color(theme) {
|
|
262
|
+
return theme.palette.error.main;
|
|
263
|
+
}
|
|
264
|
+
}, "Error")))))), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
265
|
+
onClick: handleClose,
|
|
266
|
+
autoFocus: true
|
|
267
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
268
|
+
id: "close"
|
|
269
|
+
}))));
|
|
270
|
+
};
|
|
271
|
+
export default AboutDialog;
|
|
272
|
+
AboutDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
273
|
+
open: PropTypes.bool.isRequired,
|
|
274
|
+
onClose: PropTypes.func,
|
|
275
|
+
appName: PropTypes.string.isRequired,
|
|
276
|
+
appVersion: PropTypes.string,
|
|
277
|
+
appGitTag: PropTypes.string,
|
|
278
|
+
appLicense: PropTypes.string,
|
|
279
|
+
getGlobalVersion: PropTypes.func,
|
|
280
|
+
getAdditionalModules: PropTypes.func
|
|
281
|
+
} : {};
|
|
282
|
+
var ModuleTypesIcons = {
|
|
283
|
+
app: /*#__PURE__*/React.createElement(WidgetsOutlined, {
|
|
284
|
+
fontSize: "small",
|
|
285
|
+
color: "primary"
|
|
286
|
+
}),
|
|
287
|
+
server: /*#__PURE__*/React.createElement(DnsOutlined, {
|
|
288
|
+
fontSize: "small",
|
|
289
|
+
color: "secondary"
|
|
290
|
+
}),
|
|
291
|
+
other: /*#__PURE__*/React.createElement(QuestionMark, {
|
|
292
|
+
fontSize: "small"
|
|
293
|
+
})
|
|
294
|
+
};
|
|
295
|
+
var Module = function Module(_ref2) {
|
|
296
|
+
var type = _ref2.type,
|
|
297
|
+
name = _ref2.name,
|
|
298
|
+
version = _ref2.version,
|
|
299
|
+
license = _ref2.license;
|
|
300
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
301
|
+
item: true,
|
|
302
|
+
xs: 12,
|
|
303
|
+
sm: 6,
|
|
304
|
+
md: 4,
|
|
305
|
+
sx: {
|
|
306
|
+
'.MuiTypography-root': {
|
|
307
|
+
minWidth: '3em'
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
311
|
+
direction: "row",
|
|
312
|
+
justifyContent: "flex-start",
|
|
313
|
+
alignItems: "baseline",
|
|
314
|
+
spacing: 1
|
|
315
|
+
}, ModuleTypesIcons[type] || ModuleTypesIcons['other'], /*#__PURE__*/React.createElement(Typography, {
|
|
316
|
+
display: "inline-block",
|
|
317
|
+
noWrap: true
|
|
318
|
+
}, name || '<?>'), /*#__PURE__*/React.createElement(Typography, {
|
|
319
|
+
variant: "caption",
|
|
320
|
+
color: function color(theme) {
|
|
321
|
+
return theme.palette.text.secondary;
|
|
322
|
+
},
|
|
323
|
+
display: "inline",
|
|
324
|
+
marginLeft: 1,
|
|
325
|
+
noWrap: true
|
|
326
|
+
}, version || null)));
|
|
327
|
+
};
|
|
328
|
+
Module.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
329
|
+
type: PropTypes.string,
|
|
330
|
+
name: PropTypes.string,
|
|
331
|
+
version: PropTypes.string,
|
|
332
|
+
license: PropTypes.string
|
|
333
|
+
} : {};
|
|
@@ -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,64 +6,27 @@ 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, { useEffect, useRef, useState, useMemo } from 'react';
|
|
10
10
|
import { FormattedMessage } from 'react-intl';
|
|
11
|
-
import AppBar from '@mui/material
|
|
12
|
-
import ExitToAppIcon from '@mui/icons-material
|
|
11
|
+
import { AppBar, Box, Button, ClickAwayListener, 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, FullscreenExit as FullscreenExitIcon, Fullscreen as FullscreenIcon, HelpOutline as HelpOutlineIcon, Person as PersonIcon, Search as SearchIcon, 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
17
|
import ElementSearchDialog from '../ElementSearchDialog';
|
|
18
|
+
import GridLogo from './GridLogo';
|
|
19
|
+
import AboutDialog from './AboutDialog';
|
|
45
20
|
var styles = {
|
|
46
21
|
grow: {
|
|
47
22
|
flexGrow: 1,
|
|
48
23
|
display: 'flex',
|
|
49
24
|
overflow: 'hidden'
|
|
50
25
|
},
|
|
51
|
-
logo: {
|
|
52
|
-
flexShrink: 0,
|
|
53
|
-
width: 48,
|
|
54
|
-
height: 48,
|
|
55
|
-
marginBottom: '8px'
|
|
56
|
-
},
|
|
57
26
|
menuIcon: {
|
|
58
27
|
width: 24,
|
|
59
28
|
height: 24
|
|
60
29
|
},
|
|
61
|
-
title: {
|
|
62
|
-
marginLeft: '18px'
|
|
63
|
-
},
|
|
64
|
-
clickable: {
|
|
65
|
-
cursor: 'pointer'
|
|
66
|
-
},
|
|
67
30
|
link: {
|
|
68
31
|
textDecoration: 'none',
|
|
69
32
|
color: 'inherit'
|
|
@@ -162,6 +125,8 @@ var TopBar = function TopBar(_ref2) {
|
|
|
162
125
|
var appName = _ref2.appName,
|
|
163
126
|
appColor = _ref2.appColor,
|
|
164
127
|
appLogo = _ref2.appLogo,
|
|
128
|
+
appVersion = _ref2.appVersion,
|
|
129
|
+
appLicense = _ref2.appLicense,
|
|
165
130
|
onParametersClick = _ref2.onParametersClick,
|
|
166
131
|
onLogoutClick = _ref2.onLogoutClick,
|
|
167
132
|
onLogoClick = _ref2.onLogoClick,
|
|
@@ -169,6 +134,8 @@ var TopBar = function TopBar(_ref2) {
|
|
|
169
134
|
children = _ref2.children,
|
|
170
135
|
appsAndUrls = _ref2.appsAndUrls,
|
|
171
136
|
onAboutClick = _ref2.onAboutClick,
|
|
137
|
+
getGlobalVersion = _ref2.getGlobalVersion,
|
|
138
|
+
getAdditionalModules = _ref2.getAdditionalModules,
|
|
172
139
|
onThemeClick = _ref2.onThemeClick,
|
|
173
140
|
theme = _ref2.theme,
|
|
174
141
|
onEquipmentLabellingClick = _ref2.onEquipmentLabellingClick,
|
|
@@ -251,10 +218,15 @@ var TopBar = function TopBar(_ref2) {
|
|
|
251
218
|
onLanguageClick(value);
|
|
252
219
|
}
|
|
253
220
|
};
|
|
221
|
+
var _useState3 = useState(false),
|
|
222
|
+
isAboutDialogOpen = _useState3[0],
|
|
223
|
+
setAboutDialogOpen = _useState3[1];
|
|
254
224
|
var onAboutClicked = function onAboutClicked() {
|
|
255
225
|
setAnchorElSettingsMenu(false);
|
|
256
226
|
if (onAboutClick) {
|
|
257
227
|
onAboutClick();
|
|
228
|
+
} else {
|
|
229
|
+
setAboutDialogOpen(true);
|
|
258
230
|
}
|
|
259
231
|
};
|
|
260
232
|
useEffect(function () {
|
|
@@ -271,6 +243,14 @@ var TopBar = function TopBar(_ref2) {
|
|
|
271
243
|
};
|
|
272
244
|
}
|
|
273
245
|
}, [user, withElementsSearch, searchDisabled]);
|
|
246
|
+
var logo_clickable = useMemo(function () {
|
|
247
|
+
return /*#__PURE__*/React.createElement(GridLogo, {
|
|
248
|
+
onClick: onLogoClick,
|
|
249
|
+
appLogo: appLogo,
|
|
250
|
+
appName: appName,
|
|
251
|
+
appColor: appColor
|
|
252
|
+
});
|
|
253
|
+
}, [onLogoClick, appLogo, appName, appColor]);
|
|
274
254
|
return /*#__PURE__*/React.createElement(AppBar, {
|
|
275
255
|
position: "static",
|
|
276
256
|
color: "default",
|
|
@@ -281,22 +261,7 @@ var TopBar = function TopBar(_ref2) {
|
|
|
281
261
|
onFullScreenError: function onFullScreenError(e) {
|
|
282
262
|
return console.debug('full screen error : ' + e.message);
|
|
283
263
|
}
|
|
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, {
|
|
264
|
+
}), /*#__PURE__*/React.createElement(Toolbar, null, logo_clickable, /*#__PURE__*/React.createElement(Box, {
|
|
300
265
|
sx: styles.grow
|
|
301
266
|
}, children), user && withElementsSearch && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ElementSearchDialog, {
|
|
302
267
|
open: isDialogSearchOpen,
|
|
@@ -497,7 +462,6 @@ var TopBar = function TopBar(_ref2) {
|
|
|
497
462
|
defaultMessage: 'Settings'
|
|
498
463
|
})))), /*#__PURE__*/React.createElement(StyledMenuItem, {
|
|
499
464
|
sx: styles.borderBottom,
|
|
500
|
-
disabled: !onAboutClick,
|
|
501
465
|
style: {
|
|
502
466
|
opacity: '1'
|
|
503
467
|
},
|
|
@@ -534,7 +498,17 @@ var TopBar = function TopBar(_ref2) {
|
|
|
534
498
|
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
535
499
|
id: "top-bar/logout",
|
|
536
500
|
defaultMessage: 'Logout'
|
|
537
|
-
})))))))))
|
|
501
|
+
}))))))))), /*#__PURE__*/React.createElement(AboutDialog, {
|
|
502
|
+
open: isAboutDialogOpen,
|
|
503
|
+
onClose: function onClose() {
|
|
504
|
+
return setAboutDialogOpen(false);
|
|
505
|
+
},
|
|
506
|
+
appName: appName,
|
|
507
|
+
appVersion: appVersion,
|
|
508
|
+
appLicense: appLicense,
|
|
509
|
+
getGlobalVersion: getGlobalVersion,
|
|
510
|
+
getAdditionalModules: getAdditionalModules
|
|
511
|
+
})));
|
|
538
512
|
};
|
|
539
513
|
TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
540
514
|
onParametersClick: PropTypes.func,
|
|
@@ -543,12 +517,16 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
543
517
|
appName: PropTypes.string,
|
|
544
518
|
appColor: PropTypes.string,
|
|
545
519
|
appLogo: PropTypes.object,
|
|
520
|
+
appVersion: PropTypes.string,
|
|
521
|
+
appLicense: PropTypes.string,
|
|
546
522
|
user: PropTypes.object,
|
|
547
523
|
children: PropTypes.node,
|
|
548
524
|
appsAndUrls: PropTypes.array,
|
|
549
525
|
onThemeClick: PropTypes.func,
|
|
550
526
|
theme: PropTypes.string,
|
|
551
527
|
onAboutClick: PropTypes.func,
|
|
528
|
+
getGlobalVersion: PropTypes.func,
|
|
529
|
+
getAdditionalModules: PropTypes.func,
|
|
552
530
|
onEquipmentLabellingClick: PropTypes.func,
|
|
553
531
|
equipmentLabelling: PropTypes.bool,
|
|
554
532
|
withElementsSearch: PropTypes.bool,
|
|
@@ -557,6 +535,7 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
557
535
|
onSearchTermChange: PropTypes.func,
|
|
558
536
|
onSelectionChange: PropTypes.func,
|
|
559
537
|
elementsFound: PropTypes.array,
|
|
538
|
+
renderElement: PropTypes.func.isRequired,
|
|
560
539
|
onLanguageClick: PropTypes.func.isRequired,
|
|
561
540
|
language: PropTypes.string.isRequired,
|
|
562
541
|
searchTermDisabled: PropTypes.bool,
|
|
@@ -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,12 @@ 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',
|
|
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/git-version': 'Tag'
|
|
20
26
|
};
|
|
21
27
|
export default top_bar_en;
|
|
@@ -10,12 +10,18 @@ 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': '
|
|
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',
|
|
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/git-version': 'Tag'
|
|
20
26
|
};
|
|
21
27
|
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';
|