@webiny/app-security-access-management 0.0.0-mt-2 → 0.0.0-unstable.5e7233243f
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/components/GroupAutocomplete/graphql.d.ts +1 -1
- package/components/GroupAutocomplete/graphql.js +14 -3
- package/components/GroupAutocomplete/graphql.js.map +1 -0
- package/components/GroupAutocomplete/index.d.ts +5 -2
- package/components/GroupAutocomplete/index.js +25 -10
- package/components/GroupAutocomplete/index.js.map +1 -0
- package/components/NotAuthorizedError/NotAuthorizedError.d.ts +2 -2
- package/components/NotAuthorizedError/NotAuthorizedError.js +39 -18
- package/components/NotAuthorizedError/NotAuthorizedError.js.map +1 -0
- package/components/NotAuthorizedError/index.js +13 -1
- package/components/NotAuthorizedError/index.js.map +1 -0
- package/index.d.ts +8 -1
- package/index.js +80 -4
- package/index.js.map +1 -0
- package/package.json +25 -30
- package/plugins/constants.js +9 -2
- package/plugins/constants.js.map +1 -0
- package/plugins/index.js +20 -8
- package/plugins/index.js.map +1 -0
- package/plugins/installation.js +47 -25
- package/plugins/installation.js.map +1 -0
- package/plugins/permissionRenderer/SecurityPermissions.d.ts +8 -5
- package/plugins/permissionRenderer/SecurityPermissions.js +69 -46
- package/plugins/permissionRenderer/SecurityPermissions.js.map +1 -0
- package/plugins/permissionRenderer/index.js +33 -15
- package/plugins/permissionRenderer/index.js.map +1 -0
- package/plugins/routes.js +37 -19
- package/plugins/routes.js.map +1 -0
- package/plugins/secureRouteError.js +16 -4
- package/plugins/secureRouteError.js.map +1 -0
- package/types.d.ts +15 -0
- package/types.js +5 -0
- package/types.js.map +1 -0
- package/ui/elements/GroupAutocompleteElement.d.ts +2 -1
- package/ui/elements/GroupAutocompleteElement.js +52 -23
- package/ui/elements/GroupAutocompleteElement.js.map +1 -0
- package/ui/views/ApiKeys/ApiKeyForm.d.ts +5 -3
- package/ui/views/ApiKeys/ApiKeyForm.js +127 -83
- package/ui/views/ApiKeys/ApiKeyForm.js.map +1 -0
- package/ui/views/ApiKeys/ApiKeys.d.ts +8 -3
- package/ui/views/ApiKeys/ApiKeys.js +22 -8
- 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 -82
- package/ui/views/ApiKeys/ApiKeysDataList.js.map +1 -0
- package/ui/views/ApiKeys/graphql.d.ts +5 -5
- package/ui/views/ApiKeys/graphql.js +22 -7
- package/ui/views/ApiKeys/graphql.js.map +1 -0
- package/ui/views/ApiKeys/index.d.ts +1 -1
- package/ui/views/ApiKeys/index.js +18 -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 +18 -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 +22 -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 +111 -87
- package/ui/views/Groups/GroupsDataList.js.map +1 -0
- package/ui/views/Groups/GroupsForm.d.ts +5 -3
- package/ui/views/Groups/GroupsForm.js +131 -87
- package/ui/views/Groups/GroupsForm.js.map +1 -0
- package/ui/views/Groups/graphql.d.ts +5 -5
- package/ui/views/Groups/graphql.js +23 -8
- package/ui/views/Groups/graphql.js.map +1 -0
- package/ui/views/Groups/index.d.ts +1 -1
- package/ui/views/Groups/index.js +18 -1
- package/ui/views/Groups/index.js.map +1 -0
- package/ui/views/utils.d.ts +3 -2
- package/ui/views/utils.js +19 -20
- package/ui/views/utils.js.map +1 -0
- package/plugins/menus.d.ts +0 -4
- package/plugins/menus.js +0 -61
|
@@ -1,35 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.GroupsForm = void 0;
|
|
11
|
+
|
|
12
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
13
|
+
|
|
14
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
+
|
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
+
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _reactHooks = require("@apollo/react-hooks");
|
|
23
|
+
|
|
24
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
25
|
+
|
|
26
|
+
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
27
|
+
|
|
28
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
29
|
+
|
|
30
|
+
var _reactRouter = require("@webiny/react-router");
|
|
31
|
+
|
|
32
|
+
var _i18n = require("@webiny/app/i18n");
|
|
33
|
+
|
|
34
|
+
var _form = require("@webiny/form");
|
|
35
|
+
|
|
36
|
+
var _Grid = require("@webiny/ui/Grid");
|
|
37
|
+
|
|
38
|
+
var _Input = require("@webiny/ui/Input");
|
|
39
|
+
|
|
40
|
+
var _Alert = require("@webiny/ui/Alert");
|
|
41
|
+
|
|
42
|
+
var _Button = require("@webiny/ui/Button");
|
|
43
|
+
|
|
44
|
+
var _Progress = require("@webiny/ui/Progress");
|
|
45
|
+
|
|
46
|
+
var _validation = require("@webiny/validation");
|
|
47
|
+
|
|
48
|
+
var _SimpleForm = require("@webiny/app-admin/components/SimpleForm");
|
|
49
|
+
|
|
50
|
+
var _Typography = require("@webiny/ui/Typography");
|
|
51
|
+
|
|
52
|
+
var _Permissions = require("@webiny/app-admin/components/Permissions");
|
|
53
|
+
|
|
54
|
+
var _useSnackbar2 = require("@webiny/app-admin/hooks/useSnackbar");
|
|
55
|
+
|
|
56
|
+
var _graphql = require("./graphql");
|
|
57
|
+
|
|
58
|
+
var _Snackbar = require("@webiny/ui/Snackbar");
|
|
59
|
+
|
|
60
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
61
|
+
|
|
62
|
+
var _EmptyView = _interopRequireDefault(require("@webiny/app-admin/components/EmptyView"));
|
|
63
|
+
|
|
64
|
+
var _add18px = require("@webiny/app-admin/assets/icons/add-18px.svg");
|
|
4
65
|
|
|
5
66
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
6
67
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import styled from "@emotion/styled";
|
|
11
|
-
import pick from "lodash/pick";
|
|
12
|
-
import get from "lodash/get";
|
|
13
|
-
import { useRouter } from "@webiny/react-router";
|
|
14
|
-
import { i18n } from "@webiny/app/i18n";
|
|
15
|
-
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
|
-
import { validation } from "@webiny/validation";
|
|
22
|
-
import { SimpleForm, SimpleFormFooter, SimpleFormContent, SimpleFormHeader } from "@webiny/app-admin/components/SimpleForm";
|
|
23
|
-
import { Typography } from "@webiny/ui/Typography";
|
|
24
|
-
import { Permissions } from "@webiny/app-admin/components/Permissions";
|
|
25
|
-
import { useSnackbar } from "@webiny/app-admin/hooks/useSnackbar";
|
|
26
|
-
import { CREATE_GROUP, LIST_GROUPS, READ_GROUP, UPDATE_GROUP } from "./graphql";
|
|
27
|
-
import { SnackbarAction } from "@webiny/ui/Snackbar";
|
|
28
|
-
import isEmpty from "lodash/isEmpty";
|
|
29
|
-
import EmptyView from "@webiny/app-admin/components/EmptyView";
|
|
30
|
-
import { ReactComponent as AddIcon } from "@svgr/webpack!@webiny/app-admin/assets/icons/add-18px.svg";
|
|
31
|
-
var t = i18n.ns("app-security/admin/groups/form");
|
|
32
|
-
var ButtonWrapper = /*#__PURE__*/styled("div", {
|
|
68
|
+
var t = _i18n.i18n.ns("app-security/admin/groups/form");
|
|
69
|
+
|
|
70
|
+
var ButtonWrapper = /*#__PURE__*/(0, _styled.default)("div", {
|
|
33
71
|
target: "euuiyav0",
|
|
34
72
|
label: "ButtonWrapper"
|
|
35
73
|
})({
|
|
@@ -37,17 +75,17 @@ var ButtonWrapper = /*#__PURE__*/styled("div", {
|
|
|
37
75
|
justifyContent: "space-between"
|
|
38
76
|
});
|
|
39
77
|
|
|
40
|
-
var
|
|
41
|
-
var _useRouter = useRouter(),
|
|
78
|
+
var GroupsForm = function GroupsForm() {
|
|
79
|
+
var _useRouter = (0, _reactRouter.useRouter)(),
|
|
42
80
|
location = _useRouter.location,
|
|
43
81
|
history = _useRouter.history;
|
|
44
82
|
|
|
45
|
-
var _useSnackbar = useSnackbar(),
|
|
83
|
+
var _useSnackbar = (0, _useSnackbar2.useSnackbar)(),
|
|
46
84
|
showSnackbar = _useSnackbar.showSnackbar;
|
|
47
85
|
|
|
48
86
|
var newGroup = new URLSearchParams(location.search).get("new") === "true";
|
|
49
87
|
var id = new URLSearchParams(location.search).get("id");
|
|
50
|
-
var getQuery = useQuery(READ_GROUP, {
|
|
88
|
+
var getQuery = (0, _reactHooks.useQuery)(_graphql.READ_GROUP, {
|
|
51
89
|
variables: {
|
|
52
90
|
id: id
|
|
53
91
|
},
|
|
@@ -66,32 +104,32 @@ var GroupForm = function GroupForm() {
|
|
|
66
104
|
}
|
|
67
105
|
});
|
|
68
106
|
|
|
69
|
-
var _useMutation = useMutation(CREATE_GROUP, {
|
|
107
|
+
var _useMutation = (0, _reactHooks.useMutation)(_graphql.CREATE_GROUP, {
|
|
70
108
|
refetchQueries: [{
|
|
71
|
-
query: LIST_GROUPS
|
|
109
|
+
query: _graphql.LIST_GROUPS
|
|
72
110
|
}]
|
|
73
111
|
}),
|
|
74
|
-
_useMutation2 =
|
|
112
|
+
_useMutation2 = (0, _slicedToArray2.default)(_useMutation, 2),
|
|
75
113
|
create = _useMutation2[0],
|
|
76
114
|
createMutation = _useMutation2[1];
|
|
77
115
|
|
|
78
|
-
var _useMutation3 = useMutation(UPDATE_GROUP, {
|
|
116
|
+
var _useMutation3 = (0, _reactHooks.useMutation)(_graphql.UPDATE_GROUP, {
|
|
79
117
|
refetchQueries: [{
|
|
80
|
-
query: LIST_GROUPS
|
|
118
|
+
query: _graphql.LIST_GROUPS
|
|
81
119
|
}]
|
|
82
120
|
}),
|
|
83
|
-
_useMutation4 =
|
|
121
|
+
_useMutation4 = (0, _slicedToArray2.default)(_useMutation3, 2),
|
|
84
122
|
update = _useMutation4[0],
|
|
85
123
|
updateMutation = _useMutation4[1];
|
|
86
124
|
|
|
87
125
|
var loading = [getQuery, createMutation, updateMutation].find(function (item) {
|
|
88
126
|
return item.loading;
|
|
89
127
|
});
|
|
90
|
-
var onSubmit = useCallback( /*#__PURE__*/function () {
|
|
91
|
-
var _ref =
|
|
128
|
+
var onSubmit = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
129
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(data) {
|
|
92
130
|
var isUpdate, _ref2, _ref3, operation, args, response, _response$data$securi, group, error;
|
|
93
131
|
|
|
94
|
-
return
|
|
132
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
95
133
|
while (1) {
|
|
96
134
|
switch (_context.prev = _context.next) {
|
|
97
135
|
case 0:
|
|
@@ -100,10 +138,10 @@ var GroupForm = function GroupForm() {
|
|
|
100
138
|
break;
|
|
101
139
|
}
|
|
102
140
|
|
|
103
|
-
showSnackbar(t(_templateObject || (_templateObject =
|
|
141
|
+
showSnackbar(t(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["You must configure permissions before saving!"]))), {
|
|
104
142
|
timeout: 60000,
|
|
105
143
|
dismissesOnAction: true,
|
|
106
|
-
action: /*#__PURE__*/
|
|
144
|
+
action: /*#__PURE__*/_react.default.createElement(_Snackbar.SnackbarAction, {
|
|
107
145
|
label: "OK"
|
|
108
146
|
})
|
|
109
147
|
});
|
|
@@ -114,13 +152,13 @@ var GroupForm = function GroupForm() {
|
|
|
114
152
|
_ref2 = isUpdate ? [update, {
|
|
115
153
|
variables: {
|
|
116
154
|
id: data.id,
|
|
117
|
-
data:
|
|
155
|
+
data: (0, _pick.default)(data, ["name", "description", "permissions"])
|
|
118
156
|
}
|
|
119
157
|
}] : [create, {
|
|
120
158
|
variables: {
|
|
121
|
-
data:
|
|
159
|
+
data: (0, _pick.default)(data, ["name", "slug", "description", "permissions"])
|
|
122
160
|
}
|
|
123
|
-
}], _ref3 =
|
|
161
|
+
}], _ref3 = (0, _slicedToArray2.default)(_ref2, 2), operation = _ref3[0], args = _ref3[1];
|
|
124
162
|
_context.next = 7;
|
|
125
163
|
return operation(args);
|
|
126
164
|
|
|
@@ -137,7 +175,7 @@ var GroupForm = function GroupForm() {
|
|
|
137
175
|
|
|
138
176
|
case 11:
|
|
139
177
|
!isUpdate && history.push("/access-management/groups?id=".concat(group.id));
|
|
140
|
-
showSnackbar(t(_templateObject2 || (_templateObject2 =
|
|
178
|
+
showSnackbar(t(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["Group saved successfully!"]))));
|
|
141
179
|
|
|
142
180
|
case 13:
|
|
143
181
|
case "end":
|
|
@@ -151,84 +189,90 @@ var GroupForm = function GroupForm() {
|
|
|
151
189
|
return _ref.apply(this, arguments);
|
|
152
190
|
};
|
|
153
191
|
}(), [id]);
|
|
154
|
-
var data = loading ? {} :
|
|
192
|
+
var data = loading ? {} : (0, _get.default)(getQuery, "data.security.group.data", {});
|
|
155
193
|
var systemGroup = data.slug === "full-access";
|
|
156
|
-
var showEmptyView = !newGroup && !loading &&
|
|
194
|
+
var showEmptyView = !newGroup && !loading && (0, _isEmpty.default)(data); // Render "No content" selected view.
|
|
157
195
|
|
|
158
196
|
if (showEmptyView) {
|
|
159
|
-
return /*#__PURE__*/
|
|
160
|
-
title: t(_templateObject3 || (_templateObject3 =
|
|
161
|
-
action: /*#__PURE__*/
|
|
197
|
+
return /*#__PURE__*/_react.default.createElement(_EmptyView.default, {
|
|
198
|
+
title: t(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["Click on the left side list to display group details or create a..."]))),
|
|
199
|
+
action: /*#__PURE__*/_react.default.createElement(_Button.ButtonDefault, {
|
|
162
200
|
"data-testid": "new-record-button",
|
|
163
201
|
onClick: function onClick() {
|
|
164
202
|
return history.push("/access-management/groups?new=true");
|
|
165
203
|
}
|
|
166
|
-
}, /*#__PURE__*/
|
|
167
|
-
icon: /*#__PURE__*/
|
|
168
|
-
}), t(_templateObject4 || (_templateObject4 =
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.ButtonIcon, {
|
|
205
|
+
icon: /*#__PURE__*/_react.default.createElement(_add18px.ReactComponent, null)
|
|
206
|
+
}), t(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["New Group"]))))
|
|
169
207
|
});
|
|
170
208
|
}
|
|
171
209
|
|
|
172
|
-
return /*#__PURE__*/
|
|
210
|
+
return /*#__PURE__*/_react.default.createElement(_form.Form, {
|
|
173
211
|
data: data,
|
|
174
212
|
onSubmit: onSubmit
|
|
175
213
|
}, function (_ref4) {
|
|
176
214
|
var data = _ref4.data,
|
|
177
215
|
form = _ref4.form,
|
|
178
216
|
Bind = _ref4.Bind;
|
|
179
|
-
return /*#__PURE__*/
|
|
217
|
+
return /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleForm, null, loading && /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, null), /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormHeader, {
|
|
180
218
|
title: data.name ? data.name : "Untitled"
|
|
181
|
-
}), /*#__PURE__*/
|
|
219
|
+
}), /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormContent, null, /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
182
220
|
span: 6
|
|
183
|
-
}, /*#__PURE__*/
|
|
221
|
+
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
184
222
|
name: "name",
|
|
185
|
-
validators: validation.create("required,minLength:3")
|
|
186
|
-
}, /*#__PURE__*/
|
|
187
|
-
label: t(_templateObject5 || (_templateObject5 =
|
|
188
|
-
disabled: systemGroup
|
|
189
|
-
|
|
223
|
+
validators: _validation.validation.create("required,minLength:3")
|
|
224
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
225
|
+
label: t(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["Name"]))),
|
|
226
|
+
disabled: systemGroup,
|
|
227
|
+
"data-testid": "admin.am.group.new.name"
|
|
228
|
+
}))), /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
190
229
|
span: 6
|
|
191
|
-
}, /*#__PURE__*/
|
|
230
|
+
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
192
231
|
name: "slug",
|
|
193
|
-
validators: validation.create("required,minLength:3")
|
|
194
|
-
}, /*#__PURE__*/
|
|
232
|
+
validators: _validation.validation.create("required,minLength:3")
|
|
233
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
195
234
|
disabled: Boolean(data.id),
|
|
196
|
-
label: t(_templateObject6 || (_templateObject6 =
|
|
197
|
-
|
|
235
|
+
label: t(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["Slug"]))),
|
|
236
|
+
"data-testid": "admin.am.group.new.slug"
|
|
237
|
+
})))), /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
198
238
|
span: 12
|
|
199
|
-
}, /*#__PURE__*/
|
|
239
|
+
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
200
240
|
name: "description",
|
|
201
|
-
validators: validation.create("maxLength:500")
|
|
202
|
-
}, /*#__PURE__*/
|
|
203
|
-
label: t(_templateObject7 || (_templateObject7 =
|
|
241
|
+
validators: _validation.validation.create("maxLength:500")
|
|
242
|
+
}, /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
243
|
+
label: t(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["Description"]))),
|
|
204
244
|
rows: 3,
|
|
205
|
-
disabled: systemGroup
|
|
206
|
-
|
|
245
|
+
disabled: systemGroup,
|
|
246
|
+
"data-testid": "admin.am.group.new.description"
|
|
247
|
+
})))), systemGroup && /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
207
248
|
span: 12
|
|
208
|
-
}, /*#__PURE__*/
|
|
249
|
+
}, /*#__PURE__*/_react.default.createElement(_Alert.Alert, {
|
|
209
250
|
type: "info",
|
|
210
251
|
title: "Permissions are locked"
|
|
211
|
-
}, "This is a protected system group and you can't modify its permissions."))), !systemGroup && /*#__PURE__*/
|
|
252
|
+
}, "This is a protected system group and you can't modify its permissions."))), !systemGroup && /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
212
253
|
span: 12
|
|
213
|
-
}, /*#__PURE__*/
|
|
254
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
|
|
214
255
|
use: "subtitle1"
|
|
215
|
-
}, t(_templateObject8 || (_templateObject8 =
|
|
256
|
+
}, t(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["Permissions"]))))), /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
216
257
|
span: 12
|
|
217
|
-
}, /*#__PURE__*/
|
|
258
|
+
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
218
259
|
name: "permissions",
|
|
219
260
|
defaultValue: []
|
|
220
261
|
}, function (bind) {
|
|
221
|
-
return /*#__PURE__*/
|
|
262
|
+
return /*#__PURE__*/_react.default.createElement(_Permissions.Permissions, Object.assign({
|
|
222
263
|
id: data.id || "new"
|
|
223
264
|
}, bind));
|
|
224
|
-
})))), systemGroup ? null : /*#__PURE__*/
|
|
265
|
+
})))), systemGroup ? null : /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormFooter, null, /*#__PURE__*/_react.default.createElement(ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_Button.ButtonDefault, {
|
|
225
266
|
onClick: function onClick() {
|
|
226
267
|
return history.push("/access-management/groups");
|
|
227
268
|
}
|
|
228
|
-
}, t(_templateObject9 || (_templateObject9 =
|
|
229
|
-
|
|
230
|
-
|
|
269
|
+
}, t(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["Cancel"])))), /*#__PURE__*/_react.default.createElement(_Button.ButtonPrimary, {
|
|
270
|
+
"data-testid": "admin.am.group.new.save",
|
|
271
|
+
onClick: function onClick(ev) {
|
|
272
|
+
form.submit(ev);
|
|
273
|
+
}
|
|
274
|
+
}, t(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["Save group"])))))));
|
|
231
275
|
});
|
|
232
276
|
};
|
|
233
277
|
|
|
234
|
-
|
|
278
|
+
exports.GroupsForm = GroupsForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["t","i18n","ns","ButtonWrapper","styled","display","justifyContent","GroupsForm","useRouter","location","history","useSnackbar","showSnackbar","newGroup","URLSearchParams","search","get","id","getQuery","useQuery","READ_GROUP","variables","skip","onCompleted","data","error","security","group","push","message","useMutation","CREATE_GROUP","refetchQueries","query","LIST_GROUPS","create","createMutation","UPDATE_GROUP","update","updateMutation","loading","find","item","onSubmit","useCallback","permissions","length","timeout","dismissesOnAction","action","isUpdate","createdOn","pick","operation","args","response","systemGroup","slug","showEmptyView","isEmpty","form","Bind","name","validation","Boolean","bind","ev","submit"],"sources":["GroupsForm.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useMutation, useQuery } from \"@apollo/react-hooks\";\nimport styled from \"@emotion/styled\";\nimport pick from \"lodash/pick\";\nimport get from \"lodash/get\";\nimport { useRouter } from \"@webiny/react-router\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { Form } from \"@webiny/form\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Input } from \"@webiny/ui/Input\";\nimport { Alert } from \"@webiny/ui/Alert\";\nimport { ButtonDefault, ButtonIcon, ButtonPrimary } from \"@webiny/ui/Button\";\nimport { CircularProgress } from \"@webiny/ui/Progress\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormFooter,\n SimpleFormContent,\n SimpleFormHeader\n} from \"@webiny/app-admin/components/SimpleForm\";\nimport { Typography } from \"@webiny/ui/Typography\";\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 { SnackbarAction } from \"@webiny/ui/Snackbar\";\nimport isEmpty from \"lodash/isEmpty\";\nimport EmptyView from \"@webiny/app-admin/components/EmptyView\";\nimport { ReactComponent as AddIcon } from \"@webiny/app-admin/assets/icons/add-18px.svg\";\n\nconst t = i18n.ns(\"app-security/admin/groups/form\");\n\nconst ButtonWrapper = styled(\"div\")({\n display: \"flex\",\n justifyContent: \"space-between\"\n});\n\nexport interface GroupsFormProps {\n // TODO @ts-refactor delete and go up the tree and sort it out\n [key: string]: any;\n}\nexport const GroupsForm: React.FC<GroupsFormProps> = () => {\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/groups\");\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 data => {\n if (!data.permissions || !data.permissions.length) {\n showSnackbar(t`You must configure permissions before saving!`, {\n timeout: 60000,\n dismissesOnAction: true,\n action: <SnackbarAction label={\"OK\"} />\n });\n return;\n }\n\n const isUpdate = data.createdOn;\n const [operation, args] = isUpdate\n ? [\n update,\n {\n variables: {\n id: data.id,\n data: pick(data, [\"name\", \"description\", \"permissions\"])\n }\n }\n ]\n : [\n create,\n {\n variables: {\n data: pick(data, [\"name\", \"slug\", \"description\", \"permissions\"])\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/groups?id=${group.id}`);\n showSnackbar(t`Group saved successfully!`);\n },\n [id]\n );\n\n const data = loading ? {} : get(getQuery, \"data.security.group.data\", {});\n\n const systemGroup = data.slug === \"full-access\";\n\n const showEmptyView = !newGroup && !loading && isEmpty(data);\n // Render \"No content\" selected view.\n if (showEmptyView) {\n return (\n <EmptyView\n title={t`Click on the left side list to display group details or create a...`}\n action={\n <ButtonDefault\n data-testid=\"new-record-button\"\n onClick={() => history.push(\"/access-management/groups?new=true\")}\n >\n <ButtonIcon icon={<AddIcon />} />\n {t`New Group`}\n </ButtonDefault>\n }\n />\n );\n }\n\n return (\n <Form data={data} onSubmit={onSubmit}>\n {({ data, form, Bind }) => {\n return (\n <SimpleForm>\n {loading && <CircularProgress />}\n <SimpleFormHeader title={data.name ? data.name : \"Untitled\"} />\n <SimpleFormContent>\n <Grid>\n <Cell span={6}>\n <Bind\n name=\"name\"\n validators={validation.create(\"required,minLength:3\")}\n >\n <Input\n label={t`Name`}\n disabled={systemGroup}\n data-testid=\"admin.am.group.new.name\"\n />\n </Bind>\n </Cell>\n <Cell span={6}>\n <Bind\n name=\"slug\"\n validators={validation.create(\"required,minLength:3\")}\n >\n <Input\n disabled={Boolean(data.id)}\n label={t`Slug`}\n data-testid=\"admin.am.group.new.slug\"\n />\n </Bind>\n </Cell>\n </Grid>\n <Grid>\n <Cell span={12}>\n <Bind\n name=\"description\"\n validators={validation.create(\"maxLength:500\")}\n >\n <Input\n label={t`Description`}\n rows={3}\n disabled={systemGroup}\n data-testid=\"admin.am.group.new.description\"\n />\n </Bind>\n </Cell>\n </Grid>\n {systemGroup && (\n <Grid>\n <Cell span={12}>\n <Alert type={\"info\"} title={\"Permissions are locked\"}>\n This is a protected system group and you can't\n modify its permissions.\n </Alert>\n </Cell>\n </Grid>\n )}\n {!systemGroup && (\n <Grid>\n <Cell span={12}>\n <Typography use={\"subtitle1\"}>{t`Permissions`}</Typography>\n </Cell>\n <Cell span={12}>\n <Bind name={\"permissions\"} defaultValue={[]}>\n {bind => (\n <Permissions id={data.id || \"new\"} {...bind} />\n )}\n </Bind>\n </Cell>\n </Grid>\n )}\n </SimpleFormContent>\n {systemGroup ? null : (\n <SimpleFormFooter>\n <ButtonWrapper>\n <ButtonDefault\n onClick={() => history.push(\"/access-management/groups\")}\n >{t`Cancel`}</ButtonDefault>\n <ButtonPrimary\n data-testid=\"admin.am.group.new.save\"\n onClick={ev => {\n form.submit(ev);\n }}\n >{t`Save group`}</ButtonPrimary>\n </ButtonWrapper>\n </SimpleFormFooter>\n )}\n </SimpleForm>\n );\n }}\n </Form>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,CAAC,GAAGC,UAAA,CAAKC,EAAL,CAAQ,gCAAR,CAAV;;AAEA,IAAMC,aAAa,oBAAGC,eAAH,EAAU,KAAV;EAAA;EAAA;AAAA,GAAiB;EAChCC,OAAO,EAAE,MADuB;EAEhCC,cAAc,EAAE;AAFgB,CAAjB,CAAnB;;AASO,IAAMC,UAAqC,GAAG,SAAxCA,UAAwC,GAAM;EACvD,iBAA8B,IAAAC,sBAAA,GAA9B;EAAA,IAAQC,QAAR,cAAQA,QAAR;EAAA,IAAkBC,OAAlB,cAAkBA,OAAlB;;EACA,mBAAyB,IAAAC,yBAAA,GAAzB;EAAA,IAAQC,YAAR,gBAAQA,YAAR;;EACA,IAAMC,QAAQ,GAAG,IAAIC,eAAJ,CAAoBL,QAAQ,CAACM,MAA7B,EAAqCC,GAArC,CAAyC,KAAzC,MAAoD,MAArE;EACA,IAAMC,EAAE,GAAG,IAAIH,eAAJ,CAAoBL,QAAQ,CAACM,MAA7B,EAAqCC,GAArC,CAAyC,IAAzC,CAAX;EAEA,IAAME,QAAQ,GAAG,IAAAC,oBAAA,EAASC,mBAAT,EAAqB;IAClCC,SAAS,EAAE;MAAEJ,EAAE,EAAFA;IAAF,CADuB;IAElCK,IAAI,EAAE,CAACL,EAF2B;IAGlCM,WAAW,EAAE,qBAAAC,IAAI,EAAI;MACjB,IAAI,CAACA,IAAL,E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B;MAEI,OAAO,EAAE,iBAAAkE,EAAE,EAAI;QACXN,IAAI,CAACO,MAAL,CAAYD,EAAZ;MACH;IAJL,GAKElE,CALF,kGAJJ,CADJ,CAvER,CADJ;EAwFH,CA1FL,CADJ;AA8FH,CAjMM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const LIST_GROUPS:
|
|
2
|
-
export declare const READ_GROUP:
|
|
3
|
-
export declare const CREATE_GROUP:
|
|
4
|
-
export declare const UPDATE_GROUP:
|
|
5
|
-
export declare const DELETE_GROUP:
|
|
1
|
+
export declare const LIST_GROUPS: import("graphql").DocumentNode;
|
|
2
|
+
export declare const READ_GROUP: import("graphql").DocumentNode;
|
|
3
|
+
export declare const CREATE_GROUP: import("graphql").DocumentNode;
|
|
4
|
+
export declare const UPDATE_GROUP: import("graphql").DocumentNode;
|
|
5
|
+
export declare const DELETE_GROUP: import("graphql").DocumentNode;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.UPDATE_GROUP = exports.READ_GROUP = exports.LIST_GROUPS = exports.DELETE_GROUP = exports.CREATE_GROUP = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
2
13
|
|
|
3
14
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
15
|
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
var fields = "\n id\n name\n slug\n description\n permissions\n system\n createdOn\n";
|
|
17
|
+
var LIST_GROUPS = (0, _graphqlTag.default)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n query listGroups {\n security {\n groups: listGroups {\n data {\n ", "\n }\n }\n }\n }\n"])), fields);
|
|
18
|
+
exports.LIST_GROUPS = LIST_GROUPS;
|
|
19
|
+
var READ_GROUP = (0, _graphqlTag.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n query getGroup($id: ID!) {\n security {\n group: getGroup(where: { id: $id }){\n data {\n ", "\n }\n error {\n code\n message\n }\n }\n }\n }\n"])), fields);
|
|
20
|
+
exports.READ_GROUP = READ_GROUP;
|
|
21
|
+
var CREATE_GROUP = (0, _graphqlTag.default)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n mutation createGroup($data: SecurityGroupCreateInput!){\n security {\n group: createGroup(data: $data) {\n data {\n ", "\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n"])), fields);
|
|
22
|
+
exports.CREATE_GROUP = CREATE_GROUP;
|
|
23
|
+
var UPDATE_GROUP = (0, _graphqlTag.default)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n mutation updateGroup($id: ID!, $data: SecurityGroupUpdateInput!){\n security {\n group: updateGroup(id: $id, data: $data) {\n data {\n ", "\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n"])), fields);
|
|
24
|
+
exports.UPDATE_GROUP = UPDATE_GROUP;
|
|
25
|
+
var DELETE_GROUP = (0, _graphqlTag.default)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n mutation deleteGroup($id: ID!) {\n security {\n deleteGroup(id: $id) {\n data\n error {\n code\n message\n }\n }\n }\n }\n"])));
|
|
26
|
+
exports.DELETE_GROUP = DELETE_GROUP;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fields","LIST_GROUPS","gql","READ_GROUP","CREATE_GROUP","UPDATE_GROUP","DELETE_GROUP"],"sources":["graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\n\nconst fields = `\n id\n name\n slug\n description\n permissions\n system\n createdOn\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 }\n }\n }\n }\n`;\n"],"mappings":";;;;;;;;;;;AAAA;;;;AAEA,IAAMA,MAAM,gGAAZ;AAUO,IAAMC,WAAW,OAAGC,mBAAH,2QAKFF,MALE,CAAjB;;AAYA,IAAMG,UAAU,OAAGD,mBAAH,wYAKDF,MALC,CAAhB;;AAgBA,IAAMI,YAAY,OAAGF,mBAAH,4bAKHF,MALG,CAAlB;;AAiBA,IAAMK,YAAY,OAAGH,mBAAH,+cAKHF,MALG,CAAlB;;AAiBA,IAAMM,YAAY,OAAGJ,mBAAH,gVAAlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./Groups";
|
package/ui/views/Groups/index.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _Groups = require("./Groups");
|
|
8
|
+
|
|
9
|
+
Object.keys(_Groups).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _Groups[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Groups[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Groups\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/ui/views/utils.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const deserializeSorters: (data: string) =>
|
|
1
|
+
declare type SortTypes = "asc" | "desc";
|
|
2
|
+
export declare const deserializeSorters: (data: string) => [string, SortTypes];
|
|
3
|
+
export {};
|
package/ui/views/utils.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
export var serializeSorters = function serializeSorters(data) {
|
|
4
|
-
if (!data) {
|
|
5
|
-
return data;
|
|
6
|
-
}
|
|
1
|
+
"use strict";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
_Object$entries2 = _slicedToArray(_Object$entries, 1),
|
|
10
|
-
_Object$entries2$ = _slicedToArray(_Object$entries2[0], 2),
|
|
11
|
-
key = _Object$entries2$[0],
|
|
12
|
-
value = _Object$entries2$[1];
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.deserializeSorters = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var deserializeSorters = function deserializeSorters(data) {
|
|
17
13
|
if (typeof data !== "string") {
|
|
18
14
|
return data;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
var _ref = data.split("
|
|
22
|
-
_ref2 =
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var _ref = data.split("_"),
|
|
18
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
19
|
+
field = _ref2[0],
|
|
20
|
+
orderBy = _ref2[1];
|
|
21
|
+
|
|
22
|
+
var order = String(orderBy).toLowerCase() === "asc" ? "asc" : "desc";
|
|
23
|
+
return [field, order];
|
|
24
|
+
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
};
|
|
26
|
+
exports.deserializeSorters = deserializeSorters;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["deserializeSorters","data","split","field","orderBy","order","String","toLowerCase"],"sources":["utils.ts"],"sourcesContent":["type SortTypes = \"asc\" | \"desc\";\nexport const deserializeSorters = (data: string): [string, SortTypes] => {\n if (typeof data !== \"string\") {\n return data;\n }\n const [field, orderBy] = data.split(\"_\") as [string, SortTypes];\n const order = String(orderBy).toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n return [field, order];\n};\n"],"mappings":";;;;;;;;;;;AACO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,IAAD,EAAuC;EACrE,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IAC1B,OAAOA,IAAP;EACH;;EACD,WAAyBA,IAAI,CAACC,KAAL,CAAW,GAAX,CAAzB;EAAA;EAAA,IAAOC,KAAP;EAAA,IAAcC,OAAd;;EACA,IAAMC,KAAK,GAAGC,MAAM,CAACF,OAAD,CAAN,CAAgBG,WAAhB,OAAkC,KAAlC,GAA0C,KAA1C,GAAkD,MAAhE;EACA,OAAO,CAACJ,KAAD,EAAQE,KAAR,CAAP;AACH,CAPM"}
|
package/plugins/menus.d.ts
DELETED
package/plugins/menus.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { NavigationMenuElement, TAGS } from "@webiny/app-admin/ui/elements/NavigationMenuElement";
|
|
4
|
-
import { Permission } from "./constants";
|
|
5
|
-
import { UIViewPlugin } from "@webiny/app-admin/ui/UIView";
|
|
6
|
-
import { NavigationView } from "@webiny/app-admin/ui/views/NavigationView";
|
|
7
|
-
export default new UIViewPlugin(NavigationView, /*#__PURE__*/function () {
|
|
8
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(view) {
|
|
9
|
-
var _view$getSecurityHook, identity, groups, apiKeys, mainMenu;
|
|
10
|
-
|
|
11
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
-
while (1) {
|
|
13
|
-
switch (_context.prev = _context.next) {
|
|
14
|
-
case 0:
|
|
15
|
-
_context.next = 2;
|
|
16
|
-
return view.isRendered();
|
|
17
|
-
|
|
18
|
-
case 2:
|
|
19
|
-
_view$getSecurityHook = view.getSecurityHook(), identity = _view$getSecurityHook.identity;
|
|
20
|
-
groups = identity.getPermission(Permission.Groups);
|
|
21
|
-
apiKeys = identity.getPermission(Permission.ApiKeys);
|
|
22
|
-
|
|
23
|
-
if (!(!groups && !apiKeys)) {
|
|
24
|
-
_context.next = 7;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return _context.abrupt("return");
|
|
29
|
-
|
|
30
|
-
case 7:
|
|
31
|
-
mainMenu = view.getSettingsMenuElement().addElement(new NavigationMenuElement("accessManagement", {
|
|
32
|
-
label: "Access Management",
|
|
33
|
-
tags: [TAGS.UTILS]
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
if (groups) {
|
|
37
|
-
mainMenu.addElement(new NavigationMenuElement("groups", {
|
|
38
|
-
label: "Groups",
|
|
39
|
-
path: "/access-management/groups"
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (apiKeys) {
|
|
44
|
-
mainMenu.addElement(new NavigationMenuElement("apiKeys", {
|
|
45
|
-
label: "API Keys",
|
|
46
|
-
path: "/access-management/api-keys"
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
case 10:
|
|
51
|
-
case "end":
|
|
52
|
-
return _context.stop();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}, _callee);
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
return function (_x) {
|
|
59
|
-
return _ref.apply(this, arguments);
|
|
60
|
-
};
|
|
61
|
-
}());
|