@webiny/app-security-access-management 0.0.0-mt-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/components/GroupAutocomplete/graphql.d.ts +1 -0
- package/components/GroupAutocomplete/graphql.js +6 -0
- package/components/GroupAutocomplete/index.d.ts +2 -0
- package/components/GroupAutocomplete/index.js +16 -0
- package/components/NotAuthorizedError/NotAuthorizedError.d.ts +2 -0
- package/components/NotAuthorizedError/NotAuthorizedError.js +50 -0
- package/components/NotAuthorizedError/SecureRouteError.svg +1 -0
- package/components/NotAuthorizedError/index.d.ts +1 -0
- package/components/NotAuthorizedError/index.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +4 -0
- package/package.json +70 -0
- package/plugins/constants.d.ts +4 -0
- package/plugins/constants.js +6 -0
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +8 -0
- package/plugins/installation.d.ts +3 -0
- package/plugins/installation.js +99 -0
- package/plugins/menus.d.ts +4 -0
- package/plugins/menus.js +61 -0
- package/plugins/permissionRenderer/SecurityPermissions.d.ts +5 -0
- package/plugins/permissionRenderer/SecurityPermissions.js +176 -0
- package/plugins/permissionRenderer/index.d.ts +3 -0
- package/plugins/permissionRenderer/index.js +21 -0
- package/plugins/routes.d.ts +3 -0
- package/plugins/routes.js +38 -0
- package/plugins/secureRouteError.d.ts +7 -0
- package/plugins/secureRouteError.js +10 -0
- package/ui/elements/GroupAutocompleteElement.d.ts +5 -0
- package/ui/elements/GroupAutocompleteElement.js +35 -0
- package/ui/views/ApiKeys/ApiKeyForm.d.ts +3 -0
- package/ui/views/ApiKeys/ApiKeyForm.js +244 -0
- package/ui/views/ApiKeys/ApiKeys.d.ts +3 -0
- package/ui/views/ApiKeys/ApiKeys.js +12 -0
- package/ui/views/ApiKeys/ApiKeysDataList.d.ts +3 -0
- package/ui/views/ApiKeys/ApiKeysDataList.js +209 -0
- package/ui/views/ApiKeys/graphql.d.ts +5 -0
- package/ui/views/ApiKeys/graphql.js +11 -0
- package/ui/views/ApiKeys/index.d.ts +1 -0
- package/ui/views/ApiKeys/index.js +1 -0
- package/ui/views/ApiKeys/utils.d.ts +1 -0
- package/ui/views/ApiKeys/utils.js +5 -0
- package/ui/views/Groups/Groups.d.ts +3 -0
- package/ui/views/Groups/Groups.js +12 -0
- package/ui/views/Groups/GroupsDataList.d.ts +3 -0
- package/ui/views/Groups/GroupsDataList.js +215 -0
- package/ui/views/Groups/GroupsForm.d.ts +3 -0
- package/ui/views/Groups/GroupsForm.js +234 -0
- package/ui/views/Groups/graphql.d.ts +5 -0
- package/ui/views/Groups/graphql.js +11 -0
- package/ui/views/Groups/index.d.ts +1 -0
- package/ui/views/Groups/index.js +1 -0
- package/ui/views/utils.d.ts +2 -0
- package/ui/views/utils.js +27 -0
|
@@ -0,0 +1,234 @@
|
|
|
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
|
+
import React, { useCallback } from "react";
|
|
9
|
+
import { useMutation, useQuery } from "@apollo/react-hooks";
|
|
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", {
|
|
33
|
+
target: "euuiyav0",
|
|
34
|
+
label: "ButtonWrapper"
|
|
35
|
+
})({
|
|
36
|
+
display: "flex",
|
|
37
|
+
justifyContent: "space-between"
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var GroupForm = function GroupForm() {
|
|
41
|
+
var _useRouter = useRouter(),
|
|
42
|
+
location = _useRouter.location,
|
|
43
|
+
history = _useRouter.history;
|
|
44
|
+
|
|
45
|
+
var _useSnackbar = useSnackbar(),
|
|
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, {
|
|
51
|
+
variables: {
|
|
52
|
+
id: id
|
|
53
|
+
},
|
|
54
|
+
skip: !id,
|
|
55
|
+
onCompleted: function onCompleted(data) {
|
|
56
|
+
if (!data) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var error = data.security.group.error;
|
|
61
|
+
|
|
62
|
+
if (error) {
|
|
63
|
+
history.push("/access-management/groups");
|
|
64
|
+
showSnackbar(error.message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
var _useMutation = useMutation(CREATE_GROUP, {
|
|
70
|
+
refetchQueries: [{
|
|
71
|
+
query: LIST_GROUPS
|
|
72
|
+
}]
|
|
73
|
+
}),
|
|
74
|
+
_useMutation2 = _slicedToArray(_useMutation, 2),
|
|
75
|
+
create = _useMutation2[0],
|
|
76
|
+
createMutation = _useMutation2[1];
|
|
77
|
+
|
|
78
|
+
var _useMutation3 = useMutation(UPDATE_GROUP, {
|
|
79
|
+
refetchQueries: [{
|
|
80
|
+
query: LIST_GROUPS
|
|
81
|
+
}]
|
|
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
|
+
});
|
|
90
|
+
var onSubmit = useCallback( /*#__PURE__*/function () {
|
|
91
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
|
92
|
+
var isUpdate, _ref2, _ref3, operation, args, response, _response$data$securi, group, error;
|
|
93
|
+
|
|
94
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
95
|
+
while (1) {
|
|
96
|
+
switch (_context.prev = _context.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!(!data.permissions || !data.permissions.length)) {
|
|
99
|
+
_context.next = 3;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
showSnackbar(t(_templateObject || (_templateObject = _taggedTemplateLiteral(["You must configure permissions before saving!"]))), {
|
|
104
|
+
timeout: 60000,
|
|
105
|
+
dismissesOnAction: true,
|
|
106
|
+
action: /*#__PURE__*/React.createElement(SnackbarAction, {
|
|
107
|
+
label: "OK"
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
return _context.abrupt("return");
|
|
111
|
+
|
|
112
|
+
case 3:
|
|
113
|
+
isUpdate = data.createdOn;
|
|
114
|
+
_ref2 = isUpdate ? [update, {
|
|
115
|
+
variables: {
|
|
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
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, _callee);
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
return function (_x) {
|
|
151
|
+
return _ref.apply(this, arguments);
|
|
152
|
+
};
|
|
153
|
+
}(), [id]);
|
|
154
|
+
var data = loading ? {} : get(getQuery, "data.security.group.data", {});
|
|
155
|
+
var systemGroup = data.slug === "full-access";
|
|
156
|
+
var showEmptyView = !newGroup && !loading && isEmpty(data); // Render "No content" selected view.
|
|
157
|
+
|
|
158
|
+
if (showEmptyView) {
|
|
159
|
+
return /*#__PURE__*/React.createElement(EmptyView, {
|
|
160
|
+
title: t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Click on the left side list to display group details or create a..."]))),
|
|
161
|
+
action: /*#__PURE__*/React.createElement(ButtonDefault, {
|
|
162
|
+
"data-testid": "new-record-button",
|
|
163
|
+
onClick: function onClick() {
|
|
164
|
+
return history.push("/access-management/groups?new=true");
|
|
165
|
+
}
|
|
166
|
+
}, /*#__PURE__*/React.createElement(ButtonIcon, {
|
|
167
|
+
icon: /*#__PURE__*/React.createElement(AddIcon, null)
|
|
168
|
+
}), t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["New Group"]))))
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
173
|
+
data: data,
|
|
174
|
+
onSubmit: onSubmit
|
|
175
|
+
}, function (_ref4) {
|
|
176
|
+
var data = _ref4.data,
|
|
177
|
+
form = _ref4.form,
|
|
178
|
+
Bind = _ref4.Bind;
|
|
179
|
+
return /*#__PURE__*/React.createElement(SimpleForm, null, loading && /*#__PURE__*/React.createElement(CircularProgress, null), /*#__PURE__*/React.createElement(SimpleFormHeader, {
|
|
180
|
+
title: data.name ? data.name : "Untitled"
|
|
181
|
+
}), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
182
|
+
span: 6
|
|
183
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
184
|
+
name: "name",
|
|
185
|
+
validators: validation.create("required,minLength:3")
|
|
186
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
187
|
+
label: t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Name"]))),
|
|
188
|
+
disabled: systemGroup
|
|
189
|
+
}))), /*#__PURE__*/React.createElement(Cell, {
|
|
190
|
+
span: 6
|
|
191
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
192
|
+
name: "slug",
|
|
193
|
+
validators: validation.create("required,minLength:3")
|
|
194
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
195
|
+
disabled: Boolean(data.id),
|
|
196
|
+
label: t(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Slug"])))
|
|
197
|
+
})))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
198
|
+
span: 12
|
|
199
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
200
|
+
name: "description",
|
|
201
|
+
validators: validation.create("maxLength:500")
|
|
202
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
203
|
+
label: t(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Description"]))),
|
|
204
|
+
rows: 3,
|
|
205
|
+
disabled: systemGroup
|
|
206
|
+
})))), systemGroup && /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
207
|
+
span: 12
|
|
208
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
209
|
+
type: "info",
|
|
210
|
+
title: "Permissions are locked"
|
|
211
|
+
}, "This is a protected system group and you can't modify its permissions."))), !systemGroup && /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
212
|
+
span: 12
|
|
213
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
214
|
+
use: "subtitle1"
|
|
215
|
+
}, t(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Permissions"]))))), /*#__PURE__*/React.createElement(Cell, {
|
|
216
|
+
span: 12
|
|
217
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
218
|
+
name: "permissions",
|
|
219
|
+
defaultValue: []
|
|
220
|
+
}, function (bind) {
|
|
221
|
+
return /*#__PURE__*/React.createElement(Permissions, Object.assign({
|
|
222
|
+
id: data.id || "new"
|
|
223
|
+
}, bind));
|
|
224
|
+
})))), systemGroup ? null : /*#__PURE__*/React.createElement(SimpleFormFooter, null, /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(ButtonDefault, {
|
|
225
|
+
onClick: function onClick() {
|
|
226
|
+
return history.push("/access-management/groups");
|
|
227
|
+
}
|
|
228
|
+
}, t(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Cancel"])))), /*#__PURE__*/React.createElement(ButtonPrimary, {
|
|
229
|
+
onClick: form.submit
|
|
230
|
+
}, t(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Save group"])))))));
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export default GroupForm;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
|
+
|
|
5
|
+
import gql from "graphql-tag";
|
|
6
|
+
var fields = "\n id\n name\n slug\n description\n permissions\n createdOn\n";
|
|
7
|
+
export var LIST_GROUPS = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n query listGroups {\n security {\n groups: listGroups {\n data {\n id\n slug\n name\n description\n createdOn\n }\n }\n }\n }\n"])));
|
|
8
|
+
export var READ_GROUP = gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\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);
|
|
9
|
+
export var CREATE_GROUP = gql(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\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);
|
|
10
|
+
export var UPDATE_GROUP = gql(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\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);
|
|
11
|
+
export var DELETE_GROUP = gql(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n mutation deleteGroup($id: ID!) {\n security {\n deleteGroup(id: $id) {\n data\n error {\n code\n message\n }\n }\n }\n }\n"])));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Groups } from "./Groups";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Groups } from "./Groups";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
export var serializeSorters = function serializeSorters(data) {
|
|
4
|
+
if (!data) {
|
|
5
|
+
return data;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var _Object$entries = Object.entries(data),
|
|
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];
|
|
13
|
+
|
|
14
|
+
return "".concat(key, ":").concat(value);
|
|
15
|
+
};
|
|
16
|
+
export var deserializeSorters = function deserializeSorters(data) {
|
|
17
|
+
if (typeof data !== "string") {
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var _ref = data.split(":"),
|
|
22
|
+
_ref2 = _slicedToArray(_ref, 2),
|
|
23
|
+
key = _ref2[0],
|
|
24
|
+
value = _ref2[1];
|
|
25
|
+
|
|
26
|
+
return _defineProperty({}, key, value);
|
|
27
|
+
};
|