@deix/rossini-core 2.0.1 → 2.1.1
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/lib/components/buttons/Avatar/Avatar.js +2 -2
- package/lib/components/buttons/LanguageSelect/LanguageSelect.d.ts.map +1 -1
- package/lib/components/buttons/LanguageSelect/LanguageSelect.js +3 -0
- package/lib/components/display/StyledValue/StyledValue.d.ts +1 -1
- package/lib/components/display/StyledValue/StyledValue.d.ts.map +1 -1
- package/lib/components/display/StyledValue/StyledValue.js +2 -2
- package/lib/components/index.d.ts +2 -2
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/layout/MinimalLayout/MinimalLayout.js +8 -8
- package/lib/components/layout/StandardLayout/StandardLayout.js +8 -8
- package/lib/components/layout/components/Footer/Footer.js +2 -2
- package/lib/components/layout/components/Sidebar/Sidebar.d.ts +4 -0
- package/lib/components/layout/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/lib/components/layout/components/Sidebar/Sidebar.js +10 -0
- package/lib/components/provider/PageProvider.d.ts +3 -0
- package/lib/components/provider/PageProvider.d.ts.map +1 -1
- package/lib/components/provider/PageProvider.js +4 -2
- package/lib/components/provider/UserInfoProvider.d.ts +28 -0
- package/lib/components/provider/UserInfoProvider.d.ts.map +1 -0
- package/lib/components/provider/UserInfoProvider.js +22 -0
- package/lib/components/provider/index.d.ts +2 -0
- package/lib/components/provider/index.d.ts.map +1 -1
- package/lib/components/provider/index.js +1 -0
- package/lib/index.d.ts +3 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/hooks/index.d.ts +2 -3
- package/lib/utils/hooks/index.d.ts.map +1 -1
- package/lib/utils/hooks/index.js +1 -2
- package/lib/utils/hooks/useAPI.d.ts +8 -1
- package/lib/utils/hooks/useAPI.d.ts.map +1 -1
- package/lib/utils/hooks/useAPI.js +14 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -1
- package/package.json +1 -1
- package/lib/utils/hooks/useUserInfo.d.ts +0 -17
- package/lib/utils/hooks/useUserInfo.d.ts.map +0 -1
- package/lib/utils/hooks/useUserInfo.js +0 -25
|
@@ -5,7 +5,7 @@ import FaceIcon from '@mui/icons-material/Face';
|
|
|
5
5
|
import LogoutIcon from '@mui/icons-material/Logout';
|
|
6
6
|
import PersonIcon from '@mui/icons-material/Person';
|
|
7
7
|
import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Tooltip, useTheme, } from '@mui/material';
|
|
8
|
-
import { useUserInfo } from '
|
|
8
|
+
import { useUserInfo } from '../../provider/UserInfoProvider';
|
|
9
9
|
export const Avatar = ({ logoutUrl, accountSettingsUrl, }) => {
|
|
10
10
|
const muiTheme = useTheme();
|
|
11
11
|
// Menu
|
|
@@ -18,7 +18,7 @@ export const Avatar = ({ logoutUrl, accountSettingsUrl, }) => {
|
|
|
18
18
|
setAnchorEl(null);
|
|
19
19
|
};
|
|
20
20
|
// User data
|
|
21
|
-
const
|
|
21
|
+
const userInfo = useUserInfo();
|
|
22
22
|
return (React.createElement(React.Fragment, null,
|
|
23
23
|
React.createElement(Tooltip, { title: userInfo?.preferredUsername || 'Anonymous User' },
|
|
24
24
|
React.createElement(IconButton, { component: 'span', "aria-label": 'toggle dark mode', onClick: handleClick },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/buttons/LanguageSelect/LanguageSelect.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgBjD,OAAO,EAGL,QAAQ,EACR,MAAM,EACP,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/buttons/LanguageSelect/LanguageSelect.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgBjD,OAAO,EAGL,QAAQ,EACR,MAAM,EACP,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,CAqFjE,CAAC"}
|
|
@@ -32,6 +32,9 @@ export const LanguageSelect = ({ languages = [
|
|
|
32
32
|
// If no max-age is set the cookie will expire when the session ends.
|
|
33
33
|
document.cookie = `${cookieName}=${locale}; max-age=315360000; path=/`; // 10 years
|
|
34
34
|
};
|
|
35
|
+
if (!languages || languages.length < 2) {
|
|
36
|
+
return React.createElement("div", null);
|
|
37
|
+
}
|
|
35
38
|
return (React.createElement(React.Fragment, null,
|
|
36
39
|
React.createElement(Tooltip, { title: t['tooltip'][locale] },
|
|
37
40
|
React.createElement(IconButton, { component: 'span', "aria-label": 'language', onClick: openOptions },
|
|
@@ -4,7 +4,7 @@ import { CardProps, TypographyProps } from '@mui/material';
|
|
|
4
4
|
import { StringTranslation } from '../../../types';
|
|
5
5
|
import { ImprovementChipProps } from './ImprovementChip';
|
|
6
6
|
export interface FetchedValue {
|
|
7
|
-
baseURL
|
|
7
|
+
baseURL: string;
|
|
8
8
|
endpoint: string;
|
|
9
9
|
config?: AxiosRequestConfig;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledValue.d.ts","sourceRoot":"","sources":["../../../../src/components/display/StyledValue/StyledValue.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,SAAS,EAGT,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAuB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"StyledValue.d.ts","sourceRoot":"","sources":["../../../../src/components/display/StyledValue/StyledValue.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAIL,SAAS,EAGT,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAuB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,CAAC;IACtD,aAAa,CAAC,EAAE,OAAO,CACrB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,mBAAmB,CACtD,CAAC;IACF,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,eAAe,CAAC;IACvC,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACzD,oBAAoB,CAAC,EAAE,IAAI,CACzB,OAAO,CAAC,oBAAoB,CAAC,EAC7B,oBAAoB,GAAG,qBAAqB,GAAG,OAAO,CACvD,CAAC;CACH;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4I3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Box, Card, CardActionArea, Skeleton, Typography, } from '@mui/material';
|
|
4
4
|
import { isStringTranslation } from '../../../types';
|
|
5
|
-
import { isValidDate,
|
|
5
|
+
import { isValidDate, useOptionalAPI, useLocale } from '../../../utils';
|
|
6
6
|
import { useValue } from './hooks';
|
|
7
7
|
import ImprovementChip from './ImprovementChip';
|
|
8
8
|
import t from './translations.json';
|
|
@@ -19,7 +19,7 @@ const StyledValue = (props) => {
|
|
|
19
19
|
}, } = props;
|
|
20
20
|
const locale = useLocale();
|
|
21
21
|
// Value
|
|
22
|
-
const apiClient =
|
|
22
|
+
const apiClient = useOptionalAPI(props.value && isFetchedValue(props.value)
|
|
23
23
|
? props.value.baseURL
|
|
24
24
|
: undefined);
|
|
25
25
|
const { data: value, isLoading: isLoadingValue } = useValue(apiClient, props.value);
|
|
@@ -8,6 +8,6 @@ export { MinimalLayout, StandardLayout } from './layout';
|
|
|
8
8
|
export type { AppLogoInfo, FooterProps, SidebarLink, SidebarProps, } from './layout';
|
|
9
9
|
export { CircularLoading } from './progress';
|
|
10
10
|
export type { CircularLoadingProps } from './progress';
|
|
11
|
-
export { PageProvider } from './provider';
|
|
12
|
-
export type { PageProviderProps } from './provider';
|
|
11
|
+
export { PageProvider, useUserInfo } from './provider';
|
|
12
|
+
export type { PageProviderProps, UserInfo } from './provider';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACtE,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACtE,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/lib/components/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { Accordion, StyledValue, ImprovementChip } from './display';
|
|
|
3
3
|
export { Link } from './i18n';
|
|
4
4
|
export { MinimalLayout, StandardLayout } from './layout';
|
|
5
5
|
export { CircularLoading } from './progress';
|
|
6
|
-
export { PageProvider } from './provider';
|
|
6
|
+
export { PageProvider, useUserInfo } from './provider';
|
|
@@ -25,10 +25,10 @@ const MinimalLayout = ({ isLoading, isError, error, footer, children, }) => {
|
|
|
25
25
|
flexGrow: 1,
|
|
26
26
|
maxWidth: '100%',
|
|
27
27
|
overflowX: 'hidden',
|
|
28
|
-
paddingTop:
|
|
29
|
-
paddingBottom:
|
|
30
|
-
paddingLeft:
|
|
31
|
-
paddingRight:
|
|
28
|
+
paddingTop: 2,
|
|
29
|
+
paddingBottom: 2,
|
|
30
|
+
paddingLeft: 2,
|
|
31
|
+
paddingRight: 2,
|
|
32
32
|
} },
|
|
33
33
|
React.createElement("div", { style: {
|
|
34
34
|
display: 'flex',
|
|
@@ -49,10 +49,10 @@ const MinimalLayout = ({ isLoading, isError, error, footer, children, }) => {
|
|
|
49
49
|
// height: '100%',
|
|
50
50
|
maxWidth: '100%',
|
|
51
51
|
overflowX: 'hidden',
|
|
52
|
-
paddingTop:
|
|
53
|
-
paddingBottom:
|
|
54
|
-
paddingLeft:
|
|
55
|
-
paddingRight:
|
|
52
|
+
paddingTop: 2,
|
|
53
|
+
paddingBottom: 2,
|
|
54
|
+
paddingLeft: 2,
|
|
55
|
+
paddingRight: 2,
|
|
56
56
|
} }, children)),
|
|
57
57
|
React.createElement(Footer, { ...footer }))));
|
|
58
58
|
};
|
|
@@ -41,10 +41,10 @@ const StandardLayout = ({ isLoading, isError, error, appLogo, footer, sidebarLin
|
|
|
41
41
|
// height: '100%',
|
|
42
42
|
maxWidth: '100%',
|
|
43
43
|
overflowX: 'hidden',
|
|
44
|
-
paddingTop:
|
|
45
|
-
paddingBottom:
|
|
46
|
-
paddingLeft:
|
|
47
|
-
paddingRight:
|
|
44
|
+
paddingTop: 2,
|
|
45
|
+
paddingBottom: 2,
|
|
46
|
+
paddingLeft: 2,
|
|
47
|
+
paddingRight: 2,
|
|
48
48
|
} },
|
|
49
49
|
React.createElement("div", { style: {
|
|
50
50
|
display: 'flex',
|
|
@@ -62,10 +62,10 @@ const StandardLayout = ({ isLoading, isError, error, appLogo, footer, sidebarLin
|
|
|
62
62
|
// flexGrow: 1,
|
|
63
63
|
maxWidth: '100%',
|
|
64
64
|
overflowX: 'hidden',
|
|
65
|
-
paddingTop:
|
|
66
|
-
paddingBottom:
|
|
67
|
-
paddingLeft:
|
|
68
|
-
paddingRight:
|
|
65
|
+
paddingTop: 2,
|
|
66
|
+
paddingBottom: 2,
|
|
67
|
+
paddingLeft: 2,
|
|
68
|
+
paddingRight: 2,
|
|
69
69
|
} }, children)),
|
|
70
70
|
React.createElement(Footer, { ...footer }))));
|
|
71
71
|
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Box, Typography, useTheme } from '@mui/material';
|
|
4
4
|
import { useQuery } from '@tanstack/react-query';
|
|
5
|
-
import {
|
|
5
|
+
import { useOptionalAPI } from '../../../../utils/index';
|
|
6
6
|
import DeixLogo from '../../assets/DeixLogo';
|
|
7
7
|
const Footer = ({ logo = React.createElement(DeixLogo, null), text = 'Deix Srl', textURL = 'https://deixsrl.com', uiInfo = { name: '', version: '' }, apiURL, children, }) => {
|
|
8
8
|
const muiTheme = useTheme();
|
|
9
9
|
// Get App Info (name and version)
|
|
10
10
|
// Get API info (name and version) from backend
|
|
11
|
-
const apiClient =
|
|
11
|
+
const apiClient = useOptionalAPI(apiURL);
|
|
12
12
|
const getAPIInfo = async () => {
|
|
13
13
|
if (apiClient) {
|
|
14
14
|
const { data } = await apiClient.get('info');
|
|
@@ -34,6 +34,10 @@ export interface SidebarLink {
|
|
|
34
34
|
* A list of nested links
|
|
35
35
|
*/
|
|
36
36
|
subPages?: SidebarLink[];
|
|
37
|
+
/**
|
|
38
|
+
* A list of groups that are allowed to see this entry. If undefined or empty all groups will be allowed
|
|
39
|
+
*/
|
|
40
|
+
allowedGroups?: string[];
|
|
37
41
|
}
|
|
38
42
|
export interface SidebarProps {
|
|
39
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAsBtD,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAEL,MAAM,EACN,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../../../../src/components/layout/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAsBtD,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAEL,MAAM,EACN,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAIrC,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AACD,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+YnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -8,10 +8,12 @@ import { useTheme as useMUITheme } from '@mui/material';
|
|
|
8
8
|
import { Link } from '../../../i18n';
|
|
9
9
|
import { isStringTranslation, } from '../../../../types/languages';
|
|
10
10
|
import { useLocale, usePathname, usePersistedState } from '../../../../utils';
|
|
11
|
+
import { useUserInfo } from '../../..';
|
|
11
12
|
const Sidebar = ({ links, open, isMobile, logo, onClose, }) => {
|
|
12
13
|
const muiTheme = useMUITheme();
|
|
13
14
|
const pathname = usePathname();
|
|
14
15
|
const locale = useLocale();
|
|
16
|
+
const userInfo = useUserInfo();
|
|
15
17
|
const selectedTextColor = muiTheme.palette.sidebar.contrastText;
|
|
16
18
|
const unselectedTextColor = alpha(selectedTextColor, 0.9);
|
|
17
19
|
const borderRadius = '8px';
|
|
@@ -47,6 +49,11 @@ const Sidebar = ({ links, open, isMobile, logo, onClose, }) => {
|
|
|
47
49
|
}
|
|
48
50
|
// Function to generate sidebar items. To be called recursively
|
|
49
51
|
const handler = (links, options) => {
|
|
52
|
+
links.forEach((link) => {
|
|
53
|
+
console.log(!link.allowedGroups ||
|
|
54
|
+
link.allowedGroups.length < 1 ||
|
|
55
|
+
userInfo?.groups?.some((g) => link.allowedGroups?.includes(g)));
|
|
56
|
+
});
|
|
50
57
|
if (open) {
|
|
51
58
|
// Render all items with their labels
|
|
52
59
|
return links
|
|
@@ -58,6 +65,9 @@ const Sidebar = ({ links, open, isMobile, logo, onClose, }) => {
|
|
|
58
65
|
return a.sidebarOrder > b.sidebarOrder ? 1 : -1;
|
|
59
66
|
}
|
|
60
67
|
})
|
|
68
|
+
.filter((link) => !link.allowedGroups ||
|
|
69
|
+
link.allowedGroups.length < 1 ||
|
|
70
|
+
userInfo?.groups?.some((g) => link.allowedGroups?.includes(g)))
|
|
61
71
|
.map((link) => {
|
|
62
72
|
const selected = pathname.startsWith(`${link.path}`);
|
|
63
73
|
if (!link.subPages) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PaletteOptions } from '@mui/material';
|
|
3
|
+
import { UserInfo } from '.';
|
|
3
4
|
export interface PageProviderProps {
|
|
4
5
|
children: React.ReactNode;
|
|
5
6
|
lightPalette?: PaletteOptions;
|
|
6
7
|
darkPalette?: PaletteOptions;
|
|
8
|
+
userInfoUrl?: string;
|
|
9
|
+
defaultUserInfo?: UserInfo;
|
|
7
10
|
}
|
|
8
11
|
declare const PageProvider: React.FC<PageProviderProps>;
|
|
9
12
|
export default PageProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageProvider.d.ts","sourceRoot":"","sources":["../../../src/components/provider/PageProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"PageProvider.d.ts","sourceRoot":"","sources":["../../../src/components/provider/PageProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAoB,MAAM,GAAG,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAc7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ThemeProvider from './ThemeProvider';
|
|
4
4
|
import { SnackbarProvider } from 'notistack';
|
|
5
|
-
|
|
5
|
+
import { UserInfoProvider } from '.';
|
|
6
|
+
const PageProvider = ({ children, lightPalette, darkPalette, userInfoUrl, defaultUserInfo, }) => {
|
|
6
7
|
return (React.createElement(ThemeProvider, { lightPalette: lightPalette, darkPalette: darkPalette },
|
|
7
|
-
React.createElement(
|
|
8
|
+
React.createElement(UserInfoProvider, { url: userInfoUrl, defaultUserInfo: defaultUserInfo },
|
|
9
|
+
React.createElement(SnackbarProvider, { maxSnack: 3 }, children))));
|
|
8
10
|
};
|
|
9
11
|
export default PageProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UserInfo {
|
|
3
|
+
/**
|
|
4
|
+
* The email address of the user.
|
|
5
|
+
*/
|
|
6
|
+
email?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The user id.
|
|
9
|
+
*/
|
|
10
|
+
user?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The user name.
|
|
13
|
+
*/
|
|
14
|
+
preferredUsername?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The groups the user belongs to
|
|
17
|
+
*/
|
|
18
|
+
groups?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface UserInfoProviderProps {
|
|
21
|
+
url?: string;
|
|
22
|
+
defaultUserInfo?: UserInfo;
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
declare const UserInfoProvider: ({ url, defaultUserInfo, children, }: UserInfoProviderProps) => React.JSX.Element;
|
|
26
|
+
export declare const useUserInfo: () => UserInfo | undefined;
|
|
27
|
+
export default UserInfoProvider;
|
|
28
|
+
//# sourceMappingURL=UserInfoProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserInfoProvider.d.ts","sourceRoot":"","sources":["../../../src/components/provider/UserInfoProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAYD,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,QAAA,MAAM,gBAAgB,wCAInB,qBAAqB,sBAWvB,CAAC;AAEF,eAAO,MAAM,WAAW,4BAAoC,CAAC;AAE7D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
const getUserInfo = async (url = '/oauth2/userinfo') => {
|
|
6
|
+
const fetch = axios.get(url).then((result) => {
|
|
7
|
+
console.log('User Info', result.data);
|
|
8
|
+
return result.data;
|
|
9
|
+
});
|
|
10
|
+
return await fetch;
|
|
11
|
+
};
|
|
12
|
+
const UserInfoContext = createContext(undefined);
|
|
13
|
+
const UserInfoProvider = ({ url, defaultUserInfo, children, }) => {
|
|
14
|
+
const { data: userInfo } = useQuery({
|
|
15
|
+
queryKey: ['user-info'],
|
|
16
|
+
queryFn: () => getUserInfo(url),
|
|
17
|
+
staleTime: Infinity,
|
|
18
|
+
});
|
|
19
|
+
return (React.createElement(UserInfoContext.Provider, { value: userInfo || defaultUserInfo }, children));
|
|
20
|
+
};
|
|
21
|
+
export const useUserInfo = () => useContext(UserInfoContext);
|
|
22
|
+
export default UserInfoProvider;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as PageProvider } from './PageProvider';
|
|
2
2
|
export type { PageProviderProps } from './PageProvider';
|
|
3
|
+
export { default as UserInfoProvider, useUserInfo } from './UserInfoProvider';
|
|
4
|
+
export type { UserInfo, UserInfoProviderProps } from './UserInfoProvider';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9E,YAAY,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { Accordion, Avatar, CircularLoading, ImprovementChip, LanguageSelect, Link, MinimalLayout, PageProvider, StandardLayout, StyledValue, ToggleButtonGroup, } from './components';
|
|
2
|
-
export type { AccordionProps, AppLogoInfo, AvatarProps, ButtonGroupOption, CircularLoadingProps, FetchedValue, FooterProps, ImprovementChipProps, LanguageSelectProps, LinkProps, PageProviderProps, SidebarLink, SidebarProps, StyledValueProps, ToggleButtonGroupProps, } from './components';
|
|
1
|
+
export { Accordion, Avatar, CircularLoading, ImprovementChip, LanguageSelect, Link, MinimalLayout, PageProvider, StandardLayout, StyledValue, ToggleButtonGroup, useUserInfo, } from './components';
|
|
2
|
+
export type { AccordionProps, AppLogoInfo, AvatarProps, ButtonGroupOption, CircularLoadingProps, FetchedValue, FooterProps, ImprovementChipProps, LanguageSelectProps, LinkProps, PageProviderProps, SidebarLink, SidebarProps, StyledValueProps, ToggleButtonGroupProps, UserInfo, } from './components';
|
|
3
3
|
export { isStringTranslation } from './types';
|
|
4
4
|
export type { DBRow, DBRows, Language, Locale, PaginatedResponse, Query, StringTranslation, } from './types';
|
|
5
|
-
export { camelToSnake, colorToRgb, commonStart, createI18nMiddleware, dateDiff, getTextColor, getTimeStr, hexToRgb, interpolate, isValidDate, stringToColor, toLocalStandardDateString, toTitleCase, useAPI, useLocale, usePathname, usePersistedState,
|
|
6
|
-
export type { UserInfo } from './utils';
|
|
5
|
+
export { camelToSnake, colorToRgb, commonStart, createI18nMiddleware, dateDiff, getTextColor, getTimeStr, hexToRgb, interpolate, isValidDate, stringToColor, toLocalStandardDateString, toTitleCase, useAPI, useLocale, usePathname, usePersistedState, } from './utils';
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,MAAM,EACN,eAAe,EACf,eAAe,EACf,cAAc,EACd,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,MAAM,EACN,eAAe,EACf,eAAe,EACf,cAAc,EACd,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EACV,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,KAAK,EACL,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,yBAAyB,EACzB,WAAW,EACX,MAAM,EACN,SAAS,EACT,WAAW,EACX,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Accordion, Avatar, CircularLoading, ImprovementChip, LanguageSelect, Link, MinimalLayout, PageProvider, StandardLayout, StyledValue, ToggleButtonGroup, } from './components';
|
|
1
|
+
export { Accordion, Avatar, CircularLoading, ImprovementChip, LanguageSelect, Link, MinimalLayout, PageProvider, StandardLayout, StyledValue, ToggleButtonGroup, useUserInfo, } from './components';
|
|
2
2
|
export { isStringTranslation } from './types';
|
|
3
|
-
export { camelToSnake, colorToRgb, commonStart, createI18nMiddleware, dateDiff, getTextColor, getTimeStr, hexToRgb, interpolate, isValidDate, stringToColor, toLocalStandardDateString, toTitleCase, useAPI, useLocale, usePathname, usePersistedState,
|
|
3
|
+
export { camelToSnake, colorToRgb, commonStart, createI18nMiddleware, dateDiff, getTextColor, getTimeStr, hexToRgb, interpolate, isValidDate, stringToColor, toLocalStandardDateString, toTitleCase, useAPI, useLocale, usePathname, usePersistedState, } from './utils';
|