@bigbinary/neeto-access-control-frontend 0.1.0-beta1 → 1.1.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/README.md +15 -2
- package/app/javascript/src/translations/en.json +32 -2
- package/dist/index.cjs.js +560 -24
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +549 -25
- package/dist/index.js.map +1 -1
- package/package.json +16 -14
package/dist/index.cjs.js
CHANGED
|
@@ -14,17 +14,28 @@ var Form = require('@bigbinary/neetoui/formik/Form');
|
|
|
14
14
|
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
15
15
|
var Radio = require('@bigbinary/neetoui/formik/Radio');
|
|
16
16
|
var reactI18next = require('react-i18next');
|
|
17
|
-
var reactQuery = require('@tanstack/react-query');
|
|
18
17
|
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
19
|
-
var
|
|
18
|
+
var Delete = require('@bigbinary/neeto-icons/Delete');
|
|
19
|
+
var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
|
|
20
|
+
var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
|
|
21
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
22
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
23
|
+
var NoData = require('@bigbinary/neetoui/NoData');
|
|
24
|
+
var Pane = require('@bigbinary/neetoui/Pane');
|
|
25
|
+
var Table = require('@bigbinary/neetoui/Table');
|
|
26
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
20
27
|
var ramda = require('ramda');
|
|
28
|
+
var reactQuery = require('@tanstack/react-query');
|
|
29
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
21
30
|
var axios = require('axios');
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
31
|
+
var Modal = require('@bigbinary/neetoui/Modal');
|
|
32
|
+
var MultiEmailInput = require('@bigbinary/neetoui/formik/MultiEmailInput');
|
|
33
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
25
34
|
var i18next = require('i18next');
|
|
35
|
+
var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
36
|
+
var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
37
|
+
var formik = require('formik');
|
|
26
38
|
var yup = require('yup');
|
|
27
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
28
39
|
var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
|
|
29
40
|
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
30
41
|
|
|
@@ -57,8 +68,20 @@ var ActionBlock__default = /*#__PURE__*/_interopDefaultLegacy(ActionBlock);
|
|
|
57
68
|
var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form);
|
|
58
69
|
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
59
70
|
var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
|
|
60
|
-
var
|
|
71
|
+
var Delete__default = /*#__PURE__*/_interopDefaultLegacy(Delete);
|
|
72
|
+
var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
|
|
73
|
+
var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
|
|
74
|
+
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
61
75
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
76
|
+
var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
|
|
77
|
+
var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
|
|
78
|
+
var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
|
|
79
|
+
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
80
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
81
|
+
var Modal__default = /*#__PURE__*/_interopDefaultLegacy(Modal);
|
|
82
|
+
var MultiEmailInput__default = /*#__PURE__*/_interopDefaultLegacy(MultiEmailInput);
|
|
83
|
+
var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
|
|
84
|
+
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
|
|
62
85
|
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
63
86
|
var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
|
|
64
87
|
var HelpPopover__default = /*#__PURE__*/_interopDefaultLegacy(HelpPopover);
|
|
@@ -104,8 +127,461 @@ function _defineProperty(obj, key, value) {
|
|
|
104
127
|
return obj;
|
|
105
128
|
}
|
|
106
129
|
|
|
130
|
+
function _arrayWithHoles(arr) {
|
|
131
|
+
if (Array.isArray(arr)) return arr;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function _iterableToArrayLimit(r, l) {
|
|
135
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
136
|
+
if (null != t) {
|
|
137
|
+
var e,
|
|
138
|
+
n,
|
|
139
|
+
i,
|
|
140
|
+
u,
|
|
141
|
+
a = [],
|
|
142
|
+
f = !0,
|
|
143
|
+
o = !1;
|
|
144
|
+
try {
|
|
145
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
146
|
+
if (Object(t) !== t) return;
|
|
147
|
+
f = !1;
|
|
148
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
149
|
+
} catch (r) {
|
|
150
|
+
o = !0, n = r;
|
|
151
|
+
} finally {
|
|
152
|
+
try {
|
|
153
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
154
|
+
} finally {
|
|
155
|
+
if (o) throw n;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return a;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function _arrayLikeToArray(arr, len) {
|
|
163
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
164
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
165
|
+
return arr2;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
169
|
+
if (!o) return;
|
|
170
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
171
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
172
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
173
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
174
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function _nonIterableRest() {
|
|
178
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function _slicedToArray(arr, i) {
|
|
182
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
186
|
+
if (source == null) return {};
|
|
187
|
+
var target = {};
|
|
188
|
+
var sourceKeys = Object.keys(source);
|
|
189
|
+
var key, i;
|
|
190
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
191
|
+
key = sourceKeys[i];
|
|
192
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
193
|
+
target[key] = source[key];
|
|
194
|
+
}
|
|
195
|
+
return target;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function _objectWithoutProperties(source, excluded) {
|
|
199
|
+
if (source == null) return {};
|
|
200
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
201
|
+
var key, i;
|
|
202
|
+
if (Object.getOwnPropertySymbols) {
|
|
203
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
204
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
205
|
+
key = sourceSymbolKeys[i];
|
|
206
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
207
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
208
|
+
target[key] = source[key];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return target;
|
|
212
|
+
}
|
|
213
|
+
|
|
107
214
|
var ACCESS_CONTROL_BASE_PATH = "/secure/api/v1";
|
|
108
215
|
|
|
216
|
+
var invitationsPath = "".concat(ACCESS_CONTROL_BASE_PATH, "/configuration/invitations");
|
|
217
|
+
var list = function list(params) {
|
|
218
|
+
return axios__default["default"].get(invitationsPath, {
|
|
219
|
+
params: params
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
var bulkCreate = function bulkCreate(_ref) {
|
|
223
|
+
var configurationId = _ref.configurationId,
|
|
224
|
+
payload = _ref.payload;
|
|
225
|
+
return axios__default["default"].post("".concat(invitationsPath, "/bulk_create"), payload, {
|
|
226
|
+
params: {
|
|
227
|
+
neetoAccessControlConfigurationId: configurationId
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
var bulkDestroy = function bulkDestroy(_ref2) {
|
|
232
|
+
var configurationId = _ref2.configurationId,
|
|
233
|
+
payload = _ref2.payload;
|
|
234
|
+
return axios__default["default"].post("".concat(invitationsPath, "/bulk_destroy"), payload, {
|
|
235
|
+
params: {
|
|
236
|
+
neetoAccessControlConfigurationId: configurationId
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
var invitationsApi = {
|
|
241
|
+
list: list,
|
|
242
|
+
bulkDestroy: bulkDestroy,
|
|
243
|
+
bulkCreate: bulkCreate
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
var QUERY_KEYS = {
|
|
247
|
+
ACCESS_CONTROL_CONFIGURATION: "access-control-configuration",
|
|
248
|
+
ACCESS_CONTROL_CONFIGURATION_INVITATIONS: "access-control-configuration-invitations"
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var _excluded = ["ownerId", "ownerType"];
|
|
252
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
253
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
254
|
+
var ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1 = QUERY_KEYS.ACCESS_CONTROL_CONFIGURATION_INVITATIONS;
|
|
255
|
+
var useListInvitations = function useListInvitations(_ref, options) {
|
|
256
|
+
var ownerId = _ref.ownerId,
|
|
257
|
+
ownerType = _ref.ownerType,
|
|
258
|
+
otherParams = _objectWithoutProperties(_ref, _excluded);
|
|
259
|
+
return reactQuery.useQuery(_objectSpread$3({
|
|
260
|
+
queryKey: [ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId, otherParams],
|
|
261
|
+
queryFn: function queryFn() {
|
|
262
|
+
return invitationsApi.list(otherParams);
|
|
263
|
+
},
|
|
264
|
+
staleTime: constants.DEFAULT_STALE_TIME
|
|
265
|
+
}, options));
|
|
266
|
+
};
|
|
267
|
+
var useBulkCreateInvitations = function useBulkCreateInvitations(_ref2, options) {
|
|
268
|
+
var configurationId = _ref2.configurationId,
|
|
269
|
+
ownerId = _ref2.ownerId,
|
|
270
|
+
ownerType = _ref2.ownerType;
|
|
271
|
+
return reactUtils.useMutationWithInvalidation(function (payload) {
|
|
272
|
+
return invitationsApi.bulkCreate({
|
|
273
|
+
configurationId: configurationId,
|
|
274
|
+
payload: payload
|
|
275
|
+
});
|
|
276
|
+
}, _objectSpread$3({
|
|
277
|
+
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId]]
|
|
278
|
+
}, options));
|
|
279
|
+
};
|
|
280
|
+
var useBulkDestroyInvitations = function useBulkDestroyInvitations(_ref3, options) {
|
|
281
|
+
var configurationId = _ref3.configurationId,
|
|
282
|
+
ownerId = _ref3.ownerId,
|
|
283
|
+
ownerType = _ref3.ownerType;
|
|
284
|
+
return reactUtils.useMutationWithInvalidation(function (payload) {
|
|
285
|
+
return invitationsApi.bulkDestroy({
|
|
286
|
+
configurationId: configurationId,
|
|
287
|
+
payload: payload
|
|
288
|
+
});
|
|
289
|
+
}, _objectSpread$3({
|
|
290
|
+
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId]]
|
|
291
|
+
}, options));
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
var TRUNCATE_LENGTH = 45;
|
|
295
|
+
var ADD_EMAILS_FORM_INIT_VALUES = {
|
|
296
|
+
emails: []
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
var AddEmails = function AddEmails(_ref) {
|
|
300
|
+
var isOpen = _ref.isOpen,
|
|
301
|
+
onClose = _ref.onClose,
|
|
302
|
+
configurationId = _ref.configurationId,
|
|
303
|
+
ownerType = _ref.ownerType,
|
|
304
|
+
ownerId = _ref.ownerId;
|
|
305
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
306
|
+
t = _useTranslation.t;
|
|
307
|
+
var emailsInputRef = react.useRef();
|
|
308
|
+
var _useBulkCreateInvitat = useBulkCreateInvitations({
|
|
309
|
+
configurationId: configurationId,
|
|
310
|
+
ownerType: ownerType,
|
|
311
|
+
ownerId: ownerId
|
|
312
|
+
}),
|
|
313
|
+
addEmails = _useBulkCreateInvitat.mutate;
|
|
314
|
+
var handleAddEmails = function handleAddEmails(_ref2, _ref3) {
|
|
315
|
+
var emails = _ref2.emails;
|
|
316
|
+
var setSubmitting = _ref3.setSubmitting;
|
|
317
|
+
var payload = {
|
|
318
|
+
emails: ramda.pluck("value", emails)
|
|
319
|
+
};
|
|
320
|
+
addEmails(payload, {
|
|
321
|
+
onSuccess: function onSuccess() {
|
|
322
|
+
onClose();
|
|
323
|
+
},
|
|
324
|
+
onError: function onError() {
|
|
325
|
+
return setSubmitting(false);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Modal__default["default"], {
|
|
330
|
+
isOpen: isOpen,
|
|
331
|
+
onClose: onClose,
|
|
332
|
+
initialFocusRef: emailsInputRef,
|
|
333
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Modal__default["default"].Header, {
|
|
334
|
+
description: t("neetoAccessControl.addEmails.description"),
|
|
335
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
336
|
+
style: "h2",
|
|
337
|
+
children: t("neetoAccessControl.buttons.addEmails")
|
|
338
|
+
})
|
|
339
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Form__default["default"], {
|
|
340
|
+
formikProps: {
|
|
341
|
+
initialValues: ADD_EMAILS_FORM_INIT_VALUES,
|
|
342
|
+
onSubmit: handleAddEmails
|
|
343
|
+
},
|
|
344
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Modal__default["default"].Body, {
|
|
345
|
+
children: /*#__PURE__*/jsxRuntime.jsx(MultiEmailInput__default["default"], {
|
|
346
|
+
name: "emails",
|
|
347
|
+
placeholder: t("neetoAccessControl.addEmails.placeholder"),
|
|
348
|
+
ref: emailsInputRef
|
|
349
|
+
})
|
|
350
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Modal__default["default"].Footer, {
|
|
351
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
|
|
352
|
+
cancelButtonProps: {
|
|
353
|
+
onClick: onClose
|
|
354
|
+
},
|
|
355
|
+
submitButtonProps: {
|
|
356
|
+
label: t("neetoAccessControl.buttons.addEmails")
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
})]
|
|
360
|
+
})]
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
var renderColumnData = function renderColumnData(_ref) {
|
|
365
|
+
var onDelete = _ref.onDelete;
|
|
366
|
+
return [{
|
|
367
|
+
title: i18next.t("neetoAccessControl.titles.emails"),
|
|
368
|
+
dataIndex: "email",
|
|
369
|
+
key: "email",
|
|
370
|
+
width: 75,
|
|
371
|
+
render: function render(email, inviteData) {
|
|
372
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
373
|
+
className: "flex items-center justify-between gap-x-3",
|
|
374
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Tooltip__default["default"], {
|
|
375
|
+
content: email,
|
|
376
|
+
disabled: email.length < TRUNCATE_LENGTH,
|
|
377
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
378
|
+
style: "body2",
|
|
379
|
+
children: neetoCist.truncate(email, TRUNCATE_LENGTH)
|
|
380
|
+
})
|
|
381
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
|
|
382
|
+
dropdownProps: {
|
|
383
|
+
strategy: "fixed"
|
|
384
|
+
},
|
|
385
|
+
menuItems: [{
|
|
386
|
+
key: "delete",
|
|
387
|
+
label: i18next.t("neetoAccessControl.labels.delete"),
|
|
388
|
+
onClick: function onClick() {
|
|
389
|
+
return onDelete(inviteData);
|
|
390
|
+
}
|
|
391
|
+
}]
|
|
392
|
+
})]
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}, {
|
|
396
|
+
title: i18next.t("neetoAccessControl.titles.status"),
|
|
397
|
+
dataIndex: "status",
|
|
398
|
+
key: "status",
|
|
399
|
+
width: 75,
|
|
400
|
+
render: function render(status) {
|
|
401
|
+
return neetoCist.humanize(status);
|
|
402
|
+
}
|
|
403
|
+
}];
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
var Invitations = function Invitations(_ref) {
|
|
407
|
+
var _selectedEmails$;
|
|
408
|
+
var invitationsTableColumnData = _ref.invitationsTableColumnData,
|
|
409
|
+
configurationId = _ref.configurationId,
|
|
410
|
+
ownerType = _ref.ownerType,
|
|
411
|
+
ownerId = _ref.ownerId,
|
|
412
|
+
isOpen = _ref.isOpen,
|
|
413
|
+
onClose = _ref.onClose;
|
|
414
|
+
var _useState = react.useState([]),
|
|
415
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
416
|
+
selectedEmails = _useState2[0],
|
|
417
|
+
setSelectedEmails = _useState2[1];
|
|
418
|
+
var _useState3 = react.useState(false),
|
|
419
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
420
|
+
showDeleteAlert = _useState4[0],
|
|
421
|
+
setShowDeleteAlert = _useState4[1];
|
|
422
|
+
var _useState5 = react.useState(false),
|
|
423
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
424
|
+
showAddEmails = _useState6[0],
|
|
425
|
+
setShowAddEmails = _useState6[1];
|
|
426
|
+
var _useState7 = react.useState(constants.DEFAULT_PAGE_INDEX),
|
|
427
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
428
|
+
page = _useState8[0],
|
|
429
|
+
setPage = _useState8[1];
|
|
430
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
431
|
+
t = _useTranslation.t;
|
|
432
|
+
var _useListInvitations = useListInvitations({
|
|
433
|
+
neetoAccessControlConfigurationId: configurationId,
|
|
434
|
+
ownerType: ownerType,
|
|
435
|
+
ownerId: ownerId,
|
|
436
|
+
page: page,
|
|
437
|
+
pageSize: constants.DEFAULT_PAGE_SIZE
|
|
438
|
+
}, {
|
|
439
|
+
enabled: isOpen
|
|
440
|
+
}),
|
|
441
|
+
_useListInvitations$d = _useListInvitations.data,
|
|
442
|
+
_useListInvitations$d2 = _useListInvitations$d === void 0 ? {} : _useListInvitations$d,
|
|
443
|
+
_useListInvitations$d3 = _useListInvitations$d2.invitations,
|
|
444
|
+
invitations = _useListInvitations$d3 === void 0 ? [] : _useListInvitations$d3,
|
|
445
|
+
_useListInvitations$d4 = _useListInvitations$d2.totalCount,
|
|
446
|
+
totalCount = _useListInvitations$d4 === void 0 ? 0 : _useListInvitations$d4,
|
|
447
|
+
isFetching = _useListInvitations.isFetching,
|
|
448
|
+
isLoading = _useListInvitations.isLoading;
|
|
449
|
+
var _useBulkDestroyInvita = useBulkDestroyInvitations({
|
|
450
|
+
configurationId: configurationId,
|
|
451
|
+
ownerType: ownerType,
|
|
452
|
+
ownerId: ownerId
|
|
453
|
+
}),
|
|
454
|
+
deleteEmailInvites = _useBulkDestroyInvita.mutate,
|
|
455
|
+
isPending = _useBulkDestroyInvita.isPending;
|
|
456
|
+
var handleAddEmails = function handleAddEmails() {
|
|
457
|
+
setShowAddEmails(true);
|
|
458
|
+
};
|
|
459
|
+
var handleOnClose = function handleOnClose() {
|
|
460
|
+
onClose();
|
|
461
|
+
setSelectedEmails([]);
|
|
462
|
+
};
|
|
463
|
+
var handleDeleteEmailInvites = function handleDeleteEmailInvites() {
|
|
464
|
+
var payload = {
|
|
465
|
+
emails: ramda.pluck("email", selectedEmails)
|
|
466
|
+
};
|
|
467
|
+
deleteEmailInvites(payload, {
|
|
468
|
+
onSuccess: function onSuccess() {
|
|
469
|
+
setSelectedEmails([]);
|
|
470
|
+
setShowDeleteAlert(false);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
var handleDeleteAction = function handleDeleteAction(inviteData) {
|
|
475
|
+
setSelectedEmails([inviteData]);
|
|
476
|
+
setShowDeleteAlert(true);
|
|
477
|
+
};
|
|
478
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
479
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Pane__default["default"], {
|
|
480
|
+
isOpen: isOpen,
|
|
481
|
+
size: "large",
|
|
482
|
+
onClose: handleOnClose,
|
|
483
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Header, {
|
|
484
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
485
|
+
style: "h2",
|
|
486
|
+
weight: "semibold",
|
|
487
|
+
children: t("neetoAccessControl.titles.invitations")
|
|
488
|
+
})
|
|
489
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
|
|
490
|
+
className: "pt-2",
|
|
491
|
+
children: neetoCist.isNotEmpty(invitations) ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
492
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"], {
|
|
493
|
+
leftActionBlock: ramda.isEmpty(selectedEmails) ? /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
494
|
+
component: "h4",
|
|
495
|
+
style: "h4",
|
|
496
|
+
children: t("neetoAccessControl.titles.emailsWithCount", {
|
|
497
|
+
count: totalCount
|
|
498
|
+
})
|
|
499
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
500
|
+
className: "flex items-center gap-4",
|
|
501
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
502
|
+
style: "h4",
|
|
503
|
+
children: t("neetoAccessControl.titles.selectedEmailsWithCount", {
|
|
504
|
+
count: selectedEmails.length,
|
|
505
|
+
totalCount: totalCount
|
|
506
|
+
})
|
|
507
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
508
|
+
icon: Delete__default["default"],
|
|
509
|
+
style: "secondary",
|
|
510
|
+
tooltipProps: {
|
|
511
|
+
content: t("neetoAccessControl.labels.delete")
|
|
512
|
+
},
|
|
513
|
+
onClick: function onClick() {
|
|
514
|
+
return setShowDeleteAlert(true);
|
|
515
|
+
}
|
|
516
|
+
})]
|
|
517
|
+
}),
|
|
518
|
+
rightActionBlock: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
519
|
+
label: t("neetoAccessControl.buttons.addEmails"),
|
|
520
|
+
onClick: handleAddEmails
|
|
521
|
+
})
|
|
522
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
|
|
523
|
+
hasPagination: totalCount > constants.DEFAULT_PAGE_SIZE,
|
|
524
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
|
|
525
|
+
totalCount: totalCount,
|
|
526
|
+
fixedHeight: true,
|
|
527
|
+
rowSelection: true,
|
|
528
|
+
currentPageNumber: page,
|
|
529
|
+
handlePageChange: setPage,
|
|
530
|
+
loading: isFetching,
|
|
531
|
+
rowData: invitations,
|
|
532
|
+
selectedRowKeys: ramda.pluck("id", selectedEmails),
|
|
533
|
+
columnData: invitationsTableColumnData !== null && invitationsTableColumnData !== void 0 ? invitationsTableColumnData : renderColumnData({
|
|
534
|
+
onDelete: handleDeleteAction
|
|
535
|
+
}),
|
|
536
|
+
onRowSelect: function onRowSelect(_, selectedRows) {
|
|
537
|
+
return setSelectedEmails(selectedRows);
|
|
538
|
+
}
|
|
539
|
+
})
|
|
540
|
+
})]
|
|
541
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
542
|
+
className: "flex h-full w-full justify-center",
|
|
543
|
+
children: [!isLoading && /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], {
|
|
544
|
+
title: t("neetoAccessControl.labels.noInvitations"),
|
|
545
|
+
primaryButtonProps: {
|
|
546
|
+
label: t("neetoAccessControl.buttons.addEmails"),
|
|
547
|
+
onClick: handleAddEmails
|
|
548
|
+
}
|
|
549
|
+
}), isLoading && /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {})]
|
|
550
|
+
})
|
|
551
|
+
})]
|
|
552
|
+
}), /*#__PURE__*/jsxRuntime.jsx(AddEmails, {
|
|
553
|
+
configurationId: configurationId,
|
|
554
|
+
ownerId: ownerId,
|
|
555
|
+
ownerType: ownerType,
|
|
556
|
+
isOpen: showAddEmails,
|
|
557
|
+
onClose: function onClose() {
|
|
558
|
+
return setShowAddEmails(false);
|
|
559
|
+
}
|
|
560
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
|
|
561
|
+
isOpen: showDeleteAlert,
|
|
562
|
+
isSubmitting: isPending,
|
|
563
|
+
submitButtonLabel: t("neetoAccessControl.labels.delete"),
|
|
564
|
+
message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
565
|
+
components: [{
|
|
566
|
+
strong: /*#__PURE__*/jsxRuntime.jsx("strong", {})
|
|
567
|
+
}],
|
|
568
|
+
i18nKey: "neetoAccessControl.alerts.deleteInviation.message",
|
|
569
|
+
values: {
|
|
570
|
+
count: selectedEmails.length,
|
|
571
|
+
email: (_selectedEmails$ = selectedEmails[0]) === null || _selectedEmails$ === void 0 ? void 0 : _selectedEmails$.email
|
|
572
|
+
}
|
|
573
|
+
}),
|
|
574
|
+
title: t("neetoAccessControl.alerts.deleteInviation.title", {
|
|
575
|
+
count: selectedEmails.length
|
|
576
|
+
}),
|
|
577
|
+
onClose: function onClose() {
|
|
578
|
+
return setShowDeleteAlert(false);
|
|
579
|
+
},
|
|
580
|
+
onSubmit: handleDeleteEmailInvites
|
|
581
|
+
})]
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
|
|
109
585
|
var configurationPath = "".concat(ACCESS_CONTROL_BASE_PATH, "/configuration");
|
|
110
586
|
var show = function show(params) {
|
|
111
587
|
return axios__default["default"].get(configurationPath, {
|
|
@@ -130,13 +606,10 @@ var configurationsApi = {
|
|
|
130
606
|
update: update
|
|
131
607
|
};
|
|
132
608
|
|
|
133
|
-
var QUERY_KEYS = {
|
|
134
|
-
ACCESS_CONTROL_CONFIGURATION: "access-control-configuration"
|
|
135
|
-
};
|
|
136
|
-
|
|
137
609
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
138
610
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
139
|
-
var ACCESS_CONTROL_CONFIGURATION = QUERY_KEYS.ACCESS_CONTROL_CONFIGURATION
|
|
611
|
+
var ACCESS_CONTROL_CONFIGURATION = QUERY_KEYS.ACCESS_CONTROL_CONFIGURATION,
|
|
612
|
+
ACCESS_CONTROL_CONFIGURATION_INVITATIONS = QUERY_KEYS.ACCESS_CONTROL_CONFIGURATION_INVITATIONS;
|
|
140
613
|
var useShowConfiguration = function useShowConfiguration(_ref) {
|
|
141
614
|
var ownerId = _ref.ownerId,
|
|
142
615
|
ownerType = _ref.ownerType;
|
|
@@ -162,7 +635,7 @@ var useUpdateConfiguration = function useUpdateConfiguration(_ref2, options) {
|
|
|
162
635
|
payload: payload
|
|
163
636
|
});
|
|
164
637
|
}, _objectSpread$2({
|
|
165
|
-
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION, ownerType, ownerId]]
|
|
638
|
+
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION, ownerType, ownerId], [ACCESS_CONTROL_CONFIGURATION_INVITATIONS, ownerType, ownerId]]
|
|
166
639
|
}, options));
|
|
167
640
|
};
|
|
168
641
|
|
|
@@ -170,7 +643,8 @@ var AUTH = {
|
|
|
170
643
|
NO: "no",
|
|
171
644
|
EMAIL: "email",
|
|
172
645
|
BASIC: "basic",
|
|
173
|
-
SESSION: "session"
|
|
646
|
+
SESSION: "session",
|
|
647
|
+
INVITED: "invited"
|
|
174
648
|
};
|
|
175
649
|
var AUTH_OPTIONS = [{
|
|
176
650
|
label: i18next.t("neetoAccessControl.auth.no"),
|
|
@@ -180,6 +654,9 @@ var AUTH_OPTIONS = [{
|
|
|
180
654
|
label: i18next.t("neetoAccessControl.auth.basic"),
|
|
181
655
|
value: AUTH.BASIC,
|
|
182
656
|
"data-cy": neetoCist.hyphenate(i18next.t("neetoAccessControl.auth.basic"))
|
|
657
|
+
}, {
|
|
658
|
+
label: i18next.t("neetoAccessControl.auth.invited"),
|
|
659
|
+
value: AUTH.INVITED
|
|
183
660
|
}, {
|
|
184
661
|
label: i18next.t("neetoAccessControl.auth.email"),
|
|
185
662
|
value: AUTH.EMAIL,
|
|
@@ -239,6 +716,20 @@ var buildPayload = function buildPayload(values) {
|
|
|
239
716
|
}
|
|
240
717
|
return payload;
|
|
241
718
|
};
|
|
719
|
+
var renderLabelWithViewInvitation = function renderLabelWithViewInvitation(_ref2) {
|
|
720
|
+
var onViewInvites = _ref2.onViewInvites;
|
|
721
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
722
|
+
i18nKey: "neetoAccessControl.auth.invitedWithViewButton",
|
|
723
|
+
components: {
|
|
724
|
+
button: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
725
|
+
className: "mt-1",
|
|
726
|
+
size: "small",
|
|
727
|
+
style: "link",
|
|
728
|
+
onClick: onViewInvites
|
|
729
|
+
})
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
};
|
|
242
733
|
|
|
243
734
|
var AllowedKeywords = reactUtils.withT(function (_ref) {
|
|
244
735
|
var t = _ref.t,
|
|
@@ -263,7 +754,7 @@ var AllowedKeywords = reactUtils.withT(function (_ref) {
|
|
|
263
754
|
placeholder: t("neetoAccessControl.inputs.placeholders.enterKeyword"),
|
|
264
755
|
suffix: showDeleteButton && /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
265
756
|
"data-cy": "allowed-keyword-delete-button",
|
|
266
|
-
icon:
|
|
757
|
+
icon: Delete__default["default"],
|
|
267
758
|
size: "small",
|
|
268
759
|
style: "text",
|
|
269
760
|
onClick: function onClick() {
|
|
@@ -318,11 +809,19 @@ var Configuration = function Configuration(_ref) {
|
|
|
318
809
|
var ownerId = _ref.ownerId,
|
|
319
810
|
ownerType = _ref.ownerType,
|
|
320
811
|
onReset = _ref.onReset,
|
|
321
|
-
|
|
812
|
+
_onSuccess = _ref.onSuccess,
|
|
322
813
|
headerProps = _ref.headerProps,
|
|
323
814
|
className = _ref.className,
|
|
324
815
|
_ref$handleCancel = _ref.handleCancel,
|
|
325
|
-
handleCancel = _ref$handleCancel === void 0 ? neetoCist.noop : _ref$handleCancel
|
|
816
|
+
handleCancel = _ref$handleCancel === void 0 ? neetoCist.noop : _ref$handleCancel,
|
|
817
|
+
_ref$onConfigurationC = _ref.onConfigurationChangedToInviteOnly,
|
|
818
|
+
onConfigurationChangedToInviteOnly = _ref$onConfigurationC === void 0 ? neetoCist.noop : _ref$onConfigurationC,
|
|
819
|
+
_ref$invitationsTable = _ref.invitationsTableColumnData,
|
|
820
|
+
invitationsTableColumnData = _ref$invitationsTable === void 0 ? null : _ref$invitationsTable;
|
|
821
|
+
var _useState = react.useState(false),
|
|
822
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
823
|
+
showInviationsPane = _useState2[0],
|
|
824
|
+
setShowInviationsPane = _useState2[1];
|
|
326
825
|
var _useTranslation = reactI18next.useTranslation(),
|
|
327
826
|
t = _useTranslation.t;
|
|
328
827
|
var _useShowConfiguration = useShowConfiguration({
|
|
@@ -331,13 +830,22 @@ var Configuration = function Configuration(_ref) {
|
|
|
331
830
|
}),
|
|
332
831
|
_useShowConfiguration2 = _useShowConfiguration.data,
|
|
333
832
|
configuration = _useShowConfiguration2 === void 0 ? {} : _useShowConfiguration2,
|
|
334
|
-
isLoading = _useShowConfiguration.isLoading
|
|
833
|
+
isLoading = _useShowConfiguration.isLoading,
|
|
834
|
+
isFetching = _useShowConfiguration.isFetching;
|
|
335
835
|
var configurationInitialValues = buildConfigurationInitialValues(configuration);
|
|
336
836
|
var _useUpdateConfigurati = useUpdateConfiguration({
|
|
337
837
|
ownerId: ownerId,
|
|
338
838
|
ownerType: ownerType
|
|
339
839
|
}, {
|
|
340
|
-
onSuccess: onSuccess
|
|
840
|
+
onSuccess: function onSuccess(values) {
|
|
841
|
+
var _values$configuration = values.configuration,
|
|
842
|
+
_values$configuration2 = _values$configuration === void 0 ? {} : _values$configuration,
|
|
843
|
+
auth = _values$configuration2.auth;
|
|
844
|
+
if (auth === AUTH.INVITED) {
|
|
845
|
+
handleShowInvitations();
|
|
846
|
+
}
|
|
847
|
+
_onSuccess(values);
|
|
848
|
+
}
|
|
341
849
|
}),
|
|
342
850
|
updateConfiguration = _useUpdateConfigurati.mutate;
|
|
343
851
|
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
@@ -349,12 +857,15 @@ var Configuration = function Configuration(_ref) {
|
|
|
349
857
|
}
|
|
350
858
|
});
|
|
351
859
|
};
|
|
860
|
+
var handleShowInvitations = onConfigurationChangedToInviteOnly === neetoCist.noop ? function () {
|
|
861
|
+
return setShowInviationsPane(true);
|
|
862
|
+
} : onConfigurationChangedToInviteOnly;
|
|
352
863
|
return /*#__PURE__*/jsxRuntime.jsxs(Container__default["default"], {
|
|
353
864
|
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
354
865
|
headerProps: headerProps
|
|
355
|
-
}), isLoading ? /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {}) : /*#__PURE__*/jsxRuntime.
|
|
866
|
+
}), isLoading ? /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {}) : /*#__PURE__*/jsxRuntime.jsxs(Scrollable__default["default"], {
|
|
356
867
|
className: "w-full",
|
|
357
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Form__default["default"], {
|
|
868
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Form__default["default"], {
|
|
358
869
|
className: classNames__default["default"]("space-y-6", className),
|
|
359
870
|
formikProps: {
|
|
360
871
|
initialValues: configurationInitialValues,
|
|
@@ -374,7 +885,20 @@ var Configuration = function Configuration(_ref) {
|
|
|
374
885
|
name: "auth",
|
|
375
886
|
children: AUTH_OPTIONS.map(function (props) {
|
|
376
887
|
return /*#__PURE__*/react.createElement(Radio__default["default"].Item, _objectSpread(_objectSpread({}, props), {}, {
|
|
377
|
-
key: props.value
|
|
888
|
+
key: props.value,
|
|
889
|
+
className: classNames__default["default"]({
|
|
890
|
+
"items-start": (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED
|
|
891
|
+
}),
|
|
892
|
+
label: (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED ? renderLabelWithViewInvitation({
|
|
893
|
+
onViewInvites: function onViewInvites() {
|
|
894
|
+
return setShowInviationsPane(true);
|
|
895
|
+
}
|
|
896
|
+
}) : props.label,
|
|
897
|
+
labelProps: {
|
|
898
|
+
className: classNames__default["default"]({
|
|
899
|
+
"flex flex-col items-start justify-start": (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED
|
|
900
|
+
})
|
|
901
|
+
}
|
|
378
902
|
}));
|
|
379
903
|
})
|
|
380
904
|
}), values.auth === AUTH.BASIC && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -394,11 +918,23 @@ var Configuration = function Configuration(_ref) {
|
|
|
394
918
|
}), /*#__PURE__*/jsxRuntime.jsx(ActionBlock__default["default"], {
|
|
395
919
|
cancelButtonProps: {
|
|
396
920
|
onClick: handleCancel
|
|
397
|
-
}
|
|
921
|
+
},
|
|
922
|
+
submitButtonProps: values.auth === AUTH.INVITED ? {
|
|
923
|
+
label: t("neetoAccessControl.buttons.saveChangesAndInvite")
|
|
924
|
+
} : {}
|
|
398
925
|
})]
|
|
399
926
|
});
|
|
400
927
|
}
|
|
401
|
-
})
|
|
928
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Invitations, {
|
|
929
|
+
invitationsTableColumnData: invitationsTableColumnData,
|
|
930
|
+
ownerId: ownerId,
|
|
931
|
+
ownerType: ownerType,
|
|
932
|
+
configurationId: configuration.id,
|
|
933
|
+
isOpen: showInviationsPane && !isFetching,
|
|
934
|
+
onClose: function onClose() {
|
|
935
|
+
return setShowInviationsPane(false);
|
|
936
|
+
}
|
|
937
|
+
})]
|
|
402
938
|
})]
|
|
403
939
|
});
|
|
404
940
|
};
|