@genesislcap/blank-app-seed 3.29.1-prerelease.7 → 3.29.1-prerelease.9
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/.genx/package.json +1 -1
- package/.genx/templates/react/chart.hbs +5 -1
- package/.genx/templates/react/component/component.hbs +13 -1
- package/.genx/templates/react/entityManager.hbs +10 -6
- package/.genx/templates/react/form.hbs +5 -1
- package/.genx/templates/react/grid.hbs +5 -1
- package/.genx/templates/react/route.hbs +1 -1
- package/.genx/versions.json +1 -1
- package/CHANGELOG.md +14 -0
- package/client-tmp/react/src/App.tsx +13 -4
- package/client-tmp/react/src/components/ErrorMessage/ErrorMessage.jsx +62 -0
- package/client-tmp/react/src/config.ts +1 -0
- package/client-tmp/react/src/guards/PermissionsGuard.tsx +37 -0
- package/client-tmp/react/src/pages/NotPermittedPage/NotPermittedPage.css +0 -0
- package/client-tmp/react/src/pages/NotPermittedPage/NotPermittedPage.jsx +13 -0
- package/client-tmp/react/src/utils/index.ts +2 -1
- package/client-tmp/react/src/utils/permissions.ts +7 -0
- package/package.json +1 -1
- /package/client-tmp/react/src/pages/{auth → AuthPage}/AuthPage.css +0 -0
- /package/client-tmp/react/src/pages/{auth → AuthPage}/AuthPage.jsx +0 -0
package/.genx/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#if config.permissions.viewRight}}hasUserPermission('{{config.permissions.viewRight}}') ? ({{/if}}
|
|
1
2
|
<rapid-g2plot-chart
|
|
2
3
|
type="{{ config.type }}"
|
|
3
4
|
config={chartConfig}
|
|
@@ -6,4 +7,7 @@
|
|
|
6
7
|
resourceName="{{ config.resourceName }}"
|
|
7
8
|
server-fields="{{ config.xField }} {{ config.yField }}"
|
|
8
9
|
></chart-datasource>
|
|
9
|
-
</rapid-g2plot-chart>
|
|
10
|
+
</rapid-g2plot-chart>{{#if config.permissions.viewRight}}
|
|
11
|
+
) : (
|
|
12
|
+
<ErrorMessage elementType="h3" message="You do not have access to view this component." />
|
|
13
|
+
){{/if}}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
{{#if tile.config.permissions.viewRight}}
|
|
3
|
+
import { getUser } from '@genesislcap/foundation-user';
|
|
4
|
+
import { getViewUpdateRightComponent } from '../../../utils';
|
|
5
|
+
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
6
|
+
{{else}}{{#if tile.config.permissions.updateRight}}
|
|
7
|
+
import { getViewUpdateRightComponent } from '../../../utils';
|
|
8
|
+
import { getUser } from '@genesislcap/foundation-user';
|
|
9
|
+
import ErrorMessage from '../../../components/ErrorMessage/ErrorMessage';
|
|
10
|
+
{{/if}}{{/if}}
|
|
1
11
|
{{#if tile.config.createFormUiSchema}}
|
|
2
12
|
import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
|
|
3
13
|
{{/if}}
|
|
@@ -15,7 +25,9 @@ import { gridOptions as tileGridOptions } from './{{kebabCase tile.title}}.gridO
|
|
|
15
25
|
{{/if}}
|
|
16
26
|
import './{{kebabCase tile.title}}.component.css';
|
|
17
27
|
|
|
18
|
-
export const {{pascalCase tile.componentName}} = () => { {{#if tile.config.
|
|
28
|
+
export const {{pascalCase tile.componentName}} = () => { {{#if tile.config.permissions.viewRight}}
|
|
29
|
+
const hasUserPermission = (permissionCode) => getViewUpdateRightComponent(getUser(), permissionCode);{{else}}{{#if tile.config.permissions.updateRight}}
|
|
30
|
+
const hasUserPermission = (permissionCode) => getViewUpdateRightComponent(getUser(), permissionCode);{{/if}}{{/if}}{{#if tile.config.createFormUiSchema}}
|
|
19
31
|
const createFormSchema = createFormSchema;{{/if}}{{#if tile.config.uischema}}
|
|
20
32
|
const uischema = createFormSchema;{{/if}}{{#if tile.config.updateFormUiSchema}}
|
|
21
33
|
const updateFormSchema = updateFormSchema;{{/if}}{{#if tile.config.columns}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#if config.permissions.viewRight}}hasUserPermission('{{config.permissions.viewRight}}') ? ({{/if}}
|
|
1
2
|
<entity-management
|
|
2
3
|
design-system-prefix="rapid"
|
|
3
4
|
enable-row-flashing
|
|
@@ -7,19 +8,19 @@
|
|
|
7
8
|
{{/if}}
|
|
8
9
|
resourceName="{{ config.resourceName }}"
|
|
9
10
|
{{#if config.createEvent}}
|
|
10
|
-
createEvent=
|
|
11
|
+
createEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.createEvent }}' : undefined}
|
|
11
12
|
{{#if config.createFormUiSchema}}
|
|
12
|
-
createFormUiSchema={
|
|
13
|
+
createFormUiSchema={createFormSchema}
|
|
13
14
|
{{/if}}
|
|
14
15
|
{{/if}}
|
|
15
16
|
{{#if config.updateEvent}}
|
|
16
|
-
updateEvent=
|
|
17
|
+
updateEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.updateEvent }}' : undefined}
|
|
17
18
|
{{#if config.updateFormUiSchema}}
|
|
18
|
-
updateFormUiSchema={
|
|
19
|
+
updateFormUiSchema={updateFormSchema}
|
|
19
20
|
{{/if}}
|
|
20
21
|
{{/if}}
|
|
21
22
|
{{#if config.deleteEvent}}
|
|
22
|
-
deleteEvent=
|
|
23
|
+
deleteEvent={hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.deleteEvent }}' : undefined}
|
|
23
24
|
{{/if}}
|
|
24
25
|
{{#if config.gridOptions}}
|
|
25
26
|
gridOptions={gridOptions}
|
|
@@ -42,4 +43,7 @@
|
|
|
42
43
|
{{#if config.enableSearchBar}}
|
|
43
44
|
enable-search-bar
|
|
44
45
|
{{/if}}
|
|
45
|
-
></entity-management>
|
|
46
|
+
></entity-management>{{#if config.permissions.viewRight}}
|
|
47
|
+
) : (
|
|
48
|
+
<ErrorMessage elementType="h3" message="You do not have access to view this component." />
|
|
49
|
+
){{/if}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#if config.permissions.updateRight}}hasUserPermission('{{config.permissions.updateRight}}') ? ({{/if}}
|
|
1
2
|
<foundation-form
|
|
2
3
|
design-system-prefix="rapid"
|
|
3
4
|
resourceName="{{config.resourceName}}"
|
|
@@ -5,4 +6,7 @@
|
|
|
5
6
|
uischema={uischema}
|
|
6
7
|
{{/if}}
|
|
7
8
|
>
|
|
8
|
-
</foundation-form>
|
|
9
|
+
</foundation-form>{{#if config.permissions.updateRight}}
|
|
10
|
+
) : (
|
|
11
|
+
<ErrorMessage elementType="h3" message="You do not have access to view this component." />
|
|
12
|
+
){{/if}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#if config.permissions.viewRight}}hasUserPermission('{{config.permissions.viewRight}}') ? ({{/if}}
|
|
1
2
|
<rapid-grid-pro
|
|
2
3
|
enable-row-flashing
|
|
3
4
|
enable-cell-flashing
|
|
@@ -14,4 +15,7 @@
|
|
|
14
15
|
deferredGridOptions=\{{ onRowClicked: gridOptions?.onRowClicked }}
|
|
15
16
|
{{/if}}
|
|
16
17
|
></grid-pro-genesis-datasource>
|
|
17
|
-
</rapid-grid-pro>
|
|
18
|
+
</rapid-grid-pro>{{#if config.permissions.viewRight}}
|
|
19
|
+
) : (
|
|
20
|
+
<ErrorMessage elementType="h3" message="You do not have access to view this component." />
|
|
21
|
+
){{/if}}
|
|
@@ -8,7 +8,7 @@ const {{pascalCase route.name}} = () => {
|
|
|
8
8
|
return (
|
|
9
9
|
<section className="{{kebabCase route.name}}-page">
|
|
10
10
|
{{#if route.tiles}}
|
|
11
|
-
<rapid-layout auto-save-key="{{route.layoutKey}}">
|
|
11
|
+
<rapid-layout auto-save-key={process.env.NODE_ENV === 'production' ? "{{route.layoutKey}}" : null}>
|
|
12
12
|
{{> (lookup ./route 'layoutType') }}
|
|
13
13
|
</rapid-layout>
|
|
14
14
|
{{else}}
|
package/.genx/versions.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.29.1-prerelease.9](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.8...v3.29.1-prerelease.9) (2024-08-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) fea6c6f
|
|
9
|
+
|
|
10
|
+
## [3.29.1-prerelease.8](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.7...v3.29.1-prerelease.8) (2024-08-23)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* updating server version information for GSF [PSD-0](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/0) 0fbf0b3
|
|
16
|
+
|
|
3
17
|
## [3.29.1-prerelease.7](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.29.1-prerelease.6...v3.29.1-prerelease.7) (2024-08-20)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
} from 'react-router-dom';
|
|
8
8
|
import { history } from './utils/history';
|
|
9
9
|
import LayoutWrapper from './layouts/LayoutWrapper';
|
|
10
|
-
import { routeLayouts } from './config';
|
|
10
|
+
import { AUTH_PATH, NOT_PERMITTED_PATH, routeLayouts } from './config';
|
|
11
11
|
import AuthGuard from './guards/AuthGuard';
|
|
12
|
+
import PermissionsGuard from './guards/PermissionsGuard';
|
|
12
13
|
import { AuthProvider } from './store/AuthContext';
|
|
13
14
|
// Pages Components
|
|
14
|
-
import AuthPage from './pages/
|
|
15
|
+
import AuthPage from './pages/AuthPage/AuthPage';
|
|
16
|
+
import NotPermittedPage from './pages/NotPermittedPage/NotPermittedPage';
|
|
15
17
|
{{#each routes}}
|
|
16
18
|
import {{pascalCase this.name}} from './pages/{{kebabCase this.name}}/{{pascalCase this.name}}';
|
|
17
19
|
{{/each}}
|
|
@@ -41,14 +43,19 @@ const LayoutWithLocation = () => {
|
|
|
41
43
|
{{/if}}
|
|
42
44
|
|
|
43
45
|
let pageComponent;
|
|
46
|
+
let permissionCode = '{{this.permissions.viewRight}}';
|
|
44
47
|
|
|
45
48
|
switch (location.pathname) {
|
|
46
|
-
case
|
|
49
|
+
case `/${AUTH_PATH}`:
|
|
47
50
|
pageComponent = <AuthPage />;
|
|
48
51
|
break;
|
|
52
|
+
case `/${NOT_PERMITTED_PATH}`:
|
|
53
|
+
pageComponent = <NotPermittedPage />;
|
|
54
|
+
break;
|
|
49
55
|
{{#each routes}}
|
|
50
56
|
case '/{{kebabCase this.name}}':
|
|
51
57
|
pageComponent = <{{pascalCase this.name}} />;
|
|
58
|
+
permissionCode = '{{this.permissions.viewRight}}';
|
|
52
59
|
break;
|
|
53
60
|
{{/each}}
|
|
54
61
|
default:
|
|
@@ -63,7 +70,9 @@ const LayoutWithLocation = () => {
|
|
|
63
70
|
} else {
|
|
64
71
|
return (
|
|
65
72
|
<AuthGuard>
|
|
66
|
-
<
|
|
73
|
+
<PermissionsGuard permissionCode={permissionCode}>
|
|
74
|
+
<LayoutWrapper layout={layout}>{pageComponent}</LayoutWrapper>
|
|
75
|
+
</PermissionsGuard>
|
|
67
76
|
</AuthGuard>
|
|
68
77
|
);
|
|
69
78
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const styles = {
|
|
4
|
+
errorMessageWrapper: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
justifyContent: 'center',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
height: '100%',
|
|
10
|
+
width: '100%',
|
|
11
|
+
},
|
|
12
|
+
errorMessage: {
|
|
13
|
+
color: 'var(--neutral-foreground-rest)',
|
|
14
|
+
backgroundColor: 'var(--neutral-layer-4)',
|
|
15
|
+
borderColor: 'var(--error-color)',
|
|
16
|
+
borderRadius: '7px',
|
|
17
|
+
borderStyle: 'solid',
|
|
18
|
+
borderWidth: '4px',
|
|
19
|
+
padding: '5px',
|
|
20
|
+
margin: '15px',
|
|
21
|
+
textAlign: 'center',
|
|
22
|
+
width: 'fit-content',
|
|
23
|
+
alignSelf: 'center',
|
|
24
|
+
height: 'auto',
|
|
25
|
+
maxHeight: '100%'
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const ErrorMessage = ({ elementType = 'div', message = '' }) => {
|
|
30
|
+
const ElementType = elementType;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<section style={styles.errorMessageWrapper}>
|
|
34
|
+
<div style={styles.errorMessage}>
|
|
35
|
+
{(() => {
|
|
36
|
+
switch (ElementType) {
|
|
37
|
+
case 'h1':
|
|
38
|
+
return <h1>{message}</h1>;
|
|
39
|
+
case 'h2':
|
|
40
|
+
return <h2>{message}</h2>;
|
|
41
|
+
case 'h3':
|
|
42
|
+
return <h3>{message}</h3>;
|
|
43
|
+
case 'h4':
|
|
44
|
+
return <h4>{message}</h4>;
|
|
45
|
+
case 'h5':
|
|
46
|
+
return <h5>{message}</h5>;
|
|
47
|
+
case 'h6':
|
|
48
|
+
return <h6>{message}</h6>;
|
|
49
|
+
case 'p':
|
|
50
|
+
return <p>{message}</p>;
|
|
51
|
+
case 'span':
|
|
52
|
+
return <span>{message}</span>;
|
|
53
|
+
default:
|
|
54
|
+
return <div>{message}</div>;
|
|
55
|
+
}
|
|
56
|
+
})()}
|
|
57
|
+
</div>
|
|
58
|
+
</section>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default ErrorMessage;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState, ReactNode } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import { getUser } from '@genesislcap/foundation-user';
|
|
4
|
+
import { NOT_PERMITTED_PATH } from '../config';
|
|
5
|
+
|
|
6
|
+
interface PermissionsGuardProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
permissionCode?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PermissionsGuard: React.FC<PermissionsGuardProps> = ({ children, permissionCode }: PermissionsGuardProps) => {
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const [isAuthorized, setIsAuthorized] = useState(false);
|
|
14
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const checkPermission = async () => {
|
|
18
|
+
const user = getUser();
|
|
19
|
+
if (permissionCode && !user.hasPermission(permissionCode)) {
|
|
20
|
+
navigate(`/${NOT_PERMITTED_PATH}`);
|
|
21
|
+
} else {
|
|
22
|
+
setIsAuthorized(true);
|
|
23
|
+
}
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
checkPermission();
|
|
28
|
+
}, [navigate, permissionCode]);
|
|
29
|
+
|
|
30
|
+
if (isLoading) {
|
|
31
|
+
return <div>Loading...</div>; // Or some loading component
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return isAuthorized ? <>{children}</> : null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default PermissionsGuard;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ErrorMessage from '../../components/ErrorMessage/ErrorMessage';
|
|
2
|
+
import './NotPermittedPage.css';
|
|
3
|
+
|
|
4
|
+
const NotPermittedPage = () => {
|
|
5
|
+
return (
|
|
6
|
+
<ErrorMessage
|
|
7
|
+
elementType="h1"
|
|
8
|
+
message="You do not have permission to access this part of the application, please contact your administrator."
|
|
9
|
+
></ErrorMessage>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default NotPermittedPage;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|