@nu-art/permissions-frontend 0.400.5
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/PermissionKey_FE.d.ts +25 -0
- package/PermissionKey_FE.js +23 -0
- package/_entity/permission-access-level/ModuleFE_PermissionAccessLevel.d.ts +11 -0
- package/_entity/permission-access-level/ModuleFE_PermissionAccessLevel.js +12 -0
- package/_entity/permission-access-level/index.d.ts +2 -0
- package/_entity/permission-access-level/index.js +2 -0
- package/_entity/permission-access-level/module-pack.d.ts +1 -0
- package/_entity/permission-access-level/module-pack.js +2 -0
- package/_entity/permission-access-level/shared.d.ts +1 -0
- package/_entity/permission-access-level/shared.js +1 -0
- package/_entity/permission-access-level/ui-components.d.ts +37 -0
- package/_entity/permission-access-level/ui-components.js +21 -0
- package/_entity/permission-api/ModuleFE_PermissionAPI.d.ts +11 -0
- package/_entity/permission-api/ModuleFE_PermissionAPI.js +12 -0
- package/_entity/permission-api/index.d.ts +2 -0
- package/_entity/permission-api/index.js +2 -0
- package/_entity/permission-api/module-pack.d.ts +1 -0
- package/_entity/permission-api/module-pack.js +2 -0
- package/_entity/permission-api/shared.d.ts +1 -0
- package/_entity/permission-api/shared.js +1 -0
- package/_entity/permission-api/ui-components.d.ts +37 -0
- package/_entity/permission-api/ui-components.js +21 -0
- package/_entity/permission-domain/ModuleFE_PermissionDomain.d.ts +9 -0
- package/_entity/permission-domain/ModuleFE_PermissionDomain.js +10 -0
- package/_entity/permission-domain/index.d.ts +2 -0
- package/_entity/permission-domain/index.js +2 -0
- package/_entity/permission-domain/module-pack.d.ts +1 -0
- package/_entity/permission-domain/module-pack.js +2 -0
- package/_entity/permission-domain/shared.d.ts +1 -0
- package/_entity/permission-domain/shared.js +1 -0
- package/_entity/permission-domain/ui-components.d.ts +37 -0
- package/_entity/permission-domain/ui-components.js +21 -0
- package/_entity/permission-group/ModuleFE_PermissionGroup.d.ts +11 -0
- package/_entity/permission-group/ModuleFE_PermissionGroup.js +12 -0
- package/_entity/permission-group/index.d.ts +2 -0
- package/_entity/permission-group/index.js +2 -0
- package/_entity/permission-group/module-pack.d.ts +1 -0
- package/_entity/permission-group/module-pack.js +2 -0
- package/_entity/permission-group/shared.d.ts +1 -0
- package/_entity/permission-group/shared.js +1 -0
- package/_entity/permission-group/ui-components.d.ts +37 -0
- package/_entity/permission-group/ui-components.js +21 -0
- package/_entity/permission-project/ModuleFE_PermissionProject.d.ts +11 -0
- package/_entity/permission-project/ModuleFE_PermissionProject.js +12 -0
- package/_entity/permission-project/index.d.ts +2 -0
- package/_entity/permission-project/index.js +2 -0
- package/_entity/permission-project/module-pack.d.ts +1 -0
- package/_entity/permission-project/module-pack.js +2 -0
- package/_entity/permission-project/shared.d.ts +1 -0
- package/_entity/permission-project/shared.js +1 -0
- package/_entity/permission-project/ui-components.d.ts +37 -0
- package/_entity/permission-project/ui-components.js +21 -0
- package/_entity/permission-user/ModuleFE_PermissionUser.d.ts +11 -0
- package/_entity/permission-user/ModuleFE_PermissionUser.js +14 -0
- package/_entity/permission-user/index.d.ts +2 -0
- package/_entity/permission-user/index.js +2 -0
- package/_entity/permission-user/module-pack.d.ts +1 -0
- package/_entity/permission-user/module-pack.js +2 -0
- package/_entity/permission-user/shared.d.ts +1 -0
- package/_entity/permission-user/shared.js +1 -0
- package/_entity/permission-user/ui-components.d.ts +37 -0
- package/_entity/permission-user/ui-components.js +36 -0
- package/_entity.d.ts +12 -0
- package/_entity.js +18 -0
- package/consts.d.ts +4 -0
- package/consts.js +3 -0
- package/core/module-pack.d.ts +2 -0
- package/core/module-pack.js +29 -0
- package/core/permission-keys.d.ts +4 -0
- package/core/permission-keys.js +5 -0
- package/index.d.ts +5 -0
- package/index.js +23 -0
- package/modules/ModuleFE_PermissionsAssert.d.ts +32 -0
- package/modules/ModuleFE_PermissionsAssert.js +80 -0
- package/package.json +84 -0
- package/shared.d.ts +1 -0
- package/shared.js +19 -0
- package/ui/ATS_ComponentPermissionKeys/ATS_ComponentPermissionKeys.d.ts +11 -0
- package/ui/ATS_ComponentPermissionKeys/ATS_ComponentPermissionKeys.js +22 -0
- package/ui/ATS_ComponentPermissionKeys/permission-keys-editor.scss +153 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/Component_AccessLevelsEditor.d.ts +16 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/Component_AccessLevelsEditor.js +38 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/permission-keys-editor.d.ts +16 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/permission-keys-editor.js +33 -0
- package/ui/ATS_Permissions/ATS_Permissions.d.ts +8 -0
- package/ui/ATS_Permissions/ATS_Permissions.js +63 -0
- package/ui/ATS_Permissions/ATS_Permissions.scss +172 -0
- package/ui/Component_SwitchView.d.ts +23 -0
- package/ui/Component_SwitchView.js +32 -0
- package/ui/Component_SwitchViewV2.d.ts +21 -0
- package/ui/Component_SwitchViewV2.js +25 -0
- package/ui/PermissionsComponent.d.ts +21 -0
- package/ui/PermissionsComponent.js +42 -0
- package/ui/PermissionsEditableComponent.d.ts +18 -0
- package/ui/PermissionsEditableComponent.js +21 -0
- package/ui/Renderer_RoleNames.d.ts +1 -0
- package/ui/Renderer_RoleNames.js +7 -0
- package/ui/index.d.ts +8 -0
- package/ui/index.js +8 -0
- package/ui/permission-editors/components.d.ts +6 -0
- package/ui/permission-editors/components.js +9 -0
- package/ui/permission-editors/editor-base.d.ts +18 -0
- package/ui/permission-editors/editor-base.js +17 -0
- package/ui/permission-editors/editor-base.scss +298 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.d.ts +16 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.js +63 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.scss +7 -0
- package/ui/permission-editors/permission-domains-editor.d.ts +9 -0
- package/ui/permission-editors/permission-domains-editor.js +139 -0
- package/ui/permission-editors/permission-groups-editor.d.ts +9 -0
- package/ui/permission-editors/permission-groups-editor.js +80 -0
- package/ui/permission-editors/permission-project-editor/permission-project-editor.scss +10 -0
- package/ui/permission-editors/permission-project-editor/permission-projects-editor.d.ts +10 -0
- package/ui/permission-editors/permission-project-editor/permission-projects-editor.js +52 -0
- package/ui/permission-editors/permission-users-editor.d.ts +9 -0
- package/ui/permission-editors/permission-users-editor.js +48 -0
- package/ui/ui-props.d.ts +16 -0
- package/ui/ui-props.js +62 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
@use '@nu-art/ts-styles' as styles;
|
|
2
|
+
|
|
3
|
+
.permissions-key-editor {
|
|
4
|
+
gap: 16px;
|
|
5
|
+
display: flex;
|
|
6
|
+
|
|
7
|
+
.item-list {
|
|
8
|
+
height: 100%;
|
|
9
|
+
width: 300px;
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
border: 2px solid black;
|
|
12
|
+
border-radius: 10px;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
|
|
15
|
+
.item-list__header {
|
|
16
|
+
height: 40px;
|
|
17
|
+
width: 100%;
|
|
18
|
+
border-bottom: 2px solid black;
|
|
19
|
+
background: styles.gray(3);
|
|
20
|
+
color: styles.gray(7);
|
|
21
|
+
display: grid;
|
|
22
|
+
place-content: center;
|
|
23
|
+
font: {
|
|
24
|
+
size: 18px;
|
|
25
|
+
weight: bold;
|
|
26
|
+
}
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.item-list__list {
|
|
31
|
+
flex-grow: 1;
|
|
32
|
+
width: 100%;
|
|
33
|
+
gap: 2px;
|
|
34
|
+
|
|
35
|
+
.item-list__list-item {
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 30px;
|
|
38
|
+
padding: 0 8px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
background: styles.gray(4);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
font: {
|
|
44
|
+
size: 14px;
|
|
45
|
+
weight: bold;
|
|
46
|
+
}
|
|
47
|
+
color: white;
|
|
48
|
+
|
|
49
|
+
&.selected {
|
|
50
|
+
background: white;
|
|
51
|
+
color: styles.gray(2);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.item-list__add-button {
|
|
57
|
+
width: 100%;
|
|
58
|
+
margin: 0;
|
|
59
|
+
padding: 8px 0;
|
|
60
|
+
font: {
|
|
61
|
+
size: 16px;
|
|
62
|
+
weight: bold;
|
|
63
|
+
}
|
|
64
|
+
border-radius: 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.item-editor {
|
|
69
|
+
height: 100%;
|
|
70
|
+
//flex-grow: 1;
|
|
71
|
+
border: 2px solid black;
|
|
72
|
+
border-radius: 10px;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
|
|
75
|
+
.access-levels-section {
|
|
76
|
+
width: 100%;
|
|
77
|
+
|
|
78
|
+
.access-levels {
|
|
79
|
+
width: 100%;
|
|
80
|
+
|
|
81
|
+
.access-levels-dropdown {
|
|
82
|
+
.ts-dropdown__header {
|
|
83
|
+
.ts-dropdown__placeholder {
|
|
84
|
+
width: 100%;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.item-editor__header {
|
|
92
|
+
height: 40px;
|
|
93
|
+
width: 100%;
|
|
94
|
+
border-bottom: 2px solid black;
|
|
95
|
+
background: styles.gray(3);
|
|
96
|
+
color: styles.gray(7);
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
padding: 0 16px;
|
|
100
|
+
font: {
|
|
101
|
+
size: 18px;
|
|
102
|
+
weight: bold;
|
|
103
|
+
}
|
|
104
|
+
flex-shrink: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.item-editor__main {
|
|
108
|
+
height: 0;
|
|
109
|
+
flex-grow: 1;
|
|
110
|
+
width: 100%;
|
|
111
|
+
padding: 16px;
|
|
112
|
+
gap: 16px;
|
|
113
|
+
|
|
114
|
+
.ts-table .ts-table__td {
|
|
115
|
+
padding: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.action-button {
|
|
119
|
+
width: 50px;
|
|
120
|
+
margin: 0;
|
|
121
|
+
padding: 0;
|
|
122
|
+
background: transparent;
|
|
123
|
+
min-width: 50px;
|
|
124
|
+
|
|
125
|
+
&.delete .icon--wrapper {
|
|
126
|
+
width: 32px;
|
|
127
|
+
height: 32px;
|
|
128
|
+
@include styles.mouse-interactive-icon(styles.red(4), styles.red(3), styles.red(2));
|
|
129
|
+
@include styles.set-svg-color-transition();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.save .icon--wrapper {
|
|
133
|
+
width: 24px;
|
|
134
|
+
height: 24px;
|
|
135
|
+
@include styles.mouse-interactive-icon(styles.green(4), styles.green(3), styles.green(2));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.item-editor__buttons {
|
|
141
|
+
height: 50px;
|
|
142
|
+
width: 100%;
|
|
143
|
+
justify-content: flex-end;
|
|
144
|
+
flex-shrink: 0;
|
|
145
|
+
padding: 0 16px;
|
|
146
|
+
gap: 16px;
|
|
147
|
+
|
|
148
|
+
.ts-button, .ts-busy-button {
|
|
149
|
+
margin: 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import { PermissionKey_FE } from '../../../PermissionKey_FE.js';
|
|
3
|
+
import { DB_PermissionAccessLevel } from '@nu-art/permissions-shared';
|
|
4
|
+
type Props = {
|
|
5
|
+
permissionKey: PermissionKey_FE;
|
|
6
|
+
};
|
|
7
|
+
type State = {
|
|
8
|
+
levels: DB_PermissionAccessLevel[];
|
|
9
|
+
};
|
|
10
|
+
export declare class Component_AccessLevelsEditor extends ComponentSync<Props, State> {
|
|
11
|
+
protected deriveStateFromProps(nextProps: Props, state: State): State;
|
|
12
|
+
private renderTag;
|
|
13
|
+
private renderLevelDropDown;
|
|
14
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, ComponentSync, LL_V_L } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { dbObjectToId } from '@nu-art/ts-common';
|
|
4
|
+
import { Permissions_DropDown } from '../../ui-props.js';
|
|
5
|
+
import { TS_Icons } from '@nu-art/ts-styles';
|
|
6
|
+
import { ModuleFE_PermissionAccessLevel, ModuleFE_PermissionDomain } from '../../../_entity.js';
|
|
7
|
+
export class Component_AccessLevelsEditor extends ComponentSync {
|
|
8
|
+
deriveStateFromProps(nextProps, state) {
|
|
9
|
+
const levelIds = nextProps.permissionKey.get().accessLevelIds ?? [];
|
|
10
|
+
state.levels = ModuleFE_PermissionAccessLevel.cache.filter(i => levelIds.includes(i._id));
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
renderTag(level) {
|
|
14
|
+
return _jsxs("div", { className: 'level', children: [_jsx(Button, { variant: 'dangerous', onClick: async () => {
|
|
15
|
+
const levels = this.state.levels.filter(i => i._id !== level._id);
|
|
16
|
+
await this.props.permissionKey.set({ accessLevelIds: levels.map(dbObjectToId) });
|
|
17
|
+
this.reDeriveState();
|
|
18
|
+
}, children: _jsx(TS_Icons.x.component, {}) }), _jsx("span", { children: level.name })] }, level._id);
|
|
19
|
+
}
|
|
20
|
+
renderLevelDropDown = () => {
|
|
21
|
+
return _jsx(Permissions_DropDown.AccessLevel, { queryFilter: (item) => {
|
|
22
|
+
return !this.state.levels.map(i => i._id).includes(item._id);
|
|
23
|
+
}, mapper: level => {
|
|
24
|
+
const domain = ModuleFE_PermissionDomain.cache.unique(level.domainId);
|
|
25
|
+
return [domain.namespace, level.name, String(level.value)];
|
|
26
|
+
}, className: 'access-levels-dropdown', selected: undefined, onSelected: async (level) => {
|
|
27
|
+
const levels = [...this.state.levels, level];
|
|
28
|
+
await this.props.permissionKey.set({ accessLevelIds: levels.map(dbObjectToId) });
|
|
29
|
+
this.reDeriveState();
|
|
30
|
+
}, placeholder: 'New Access Level', caret: {
|
|
31
|
+
open: _jsx("div", { className: 'caret open', children: _jsx(TS_Icons.treeCollapse.component, { style: { rotate: '90' } }) }),
|
|
32
|
+
close: _jsx("div", { className: 'caret close', children: _jsx(TS_Icons.treeCollapse.component, { style: { rotate: '-90' } }) }),
|
|
33
|
+
}, boundingParentSelector: '.ts-tabs__content' });
|
|
34
|
+
};
|
|
35
|
+
render() {
|
|
36
|
+
return (_jsx(LL_V_L, { className: 'access-levels-section', children: _jsxs(LL_V_L, { className: 'access-levels', children: [this.state.levels.map(level => this.renderTag(level)), this.renderLevelDropDown()] }) }));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import '../permission-keys-editor.scss';
|
|
3
|
+
import { PermissionKey_FE } from '../../../PermissionKey_FE.js';
|
|
4
|
+
type Props = {};
|
|
5
|
+
type State = {
|
|
6
|
+
editedItem?: PermissionKey_FE;
|
|
7
|
+
};
|
|
8
|
+
export declare class PermissionKeysEditor extends ComponentSync<Props, State> {
|
|
9
|
+
protected deriveStateFromProps(nextProps: Props, state: State): State;
|
|
10
|
+
private renderKey;
|
|
11
|
+
private renderKeyList;
|
|
12
|
+
private renderAccessLevels;
|
|
13
|
+
private renderKeyEditor;
|
|
14
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { _className, ComponentSync, LL_H_C, LL_V_L } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { _values } from '@nu-art/ts-common';
|
|
4
|
+
import '../permission-keys-editor.scss';
|
|
5
|
+
import { Component_AccessLevelsEditor } from './Component_AccessLevelsEditor.js';
|
|
6
|
+
import { ModuleFE_PermissionsAssert } from '../../../modules/ModuleFE_PermissionsAssert.js';
|
|
7
|
+
export class PermissionKeysEditor extends ComponentSync {
|
|
8
|
+
deriveStateFromProps(nextProps, state) {
|
|
9
|
+
state ??= this.state ? { ...this.state } : {};
|
|
10
|
+
return state;
|
|
11
|
+
}
|
|
12
|
+
renderKey = (item) => {
|
|
13
|
+
const className = _className('item-list__list-item', item.key === this.state.editedItem?.key ? 'selected' : undefined);
|
|
14
|
+
return _jsx("div", { className: className, onClick: () => this.setState({ editedItem: item }), children: item.key }, item.key);
|
|
15
|
+
};
|
|
16
|
+
renderKeyList = () => {
|
|
17
|
+
const allKeys = ModuleFE_PermissionsAssert.getAllPermissionKeys();
|
|
18
|
+
return _jsxs(LL_V_L, { className: 'item-list', children: [_jsx("div", { className: 'item-list__header', children: "Permission Keys" }), _jsx(LL_V_L, { className: 'item-list__list', children: _values(allKeys).map(this.renderKey) })] });
|
|
19
|
+
};
|
|
20
|
+
renderAccessLevels() {
|
|
21
|
+
if (!this.state.editedItem)
|
|
22
|
+
return null;
|
|
23
|
+
return _jsx(Component_AccessLevelsEditor, { permissionKey: this.state.editedItem });
|
|
24
|
+
}
|
|
25
|
+
renderKeyEditor = () => {
|
|
26
|
+
if (!this.state.editedItem)
|
|
27
|
+
return '';
|
|
28
|
+
return _jsxs(LL_V_L, { className: 'item-editor', children: [_jsx("div", { className: 'item-list__header', children: this.state.editedItem.key }), this.renderAccessLevels()] });
|
|
29
|
+
};
|
|
30
|
+
render() {
|
|
31
|
+
return _jsxs(LL_H_C, { className: 'permissions-key-editor match_parent', children: [this.renderKeyList(), this.renderKeyEditor()] });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AppToolsScreen, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import './ATS_Permissions.scss';
|
|
3
|
+
export declare class ATS_Permissions extends ComponentSync {
|
|
4
|
+
static screen: AppToolsScreen;
|
|
5
|
+
componentDidMount(): void;
|
|
6
|
+
private toggleStrictMode;
|
|
7
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { _className, Button, ComponentSync, genericNotificationAction, LL_H_C, LL_V_L, ModuleFE_RoutingV2, TS_AppTools, TS_NavLink } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import './ATS_Permissions.scss';
|
|
4
|
+
import { ModuleFE_PermissionsAssert } from '../../modules/ModuleFE_PermissionsAssert.js';
|
|
5
|
+
import { ModuleFE_Account } from '@nu-art/user-account-frontend/index';
|
|
6
|
+
import { arrayIncludesAny, timeout } from '@nu-art/ts-common';
|
|
7
|
+
import { SessionKey_StrictMode_FE } from '../../consts.js';
|
|
8
|
+
import { ModuleFE_PermissionAccessLevel } from '../../_entity/permission-access-level/index.js';
|
|
9
|
+
import { ModuleFE_PermissionAPI } from '../../_entity/permission-api/index.js';
|
|
10
|
+
import { ModuleFE_PermissionProject } from '../../_entity/permission-project/index.js';
|
|
11
|
+
import { ModuleFE_PermissionDomain } from '../../_entity/permission-domain/index.js';
|
|
12
|
+
import { ModuleFE_PermissionGroup } from '../../_entity/permission-group/index.js';
|
|
13
|
+
import { ModuleFE_PermissionUser } from '../../_entity/permission-user/index.js';
|
|
14
|
+
import { Outlet } from 'react-router-dom';
|
|
15
|
+
import { PermissionUsersEditor } from '../permission-editors/permission-users-editor.js';
|
|
16
|
+
import { PermissionProjectsEditor } from '../permission-editors/permission-project-editor/permission-projects-editor.js';
|
|
17
|
+
import { PermissionDomainsEditor } from '../permission-editors/permission-domains-editor.js';
|
|
18
|
+
import { PermissionGroupsEditor } from '../permission-editors/permission-groups-editor.js';
|
|
19
|
+
export class ATS_Permissions extends ComponentSync {
|
|
20
|
+
static screen = {
|
|
21
|
+
key: 'permissions-dev-page',
|
|
22
|
+
name: 'Permissions',
|
|
23
|
+
renderer: this,
|
|
24
|
+
group: 'Permissions',
|
|
25
|
+
modulesToAwait: [
|
|
26
|
+
ModuleFE_PermissionAccessLevel,
|
|
27
|
+
ModuleFE_PermissionAPI,
|
|
28
|
+
ModuleFE_PermissionProject,
|
|
29
|
+
ModuleFE_PermissionDomain,
|
|
30
|
+
ModuleFE_PermissionGroup,
|
|
31
|
+
ModuleFE_PermissionUser,
|
|
32
|
+
],
|
|
33
|
+
children: [
|
|
34
|
+
PermissionProjectsEditor.Route,
|
|
35
|
+
PermissionDomainsEditor.Route,
|
|
36
|
+
PermissionGroupsEditor.Route,
|
|
37
|
+
PermissionUsersEditor.Route,
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
componentDidMount() {
|
|
41
|
+
const routeKeys = [PermissionProjectsEditor.Route.key,
|
|
42
|
+
PermissionDomainsEditor.Route.key,
|
|
43
|
+
PermissionGroupsEditor.Route.key,
|
|
44
|
+
PermissionUsersEditor.Route.key,
|
|
45
|
+
];
|
|
46
|
+
if (!arrayIncludesAny(window.location.pathname.split('/'), routeKeys))
|
|
47
|
+
ModuleFE_RoutingV2.goToRoute(PermissionProjectsEditor.Route);
|
|
48
|
+
}
|
|
49
|
+
//######################### Logic #########################
|
|
50
|
+
toggleStrictMode = async () => {
|
|
51
|
+
await genericNotificationAction(async (notification) => {
|
|
52
|
+
this.setState({ creatingPermissions: true });
|
|
53
|
+
await ModuleFE_PermissionsAssert.v1.toggleStrictMode({}).executeSync();
|
|
54
|
+
await timeout(3000);
|
|
55
|
+
await ModuleFE_Account._v1.refreshSession({}).executeSync();
|
|
56
|
+
}, 'Toggling Strict Mode');
|
|
57
|
+
this.setState({ creatingPermissions: false });
|
|
58
|
+
};
|
|
59
|
+
//######################### Render #########################
|
|
60
|
+
render() {
|
|
61
|
+
return _jsxs(LL_V_L, { id: 'dev-page__permissions', children: [_jsxs(LL_H_C, { className: "match_width flex__space-between", children: [TS_AppTools.renderPageHeader('Permissions Editor'), _jsx(LL_H_C, { children: _jsxs(Button, { variant: 'secondary', disabled: this.state.creatingPermissions, className: 'item-list__add-button', onClick: this.toggleStrictMode, children: [SessionKey_StrictMode_FE.get() ? 'Disable' : 'Enable', " Strict Mode"] }) })] }), _jsxs(LL_H_C, { className: 'links-container', children: [_jsx(TS_NavLink, { route: PermissionProjectsEditor.Route, ignoreClickOnSameRoute: true, className: ({ isActive }) => _className('link-button', isActive && 'selected'), children: "Project" }, PermissionProjectsEditor.Route.key), _jsx(TS_NavLink, { route: PermissionDomainsEditor.Route, ignoreClickOnSameRoute: true, className: ({ isActive }) => _className('link-button', isActive && 'selected'), children: "Domains" }, PermissionDomainsEditor.Route.key), _jsx(TS_NavLink, { route: PermissionGroupsEditor.Route, ignoreClickOnSameRoute: true, className: ({ isActive }) => _className('link-button', isActive && 'selected'), children: "Groups" }, PermissionGroupsEditor.Route.key), _jsx(TS_NavLink, { route: PermissionUsersEditor.Route, ignoreClickOnSameRoute: true, className: ({ isActive }) => _className('link-button', isActive && 'selected'), children: "Users" }, PermissionUsersEditor.Route.key)] }), _jsx(Outlet, {})] });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
@use '@nu-art/ts-styles' as styles;
|
|
2
|
+
|
|
3
|
+
#dev-page__permissions {
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
padding: 0 16px 16px;
|
|
7
|
+
|
|
8
|
+
.ts-dev-page__page-header {
|
|
9
|
+
width: 100%;
|
|
10
|
+
margin: 0 0 16px;
|
|
11
|
+
padding: 8px 0;
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.links-container {
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
padding-bottom: 10px;
|
|
19
|
+
|
|
20
|
+
.link-button {
|
|
21
|
+
display: flex;
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: 2px solid black;
|
|
24
|
+
border-radius: 8px;
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
padding-inline: 12px;
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
min-width: 100px;
|
|
29
|
+
min-height: 50px;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
32
|
+
|
|
33
|
+
font: {
|
|
34
|
+
size: 18px;
|
|
35
|
+
weight: bold;
|
|
36
|
+
}
|
|
37
|
+
color: black;
|
|
38
|
+
|
|
39
|
+
&.selected {
|
|
40
|
+
background: white;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.domain-level-renderer {
|
|
46
|
+
border: 1px solid black;
|
|
47
|
+
border-radius: 4px;
|
|
48
|
+
height: 50px;
|
|
49
|
+
width: 150px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
|
|
52
|
+
.ts-dropdown {
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 50%;
|
|
55
|
+
|
|
56
|
+
.ts-dropdown__header {
|
|
57
|
+
border: none;
|
|
58
|
+
border-radius: 0;
|
|
59
|
+
border-bottom: 1px solid black;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ts-dropdown__items-container {
|
|
63
|
+
border: 1px solid black;
|
|
64
|
+
padding-top: 0;
|
|
65
|
+
transform: none
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ts-tree__node {
|
|
69
|
+
font: {
|
|
70
|
+
size: 12px;
|
|
71
|
+
}
|
|
72
|
+
white-space: break-spaces;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:last-child {
|
|
76
|
+
.ts-dropdown__header {
|
|
77
|
+
border: none;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.domain-level-list {
|
|
84
|
+
width: 100%;
|
|
85
|
+
flex-wrap: wrap;
|
|
86
|
+
gap: 8px;
|
|
87
|
+
|
|
88
|
+
.ts-multi-select__list-value {
|
|
89
|
+
position: relative;
|
|
90
|
+
height: 50px;
|
|
91
|
+
max-width: 150px;
|
|
92
|
+
padding: 8px;
|
|
93
|
+
white-space: break-spaces;
|
|
94
|
+
text-align: center;
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
font: {
|
|
98
|
+
size: 11px;
|
|
99
|
+
weight: bold;
|
|
100
|
+
}
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
|
|
103
|
+
.icon--wrapper {
|
|
104
|
+
background: styles.red(4);
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: 0;
|
|
107
|
+
right: 0;
|
|
108
|
+
height: 50px;
|
|
109
|
+
width: 30px;
|
|
110
|
+
padding: 8px;
|
|
111
|
+
transform: translateX(100%);
|
|
112
|
+
transition: transform 200ms ease-out;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
@include styles.mouse-interactive-icon(white);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:hover {
|
|
118
|
+
.icon--wrapper {
|
|
119
|
+
transform: translateX(0);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.db-def-button {
|
|
126
|
+
width: unset;
|
|
127
|
+
padding: 4px 8px;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#db-def-list {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
max-height: 200px;
|
|
135
|
+
@include styles.customScrollbar('vertical');
|
|
136
|
+
|
|
137
|
+
.db-def-list__item {
|
|
138
|
+
height: 30px;
|
|
139
|
+
padding: 0 8px;
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
|
|
143
|
+
&:hover {
|
|
144
|
+
background: styles.gray(7);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#save-initial-domain {
|
|
150
|
+
padding: 10px;
|
|
151
|
+
border: 2px solid black;
|
|
152
|
+
border-radius: 8px;
|
|
153
|
+
height: 80px;
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
justify-content: space-between;
|
|
157
|
+
|
|
158
|
+
.save-initial-domain__title {
|
|
159
|
+
font: {
|
|
160
|
+
size: 14px;
|
|
161
|
+
weight: bold;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.save-initial-domain__buttons {
|
|
166
|
+
justify-content: space-between;
|
|
167
|
+
|
|
168
|
+
.ts-button {
|
|
169
|
+
margin: 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { ResolvableContent } from '@nu-art/ts-common';
|
|
4
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
5
|
+
type Mode = {
|
|
6
|
+
key: string;
|
|
7
|
+
renderer: ResolvableContent<React.ReactNode>;
|
|
8
|
+
permissionKey?: PermissionKey_FE;
|
|
9
|
+
};
|
|
10
|
+
type Props = {
|
|
11
|
+
mode: string;
|
|
12
|
+
modes: Mode[];
|
|
13
|
+
};
|
|
14
|
+
type State = {
|
|
15
|
+
mode: string;
|
|
16
|
+
modes: Mode[];
|
|
17
|
+
};
|
|
18
|
+
export declare class Component_SwitchView extends ComponentSync<Props, State> {
|
|
19
|
+
protected deriveStateFromProps(nextProps: Props, state: State): State;
|
|
20
|
+
private getModeForKey;
|
|
21
|
+
render(): React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import { BadImplementationException, resolveContent } from '@nu-art/ts-common';
|
|
3
|
+
import { AccessLevel } from '../modules/ModuleFE_PermissionsAssert.js';
|
|
4
|
+
export class Component_SwitchView extends ComponentSync {
|
|
5
|
+
// ######################## Lifecycle ########################
|
|
6
|
+
deriveStateFromProps(nextProps, state) {
|
|
7
|
+
state.mode = nextProps.mode;
|
|
8
|
+
state.modes = nextProps.modes;
|
|
9
|
+
return state;
|
|
10
|
+
}
|
|
11
|
+
// ######################## Logic ########################
|
|
12
|
+
getModeForKey = (key) => {
|
|
13
|
+
const mode = this.state.modes.find(mode => mode.key === key);
|
|
14
|
+
if (!mode)
|
|
15
|
+
throw new BadImplementationException(`No mode found for given key ${key}`);
|
|
16
|
+
return mode;
|
|
17
|
+
};
|
|
18
|
+
// ######################## Render ########################
|
|
19
|
+
render() {
|
|
20
|
+
const mode = this.getModeForKey(this.state.mode);
|
|
21
|
+
if (!mode.permissionKey)
|
|
22
|
+
return resolveContent(mode.renderer);
|
|
23
|
+
const accessLevel = mode.permissionKey.getAccessLevel();
|
|
24
|
+
if (accessLevel === AccessLevel.Undefined) {
|
|
25
|
+
this.logError(`Data for permission key ${mode.permissionKey.key} does not exist`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (accessLevel < AccessLevel.HasAccess)
|
|
29
|
+
return;
|
|
30
|
+
return resolveContent(mode.renderer);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { ResolvableContent } from '@nu-art/ts-common';
|
|
4
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
5
|
+
type Modes<T extends string = 'view' | 'edit'> = {
|
|
6
|
+
[key in T]: ResolvableContent<React.ReactNode | undefined>;
|
|
7
|
+
};
|
|
8
|
+
type Props<T extends string = 'view' | 'edit'> = {
|
|
9
|
+
mode: T;
|
|
10
|
+
modes: Modes<T>;
|
|
11
|
+
};
|
|
12
|
+
type State<T extends string = 'view' | 'edit'> = {
|
|
13
|
+
mode: T;
|
|
14
|
+
modes: Modes<T>;
|
|
15
|
+
};
|
|
16
|
+
export declare const permissionsGuardedRenderer: (permissionKey: PermissionKey_FE, renderer: ResolvableContent<React.ReactNode>) => React.ReactNode;
|
|
17
|
+
export declare class Component_SwitchViewV2 extends ComponentSync<Props, State> {
|
|
18
|
+
protected deriveStateFromProps(nextProps: Props, state: State): State<"view" | "edit">;
|
|
19
|
+
render(): React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import { resolveContent } from '@nu-art/ts-common';
|
|
3
|
+
import { AccessLevel } from '../modules/ModuleFE_PermissionsAssert.js';
|
|
4
|
+
export const permissionsGuardedRenderer = (permissionKey, renderer) => {
|
|
5
|
+
const accessLevel = permissionKey.getAccessLevel();
|
|
6
|
+
if (accessLevel === AccessLevel.Undefined) {
|
|
7
|
+
console.log(`Data for permission key ${permissionKey.key} does not exist`);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (accessLevel < AccessLevel.HasAccess)
|
|
11
|
+
return;
|
|
12
|
+
return resolveContent(renderer);
|
|
13
|
+
};
|
|
14
|
+
export class Component_SwitchViewV2 extends ComponentSync {
|
|
15
|
+
// ######################## Lifecycle ########################
|
|
16
|
+
deriveStateFromProps(nextProps, state) {
|
|
17
|
+
state.mode = nextProps.mode;
|
|
18
|
+
state.modes = nextProps.modes;
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
// ######################## Render ########################
|
|
22
|
+
render() {
|
|
23
|
+
return resolveContent(this.state.modes[this.state.mode]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
4
|
+
export declare const RoutePermissions: (permissionKey: PermissionKey_FE<any>) => () => boolean;
|
|
5
|
+
export type Props_PermissionComponent = React.PropsWithChildren<{
|
|
6
|
+
permissionKey: PermissionKey_FE;
|
|
7
|
+
loadingComponent?: React.ComponentType;
|
|
8
|
+
fallback?: React.ComponentType;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class PermissionsComponent<P extends Props_PermissionComponent = Props_PermissionComponent, S extends {} = {}> extends ComponentSync<P, S> {
|
|
11
|
+
static defaultProps: {
|
|
12
|
+
modules: import("@nu-art/thunderstorm-frontend/index").ModuleFE_AppConfig_Class[];
|
|
13
|
+
};
|
|
14
|
+
shouldComponentUpdate(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean;
|
|
15
|
+
protected renderLoader: () => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
protected renderWaitingOnPermissions: () => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
protected renderPermitted: () => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
protected renderFallback: () => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
private renderImpl;
|
|
20
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AwaitModules, ComponentSync, ModuleFE_AppConfig } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { AccessLevel } from '../modules/ModuleFE_PermissionsAssert.js';
|
|
4
|
+
export const RoutePermissions = (permissionKey) => () => permissionKey.getAccessLevel() === AccessLevel.HasAccess;
|
|
5
|
+
export class PermissionsComponent extends ComponentSync {
|
|
6
|
+
// ######################## Static ########################
|
|
7
|
+
static defaultProps = {
|
|
8
|
+
modules: [ModuleFE_AppConfig]
|
|
9
|
+
};
|
|
10
|
+
// ######################## Lifecycle ########################
|
|
11
|
+
shouldComponentUpdate(nextProps, nextState, nextContext) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// ######################## Render ########################
|
|
15
|
+
renderLoader = () => {
|
|
16
|
+
return _jsx(_Fragment, {});
|
|
17
|
+
};
|
|
18
|
+
renderWaitingOnPermissions = () => {
|
|
19
|
+
const Loader = this.props.loadingComponent;
|
|
20
|
+
return Loader ? _jsx(Loader, {}) : null;
|
|
21
|
+
};
|
|
22
|
+
renderPermitted = () => {
|
|
23
|
+
return _jsx(_Fragment, { children: this.props.children });
|
|
24
|
+
};
|
|
25
|
+
renderFallback = () => {
|
|
26
|
+
const Fallback = this.props.fallback;
|
|
27
|
+
if (Fallback)
|
|
28
|
+
return _jsx(Fallback, {});
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
renderImpl = () => {
|
|
32
|
+
const permitted = this.props.permissionKey.getAccessLevel();
|
|
33
|
+
if (permitted === AccessLevel.Undefined)
|
|
34
|
+
return this.renderWaitingOnPermissions();
|
|
35
|
+
if (permitted === AccessLevel.HasAccess)
|
|
36
|
+
return this.renderPermitted();
|
|
37
|
+
return this.renderFallback();
|
|
38
|
+
};
|
|
39
|
+
render() {
|
|
40
|
+
return _jsx(AwaitModules, { modules: [ModuleFE_AppConfig], children: this.renderImpl() });
|
|
41
|
+
}
|
|
42
|
+
}
|