@webiny/app-security-access-management 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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/Extension.d.ts +2 -0
- package/Extension.js +84 -0
- package/Extension.js.map +1 -0
- package/README.md +7 -111
- package/SecurityPermissions.d.ts +2 -0
- package/SecurityPermissions.js +53 -0
- package/SecurityPermissions.js.map +1 -0
- package/{plugins/constants.d.ts → constants.d.ts} +2 -1
- package/constants.js +9 -0
- package/constants.js.map +1 -0
- package/domain/permissionsSchema.d.ts +20 -0
- package/domain/permissionsSchema.js +34 -0
- package/domain/permissionsSchema.js.map +1 -0
- package/features/permissions/abstractions.d.ts +17 -0
- package/features/permissions/abstractions.js +6 -0
- package/features/permissions/abstractions.js.map +1 -0
- package/features/permissions/feature.d.ts +14 -0
- package/features/permissions/feature.js +7 -0
- package/features/permissions/feature.js.map +1 -0
- package/index.d.ts +1 -9
- package/index.js +1 -80
- package/package.json +24 -37
- package/routes.d.ts +21 -0
- package/routes.js +36 -0
- package/routes.js.map +1 -0
- package/types.d.ts +17 -3
- package/types.js +0 -5
- package/ui/views/ApiKeys/ApiKeyForm.d.ts +5 -3
- package/ui/views/ApiKeys/ApiKeyForm.js +212 -280
- package/ui/views/ApiKeys/ApiKeyForm.js.map +1 -1
- package/ui/views/ApiKeys/ApiKeys.d.ts +1 -7
- package/ui/views/ApiKeys/ApiKeys.js +15 -24
- package/ui/views/ApiKeys/ApiKeys.js.map +1 -1
- package/ui/views/ApiKeys/ApiKeysDataList.d.ts +2 -2
- package/ui/views/ApiKeys/ApiKeysDataList.js +136 -228
- package/ui/views/ApiKeys/ApiKeysDataList.js.map +1 -1
- package/ui/views/ApiKeys/graphql.d.ts +8 -0
- package/ui/views/ApiKeys/graphql.js +83 -25
- package/ui/views/ApiKeys/graphql.js.map +1 -1
- package/ui/views/ApiKeys/index.d.ts +1 -1
- package/ui/views/ApiKeys/index.js +1 -18
- package/ui/views/ApiKeys/utils.d.ts +3 -2
- package/ui/views/ApiKeys/utils.js +15 -18
- package/ui/views/ApiKeys/utils.js.map +1 -1
- package/ui/views/Roles/Roles.d.ts +2 -0
- package/ui/views/Roles/Roles.js +17 -0
- package/ui/views/Roles/Roles.js.map +1 -0
- package/ui/views/Roles/RolesDataList.d.ts +5 -0
- package/ui/views/Roles/RolesDataList.js +141 -0
- package/ui/views/Roles/RolesDataList.js.map +1 -0
- package/ui/views/Roles/RolesForm.d.ts +6 -0
- package/ui/views/Roles/RolesForm.js +213 -0
- package/ui/views/Roles/RolesForm.js.map +1 -0
- package/ui/views/Roles/graphql.d.ts +13 -0
- package/ui/views/Roles/graphql.js +86 -0
- package/ui/views/Roles/graphql.js.map +1 -0
- package/ui/views/Roles/index.d.ts +1 -0
- package/ui/views/Roles/index.js +1 -0
- package/ui/views/Teams/Teams.d.ts +2 -0
- package/ui/views/Teams/Teams.js +17 -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 +141 -0
- package/ui/views/Teams/TeamsDataList.js.map +1 -0
- package/ui/views/Teams/TeamsForm.d.ts +6 -0
- package/ui/views/Teams/TeamsForm.js +191 -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 +90 -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 +1 -0
- package/ui/views/utils.d.ts +1 -1
- package/ui/views/utils.js +10 -24
- package/ui/views/utils.js.map +1 -1
- package/components/GroupAutocomplete/graphql.d.ts +0 -1
- package/components/GroupAutocomplete/graphql.js +0 -17
- package/components/GroupAutocomplete/graphql.js.map +0 -1
- package/components/GroupAutocomplete/index.d.ts +0 -5
- package/components/GroupAutocomplete/index.js +0 -31
- package/components/GroupAutocomplete/index.js.map +0 -1
- package/components/NotAuthorizedError/NotAuthorizedError.d.ts +0 -2
- package/components/NotAuthorizedError/NotAuthorizedError.js +0 -71
- package/components/NotAuthorizedError/NotAuthorizedError.js.map +0 -1
- package/components/NotAuthorizedError/SecureRouteError.svg +0 -1
- package/components/NotAuthorizedError/index.d.ts +0 -1
- package/components/NotAuthorizedError/index.js +0 -13
- package/components/NotAuthorizedError/index.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/constants.js +0 -13
- package/plugins/constants.js.map +0 -1
- package/plugins/index.d.ts +0 -3
- package/plugins/index.js +0 -20
- package/plugins/index.js.map +0 -1
- package/plugins/installation.d.ts +0 -3
- package/plugins/installation.js +0 -121
- package/plugins/installation.js.map +0 -1
- package/plugins/permissionRenderer/SecurityPermissions.d.ts +0 -8
- package/plugins/permissionRenderer/SecurityPermissions.js +0 -199
- package/plugins/permissionRenderer/SecurityPermissions.js.map +0 -1
- package/plugins/permissionRenderer/index.d.ts +0 -3
- package/plugins/permissionRenderer/index.js +0 -39
- package/plugins/permissionRenderer/index.js.map +0 -1
- package/plugins/routes.d.ts +0 -3
- package/plugins/routes.js +0 -56
- package/plugins/routes.js.map +0 -1
- package/plugins/secureRouteError.d.ts +0 -7
- package/plugins/secureRouteError.js +0 -22
- package/plugins/secureRouteError.js.map +0 -1
- package/types.js.map +0 -1
- package/ui/elements/GroupAutocompleteElement.d.ts +0 -6
- package/ui/elements/GroupAutocompleteElement.js +0 -64
- package/ui/elements/GroupAutocompleteElement.js.map +0 -1
- package/ui/views/ApiKeys/index.js.map +0 -1
- package/ui/views/Groups/Groups.d.ts +0 -8
- package/ui/views/Groups/Groups.js +0 -26
- package/ui/views/Groups/Groups.js.map +0 -1
- package/ui/views/Groups/GroupsDataList.d.ts +0 -5
- package/ui/views/Groups/GroupsDataList.js +0 -239
- package/ui/views/Groups/GroupsDataList.js.map +0 -1
- package/ui/views/Groups/GroupsForm.d.ts +0 -5
- package/ui/views/Groups/GroupsForm.js +0 -278
- package/ui/views/Groups/GroupsForm.js.map +0 -1
- package/ui/views/Groups/graphql.d.ts +0 -5
- package/ui/views/Groups/graphql.js +0 -26
- package/ui/views/Groups/graphql.js.map +0 -1
- package/ui/views/Groups/index.d.ts +0 -1
- package/ui/views/Groups/index.js +0 -18
- package/ui/views/Groups/index.js.map +0 -1
package/routes.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Route } from "@webiny/app-admin";
|
|
2
|
+
const Routes = {
|
|
3
|
+
Roles: {
|
|
4
|
+
List: new Route({
|
|
5
|
+
name: "Security/Roles/List",
|
|
6
|
+
path: "/access-management/roles",
|
|
7
|
+
params: (z)=>({
|
|
8
|
+
id: z.string().optional(),
|
|
9
|
+
new: z.boolean().optional()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
},
|
|
13
|
+
Teams: {
|
|
14
|
+
List: new Route({
|
|
15
|
+
name: "Security/Teams/List",
|
|
16
|
+
path: "/access-management/teams",
|
|
17
|
+
params: (z)=>({
|
|
18
|
+
id: z.string().optional(),
|
|
19
|
+
new: z.boolean().optional()
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
ApiKeys: {
|
|
24
|
+
List: new Route({
|
|
25
|
+
name: "Security/ApiKeys/List",
|
|
26
|
+
path: "/access-management/api-keys",
|
|
27
|
+
params: (z)=>({
|
|
28
|
+
id: z.string().optional(),
|
|
29
|
+
new: z.boolean().optional()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export { Routes };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=routes.js.map
|
package/routes.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sources":["../src/routes.ts"],"sourcesContent":["import { Route } from \"@webiny/app-admin\";\n\nexport const Routes = {\n Roles: {\n List: new Route({\n name: \"Security/Roles/List\",\n path: \"/access-management/roles\",\n params: z => {\n return {\n id: z.string().optional(),\n new: z.boolean().optional()\n };\n }\n })\n },\n Teams: {\n List: new Route({\n name: \"Security/Teams/List\",\n path: \"/access-management/teams\",\n params: z => {\n return {\n id: z.string().optional(),\n new: z.boolean().optional()\n };\n }\n })\n },\n ApiKeys: {\n List: new Route({\n name: \"Security/ApiKeys/List\",\n path: \"/access-management/api-keys\",\n params: z => {\n return {\n id: z.string().optional(),\n new: z.boolean().optional()\n };\n }\n })\n }\n};\n"],"names":["Routes","Route","z"],"mappings":";AAEO,MAAMA,SAAS;IAClB,OAAO;QACH,MAAM,IAAIC,MAAM;YACZ,MAAM;YACN,MAAM;YACN,QAAQC,CAAAA,IACG;oBACH,IAAIA,EAAE,MAAM,GAAG,QAAQ;oBACvB,KAAKA,EAAE,OAAO,GAAG,QAAQ;gBAC7B;QAER;IACJ;IACA,OAAO;QACH,MAAM,IAAID,MAAM;YACZ,MAAM;YACN,MAAM;YACN,QAAQC,CAAAA,IACG;oBACH,IAAIA,EAAE,MAAM,GAAG,QAAQ;oBACvB,KAAKA,EAAE,OAAO,GAAG,QAAQ;gBAC7B;QAER;IACJ;IACA,SAAS;QACL,MAAM,IAAID,MAAM;YACZ,MAAM;YACN,MAAM;YACN,QAAQC,CAAAA,IACG;oBACH,IAAIA,EAAE,MAAM,GAAG,QAAQ;oBACvB,KAAKA,EAAE,OAAO,GAAG,QAAQ;gBAC7B;QAER;IACJ;AACJ"}
|
package/types.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
1
|
+
import type { Identity } from "@webiny/app-admin/domain/Identity.js";
|
|
2
|
+
export interface Role {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
description: string;
|
|
6
6
|
slug: string;
|
|
7
7
|
system?: boolean;
|
|
8
|
+
plugin: boolean | null;
|
|
9
|
+
permissions: Identity.Permission[];
|
|
10
|
+
createdOn: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Team {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
slug: string;
|
|
17
|
+
system?: boolean;
|
|
18
|
+
plugin: boolean | null;
|
|
19
|
+
createdOn: string;
|
|
8
20
|
}
|
|
9
21
|
export interface ApiKey {
|
|
10
22
|
id: string;
|
|
23
|
+
slug: string;
|
|
11
24
|
token: string;
|
|
12
25
|
name: string;
|
|
13
26
|
description: string;
|
|
14
|
-
permissions:
|
|
27
|
+
permissions: Identity.Permission[];
|
|
28
|
+
createdOn: string;
|
|
15
29
|
}
|
package/types.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface ApiKeyFormProps {
|
|
3
|
+
newEntry: boolean;
|
|
4
|
+
id: string | undefined;
|
|
4
5
|
}
|
|
5
|
-
export declare const ApiKeyForm: React.
|
|
6
|
+
export declare const ApiKeyForm: ({ id, newEntry }: ApiKeyFormProps) => React.JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,288 +1,220 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
67
|
-
|
|
68
|
-
var t = _i18n.i18n.ns("app-security-admin-users/admin/api-keys/form");
|
|
69
|
-
|
|
70
|
-
var ButtonWrapper = /*#__PURE__*/(0, _styled.default)("div", {
|
|
71
|
-
target: "e18bg2x40",
|
|
72
|
-
label: "ButtonWrapper"
|
|
73
|
-
})({
|
|
74
|
-
display: "flex",
|
|
75
|
-
justifyContent: "space-between"
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
var ApiKeyForm = function ApiKeyForm() {
|
|
79
|
-
var _useRouter = (0, _reactRouter.useRouter)(),
|
|
80
|
-
location = _useRouter.location,
|
|
81
|
-
history = _useRouter.history;
|
|
82
|
-
|
|
83
|
-
var _useSnackbar = (0, _useSnackbar2.useSnackbar)(),
|
|
84
|
-
showSnackbar = _useSnackbar.showSnackbar;
|
|
85
|
-
|
|
86
|
-
var newEntry = new URLSearchParams(location.search).get("new") === "true";
|
|
87
|
-
var id = new URLSearchParams(location.search).get("id");
|
|
88
|
-
var getQuery = (0, _reactHooks.useQuery)(GQL.READ_API_KEY, {
|
|
89
|
-
variables: {
|
|
90
|
-
id: id
|
|
91
|
-
},
|
|
92
|
-
skip: !id,
|
|
93
|
-
onCompleted: function onCompleted(data) {
|
|
94
|
-
if (!data) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var error = data.security.apiKey.error;
|
|
99
|
-
|
|
100
|
-
if (error) {
|
|
101
|
-
history.push("/access-management/api-keys");
|
|
102
|
-
showSnackbar(error.message);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
var _useMutation = (0, _reactHooks.useMutation)(GQL.CREATE_API_KEY, {
|
|
108
|
-
refetchQueries: [{
|
|
109
|
-
query: GQL.LIST_API_KEYS
|
|
110
|
-
}]
|
|
111
|
-
}),
|
|
112
|
-
_useMutation2 = (0, _slicedToArray2.default)(_useMutation, 2),
|
|
113
|
-
create = _useMutation2[0],
|
|
114
|
-
createMutation = _useMutation2[1];
|
|
115
|
-
|
|
116
|
-
var _useMutation3 = (0, _reactHooks.useMutation)(GQL.UPDATE_API_KEY, {
|
|
117
|
-
refetchQueries: [{
|
|
118
|
-
query: GQL.LIST_API_KEYS
|
|
119
|
-
}]
|
|
120
|
-
}),
|
|
121
|
-
_useMutation4 = (0, _slicedToArray2.default)(_useMutation3, 2),
|
|
122
|
-
update = _useMutation4[0],
|
|
123
|
-
updateMutation = _useMutation4[1];
|
|
124
|
-
|
|
125
|
-
var loading = [getQuery, createMutation, updateMutation].find(function (item) {
|
|
126
|
-
return item.loading;
|
|
127
|
-
});
|
|
128
|
-
var onSubmit = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
129
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(data) {
|
|
130
|
-
var isUpdate, _ref2, _ref3, operation, args, response, error, id;
|
|
131
|
-
|
|
132
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
133
|
-
while (1) {
|
|
134
|
-
switch (_context.prev = _context.next) {
|
|
135
|
-
case 0:
|
|
136
|
-
if (!(!data.permissions || !data.permissions.length)) {
|
|
137
|
-
_context.next = 3;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
showSnackbar(t(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["You must configure permissions before saving!"]))), {
|
|
142
|
-
timeout: 60000,
|
|
143
|
-
dismissesOnAction: true,
|
|
144
|
-
action: /*#__PURE__*/_react.default.createElement(_Snackbar.SnackbarAction, {
|
|
145
|
-
label: "OK"
|
|
146
|
-
})
|
|
147
|
-
});
|
|
148
|
-
return _context.abrupt("return");
|
|
149
|
-
|
|
150
|
-
case 3:
|
|
151
|
-
isUpdate = data.createdOn;
|
|
152
|
-
_ref2 = isUpdate ? [update, {
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
|
+
import { useMutation, useQuery } from "@apollo/react-hooks";
|
|
3
|
+
import get from "lodash/get.js";
|
|
4
|
+
import isEmpty from "lodash/isEmpty.js";
|
|
5
|
+
import { i18n } from "@webiny/app/i18n/index.js";
|
|
6
|
+
import { Bind as form_Bind, Form, useForm, useGenerateSlug } from "@webiny/form";
|
|
7
|
+
import { EmptyView, Permissions, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, useRouter } from "@webiny/app-admin";
|
|
8
|
+
import { validation } from "@webiny/validation";
|
|
9
|
+
import { ReactComponent } from "@webiny/icons/add.svg";
|
|
10
|
+
import { ReactComponent as content_copy_svg_ReactComponent } from "@webiny/icons/content_copy.svg";
|
|
11
|
+
import { ReactComponent as content_paste_svg_ReactComponent } from "@webiny/icons/content_paste.svg";
|
|
12
|
+
import { ReactComponent as settings_svg_ReactComponent } from "@webiny/icons/settings.svg";
|
|
13
|
+
import { pickDataForCreate, pickDataForUpdate } from "./utils.js";
|
|
14
|
+
import { Alert, Button, CopyButton, Grid, Icon, IconButton, Input, Label, OverlayLoader, Textarea, Tooltip, useToast } from "@webiny/admin-ui";
|
|
15
|
+
import { Routes } from "../../../routes.js";
|
|
16
|
+
import * as __rspack_external__graphql_js_d64db012 from "./graphql.js";
|
|
17
|
+
const t = i18n.ns("app-security-admin-users/admin/api-keys/form");
|
|
18
|
+
const ApiKeyForm = ({ id, newEntry })=>{
|
|
19
|
+
const { goToRoute } = useRouter();
|
|
20
|
+
const toast = useToast();
|
|
21
|
+
const getQuery = useQuery(__rspack_external__graphql_js_d64db012.READ_API_KEY, {
|
|
22
|
+
variables: {
|
|
23
|
+
id
|
|
24
|
+
},
|
|
25
|
+
skip: !id,
|
|
26
|
+
onCompleted: (data)=>{
|
|
27
|
+
if (!data) return;
|
|
28
|
+
const { error } = data.security.apiKey;
|
|
29
|
+
if (error) {
|
|
30
|
+
goToRoute(Routes.ApiKeys.List);
|
|
31
|
+
toast.showWarningToast({
|
|
32
|
+
title: error.message
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const [create, createMutation] = useMutation(__rspack_external__graphql_js_d64db012.CREATE_API_KEY, {
|
|
38
|
+
refetchQueries: [
|
|
39
|
+
{
|
|
40
|
+
query: __rspack_external__graphql_js_d64db012.LIST_API_KEYS
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
const [update, updateMutation] = useMutation(__rspack_external__graphql_js_d64db012.UPDATE_API_KEY, {
|
|
45
|
+
refetchQueries: [
|
|
46
|
+
{
|
|
47
|
+
query: __rspack_external__graphql_js_d64db012.LIST_API_KEYS
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
const loading = [
|
|
52
|
+
getQuery,
|
|
53
|
+
createMutation,
|
|
54
|
+
updateMutation
|
|
55
|
+
].find((item)=>item.loading);
|
|
56
|
+
const onSubmit = useCallback(async (formData)=>{
|
|
57
|
+
if (!formData.permissions || !formData.permissions.length) return void toast.showWarningToast({
|
|
58
|
+
title: t`You must configure permissions before saving!`,
|
|
59
|
+
duration: 1 / 0
|
|
60
|
+
});
|
|
61
|
+
const isUpdate = formData.createdOn;
|
|
62
|
+
const [operation, args] = isUpdate ? [
|
|
63
|
+
update,
|
|
64
|
+
{
|
|
153
65
|
variables: {
|
|
154
|
-
|
|
155
|
-
|
|
66
|
+
id: formData.id,
|
|
67
|
+
data: pickDataForUpdate(formData)
|
|
156
68
|
}
|
|
157
|
-
|
|
69
|
+
}
|
|
70
|
+
] : [
|
|
71
|
+
create,
|
|
72
|
+
{
|
|
158
73
|
variables: {
|
|
159
|
-
|
|
74
|
+
data: pickDataForCreate(formData)
|
|
160
75
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
const response = await operation(args);
|
|
79
|
+
const { error } = response.data.security.apiKey;
|
|
80
|
+
if (error) return void toast.showWarningToast({
|
|
81
|
+
title: error.message
|
|
82
|
+
});
|
|
83
|
+
const { id } = response.data.security.apiKey.data;
|
|
84
|
+
if (!isUpdate) goToRoute(Routes.ApiKeys.List, {
|
|
85
|
+
id
|
|
86
|
+
});
|
|
87
|
+
toast.showSuccessToast({
|
|
88
|
+
title: t`API key saved successfully.`
|
|
89
|
+
});
|
|
90
|
+
}, [
|
|
91
|
+
id
|
|
92
|
+
]);
|
|
93
|
+
const data = get(getQuery, "data.security.apiKey.data", {});
|
|
94
|
+
const showEmptyView = !newEntry && !loading && isEmpty(data);
|
|
95
|
+
if (showEmptyView) return /*#__PURE__*/ react.createElement(EmptyView, {
|
|
96
|
+
icon: /*#__PURE__*/ react.createElement(settings_svg_ReactComponent, null),
|
|
97
|
+
title: t`Click on the left side list to display API key details or create a...`,
|
|
98
|
+
action: /*#__PURE__*/ react.createElement(Button, {
|
|
99
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
100
|
+
text: t`New API Key`,
|
|
101
|
+
"data-testid": "new-record-button",
|
|
102
|
+
onClick: ()=>{
|
|
103
|
+
goToRoute(Routes.ApiKeys.List, {
|
|
104
|
+
new: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
return /*#__PURE__*/ react.createElement(Form, {
|
|
110
|
+
data: data,
|
|
111
|
+
onSubmit: onSubmit
|
|
112
|
+
}, ({ data, form, Bind })=>/*#__PURE__*/ react.createElement(SimpleForm, {
|
|
113
|
+
size: "lg"
|
|
114
|
+
}, loading && /*#__PURE__*/ react.createElement(OverlayLoader, null), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
115
|
+
title: data.name ? data.name : "Untitled"
|
|
116
|
+
}), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(FormContent, {
|
|
117
|
+
newEntry: newEntry
|
|
118
|
+
})), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
119
|
+
title: "Permissions",
|
|
120
|
+
rounded: false
|
|
121
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
122
|
+
className: "flex justify-end"
|
|
123
|
+
}, /*#__PURE__*/ react.createElement(CopyPermissionsToJson, {
|
|
124
|
+
permissions: data.permissions
|
|
125
|
+
}))), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
126
|
+
span: 12
|
|
127
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
128
|
+
name: "permissions",
|
|
129
|
+
defaultValue: []
|
|
130
|
+
}, (bind)=>/*#__PURE__*/ react.createElement(Permissions, {
|
|
131
|
+
id: data.id || "new",
|
|
132
|
+
...bind
|
|
133
|
+
}))))), /*#__PURE__*/ react.createElement(SimpleFormFooter, null, /*#__PURE__*/ react.createElement(Button, {
|
|
134
|
+
variant: "secondary",
|
|
135
|
+
text: t`Cancel`,
|
|
136
|
+
onClick: ()=>{
|
|
137
|
+
goToRoute(Routes.ApiKeys.List);
|
|
138
|
+
},
|
|
139
|
+
"data-testid": "sam.key.new.form.button.cancel"
|
|
140
|
+
}), /*#__PURE__*/ react.createElement(Button, {
|
|
141
|
+
text: t`Save`,
|
|
142
|
+
"data-testid": "sam.key.new.form.button.save",
|
|
143
|
+
onClick: form.submit
|
|
144
|
+
}))));
|
|
145
|
+
};
|
|
146
|
+
const FormContent = (props)=>{
|
|
147
|
+
const { newEntry } = props;
|
|
148
|
+
const form = useForm();
|
|
149
|
+
const toast = useToast();
|
|
150
|
+
const { generateSlug } = useGenerateSlug(form, "name", "slug");
|
|
151
|
+
const data = form.data;
|
|
152
|
+
return /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
153
|
+
span: 6
|
|
154
|
+
}, /*#__PURE__*/ react.createElement(form_Bind, {
|
|
155
|
+
name: "name",
|
|
156
|
+
validators: validation.create("required")
|
|
157
|
+
}, /*#__PURE__*/ react.createElement(Input, {
|
|
158
|
+
label: t`Name`,
|
|
159
|
+
"data-testid": "sam.key.new.form.name",
|
|
160
|
+
onBlur: generateSlug
|
|
161
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
162
|
+
span: 6
|
|
163
|
+
}, /*#__PURE__*/ react.createElement(form_Bind, {
|
|
164
|
+
name: "slug",
|
|
165
|
+
validators: validation.create("required")
|
|
166
|
+
}, /*#__PURE__*/ react.createElement(Input, {
|
|
167
|
+
label: t`Slug`,
|
|
168
|
+
"data-testid": "sam.key.new.form.name",
|
|
169
|
+
disabled: !newEntry
|
|
170
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
171
|
+
span: 12
|
|
172
|
+
}, /*#__PURE__*/ react.createElement(form_Bind, {
|
|
173
|
+
name: "description",
|
|
174
|
+
validators: validation.create("required")
|
|
175
|
+
}, /*#__PURE__*/ react.createElement(Textarea, {
|
|
176
|
+
size: "lg",
|
|
177
|
+
label: t`Description`,
|
|
178
|
+
rows: 4,
|
|
179
|
+
"data-testid": "sam.key.new.form.description"
|
|
180
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
181
|
+
span: 12
|
|
182
|
+
}, /*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement(Label, {
|
|
183
|
+
text: t`Token`
|
|
184
|
+
}), data.token ? /*#__PURE__*/ react.createElement("div", {
|
|
185
|
+
className: "py-sm pl-sm-extra pr-xs rounded-md mt-xs bg-neutral-disabled flex justify-between items-center"
|
|
186
|
+
}, /*#__PURE__*/ react.createElement("div", null, data.token), /*#__PURE__*/ react.createElement(CopyButton, {
|
|
187
|
+
variant: "ghost",
|
|
188
|
+
value: data.token,
|
|
189
|
+
onCopy: ()=>{
|
|
190
|
+
toast.showSuccessToast({
|
|
191
|
+
title: "Successfully copied!"
|
|
192
|
+
});
|
|
203
193
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
194
|
+
})) : /*#__PURE__*/ react.createElement(Alert, {
|
|
195
|
+
className: "mt-xs"
|
|
196
|
+
}, "Your token will be shown once you submit the form."))));
|
|
197
|
+
};
|
|
198
|
+
const CopyPermissionsToJson = ({ permissions })=>{
|
|
199
|
+
const toast = useToast();
|
|
200
|
+
return /*#__PURE__*/ react.createElement(Tooltip, {
|
|
201
|
+
content: "Copy permissions as JSON",
|
|
202
|
+
trigger: /*#__PURE__*/ react.createElement(IconButton, {
|
|
203
|
+
variant: "ghost",
|
|
204
|
+
icon: /*#__PURE__*/ react.createElement(content_copy_svg_ReactComponent, null),
|
|
205
|
+
onClick: ()=>{
|
|
206
|
+
navigator.clipboard.writeText(JSON.stringify(permissions, null, 2));
|
|
207
|
+
toast.showToast({
|
|
208
|
+
title: "JSON data copied to clipboard.",
|
|
209
|
+
icon: /*#__PURE__*/ react.createElement(Icon, {
|
|
210
|
+
icon: /*#__PURE__*/ react.createElement(content_paste_svg_ReactComponent, null),
|
|
211
|
+
label: "Paste"
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
})
|
|
207
216
|
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return /*#__PURE__*/_react.default.createElement(_form.Form, {
|
|
211
|
-
data: data,
|
|
212
|
-
onSubmit: onSubmit
|
|
213
|
-
}, function (_ref4) {
|
|
214
|
-
var data = _ref4.data,
|
|
215
|
-
form = _ref4.form,
|
|
216
|
-
Bind = _ref4.Bind;
|
|
217
|
-
return /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleForm, null, loading && /*#__PURE__*/_react.default.createElement(_Progress.CircularProgress, null), /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormHeader, {
|
|
218
|
-
title: data.name ? data.name : "Untitled"
|
|
219
|
-
}), /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormContent, null, /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
220
|
-
span: 12
|
|
221
|
-
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
222
|
-
name: "name",
|
|
223
|
-
validators: _validation.validation.create("required")
|
|
224
|
-
}, /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
225
|
-
label: t(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["Name"]))),
|
|
226
|
-
"data-testid": "sam.key.new.form.name"
|
|
227
|
-
})))), /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
228
|
-
span: 12
|
|
229
|
-
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
230
|
-
name: "description",
|
|
231
|
-
validators: _validation.validation.create("required")
|
|
232
|
-
}, /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
233
|
-
label: t(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["Description"]))),
|
|
234
|
-
rows: 4,
|
|
235
|
-
"data-testid": "sam.key.new.form.description"
|
|
236
|
-
})))), /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
237
|
-
span: 12
|
|
238
|
-
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
|
|
239
|
-
use: "subtitle1"
|
|
240
|
-
}, t(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["Token"])))), data.token ? /*#__PURE__*/_react.default.createElement("div", {
|
|
241
|
-
style: {
|
|
242
|
-
background: "var(--mdc-theme-background)",
|
|
243
|
-
padding: "8px",
|
|
244
|
-
paddingLeft: "16px"
|
|
245
|
-
}
|
|
246
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
247
|
-
style: {
|
|
248
|
-
lineHeight: "48px",
|
|
249
|
-
verticalAlign: "middle"
|
|
250
|
-
}
|
|
251
|
-
}, data.token), /*#__PURE__*/_react.default.createElement("span", {
|
|
252
|
-
style: {
|
|
253
|
-
position: "absolute",
|
|
254
|
-
right: "32px"
|
|
255
|
-
}
|
|
256
|
-
}, /*#__PURE__*/_react.default.createElement(_Button.CopyButton, {
|
|
257
|
-
value: data.token,
|
|
258
|
-
onCopy: function onCopy() {
|
|
259
|
-
return showSnackbar("Successfully copied!");
|
|
260
|
-
}
|
|
261
|
-
}))) : /*#__PURE__*/_react.default.createElement(_FormElementMessage.FormElementMessage, null, "Your token will be shown once you submit the form.")))), /*#__PURE__*/_react.default.createElement(_Grid.Grid, null, /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
262
|
-
span: 12
|
|
263
|
-
}, /*#__PURE__*/_react.default.createElement(_Typography.Typography, {
|
|
264
|
-
use: "subtitle1"
|
|
265
|
-
}, t(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["Permissions"]))))), /*#__PURE__*/_react.default.createElement(_Grid.Cell, {
|
|
266
|
-
span: 12
|
|
267
|
-
}, /*#__PURE__*/_react.default.createElement(Bind, {
|
|
268
|
-
name: "permissions",
|
|
269
|
-
defaultValue: []
|
|
270
|
-
}, function (bind) {
|
|
271
|
-
return /*#__PURE__*/_react.default.createElement(_Permissions.Permissions, Object.assign({
|
|
272
|
-
id: data.id || "new"
|
|
273
|
-
}, bind));
|
|
274
|
-
})))), /*#__PURE__*/_react.default.createElement(_SimpleForm.SimpleFormFooter, null, /*#__PURE__*/_react.default.createElement(ButtonWrapper, null, /*#__PURE__*/_react.default.createElement(_Button.ButtonDefault, {
|
|
275
|
-
onClick: function onClick() {
|
|
276
|
-
return history.push("/access-management/api-keys");
|
|
277
|
-
},
|
|
278
|
-
"data-testid": "sam.key.new.form.button.cancel"
|
|
279
|
-
}, t(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["Cancel"])))), /*#__PURE__*/_react.default.createElement(_Button.ButtonPrimary, {
|
|
280
|
-
onClick: function onClick(ev) {
|
|
281
|
-
form.submit(ev);
|
|
282
|
-
},
|
|
283
|
-
"data-testid": "sam.key.new.form.button.save"
|
|
284
|
-
}, t(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["Save API key"])))))));
|
|
285
|
-
});
|
|
286
217
|
};
|
|
218
|
+
export { ApiKeyForm };
|
|
287
219
|
|
|
288
|
-
|
|
220
|
+
//# sourceMappingURL=ApiKeyForm.js.map
|