@webiny/app-security-access-management 6.3.0-beta.4 → 6.4.0-beta.0
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.js +74 -73
- package/Extension.js.map +1 -1
- package/SecurityPermissions.js +49 -41
- package/SecurityPermissions.js.map +1 -1
- package/constants.js +6 -5
- package/constants.js.map +1 -1
- package/domain/permissionsSchema.js +30 -19
- package/domain/permissionsSchema.js.map +1 -1
- package/features/permissions/abstractions.js +2 -1
- package/features/permissions/abstractions.js.map +1 -1
- package/features/permissions/feature.js +2 -1
- package/features/permissions/feature.js.map +1 -1
- package/index.js +0 -2
- package/package.json +9 -11
- package/routes.js +32 -37
- package/routes.js.map +1 -1
- package/types.js +0 -3
- package/ui/views/ApiKeys/ApiKeyForm.js +203 -220
- package/ui/views/ApiKeys/ApiKeyForm.js.map +1 -1
- package/ui/views/ApiKeys/ApiKeys.js +11 -12
- package/ui/views/ApiKeys/ApiKeys.js.map +1 -1
- package/ui/views/ApiKeys/ApiKeysDataList.js +129 -143
- package/ui/views/ApiKeys/ApiKeysDataList.js.map +1 -1
- package/ui/views/ApiKeys/graphql.js +7 -6
- package/ui/views/ApiKeys/graphql.js.map +1 -1
- package/ui/views/ApiKeys/index.js +0 -2
- package/ui/views/ApiKeys/utils.js +12 -6
- package/ui/views/ApiKeys/utils.js.map +1 -1
- package/ui/views/Roles/Roles.js +11 -12
- package/ui/views/Roles/Roles.js.map +1 -1
- package/ui/views/Roles/RolesDataList.js +130 -144
- package/ui/views/Roles/RolesDataList.js.map +1 -1
- package/ui/views/Roles/RolesForm.js +198 -223
- package/ui/views/Roles/RolesForm.js.map +1 -1
- package/ui/views/Roles/graphql.js +7 -6
- package/ui/views/Roles/graphql.js.map +1 -1
- package/ui/views/Roles/index.js +0 -2
- package/ui/views/Teams/Teams.js +11 -12
- package/ui/views/Teams/Teams.js.map +1 -1
- package/ui/views/Teams/TeamsDataList.js +130 -146
- package/ui/views/Teams/TeamsDataList.js.map +1 -1
- package/ui/views/Teams/TeamsForm.js +174 -182
- package/ui/views/Teams/TeamsForm.js.map +1 -1
- package/ui/views/Teams/graphql.js +7 -6
- package/ui/views/Teams/graphql.js.map +1 -1
- package/ui/views/Teams/index.js +0 -2
- package/ui/views/utils.js +9 -7
- package/ui/views/utils.js.map +1 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
- package/ui/views/ApiKeys/index.js.map +0 -1
- package/ui/views/Roles/index.js.map +0 -1
- package/ui/views/Teams/index.js.map +0 -1
|
@@ -1,199 +1,191 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
2
|
import { useMutation, useQuery } from "@apollo/react-hooks";
|
|
3
3
|
import pick from "lodash/pick.js";
|
|
4
4
|
import get from "lodash/get.js";
|
|
5
5
|
import { i18n } from "@webiny/app/i18n/index.js";
|
|
6
6
|
import { Bind, Form, useForm, useGenerateSlug } from "@webiny/form";
|
|
7
7
|
import { validation } from "@webiny/validation";
|
|
8
|
-
import {
|
|
8
|
+
import { EmptyView, RolesMultiAutocomplete, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, useRouter, useSnackbar } from "@webiny/app-admin";
|
|
9
9
|
import { CREATE_TEAM, LIST_TEAMS, READ_TEAM, UPDATE_TEAM } from "./graphql.js";
|
|
10
10
|
import isEmpty from "lodash/isEmpty.js";
|
|
11
|
-
import { ReactComponent
|
|
12
|
-
import { ReactComponent as
|
|
11
|
+
import { ReactComponent } from "@webiny/app-admin/assets/icons/add-18px.svg";
|
|
12
|
+
import { ReactComponent as settings_svg_ReactComponent } from "@webiny/icons/settings.svg";
|
|
13
13
|
import { Alert, Button, Grid, Input, OverlayLoader, Textarea } from "@webiny/admin-ui";
|
|
14
|
-
import { RolesMultiAutocomplete } from "@webiny/app-admin";
|
|
15
14
|
import { Routes } from "../../../routes.js";
|
|
16
15
|
const t = i18n.ns("app-security/admin/teams/form");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
onCompleted: data => {
|
|
33
|
-
if (!data) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const {
|
|
37
|
-
error
|
|
38
|
-
} = data.security.team;
|
|
39
|
-
if (error) {
|
|
40
|
-
goToRoute(Routes.Teams.List);
|
|
41
|
-
showSnackbar(error.message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const [create, createMutation] = useMutation(CREATE_TEAM, {
|
|
46
|
-
refetchQueries: [{
|
|
47
|
-
query: LIST_TEAMS
|
|
48
|
-
}]
|
|
49
|
-
});
|
|
50
|
-
const [update, updateMutation] = useMutation(UPDATE_TEAM, {
|
|
51
|
-
refetchQueries: [{
|
|
52
|
-
query: LIST_TEAMS
|
|
53
|
-
}]
|
|
54
|
-
});
|
|
55
|
-
const loading = [getQuery, createMutation, updateMutation].find(item => item.loading);
|
|
56
|
-
const onSubmit = useCallback(async formData => {
|
|
57
|
-
const isUpdate = formData.createdOn;
|
|
58
|
-
const [operation, args] = isUpdate ? [update, {
|
|
59
|
-
variables: {
|
|
60
|
-
id: formData.id,
|
|
61
|
-
data: pick(formData, ["name", "description", "roles"])
|
|
62
|
-
}
|
|
63
|
-
}] : [create, {
|
|
64
|
-
variables: {
|
|
65
|
-
data: pick(formData, ["name", "slug", "description", "roles"])
|
|
66
|
-
}
|
|
67
|
-
}];
|
|
68
|
-
const response = await operation(args);
|
|
69
|
-
const {
|
|
70
|
-
data: team,
|
|
71
|
-
error
|
|
72
|
-
} = response.data.security.team;
|
|
73
|
-
if (error) {
|
|
74
|
-
return showSnackbar(error.message);
|
|
75
|
-
}
|
|
76
|
-
if (!isUpdate) {
|
|
77
|
-
goToRoute(Routes.Teams.List, {
|
|
78
|
-
id: team.id
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
showSnackbar(t`Team saved successfully!`);
|
|
82
|
-
}, [id]);
|
|
83
|
-
const data = loading ? {} : get(getQuery, "data.security.team.data", {});
|
|
84
|
-
const systemTeam = data.system;
|
|
85
|
-
const pluginTeam = data.plugin ?? false;
|
|
86
|
-
const canModifyTeam = !systemTeam && !pluginTeam;
|
|
87
|
-
const showEmptyView = !newEntry && !loading && isEmpty(data);
|
|
88
|
-
// Render "No content" selected view.
|
|
89
|
-
if (showEmptyView) {
|
|
90
|
-
return /*#__PURE__*/React.createElement(EmptyView, {
|
|
91
|
-
icon: /*#__PURE__*/React.createElement(SettingsIcon, null),
|
|
92
|
-
title: t`Click on the left side list to display team details or create a...`,
|
|
93
|
-
action: /*#__PURE__*/React.createElement(Button, {
|
|
94
|
-
text: t`New Team`,
|
|
95
|
-
icon: /*#__PURE__*/React.createElement(AddIcon, null),
|
|
96
|
-
"data-testid": "new-record-button",
|
|
97
|
-
onClick: () => {
|
|
98
|
-
goToRoute(Routes.Teams.List, {
|
|
99
|
-
new: true
|
|
100
|
-
});
|
|
16
|
+
const TeamsForm = ({ newEntry, id })=>{
|
|
17
|
+
const { goToRoute } = useRouter();
|
|
18
|
+
const { showSnackbar } = useSnackbar();
|
|
19
|
+
const getQuery = useQuery(READ_TEAM, {
|
|
20
|
+
variables: {
|
|
21
|
+
id
|
|
22
|
+
},
|
|
23
|
+
skip: !id,
|
|
24
|
+
onCompleted: (data)=>{
|
|
25
|
+
if (!data) return;
|
|
26
|
+
const { error } = data.security.team;
|
|
27
|
+
if (error) {
|
|
28
|
+
goToRoute(Routes.Teams.List);
|
|
29
|
+
showSnackbar(error.message);
|
|
30
|
+
}
|
|
101
31
|
}
|
|
102
|
-
})
|
|
103
32
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
33
|
+
const [create, createMutation] = useMutation(CREATE_TEAM, {
|
|
34
|
+
refetchQueries: [
|
|
35
|
+
{
|
|
36
|
+
query: LIST_TEAMS
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
const [update, updateMutation] = useMutation(UPDATE_TEAM, {
|
|
41
|
+
refetchQueries: [
|
|
42
|
+
{
|
|
43
|
+
query: LIST_TEAMS
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
const loading = [
|
|
48
|
+
getQuery,
|
|
49
|
+
createMutation,
|
|
50
|
+
updateMutation
|
|
51
|
+
].find((item)=>item.loading);
|
|
52
|
+
const onSubmit = useCallback(async (formData)=>{
|
|
53
|
+
const isUpdate = formData.createdOn;
|
|
54
|
+
const [operation, args] = isUpdate ? [
|
|
55
|
+
update,
|
|
56
|
+
{
|
|
57
|
+
variables: {
|
|
58
|
+
id: formData.id,
|
|
59
|
+
data: pick(formData, [
|
|
60
|
+
"name",
|
|
61
|
+
"description",
|
|
62
|
+
"roles"
|
|
63
|
+
])
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
] : [
|
|
67
|
+
create,
|
|
68
|
+
{
|
|
69
|
+
variables: {
|
|
70
|
+
data: pick(formData, [
|
|
71
|
+
"name",
|
|
72
|
+
"slug",
|
|
73
|
+
"description",
|
|
74
|
+
"roles"
|
|
75
|
+
])
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
const response = await operation(args);
|
|
80
|
+
const { data: team, error } = response.data.security.team;
|
|
81
|
+
if (error) return showSnackbar(error.message);
|
|
82
|
+
if (!isUpdate) goToRoute(Routes.Teams.List, {
|
|
83
|
+
id: team.id
|
|
84
|
+
});
|
|
85
|
+
showSnackbar(t`Team saved successfully!`);
|
|
86
|
+
}, [
|
|
87
|
+
id
|
|
88
|
+
]);
|
|
89
|
+
const data = loading ? {} : get(getQuery, "data.security.team.data", {});
|
|
90
|
+
const systemTeam = data.system;
|
|
91
|
+
const pluginTeam = data.plugin ?? false;
|
|
92
|
+
const canModifyTeam = !systemTeam && !pluginTeam;
|
|
93
|
+
const showEmptyView = !newEntry && !loading && isEmpty(data);
|
|
94
|
+
if (showEmptyView) return /*#__PURE__*/ react.createElement(EmptyView, {
|
|
95
|
+
icon: /*#__PURE__*/ react.createElement(settings_svg_ReactComponent, null),
|
|
96
|
+
title: t`Click on the left side list to display team details or create a...`,
|
|
97
|
+
action: /*#__PURE__*/ react.createElement(Button, {
|
|
98
|
+
text: t`New Team`,
|
|
99
|
+
icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
|
|
100
|
+
"data-testid": "new-record-button",
|
|
101
|
+
onClick: ()=>{
|
|
102
|
+
goToRoute(Routes.Teams.List, {
|
|
103
|
+
new: true
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
return /*#__PURE__*/ react.createElement(Form, {
|
|
109
|
+
data: data,
|
|
110
|
+
onSubmit: onSubmit
|
|
111
|
+
}, ({ data, form })=>/*#__PURE__*/ react.createElement(SimpleForm, null, loading && /*#__PURE__*/ react.createElement(OverlayLoader, null), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
112
|
+
title: data.name ? data.name : "Untitled"
|
|
113
|
+
}), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(FormContent, {
|
|
114
|
+
pluginTeam: pluginTeam,
|
|
115
|
+
systemTeam: systemTeam,
|
|
116
|
+
canModifyTeam: canModifyTeam,
|
|
117
|
+
newEntry: newEntry
|
|
118
|
+
})), /*#__PURE__*/ react.createElement(SimpleFormFooter, null, /*#__PURE__*/ react.createElement(Button, {
|
|
119
|
+
variant: "secondary",
|
|
120
|
+
text: t`Cancel`,
|
|
121
|
+
onClick: ()=>{
|
|
122
|
+
goToRoute(Routes.Teams.List);
|
|
123
|
+
}
|
|
124
|
+
}), canModifyTeam && /*#__PURE__*/ react.createElement(Button, {
|
|
125
|
+
text: t`Save`,
|
|
126
|
+
"data-testid": "admin.am.team.new.save",
|
|
127
|
+
onClick: (ev)=>{
|
|
128
|
+
form.submit(ev);
|
|
129
|
+
}
|
|
130
|
+
}))));
|
|
133
131
|
};
|
|
134
|
-
const FormContent = props
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
systemTeam,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
name: "roles",
|
|
191
|
-
validators: validation.create("required")
|
|
192
|
-
}, /*#__PURE__*/React.createElement(RolesMultiAutocomplete, {
|
|
193
|
-
disabled: !canModifyTeam,
|
|
194
|
-
label: t`Roles`,
|
|
195
|
-
"data-testid": "admin.am.team.new.roles"
|
|
196
|
-
}))));
|
|
132
|
+
const FormContent = (props)=>{
|
|
133
|
+
const { newEntry, pluginTeam, systemTeam, canModifyTeam } = props;
|
|
134
|
+
const form = useForm();
|
|
135
|
+
const { generateSlug } = useGenerateSlug(form, "name", "slug");
|
|
136
|
+
return /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(react.Fragment, null, systemTeam && /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
137
|
+
span: 12
|
|
138
|
+
}, /*#__PURE__*/ react.createElement(Alert, {
|
|
139
|
+
type: "info",
|
|
140
|
+
title: "Permissions are locked"
|
|
141
|
+
}, "This is a protected system team and you can't modify its permissions.")), pluginTeam && /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
142
|
+
span: 12
|
|
143
|
+
}, /*#__PURE__*/ react.createElement(Alert, {
|
|
144
|
+
type: "info",
|
|
145
|
+
title: "Important"
|
|
146
|
+
}, "This team is registered via an extension, and cannot be modified."))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
147
|
+
span: 6
|
|
148
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
149
|
+
name: "name",
|
|
150
|
+
validators: validation.create("required,minLength:1")
|
|
151
|
+
}, /*#__PURE__*/ react.createElement(Input, {
|
|
152
|
+
required: true,
|
|
153
|
+
onBlur: generateSlug,
|
|
154
|
+
disabled: !canModifyTeam,
|
|
155
|
+
label: t`Name`,
|
|
156
|
+
"data-testid": "admin.am.team.new.name"
|
|
157
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
158
|
+
span: 6
|
|
159
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
160
|
+
name: "slug",
|
|
161
|
+
validators: validation.create("required,minLength:1")
|
|
162
|
+
}, /*#__PURE__*/ react.createElement(Input, {
|
|
163
|
+
required: true,
|
|
164
|
+
disabled: !canModifyTeam || !newEntry,
|
|
165
|
+
label: t`Slug`,
|
|
166
|
+
"data-testid": "admin.am.team.new.slug"
|
|
167
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
168
|
+
span: 12
|
|
169
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
170
|
+
name: "description",
|
|
171
|
+
validators: validation.create("maxLength:500"),
|
|
172
|
+
defaultValue: ""
|
|
173
|
+
}, /*#__PURE__*/ react.createElement(Textarea, {
|
|
174
|
+
disabled: !canModifyTeam,
|
|
175
|
+
label: t`Description`,
|
|
176
|
+
rows: 3,
|
|
177
|
+
"data-testid": "admin.am.team.new.description"
|
|
178
|
+
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
179
|
+
span: 12
|
|
180
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
181
|
+
name: "roles",
|
|
182
|
+
validators: validation.create("required")
|
|
183
|
+
}, /*#__PURE__*/ react.createElement(RolesMultiAutocomplete, {
|
|
184
|
+
disabled: !canModifyTeam,
|
|
185
|
+
label: t`Roles`,
|
|
186
|
+
"data-testid": "admin.am.team.new.roles"
|
|
187
|
+
}))));
|
|
197
188
|
};
|
|
189
|
+
export { TeamsForm };
|
|
198
190
|
|
|
199
191
|
//# sourceMappingURL=TeamsForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMutation","useQuery","pick","get","i18n","Bind","Form","useForm","useGenerateSlug","validation","SimpleForm","SimpleFormFooter","SimpleFormContent","SimpleFormHeader","EmptyView","useSnackbar","useRouter","CREATE_TEAM","LIST_TEAMS","READ_TEAM","UPDATE_TEAM","isEmpty","ReactComponent","AddIcon","SettingsIcon","Alert","Button","Grid","Input","OverlayLoader","Textarea","RolesMultiAutocomplete","Routes","t","ns","TeamsForm","newEntry","id","goToRoute","showSnackbar","getQuery","variables","skip","onCompleted","data","error","security","team","Teams","List","message","create","createMutation","refetchQueries","query","update","updateMutation","loading","find","item","onSubmit","formData","isUpdate","createdOn","operation","args","response","systemTeam","system","pluginTeam","plugin","canModifyTeam","showEmptyView","createElement","icon","title","action","text","onClick","new","form","name","FormContent","variant","ev","submit","props","generateSlug","Fragment","Column","span","type","validators","required","onBlur","disabled","label","defaultValue","rows"],"sources":["TeamsForm.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useMutation, useQuery } from \"@apollo/react-hooks\";\nimport pick from \"lodash/pick.js\";\nimport get from \"lodash/get.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { Bind, Form, useForm, useGenerateSlug } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormFooter,\n SimpleFormContent,\n SimpleFormHeader,\n EmptyView,\n useSnackbar,\n useRouter\n} from \"@webiny/app-admin\";\nimport { CREATE_TEAM, LIST_TEAMS, READ_TEAM, UPDATE_TEAM } from \"./graphql.js\";\nimport isEmpty from \"lodash/isEmpty.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/app-admin/assets/icons/add-18px.svg\";\nimport type { Team } from \"~/types.js\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { Alert, Button, Grid, Input, OverlayLoader, Textarea } from \"@webiny/admin-ui\";\nimport { RolesMultiAutocomplete } from \"@webiny/app-admin\";\nimport { Routes } from \"~/routes.js\";\n\nconst t = i18n.ns(\"app-security/admin/teams/form\");\n\nexport interface TeamsFormProps {\n newEntry: boolean;\n id: string | undefined;\n}\n\nexport const TeamsForm = ({ newEntry, id }: TeamsFormProps) => {\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n\n const getQuery = useQuery(READ_TEAM, {\n variables: { id },\n skip: !id,\n onCompleted: data => {\n if (!data) {\n return;\n }\n\n const { error } = data.security.team;\n if (error) {\n goToRoute(Routes.Teams.List);\n showSnackbar(error.message);\n }\n }\n });\n\n const [create, createMutation] = useMutation(CREATE_TEAM, {\n refetchQueries: [{ query: LIST_TEAMS }]\n });\n\n const [update, updateMutation] = useMutation(UPDATE_TEAM, {\n refetchQueries: [{ query: LIST_TEAMS }]\n });\n\n const loading = [getQuery, createMutation, updateMutation].find(item => item.loading);\n\n const onSubmit = useCallback(\n async (formData: Team) => {\n const isUpdate = formData.createdOn;\n const [operation, args] = isUpdate\n ? [\n update,\n {\n variables: {\n id: formData.id,\n data: pick(formData, [\"name\", \"description\", \"roles\"])\n }\n }\n ]\n : [\n create,\n {\n variables: {\n data: pick(formData, [\"name\", \"slug\", \"description\", \"roles\"])\n }\n }\n ];\n\n const response = await operation(args);\n\n const { data: team, error } = response.data.security.team;\n if (error) {\n return showSnackbar(error.message);\n }\n\n if (!isUpdate) {\n goToRoute(Routes.Teams.List, { id: team.id });\n }\n showSnackbar(t`Team saved successfully!`);\n },\n [id]\n );\n\n const data = loading ? {} : get(getQuery, \"data.security.team.data\", {});\n\n const systemTeam = data.system;\n const pluginTeam = data.plugin ?? false;\n const canModifyTeam = !systemTeam && !pluginTeam;\n\n const showEmptyView = !newEntry && !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 team details or create a...`}\n action={\n <Button\n text={t`New Team`}\n icon={<AddIcon />}\n data-testid=\"new-record-button\"\n onClick={() => {\n goToRoute(Routes.Teams.List, { new: true });\n }}\n />\n }\n />\n );\n }\n\n return (\n <Form data={data} onSubmit={onSubmit}>\n {({ data, form }) => {\n return (\n <SimpleForm>\n {loading && <OverlayLoader />}\n <SimpleFormHeader title={data.name ? data.name : \"Untitled\"} />\n <SimpleFormContent>\n <FormContent\n pluginTeam={pluginTeam}\n systemTeam={systemTeam}\n canModifyTeam={canModifyTeam}\n newEntry={newEntry}\n />\n </SimpleFormContent>\n <SimpleFormFooter>\n <Button\n variant={\"secondary\"}\n text={t`Cancel`}\n onClick={() => {\n goToRoute(Routes.Teams.List);\n }}\n />\n {canModifyTeam && (\n <Button\n text={t`Save`}\n data-testid=\"admin.am.team.new.save\"\n onClick={ev => {\n form.submit(ev);\n }}\n />\n )}\n </SimpleFormFooter>\n </SimpleForm>\n );\n }}\n </Form>\n );\n};\n\ninterface FormContentProps {\n systemTeam: boolean;\n pluginTeam: boolean;\n canModifyTeam: boolean;\n newEntry: boolean;\n}\n\nconst FormContent = (props: FormContentProps) => {\n const { newEntry, pluginTeam, systemTeam, canModifyTeam } = props;\n\n const form = useForm();\n const { generateSlug } = useGenerateSlug(form, \"name\", \"slug\");\n\n return (\n <Grid>\n <>\n {systemTeam && (\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Permissions are locked\"}>\n This is a protected system team and you can't modify its\n permissions.\n </Alert>\n </Grid.Column>\n )}\n {pluginTeam && (\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Important\"}>\n This team is registered via an extension, and cannot be modified.\n </Alert>\n </Grid.Column>\n )}\n </>\n <Grid.Column span={6}>\n <Bind name=\"name\" validators={validation.create(\"required,minLength:1\")}>\n <Input\n required\n onBlur={generateSlug}\n disabled={!canModifyTeam}\n label={t`Name`}\n data-testid=\"admin.am.team.new.name\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={6}>\n <Bind name=\"slug\" validators={validation.create(\"required,minLength:1\")}>\n <Input\n required\n disabled={!canModifyTeam || !newEntry}\n label={t`Slug`}\n data-testid=\"admin.am.team.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 defaultValue={\"\"}\n >\n <Textarea\n disabled={!canModifyTeam}\n label={t`Description`}\n rows={3}\n data-testid=\"admin.am.team.new.description\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name=\"roles\" validators={validation.create(\"required\")}>\n <RolesMultiAutocomplete\n disabled={!canModifyTeam}\n label={t`Roles`}\n data-testid=\"admin.am.team.new.roles\"\n />\n </Bind>\n </Grid.Column>\n </Grid>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ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/views/Teams/TeamsForm.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { useMutation, useQuery } from \"@apollo/react-hooks\";\nimport pick from \"lodash/pick.js\";\nimport get from \"lodash/get.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { Bind, Form, useForm, useGenerateSlug } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormFooter,\n SimpleFormContent,\n SimpleFormHeader,\n EmptyView,\n useSnackbar,\n useRouter\n} from \"@webiny/app-admin\";\nimport { CREATE_TEAM, LIST_TEAMS, READ_TEAM, UPDATE_TEAM } from \"./graphql.js\";\nimport isEmpty from \"lodash/isEmpty.js\";\nimport { ReactComponent as AddIcon } from \"@webiny/app-admin/assets/icons/add-18px.svg\";\nimport type { Team } from \"~/types.js\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { Alert, Button, Grid, Input, OverlayLoader, Textarea } from \"@webiny/admin-ui\";\nimport { RolesMultiAutocomplete } from \"@webiny/app-admin\";\nimport { Routes } from \"~/routes.js\";\n\nconst t = i18n.ns(\"app-security/admin/teams/form\");\n\nexport interface TeamsFormProps {\n newEntry: boolean;\n id: string | undefined;\n}\n\nexport const TeamsForm = ({ newEntry, id }: TeamsFormProps) => {\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n\n const getQuery = useQuery(READ_TEAM, {\n variables: { id },\n skip: !id,\n onCompleted: data => {\n if (!data) {\n return;\n }\n\n const { error } = data.security.team;\n if (error) {\n goToRoute(Routes.Teams.List);\n showSnackbar(error.message);\n }\n }\n });\n\n const [create, createMutation] = useMutation(CREATE_TEAM, {\n refetchQueries: [{ query: LIST_TEAMS }]\n });\n\n const [update, updateMutation] = useMutation(UPDATE_TEAM, {\n refetchQueries: [{ query: LIST_TEAMS }]\n });\n\n const loading = [getQuery, createMutation, updateMutation].find(item => item.loading);\n\n const onSubmit = useCallback(\n async (formData: Team) => {\n const isUpdate = formData.createdOn;\n const [operation, args] = isUpdate\n ? [\n update,\n {\n variables: {\n id: formData.id,\n data: pick(formData, [\"name\", \"description\", \"roles\"])\n }\n }\n ]\n : [\n create,\n {\n variables: {\n data: pick(formData, [\"name\", \"slug\", \"description\", \"roles\"])\n }\n }\n ];\n\n const response = await operation(args);\n\n const { data: team, error } = response.data.security.team;\n if (error) {\n return showSnackbar(error.message);\n }\n\n if (!isUpdate) {\n goToRoute(Routes.Teams.List, { id: team.id });\n }\n showSnackbar(t`Team saved successfully!`);\n },\n [id]\n );\n\n const data = loading ? {} : get(getQuery, \"data.security.team.data\", {});\n\n const systemTeam = data.system;\n const pluginTeam = data.plugin ?? false;\n const canModifyTeam = !systemTeam && !pluginTeam;\n\n const showEmptyView = !newEntry && !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 team details or create a...`}\n action={\n <Button\n text={t`New Team`}\n icon={<AddIcon />}\n data-testid=\"new-record-button\"\n onClick={() => {\n goToRoute(Routes.Teams.List, { new: true });\n }}\n />\n }\n />\n );\n }\n\n return (\n <Form data={data} onSubmit={onSubmit}>\n {({ data, form }) => {\n return (\n <SimpleForm>\n {loading && <OverlayLoader />}\n <SimpleFormHeader title={data.name ? data.name : \"Untitled\"} />\n <SimpleFormContent>\n <FormContent\n pluginTeam={pluginTeam}\n systemTeam={systemTeam}\n canModifyTeam={canModifyTeam}\n newEntry={newEntry}\n />\n </SimpleFormContent>\n <SimpleFormFooter>\n <Button\n variant={\"secondary\"}\n text={t`Cancel`}\n onClick={() => {\n goToRoute(Routes.Teams.List);\n }}\n />\n {canModifyTeam && (\n <Button\n text={t`Save`}\n data-testid=\"admin.am.team.new.save\"\n onClick={ev => {\n form.submit(ev);\n }}\n />\n )}\n </SimpleFormFooter>\n </SimpleForm>\n );\n }}\n </Form>\n );\n};\n\ninterface FormContentProps {\n systemTeam: boolean;\n pluginTeam: boolean;\n canModifyTeam: boolean;\n newEntry: boolean;\n}\n\nconst FormContent = (props: FormContentProps) => {\n const { newEntry, pluginTeam, systemTeam, canModifyTeam } = props;\n\n const form = useForm();\n const { generateSlug } = useGenerateSlug(form, \"name\", \"slug\");\n\n return (\n <Grid>\n <>\n {systemTeam && (\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Permissions are locked\"}>\n This is a protected system team and you can't modify its\n permissions.\n </Alert>\n </Grid.Column>\n )}\n {pluginTeam && (\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Important\"}>\n This team is registered via an extension, and cannot be modified.\n </Alert>\n </Grid.Column>\n )}\n </>\n <Grid.Column span={6}>\n <Bind name=\"name\" validators={validation.create(\"required,minLength:1\")}>\n <Input\n required\n onBlur={generateSlug}\n disabled={!canModifyTeam}\n label={t`Name`}\n data-testid=\"admin.am.team.new.name\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={6}>\n <Bind name=\"slug\" validators={validation.create(\"required,minLength:1\")}>\n <Input\n required\n disabled={!canModifyTeam || !newEntry}\n label={t`Slug`}\n data-testid=\"admin.am.team.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 defaultValue={\"\"}\n >\n <Textarea\n disabled={!canModifyTeam}\n label={t`Description`}\n rows={3}\n data-testid=\"admin.am.team.new.description\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name=\"roles\" validators={validation.create(\"required\")}>\n <RolesMultiAutocomplete\n disabled={!canModifyTeam}\n label={t`Roles`}\n data-testid=\"admin.am.team.new.roles\"\n />\n </Bind>\n </Grid.Column>\n </Grid>\n );\n};\n"],"names":["t","i18n","TeamsForm","newEntry","id","goToRoute","useRouter","showSnackbar","useSnackbar","getQuery","useQuery","READ_TEAM","data","error","Routes","create","createMutation","useMutation","CREATE_TEAM","LIST_TEAMS","update","updateMutation","UPDATE_TEAM","loading","item","onSubmit","useCallback","formData","isUpdate","operation","args","pick","response","team","get","systemTeam","pluginTeam","canModifyTeam","showEmptyView","isEmpty","EmptyView","SettingsIcon","Button","AddIcon","Form","form","SimpleForm","OverlayLoader","SimpleFormHeader","SimpleFormContent","FormContent","SimpleFormFooter","ev","props","useForm","generateSlug","useGenerateSlug","Grid","Alert","Bind","validation","Input","Textarea","RolesMultiAutocomplete"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAOX,MAAMC,YAAY,CAAC,EAAEC,QAAQ,EAAEC,EAAE,EAAkB;IACtD,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,SAASC,WAAW;QACjC,WAAW;YAAEP;QAAG;QAChB,MAAM,CAACA;QACP,aAAaQ,CAAAA;YACT,IAAI,CAACA,MACD;YAGJ,MAAM,EAAEC,KAAK,EAAE,GAAGD,KAAK,QAAQ,CAAC,IAAI;YACpC,IAAIC,OAAO;gBACPR,UAAUS,OAAO,KAAK,CAAC,IAAI;gBAC3BP,aAAaM,MAAM,OAAO;YAC9B;QACJ;IACJ;IAEA,MAAM,CAACE,QAAQC,eAAe,GAAGC,YAAYC,aAAa;QACtD,gBAAgB;YAAC;gBAAE,OAAOC;YAAW;SAAE;IAC3C;IAEA,MAAM,CAACC,QAAQC,eAAe,GAAGJ,YAAYK,aAAa;QACtD,gBAAgB;YAAC;gBAAE,OAAOH;YAAW;SAAE;IAC3C;IAEA,MAAMI,UAAU;QAACd;QAAUO;QAAgBK;KAAe,CAAC,IAAI,CAACG,CAAAA,OAAQA,KAAK,OAAO;IAEpF,MAAMC,WAAWC,YACb,OAAOC;QACH,MAAMC,WAAWD,SAAS,SAAS;QACnC,MAAM,CAACE,WAAWC,KAAK,GAAGF,WACpB;YACIR;YACA;gBACI,WAAW;oBACP,IAAIO,SAAS,EAAE;oBACf,MAAMI,KAAKJ,UAAU;wBAAC;wBAAQ;wB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AC,MAAM;qBACf,oBAACE,MAAIA;QAAC,MAAK;QAAO,YAAYC,WAAW,MAAM,CAAC;qBAC5C,oBAACC,OAAKA;QACF;QACA,UAAU,CAACxB,iBAAiB,CAAClC;QAC7B,OAAOH,CAAC,CAAC,IAAI,CAAC;QACd,eAAY;wBAIxB,oBAACyD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACE,MAAIA;QACD,MAAK;QACL,YAAYC,WAAW,MAAM,CAAC;QAC9B,cAAc;qBAEd,oBAACE,UAAQA;QACL,UAAU,CAACzB;QACX,OAAOrC,CAAC,CAAC,WAAW,CAAC;QACrB,MAAM;QACN,eAAY;wBAIxB,oBAACyD,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACE,MAAIA;QAAC,MAAK;QAAQ,YAAYC,WAAW,MAAM,CAAC;qBAC7C,oBAACG,wBAAsBA;QACnB,UAAU,CAAC1B;QACX,OAAOrC,CAAC,CAAC,KAAK,CAAC;QACf,eAAY;;AAMpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import graphql_tag from "graphql-tag";
|
|
2
2
|
const fields = `
|
|
3
3
|
id
|
|
4
4
|
name
|
|
@@ -13,7 +13,7 @@ const fields = `
|
|
|
13
13
|
plugin
|
|
14
14
|
createdOn
|
|
15
15
|
`;
|
|
16
|
-
|
|
16
|
+
const LIST_TEAMS = graphql_tag`
|
|
17
17
|
query listTeams {
|
|
18
18
|
security {
|
|
19
19
|
teams: listTeams {
|
|
@@ -24,7 +24,7 @@ export const LIST_TEAMS = gql`
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
`;
|
|
27
|
-
|
|
27
|
+
const READ_TEAM = graphql_tag`
|
|
28
28
|
query getTeam($id: ID!) {
|
|
29
29
|
security {
|
|
30
30
|
team: getTeam(where: { id: $id }){
|
|
@@ -39,7 +39,7 @@ export const READ_TEAM = gql`
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
`;
|
|
42
|
-
|
|
42
|
+
const CREATE_TEAM = graphql_tag`
|
|
43
43
|
mutation createTeam($data: SecurityTeamCreateInput!){
|
|
44
44
|
security {
|
|
45
45
|
team: createTeam(data: $data) {
|
|
@@ -55,7 +55,7 @@ export const CREATE_TEAM = gql`
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
|
-
|
|
58
|
+
const UPDATE_TEAM = graphql_tag`
|
|
59
59
|
mutation updateTeam($id: ID!, $data: SecurityTeamUpdateInput!){
|
|
60
60
|
security {
|
|
61
61
|
team: updateTeam(id: $id, data: $data) {
|
|
@@ -71,7 +71,7 @@ export const UPDATE_TEAM = gql`
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
`;
|
|
74
|
-
|
|
74
|
+
const DELETE_TEAM = graphql_tag`
|
|
75
75
|
mutation deleteTeam($id: ID!) {
|
|
76
76
|
security {
|
|
77
77
|
deleteTeam(id: $id) {
|
|
@@ -85,5 +85,6 @@ export const DELETE_TEAM = gql`
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
`;
|
|
88
|
+
export { CREATE_TEAM, DELETE_TEAM, LIST_TEAMS, READ_TEAM, UPDATE_TEAM };
|
|
88
89
|
|
|
89
90
|
//# sourceMappingURL=graphql.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/views/Teams/graphql.js","sources":["../../../../src/ui/views/Teams/graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { Team } from \"~/types.js\";\n\nconst fields = `\n id\n name\n slug\n description\n roles {\n id\n slug\n name\n }\n system\n plugin\n createdOn\n`;\n\nexport interface ListTeamsResponse {\n security: {\n teams: {\n data: Team[];\n };\n };\n}\n\nexport const LIST_TEAMS = gql`\n query listTeams {\n security {\n teams: listTeams {\n data {\n ${fields}\n }\n }\n }\n }\n`;\n\nexport const READ_TEAM = gql`\n query getTeam($id: ID!) {\n security {\n team: getTeam(where: { id: $id }){\n data {\n ${fields}\n }\n error {\n code\n message\n }\n }\n }\n }\n`;\n\nexport const CREATE_TEAM = gql`\n mutation createTeam($data: SecurityTeamCreateInput!){\n security {\n team: createTeam(data: $data) {\n data {\n ${fields}\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\nexport const UPDATE_TEAM = gql`\n mutation updateTeam($id: ID!, $data: SecurityTeamUpdateInput!){\n security {\n team: updateTeam(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_TEAM = gql`\n mutation deleteTeam($id: ID!) {\n security {\n deleteTeam(id: $id) {\n data\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"names":["fields","LIST_TEAMS","gql","READ_TEAM","CREATE_TEAM","UPDATE_TEAM","DELETE_TEAM"],"mappings":";AAGA,MAAMA,SAAS,CAAC;;;;;;;;;;;;;AAahB,CAAC;AAUM,MAAMC,aAAaC,WAAG,CAAC;;;;;oBAKV,EAAEF,OAAO;;;;;AAK7B,CAAC;AAEM,MAAMG,YAAYD,WAAG,CAAC;;;;;oBAKT,EAAEF,OAAO;;;;;;;;;AAS7B,CAAC;AAEM,MAAMI,cAAcF,WAAG,CAAC;;;;;oBAKX,EAAEF,OAAO;;;;;;;;;;AAU7B,CAAC;AAEM,MAAMK,cAAcH,WAAG,CAAC;;;;;oBAKX,EAAEF,OAAO;;;;;;;;;;AAU7B,CAAC;AAEM,MAAMM,cAAcJ,WAAG,CAAC;;;;;;;;;;;;;AAa/B,CAAC"}
|
package/ui/views/Teams/index.js
CHANGED
package/ui/views/utils.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const deserializeSorters = (data)=>{
|
|
2
|
+
if ("string" != typeof data) return data;
|
|
3
|
+
const [field, orderBy] = data.split("_");
|
|
4
|
+
const order = "asc" === String(orderBy).toLowerCase() ? "asc" : "desc";
|
|
5
|
+
return [
|
|
6
|
+
field,
|
|
7
|
+
order
|
|
8
|
+
];
|
|
8
9
|
};
|
|
10
|
+
export { deserializeSorters };
|
|
9
11
|
|
|
10
12
|
//# sourceMappingURL=utils.js.map
|
package/ui/views/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ui/views/utils.js","sources":["../../../src/ui/views/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"],"names":["deserializeSorters","data","field","orderBy","order","String"],"mappings":"AACO,MAAMA,qBAAqB,CAACC;IAC/B,IAAI,AAAgB,YAAhB,OAAOA,MACP,OAAOA;IAEX,MAAM,CAACC,OAAOC,QAAQ,GAAGF,KAAK,KAAK,CAAC;IACpC,MAAMG,QAAQC,AAAkC,UAAlCA,OAAOF,SAAS,WAAW,KAAe,QAAQ;IAChE,OAAO;QAACD;QAAOE;KAAM;AACzB"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["AccessManagement"],"sources":["index.tsx"],"sourcesContent":["export { AccessManagement } from \"./Extension.js\";\n"],"mappings":"AAAA,SAASA,gBAAgB","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\nexport interface Role {\n id: string;\n name: string;\n description: string;\n slug: string;\n system?: boolean;\n plugin: boolean | null;\n permissions: Identity.Permission[];\n createdOn: string;\n}\n\nexport interface Team {\n id: string;\n name: string;\n description: string;\n slug: string;\n system?: boolean;\n plugin: boolean | null;\n createdOn: string;\n}\n\nexport interface ApiKey {\n id: string;\n slug: string;\n token: string;\n name: string;\n description: string;\n permissions: Identity.Permission[];\n createdOn: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ApiKeys.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Roles.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Teams.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|