@webiny/app-security-access-management 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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/README.md +6 -4
- package/components/GroupAutocomplete/graphql.d.ts +1 -1
- package/components/GroupAutocomplete/graphql.js +17 -5
- package/components/GroupAutocomplete/graphql.js.map +1 -0
- package/components/GroupAutocomplete/index.d.ts +5 -2
- package/components/GroupAutocomplete/index.js +10 -8
- package/components/GroupAutocomplete/index.js.map +1 -0
- package/components/GroupsMultiAutocomplete/graphql.d.ts +1 -0
- package/components/GroupsMultiAutocomplete/graphql.js +23 -0
- package/components/GroupsMultiAutocomplete/graphql.js.map +1 -0
- package/components/GroupsMultiAutocomplete/index.d.ts +5 -0
- package/components/GroupsMultiAutocomplete/index.js +19 -0
- package/components/GroupsMultiAutocomplete/index.js.map +1 -0
- package/components/NotAuthorizedError/NotAuthorizedError.d.ts +2 -2
- package/components/NotAuthorizedError/NotAuthorizedError.js +17 -44
- package/components/NotAuthorizedError/NotAuthorizedError.js.map +1 -0
- package/components/NotAuthorizedError/index.js +3 -1
- package/components/NotAuthorizedError/index.js.map +1 -0
- package/components/TeamAutocomplete/graphql.d.ts +1 -0
- package/components/TeamAutocomplete/graphql.js +18 -0
- package/components/TeamAutocomplete/graphql.js.map +1 -0
- package/components/TeamAutocomplete/index.d.ts +5 -0
- package/components/TeamAutocomplete/index.js +18 -0
- package/components/TeamAutocomplete/index.js.map +1 -0
- package/components/TeamsMultiAutocomplete/graphql.d.ts +1 -0
- package/components/TeamsMultiAutocomplete/graphql.js +23 -0
- package/components/TeamsMultiAutocomplete/graphql.js.map +1 -0
- package/components/TeamsMultiAutocomplete/index.d.ts +5 -0
- package/components/TeamsMultiAutocomplete/index.js +19 -0
- package/components/TeamsMultiAutocomplete/index.js.map +1 -0
- package/index.d.ts +2 -2
- package/index.js +83 -4
- package/index.js.map +1 -0
- package/package.json +24 -37
- package/plugins/constants.d.ts +1 -0
- package/plugins/constants.js +6 -4
- package/plugins/constants.js.map +1 -0
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +3 -5
- package/plugins/index.js.map +1 -0
- package/plugins/installation.d.ts +1 -1
- package/plugins/installation.js +68 -67
- package/plugins/installation.js.map +1 -0
- package/plugins/permissionRenderer/SecurityPermissions.d.ts +8 -5
- package/plugins/permissionRenderer/SecurityPermissions.js +93 -94
- package/plugins/permissionRenderer/SecurityPermissions.js.map +1 -0
- package/plugins/permissionRenderer/index.js +14 -13
- package/plugins/permissionRenderer/index.js.map +1 -0
- package/plugins/routes.d.ts +1 -1
- package/plugins/routes.js +14 -16
- package/plugins/routes.js.map +1 -0
- package/plugins/secureRouteError.d.ts +2 -2
- package/plugins/secureRouteError.js +5 -3
- package/plugins/secureRouteError.js.map +1 -0
- package/types.d.ts +28 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/ui/elements/GroupAutocompleteElement.d.ts +2 -1
- package/ui/elements/GroupAutocompleteElement.js +27 -30
- package/ui/elements/GroupAutocompleteElement.js.map +1 -0
- package/ui/elements/GroupsMultiAutocompleteElement.d.ts +6 -0
- package/ui/elements/GroupsMultiAutocompleteElement.js +32 -0
- package/ui/elements/GroupsMultiAutocompleteElement.js.map +1 -0
- package/ui/elements/TeamAutocompleteElement.d.ts +6 -0
- package/ui/elements/TeamAutocompleteElement.js +32 -0
- package/ui/elements/TeamAutocompleteElement.js.map +1 -0
- package/ui/views/ApiKeys/ApiKeyForm.d.ts +5 -3
- package/ui/views/ApiKeys/ApiKeyForm.js +125 -183
- package/ui/views/ApiKeys/ApiKeyForm.js.map +1 -0
- package/ui/views/ApiKeys/ApiKeys.d.ts +8 -3
- package/ui/views/ApiKeys/ApiKeys.js +7 -7
- package/ui/views/ApiKeys/ApiKeys.js.map +1 -0
- package/ui/views/ApiKeys/ApiKeysDataList.d.ts +5 -3
- package/ui/views/ApiKeys/ApiKeysDataList.js +105 -169
- package/ui/views/ApiKeys/ApiKeysDataList.js.map +1 -0
- package/ui/views/ApiKeys/graphql.d.ts +13 -5
- package/ui/views/ApiKeys/graphql.js +81 -10
- package/ui/views/ApiKeys/graphql.js.map +1 -0
- package/ui/views/ApiKeys/index.d.ts +1 -1
- package/ui/views/ApiKeys/index.js +3 -1
- package/ui/views/ApiKeys/index.js.map +1 -0
- package/ui/views/ApiKeys/utils.d.ts +2 -1
- package/ui/views/ApiKeys/utils.js +6 -5
- package/ui/views/ApiKeys/utils.js.map +1 -0
- package/ui/views/Groups/Groups.d.ts +8 -3
- package/ui/views/Groups/Groups.js +8 -8
- package/ui/views/Groups/Groups.js.map +1 -0
- package/ui/views/Groups/GroupsDataList.d.ts +5 -3
- package/ui/views/Groups/GroupsDataList.js +110 -176
- package/ui/views/Groups/GroupsDataList.js.map +1 -0
- package/ui/views/Groups/GroupsForm.d.ts +5 -3
- package/ui/views/Groups/GroupsForm.js +150 -170
- package/ui/views/Groups/GroupsForm.js.map +1 -0
- package/ui/views/Groups/graphql.d.ts +13 -5
- package/ui/views/Groups/graphql.js +84 -10
- package/ui/views/Groups/graphql.js.map +1 -0
- package/ui/views/Groups/index.d.ts +1 -1
- package/ui/views/Groups/index.js +3 -1
- package/ui/views/Groups/index.js.map +1 -0
- package/ui/views/Teams/Teams.d.ts +8 -0
- package/ui/views/Teams/Teams.js +12 -0
- package/ui/views/Teams/Teams.js.map +1 -0
- package/ui/views/Teams/TeamsDataList.d.ts +5 -0
- package/ui/views/Teams/TeamsDataList.js +151 -0
- package/ui/views/Teams/TeamsDataList.js.map +1 -0
- package/ui/views/Teams/TeamsForm.d.ts +5 -0
- package/ui/views/Teams/TeamsForm.js +173 -0
- package/ui/views/Teams/TeamsForm.js.map +1 -0
- package/ui/views/Teams/graphql.d.ts +13 -0
- package/ui/views/Teams/graphql.js +89 -0
- package/ui/views/Teams/graphql.js.map +1 -0
- package/ui/views/Teams/index.d.ts +1 -0
- package/ui/views/Teams/index.js +3 -0
- package/ui/views/Teams/index.js.map +1 -0
- package/ui/views/utils.d.ts +3 -2
- package/ui/views/utils.js +6 -23
- package/ui/views/utils.js.map +1 -0
- package/plugins/menus.d.ts +0 -4
- package/plugins/menus.js +0 -61
|
@@ -1,234 +1,214 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
|
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
6
|
-
|
|
7
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
1
|
import React, { useCallback } from "react";
|
|
9
2
|
import { useMutation, useQuery } from "@apollo/react-hooks";
|
|
10
|
-
import styled from "@emotion/styled";
|
|
11
|
-
import pick from "lodash/pick";
|
|
12
3
|
import get from "lodash/get";
|
|
13
4
|
import { useRouter } from "@webiny/react-router";
|
|
14
5
|
import { i18n } from "@webiny/app/i18n";
|
|
15
6
|
import { Form } from "@webiny/form";
|
|
16
|
-
import { Grid, Cell } from "@webiny/ui/Grid";
|
|
17
|
-
import { Input } from "@webiny/ui/Input";
|
|
18
|
-
import { Alert } from "@webiny/ui/Alert";
|
|
19
|
-
import { ButtonDefault, ButtonIcon, ButtonPrimary } from "@webiny/ui/Button";
|
|
20
|
-
import { CircularProgress } from "@webiny/ui/Progress";
|
|
21
7
|
import { validation } from "@webiny/validation";
|
|
22
8
|
import { SimpleForm, SimpleFormFooter, SimpleFormContent, SimpleFormHeader } from "@webiny/app-admin/components/SimpleForm";
|
|
23
|
-
import { Typography } from "@webiny/ui/Typography";
|
|
24
9
|
import { Permissions } from "@webiny/app-admin/components/Permissions";
|
|
25
10
|
import { useSnackbar } from "@webiny/app-admin/hooks/useSnackbar";
|
|
26
11
|
import { CREATE_GROUP, LIST_GROUPS, READ_GROUP, UPDATE_GROUP } from "./graphql";
|
|
27
|
-
import { SnackbarAction } from "@webiny/ui/Snackbar";
|
|
28
12
|
import isEmpty from "lodash/isEmpty";
|
|
29
13
|
import EmptyView from "@webiny/app-admin/components/EmptyView";
|
|
30
|
-
import { ReactComponent as AddIcon } from "@
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
showSnackbar = _useSnackbar.showSnackbar;
|
|
47
|
-
|
|
48
|
-
var newGroup = new URLSearchParams(location.search).get("new") === "true";
|
|
49
|
-
var id = new URLSearchParams(location.search).get("id");
|
|
50
|
-
var getQuery = useQuery(READ_GROUP, {
|
|
14
|
+
import { ReactComponent as AddIcon } from "@webiny/icons/add.svg";
|
|
15
|
+
import { ReactComponent as CopyIcon } from "@webiny/icons/content_copy.svg";
|
|
16
|
+
import { ReactComponent as SettingsIcon } from "@webiny/icons/settings.svg";
|
|
17
|
+
import { Alert, Button, Grid, IconButton, Input, OverlayLoader, Textarea, Tooltip } from "@webiny/admin-ui";
|
|
18
|
+
const t = i18n.ns("app-security/admin/roles/form");
|
|
19
|
+
export const GroupsForm = () => {
|
|
20
|
+
const {
|
|
21
|
+
location,
|
|
22
|
+
history
|
|
23
|
+
} = useRouter();
|
|
24
|
+
const {
|
|
25
|
+
showSnackbar
|
|
26
|
+
} = useSnackbar();
|
|
27
|
+
const newGroup = new URLSearchParams(location.search).get("new") === "true";
|
|
28
|
+
const id = new URLSearchParams(location.search).get("id");
|
|
29
|
+
const getQuery = useQuery(READ_GROUP, {
|
|
51
30
|
variables: {
|
|
52
|
-
id
|
|
31
|
+
id
|
|
53
32
|
},
|
|
54
33
|
skip: !id,
|
|
55
|
-
onCompleted:
|
|
34
|
+
onCompleted: data => {
|
|
56
35
|
if (!data) {
|
|
57
36
|
return;
|
|
58
37
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
38
|
+
const {
|
|
39
|
+
error
|
|
40
|
+
} = data.security.group;
|
|
62
41
|
if (error) {
|
|
63
|
-
history.push("/access-management/
|
|
42
|
+
history.push("/access-management/roles");
|
|
64
43
|
showSnackbar(error.message);
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
});
|
|
68
|
-
|
|
69
|
-
var _useMutation = useMutation(CREATE_GROUP, {
|
|
47
|
+
const [create, createMutation] = useMutation(CREATE_GROUP, {
|
|
70
48
|
refetchQueries: [{
|
|
71
49
|
query: LIST_GROUPS
|
|
72
50
|
}]
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
create = _useMutation2[0],
|
|
76
|
-
createMutation = _useMutation2[1];
|
|
77
|
-
|
|
78
|
-
var _useMutation3 = useMutation(UPDATE_GROUP, {
|
|
51
|
+
});
|
|
52
|
+
const [update, updateMutation] = useMutation(UPDATE_GROUP, {
|
|
79
53
|
refetchQueries: [{
|
|
80
54
|
query: LIST_GROUPS
|
|
81
55
|
}]
|
|
82
|
-
}),
|
|
83
|
-
_useMutation4 = _slicedToArray(_useMutation3, 2),
|
|
84
|
-
update = _useMutation4[0],
|
|
85
|
-
updateMutation = _useMutation4[1];
|
|
86
|
-
|
|
87
|
-
var loading = [getQuery, createMutation, updateMutation].find(function (item) {
|
|
88
|
-
return item.loading;
|
|
89
56
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
id: data.id,
|
|
117
|
-
data: pick(data, ["name", "description", "permissions"])
|
|
118
|
-
}
|
|
119
|
-
}] : [create, {
|
|
120
|
-
variables: {
|
|
121
|
-
data: pick(data, ["name", "slug", "description", "permissions"])
|
|
122
|
-
}
|
|
123
|
-
}], _ref3 = _slicedToArray(_ref2, 2), operation = _ref3[0], args = _ref3[1];
|
|
124
|
-
_context.next = 7;
|
|
125
|
-
return operation(args);
|
|
126
|
-
|
|
127
|
-
case 7:
|
|
128
|
-
response = _context.sent;
|
|
129
|
-
_response$data$securi = response.data.security.group, group = _response$data$securi.data, error = _response$data$securi.error;
|
|
130
|
-
|
|
131
|
-
if (!error) {
|
|
132
|
-
_context.next = 11;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return _context.abrupt("return", showSnackbar(error.message));
|
|
137
|
-
|
|
138
|
-
case 11:
|
|
139
|
-
!isUpdate && history.push("/access-management/groups?id=".concat(group.id));
|
|
140
|
-
showSnackbar(t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Group saved successfully!"]))));
|
|
141
|
-
|
|
142
|
-
case 13:
|
|
143
|
-
case "end":
|
|
144
|
-
return _context.stop();
|
|
145
|
-
}
|
|
57
|
+
const loading = [getQuery, createMutation, updateMutation].find(item => item.loading);
|
|
58
|
+
const onSubmit = useCallback(async ({
|
|
59
|
+
id,
|
|
60
|
+
name,
|
|
61
|
+
description,
|
|
62
|
+
slug,
|
|
63
|
+
permissions,
|
|
64
|
+
createdOn
|
|
65
|
+
}) => {
|
|
66
|
+
if (!permissions || !permissions.length) {
|
|
67
|
+
showSnackbar(t`You must configure permissions before saving!`, {
|
|
68
|
+
timeout: 60000,
|
|
69
|
+
dismissesOnAction: true
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const isUpdate = createdOn;
|
|
74
|
+
const [operation, args] = isUpdate ? [update, {
|
|
75
|
+
variables: {
|
|
76
|
+
id,
|
|
77
|
+
data: {
|
|
78
|
+
name,
|
|
79
|
+
permissions,
|
|
80
|
+
...(description && {
|
|
81
|
+
description
|
|
82
|
+
})
|
|
146
83
|
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
84
|
+
}
|
|
85
|
+
}] : [create, {
|
|
86
|
+
variables: {
|
|
87
|
+
data: {
|
|
88
|
+
name,
|
|
89
|
+
slug,
|
|
90
|
+
description,
|
|
91
|
+
permissions
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}];
|
|
95
|
+
const response = await operation(args);
|
|
96
|
+
const {
|
|
97
|
+
data: group,
|
|
98
|
+
error
|
|
99
|
+
} = response.data.security.group;
|
|
100
|
+
if (error) {
|
|
101
|
+
return showSnackbar(error.message);
|
|
102
|
+
}
|
|
103
|
+
!isUpdate && history.push(`/access-management/roles?id=${group.id}`);
|
|
104
|
+
showSnackbar(t`Role saved successfully!`);
|
|
105
|
+
}, [id]);
|
|
106
|
+
const data = loading ? {} : get(getQuery, "data.security.group.data", {});
|
|
107
|
+
const systemGroup = data.slug === "full-access" || data.system;
|
|
108
|
+
const pluginGroup = data.plugin;
|
|
109
|
+
const canModifyGroup = !systemGroup && !pluginGroup;
|
|
110
|
+
const showEmptyView = !newGroup && !loading && isEmpty(data);
|
|
111
|
+
// Render "No content" selected view.
|
|
158
112
|
if (showEmptyView) {
|
|
159
113
|
return /*#__PURE__*/React.createElement(EmptyView, {
|
|
160
|
-
|
|
161
|
-
|
|
114
|
+
icon: /*#__PURE__*/React.createElement(SettingsIcon, null),
|
|
115
|
+
title: t`Click on the left side list to display role details or create a...`,
|
|
116
|
+
action: /*#__PURE__*/React.createElement(Button, {
|
|
117
|
+
icon: /*#__PURE__*/React.createElement(AddIcon, null),
|
|
118
|
+
text: t`New Role`,
|
|
162
119
|
"data-testid": "new-record-button",
|
|
163
|
-
onClick:
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
}, /*#__PURE__*/React.createElement(ButtonIcon, {
|
|
167
|
-
icon: /*#__PURE__*/React.createElement(AddIcon, null)
|
|
168
|
-
}), t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["New Group"]))))
|
|
120
|
+
onClick: () => history.push("/access-management/roles?new=true")
|
|
121
|
+
})
|
|
169
122
|
});
|
|
170
123
|
}
|
|
171
|
-
|
|
172
124
|
return /*#__PURE__*/React.createElement(Form, {
|
|
173
125
|
data: data,
|
|
174
126
|
onSubmit: onSubmit
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
127
|
+
}, ({
|
|
128
|
+
data,
|
|
129
|
+
form,
|
|
130
|
+
Bind
|
|
131
|
+
}) => {
|
|
132
|
+
return /*#__PURE__*/React.createElement(SimpleForm, {
|
|
133
|
+
size: "lg"
|
|
134
|
+
}, loading && /*#__PURE__*/React.createElement(OverlayLoader, null), /*#__PURE__*/React.createElement(SimpleFormHeader, {
|
|
180
135
|
title: data.name ? data.name : "Untitled"
|
|
181
|
-
}), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(
|
|
136
|
+
}), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(React.Fragment, null, systemGroup && /*#__PURE__*/React.createElement(Grid.Column, {
|
|
137
|
+
span: 12
|
|
138
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
139
|
+
type: "warning",
|
|
140
|
+
title: "Permissions are locked"
|
|
141
|
+
}, "This is a protected system role and you can't modify its permissions.")), pluginGroup && /*#__PURE__*/React.createElement(Grid.Column, {
|
|
142
|
+
span: 12
|
|
143
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
144
|
+
type: "warning",
|
|
145
|
+
title: "Permissions are locked"
|
|
146
|
+
}, "This role is registered via an extension, and cannot be modified.")), /*#__PURE__*/React.createElement(Grid.Column, {
|
|
182
147
|
span: 6
|
|
183
148
|
}, /*#__PURE__*/React.createElement(Bind, {
|
|
184
149
|
name: "name",
|
|
185
150
|
validators: validation.create("required,minLength:3")
|
|
186
151
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
152
|
+
size: "lg",
|
|
153
|
+
label: t`Name`,
|
|
154
|
+
disabled: !canModifyGroup,
|
|
155
|
+
"data-testid": "admin.am.group.new.name"
|
|
156
|
+
}))), /*#__PURE__*/React.createElement(Grid.Column, {
|
|
190
157
|
span: 6
|
|
191
158
|
}, /*#__PURE__*/React.createElement(Bind, {
|
|
192
159
|
name: "slug",
|
|
193
160
|
validators: validation.create("required,minLength:3")
|
|
194
161
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
162
|
+
size: "lg",
|
|
163
|
+
disabled: !canModifyGroup || !newGroup,
|
|
164
|
+
label: t`Slug`,
|
|
165
|
+
"data-testid": "admin.am.group.new.slug"
|
|
166
|
+
}))), /*#__PURE__*/React.createElement(Grid.Column, {
|
|
198
167
|
span: 12
|
|
199
168
|
}, /*#__PURE__*/React.createElement(Bind, {
|
|
200
169
|
name: "description",
|
|
201
170
|
validators: validation.create("maxLength:500")
|
|
202
|
-
}, /*#__PURE__*/React.createElement(
|
|
203
|
-
|
|
171
|
+
}, /*#__PURE__*/React.createElement(Textarea, {
|
|
172
|
+
size: "lg",
|
|
173
|
+
label: t`Description`,
|
|
204
174
|
rows: 3,
|
|
205
|
-
disabled:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
175
|
+
disabled: !canModifyGroup,
|
|
176
|
+
"data-testid": "admin.am.group.new.description"
|
|
177
|
+
})))))), /*#__PURE__*/React.createElement(SimpleFormHeader, {
|
|
178
|
+
title: "Permissions",
|
|
179
|
+
rounded: false
|
|
180
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: "wby-flex wby-justify-end"
|
|
182
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
183
|
+
content: "Copy permissions as JSON",
|
|
184
|
+
trigger: /*#__PURE__*/React.createElement(IconButton, {
|
|
185
|
+
variant: "ghost",
|
|
186
|
+
icon: /*#__PURE__*/React.createElement(CopyIcon, null),
|
|
187
|
+
onClick: () => {
|
|
188
|
+
navigator.clipboard.writeText(JSON.stringify(data.permissions, null, 2));
|
|
189
|
+
showSnackbar("JSON data copied to clipboard.");
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
}))), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(React.Fragment, null, canModifyGroup && /*#__PURE__*/React.createElement(Grid.Column, {
|
|
216
193
|
span: 12
|
|
217
194
|
}, /*#__PURE__*/React.createElement(Bind, {
|
|
218
195
|
name: "permissions",
|
|
219
196
|
defaultValue: []
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
onClick:
|
|
226
|
-
|
|
197
|
+
}, bind => /*#__PURE__*/React.createElement(Permissions, Object.assign({
|
|
198
|
+
id: data.id || "new"
|
|
199
|
+
}, bind))))))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, canModifyGroup && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
200
|
+
variant: "secondary",
|
|
201
|
+
text: t`Cancel`,
|
|
202
|
+
onClick: () => history.push("/access-management/roles"),
|
|
203
|
+
"data-testid": "pb.category.new.form.button.cancel"
|
|
204
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
205
|
+
text: t`Save`,
|
|
206
|
+
"data-testid": "admin.am.group.new.save",
|
|
207
|
+
onClick: ev => {
|
|
208
|
+
form.submit(ev);
|
|
227
209
|
}
|
|
228
|
-
}
|
|
229
|
-
onClick: form.submit
|
|
230
|
-
}, t(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Save group"])))))));
|
|
210
|
+
}))));
|
|
231
211
|
});
|
|
232
212
|
};
|
|
233
213
|
|
|
234
|
-
|
|
214
|
+
//# sourceMappingURL=GroupsForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMutation","useQuery","get","useRouter","i18n","Form","validation","SimpleForm","SimpleFormFooter","SimpleFormContent","SimpleFormHeader","Permissions","useSnackbar","CREATE_GROUP","LIST_GROUPS","READ_GROUP","UPDATE_GROUP","isEmpty","EmptyView","ReactComponent","AddIcon","CopyIcon","SettingsIcon","Alert","Button","Grid","IconButton","Input","OverlayLoader","Textarea","Tooltip","t","ns","GroupsForm","location","history","showSnackbar","newGroup","URLSearchParams","search","id","getQuery","variables","skip","onCompleted","data","error","security","group","push","message","create","createMutation","refetchQueries","query","update","updateMutation","loading","find","item","onSubmit","name","description","slug","permissions","createdOn","length","timeout","dismissesOnAction","isUpdate","operation","args","response","systemGroup","system","pluginGroup","plugin","canModifyGroup","showEmptyView","createElement","icon","title","action","text","onClick","form","Bind","size","Fragment","Column","span","type","validators","label","disabled","rows","rounded","className","content","trigger","variant","navigator","clipboard","writeText","JSON","stringify","defaultValue","bind","Object","assign","ev","submit"],"sources":["GroupsForm.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useMutation, useQuery } from \"@apollo/react-hooks\";\nimport get from \"lodash/get\";\nimport { useRouter } from \"@webiny/react-router\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormFooter,\n SimpleFormContent,\n SimpleFormHeader\n} from \"@webiny/app-admin/components/SimpleForm\";\nimport { Permissions } from \"@webiny/app-admin/components/Permissions\";\nimport { useSnackbar } from \"@webiny/app-admin/hooks/useSnackbar\";\nimport { CREATE_GROUP, LIST_GROUPS, READ_GROUP, UPDATE_GROUP } from \"./graphql\";\nimport isEmpty from \"lodash/isEmpty\";\nimport EmptyView from \"@webiny/app-admin/components/EmptyView\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as CopyIcon } from \"@webiny/icons/content_copy.svg\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport type { Group } from \"~/types\";\nimport {\n Alert,\n Button,\n Grid,\n IconButton,\n Input,\n OverlayLoader,\n Textarea,\n Tooltip\n} from \"@webiny/admin-ui\";\n\nconst t = i18n.ns(\"app-security/admin/roles/form\");\n\nexport interface GroupsFormProps {\n // TODO @ts-refactor delete and go up the tree and sort it out\n [key: string]: any;\n}\n\nexport const GroupsForm = () => {\n const { location, history } = useRouter();\n const { showSnackbar } = useSnackbar();\n const newGroup = new URLSearchParams(location.search).get(\"new\") === \"true\";\n const id = new URLSearchParams(location.search).get(\"id\");\n\n const getQuery = useQuery(READ_GROUP, {\n variables: { id },\n skip: !id,\n onCompleted: data => {\n if (!data) {\n return;\n }\n\n const { error } = data.security.group;\n if (error) {\n history.push(\"/access-management/roles\");\n showSnackbar(error.message);\n }\n }\n });\n\n const [create, createMutation] = useMutation(CREATE_GROUP, {\n refetchQueries: [{ query: LIST_GROUPS }]\n });\n\n const [update, updateMutation] = useMutation(UPDATE_GROUP, {\n refetchQueries: [{ query: LIST_GROUPS }]\n });\n\n const loading = [getQuery, createMutation, updateMutation].find(item => item.loading);\n\n const onSubmit = useCallback(\n async ({ id, name, description, slug, permissions, createdOn }: Group) => {\n if (!permissions || !permissions.length) {\n showSnackbar(t`You must configure permissions before saving!`, {\n timeout: 60000,\n dismissesOnAction: true\n });\n return;\n }\n\n const isUpdate = createdOn;\n const [operation, args] = isUpdate\n ? [\n update,\n {\n variables: {\n id,\n data: {\n name,\n permissions,\n ...(description && { description })\n }\n }\n }\n ]\n : [\n create,\n {\n variables: {\n data: {\n name,\n slug,\n description,\n permissions\n }\n }\n }\n ];\n\n const response = await operation(args);\n\n const { data: group, error } = response.data.security.group;\n if (error) {\n return showSnackbar(error.message);\n }\n\n !isUpdate && history.push(`/access-management/roles?id=${group.id}`);\n showSnackbar(t`Role saved successfully!`);\n },\n [id]\n );\n\n const data: Group = loading ? {} : get(getQuery, \"data.security.group.data\", {});\n\n const systemGroup = data.slug === \"full-access\" || data.system;\n const pluginGroup = data.plugin;\n const canModifyGroup = !systemGroup && !pluginGroup;\n\n const showEmptyView = !newGroup && !loading && isEmpty(data);\n // Render \"No content\" selected view.\n if (showEmptyView) {\n return (\n <EmptyView\n icon={<SettingsIcon />}\n title={t`Click on the left side list to display role details or create a...`}\n action={\n <Button\n icon={<AddIcon />}\n text={t`New Role`}\n data-testid=\"new-record-button\"\n onClick={() => history.push(\"/access-management/roles?new=true\")}\n />\n }\n />\n );\n }\n\n return (\n <Form data={data} onSubmit={onSubmit}>\n {({ data, form, Bind }) => {\n return (\n <SimpleForm size={\"lg\"}>\n {loading && <OverlayLoader />}\n <SimpleFormHeader title={data.name ? data.name : \"Untitled\"} />\n <SimpleFormContent>\n <Grid>\n <>\n {systemGroup && (\n <Grid.Column span={12}>\n <Alert\n type={\"warning\"}\n title={\"Permissions are locked\"}\n >\n This is a protected system role and you can't\n modify its permissions.\n </Alert>\n </Grid.Column>\n )}\n {pluginGroup && (\n <Grid.Column span={12}>\n <Alert\n type={\"warning\"}\n title={\"Permissions are locked\"}\n >\n This role is registered via an extension, and cannot\n be modified.\n </Alert>\n </Grid.Column>\n )}\n <Grid.Column span={6}>\n <Bind\n name=\"name\"\n validators={validation.create(\"required,minLength:3\")}\n >\n <Input\n size={\"lg\"}\n label={t`Name`}\n disabled={!canModifyGroup}\n data-testid=\"admin.am.group.new.name\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={6}>\n <Bind\n name=\"slug\"\n validators={validation.create(\"required,minLength:3\")}\n >\n <Input\n size={\"lg\"}\n disabled={!canModifyGroup || !newGroup}\n label={t`Slug`}\n data-testid=\"admin.am.group.new.slug\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name=\"description\"\n validators={validation.create(\"maxLength:500\")}\n >\n <Textarea\n size={\"lg\"}\n label={t`Description`}\n rows={3}\n disabled={!canModifyGroup}\n data-testid=\"admin.am.group.new.description\"\n />\n </Bind>\n </Grid.Column>\n </>\n </Grid>\n </SimpleFormContent>\n <SimpleFormHeader title={\"Permissions\"} rounded={false}>\n <div className={\"wby-flex wby-justify-end\"}>\n <Tooltip\n content=\"Copy permissions as JSON\"\n trigger={\n <IconButton\n variant={\"ghost\"}\n icon={<CopyIcon />}\n onClick={() => {\n navigator.clipboard.writeText(\n JSON.stringify(data.permissions, null, 2)\n );\n showSnackbar(\"JSON data copied to clipboard.\");\n }}\n />\n }\n />\n </div>\n </SimpleFormHeader>\n <SimpleFormContent>\n <Grid>\n <>\n {canModifyGroup && (\n <Grid.Column span={12}>\n <Bind name={\"permissions\"} defaultValue={[]}>\n {bind => (\n <Permissions id={data.id || \"new\"} {...bind} />\n )}\n </Bind>\n </Grid.Column>\n )}\n </>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>\n {canModifyGroup && (\n <>\n <Button\n variant={\"secondary\"}\n text={t`Cancel`}\n onClick={() => history.push(\"/access-management/roles\")}\n data-testid=\"pb.category.new.form.button.cancel\"\n />\n <Button\n text={t`Save`}\n data-testid=\"admin.am.group.new.save\"\n onClick={ev => {\n form.submit(ev);\n }}\n />\n </>\n )}\n </SimpleFormFooter>\n </SimpleForm>\n );\n }}\n </Form>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,WAAW,EAAEC,QAAQ,QAAQ,qBAAqB;AAC3D,OAAOC,GAAG,MAAM,YAAY;AAC5B,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC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E,KAAA,CAAAiF,aAAA,CAAAjF,KAAA,CAAA0F,QAAA,qBACI1F,KAAA,CAAAiF,aAAA,CAACvD,MAAM;MACH4E,OAAO,EAAE,WAAY;MACrBjB,IAAI,EAAEpD,CAAC,QAAS;MAChBqD,OAAO,EAAEA,CAAA,KAAMjD,OAAO,CAACc,IAAI,CAAC,0BAA0B,CAAE;MACxD,eAAY;IAAoC,CACnD,CAAC,eACFnD,KAAA,CAAAiF,aAAA,CAACvD,MAAM;MACH2D,IAAI,EAAEpD,CAAC,MAAO;MACd,eAAY,yBAAyB;MACrCqD,OAAO,EAAE0B,EAAE,IAAI;QACXzB,IAAI,CAAC0B,MAAM,CAACD,EAAE,CAAC;MACnB;IAAE,CACL,CACH,CAEQ,CACV,CAAC;EAErB,CACE,CAAC;AAEf,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { Group } from "../../../types";
|
|
2
|
+
export interface ListGroupsResponse {
|
|
3
|
+
security: {
|
|
4
|
+
groups: {
|
|
5
|
+
data: Group[];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const LIST_GROUPS: import("graphql").DocumentNode;
|
|
10
|
+
export declare const READ_GROUP: import("graphql").DocumentNode;
|
|
11
|
+
export declare const CREATE_GROUP: import("graphql").DocumentNode;
|
|
12
|
+
export declare const UPDATE_GROUP: import("graphql").DocumentNode;
|
|
13
|
+
export declare const DELETE_GROUP: import("graphql").DocumentNode;
|
|
@@ -1,11 +1,85 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
|
-
|
|
5
1
|
import gql from "graphql-tag";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
const fields = `
|
|
3
|
+
id
|
|
4
|
+
name
|
|
5
|
+
slug
|
|
6
|
+
description
|
|
7
|
+
permissions
|
|
8
|
+
system
|
|
9
|
+
plugin
|
|
10
|
+
createdOn
|
|
11
|
+
`;
|
|
12
|
+
export const LIST_GROUPS = gql`
|
|
13
|
+
query listGroups {
|
|
14
|
+
security {
|
|
15
|
+
groups: listGroups {
|
|
16
|
+
data {
|
|
17
|
+
${fields}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
export const READ_GROUP = gql`
|
|
24
|
+
query getGroup($id: ID!) {
|
|
25
|
+
security {
|
|
26
|
+
group: getGroup(where: { id: $id }){
|
|
27
|
+
data {
|
|
28
|
+
${fields}
|
|
29
|
+
}
|
|
30
|
+
error {
|
|
31
|
+
code
|
|
32
|
+
message
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
export const CREATE_GROUP = gql`
|
|
39
|
+
mutation createGroup($data: SecurityGroupCreateInput!){
|
|
40
|
+
security {
|
|
41
|
+
group: createGroup(data: $data) {
|
|
42
|
+
data {
|
|
43
|
+
${fields}
|
|
44
|
+
}
|
|
45
|
+
error {
|
|
46
|
+
code
|
|
47
|
+
message
|
|
48
|
+
data
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
export const UPDATE_GROUP = gql`
|
|
55
|
+
mutation updateGroup($id: ID!, $data: SecurityGroupUpdateInput!){
|
|
56
|
+
security {
|
|
57
|
+
group: updateGroup(id: $id, data: $data) {
|
|
58
|
+
data {
|
|
59
|
+
${fields}
|
|
60
|
+
}
|
|
61
|
+
error {
|
|
62
|
+
code
|
|
63
|
+
message
|
|
64
|
+
data
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
export const DELETE_GROUP = gql`
|
|
71
|
+
mutation deleteGroup($id: ID!) {
|
|
72
|
+
security {
|
|
73
|
+
deleteGroup(id: $id) {
|
|
74
|
+
data
|
|
75
|
+
error {
|
|
76
|
+
code
|
|
77
|
+
message
|
|
78
|
+
data
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["gql","fields","LIST_GROUPS","READ_GROUP","CREATE_GROUP","UPDATE_GROUP","DELETE_GROUP"],"sources":["graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { Group } from \"~/types\";\n\nconst fields = `\n id\n name\n slug\n description\n permissions\n system\n plugin\n createdOn\n`;\n\nexport interface ListGroupsResponse {\n security: {\n groups: {\n data: Group[];\n };\n };\n}\n\nexport const LIST_GROUPS = gql`\n query listGroups {\n security {\n groups: listGroups {\n data {\n ${fields}\n }\n }\n }\n }\n`;\n\nexport const READ_GROUP = gql`\n query getGroup($id: ID!) {\n security {\n group: getGroup(where: { id: $id }){\n data {\n ${fields}\n }\n error {\n code\n message\n }\n }\n }\n }\n`;\n\nexport const CREATE_GROUP = gql`\n mutation createGroup($data: SecurityGroupCreateInput!){\n security {\n group: createGroup(data: $data) {\n data {\n ${fields}\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\nexport const UPDATE_GROUP = gql`\n mutation updateGroup($id: ID!, $data: SecurityGroupUpdateInput!){\n security {\n group: updateGroup(id: $id, data: $data) {\n data {\n ${fields}\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\nexport const DELETE_GROUP = gql`\n mutation deleteGroup($id: ID!) {\n security {\n deleteGroup(id: $id) {\n data\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,aAAa;AAG7B,MAAMC,MAAM,GAAG;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAUD,OAAO,MAAMC,WAAW,GAAGF,GAAG;AAC9B;AACA;AACA;AACA;AACA,sBAAsBC,MAAM;AAC5B;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAME,UAAU,GAAGH,GAAG;AAC7B;AACA;AACA;AACA;AACA,sBAAsBC,MAAM;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,YAAY,GAAGJ,GAAG;AAC/B;AACA;AACA;AACA;AACA,sBAAsBC,MAAM;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMI,YAAY,GAAGL,GAAG;AAC/B;AACA;AACA;AACA;AACA,sBAAsBC,MAAM;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMK,YAAY,GAAGN,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./Groups";
|
package/ui/views/Groups/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Groups\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { TeamsDataListProps } from "./TeamsDataList";
|
|
3
|
+
import type { TeamsFormProps } from "./TeamsForm";
|
|
4
|
+
export interface TeamsProps {
|
|
5
|
+
listProps?: TeamsDataListProps;
|
|
6
|
+
formProps?: TeamsFormProps;
|
|
7
|
+
}
|
|
8
|
+
export declare const Teams: ({ formProps, listProps }: TeamsProps) => React.JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SplitView, LeftPanel, RightPanel } from "@webiny/app-admin/components/SplitView";
|
|
3
|
+
import { TeamsDataList } from "./TeamsDataList";
|
|
4
|
+
import { TeamsForm } from "./TeamsForm";
|
|
5
|
+
export const Teams = ({
|
|
6
|
+
formProps = {},
|
|
7
|
+
listProps = {}
|
|
8
|
+
}) => {
|
|
9
|
+
return /*#__PURE__*/React.createElement(SplitView, null, /*#__PURE__*/React.createElement(LeftPanel, null, /*#__PURE__*/React.createElement(TeamsDataList, listProps)), /*#__PURE__*/React.createElement(RightPanel, null, /*#__PURE__*/React.createElement(TeamsForm, formProps)));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=Teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","SplitView","LeftPanel","RightPanel","TeamsDataList","TeamsForm","Teams","formProps","listProps","createElement"],"sources":["Teams.tsx"],"sourcesContent":["import React from \"react\";\nimport { SplitView, LeftPanel, RightPanel } from \"@webiny/app-admin/components/SplitView\";\nimport type { TeamsDataListProps } from \"./TeamsDataList\";\nimport { TeamsDataList } from \"./TeamsDataList\";\nimport type { TeamsFormProps } from \"./TeamsForm\";\nimport { TeamsForm } from \"./TeamsForm\";\n\nexport interface TeamsProps {\n listProps?: TeamsDataListProps;\n formProps?: TeamsFormProps;\n}\nexport const Teams = ({ formProps = {}, listProps = {} }: TeamsProps) => {\n return (\n <SplitView>\n <LeftPanel>\n <TeamsDataList {...listProps} />\n </LeftPanel>\n <RightPanel>\n <TeamsForm {...formProps} />\n </RightPanel>\n </SplitView>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,SAAS,EAAEC,UAAU,QAAQ,wCAAwC;AAEzF,SAASC,aAAa;AAEtB,SAASC,SAAS;AAMlB,OAAO,MAAMC,KAAK,GAAGA,CAAC;EAAEC,SAAS,GAAG,CAAC,CAAC;EAAEC,SAAS,GAAG,CAAC;AAAc,CAAC,KAAK;EACrE,oBACIR,KAAA,CAAAS,aAAA,CAACR,SAAS,qBACND,KAAA,CAAAS,aAAA,CAACP,SAAS,qBACNF,KAAA,CAAAS,aAAA,CAACL,aAAa,EAAKI,SAAY,CACxB,CAAC,eACZR,KAAA,CAAAS,aAAA,CAACN,UAAU,qBACPH,KAAA,CAAAS,aAAA,CAACJ,SAAS,EAAKE,SAAY,CACnB,CACL,CAAC;AAEpB,CAAC","ignoreList":[]}
|