@bigbinary/neeto-access-control-frontend 1.7.4 → 1.7.6-beta1
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 +62 -0
- package/app/javascript/src/translations/ar.json +3 -1
- package/app/javascript/src/translations/bg.json +3 -1
- package/app/javascript/src/translations/ca.json +3 -1
- package/app/javascript/src/translations/cs.json +3 -1
- package/app/javascript/src/translations/da.json +3 -1
- package/app/javascript/src/translations/de.json +3 -1
- package/app/javascript/src/translations/en.json +58 -4
- package/app/javascript/src/translations/es-MX.json +3 -1
- package/app/javascript/src/translations/es.json +3 -1
- package/app/javascript/src/translations/et.json +3 -1
- package/app/javascript/src/translations/fi.json +3 -1
- package/app/javascript/src/translations/fil.json +3 -1
- package/app/javascript/src/translations/fr.json +3 -1
- package/app/javascript/src/translations/he.json +3 -1
- package/app/javascript/src/translations/hi.json +3 -1
- package/app/javascript/src/translations/hr.json +3 -1
- package/app/javascript/src/translations/hu.json +3 -1
- package/app/javascript/src/translations/id.json +3 -1
- package/app/javascript/src/translations/it.json +3 -1
- package/app/javascript/src/translations/ja.json +3 -1
- package/app/javascript/src/translations/ko.json +3 -1
- package/app/javascript/src/translations/lv.json +3 -1
- package/app/javascript/src/translations/nl.json +3 -1
- package/app/javascript/src/translations/pl.json +3 -1
- package/app/javascript/src/translations/pt-BR.json +3 -1
- package/app/javascript/src/translations/pt.json +3 -1
- package/app/javascript/src/translations/ro.json +3 -1
- package/app/javascript/src/translations/ru.json +3 -1
- package/app/javascript/src/translations/sk.json +3 -1
- package/app/javascript/src/translations/sl.json +3 -1
- package/app/javascript/src/translations/sv.json +3 -1
- package/app/javascript/src/translations/th.json +3 -1
- package/app/javascript/src/translations/tr.json +3 -1
- package/app/javascript/src/translations/uk.json +3 -1
- package/app/javascript/src/translations/vi.json +3 -1
- package/app/javascript/src/translations/zh-CN.json +3 -1
- package/app/javascript/src/translations/zh-TW.json +3 -1
- package/dist/.ready +1 -1
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/index.js +1070 -304
- package/dist/cjs/v2/index.js.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/{useConfigurationsApi-C2NuK3x4.js → useConfigurationsApi-DGFFiq3w.js} +102 -31
- package/dist/useConfigurationsApi-DGFFiq3w.js.map +1 -0
- package/dist/{useConfigurationsApi-DkMeZA_t.js → useConfigurationsApi-DeqVxieL.js} +103 -30
- package/dist/useConfigurationsApi-DeqVxieL.js.map +1 -0
- package/dist/v2/index.js +1065 -299
- package/dist/v2/index.js.map +1 -1
- package/package.json +15 -15
- package/types.d.ts +15 -0
- package/dist/useConfigurationsApi-C2NuK3x4.js.map +0 -1
- package/dist/useConfigurationsApi-DkMeZA_t.js.map +0 -1
package/dist/v2/index.js
CHANGED
|
@@ -1,100 +1,79 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as useListInvitations, u as useBulkCreateInvitations, b as useBulkDestroyInvitations, e as useResendInvitations, c as useShowConfiguration, d as useUpdateConfiguration, f as useCreateConfigurationInvitations, Q as QUERY_KEYS } from '../useConfigurationsApi-DGFFiq3w.js';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
3
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import
|
|
6
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
7
|
+
import { useState, useRef, createElement, useEffect, useMemo, Fragment as Fragment$1 } from 'react';
|
|
5
8
|
import classNames from 'classnames';
|
|
6
|
-
import { Tooltip, Typography, Sheet,
|
|
7
|
-
import { Form,
|
|
8
|
-
import { humanize, isNotEmpty, noop, nullSafe, filterBy, findBy } from '@bigbinary/neeto-cist';
|
|
9
|
+
import { Tooltip, Typography, Button, Sheet, Spinner, Empty, Input as Input$1, DataTable, Alert, Tabs, Toastr, Callout, Label, RadioGroup as RadioGroup$1 } from '@bigbinary/neeto-atoms';
|
|
10
|
+
import { Input, Form, ActionBlock, MultiEmailInput, Checkbox, RadioGroup, BlockNavigation } from '@bigbinary/neeto-atoms/formik';
|
|
11
|
+
import { humanize, isNotEmpty, noop, nullSafe, filterBy, findBy, isPresent } from '@bigbinary/neeto-cist';
|
|
9
12
|
import CardLayout from '@bigbinary/neeto-molecules/v2/CardLayout';
|
|
10
13
|
import Container from '@bigbinary/neeto-molecules/v2/Container';
|
|
11
|
-
import { prop,
|
|
14
|
+
import { prop, mergeDeepRight, indexBy, values, isEmpty, isNil, pluck, includes, equals, omit, has, pick, reject, pipe, trim, mergeLeft, keys } from 'ramda';
|
|
12
15
|
import { useTranslation, Trans } from 'react-i18next';
|
|
13
|
-
import { Trash2, Users, Plus } from 'lucide-react';
|
|
14
|
-
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/v2/constants';
|
|
15
|
-
import SubHeader from '@bigbinary/neeto-molecules/v2/SubHeader';
|
|
16
16
|
import { t } from 'i18next';
|
|
17
17
|
import * as yup from 'yup';
|
|
18
|
-
import {
|
|
18
|
+
import { useFormikContext, FieldArray } from 'formik';
|
|
19
|
+
import DynamicVariables from '@bigbinary/neeto-molecules/v2/DynamicVariables';
|
|
20
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
21
|
import MoreDropdown from '@bigbinary/neeto-molecules/v2/MoreDropdown';
|
|
20
|
-
import {
|
|
22
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
23
|
+
import { keepPreviousData } from '@tanstack/react-query';
|
|
24
|
+
import { Users, Search, Trash2, Plus } from 'lucide-react';
|
|
25
|
+
import { useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
26
|
+
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/v2/constants';
|
|
27
|
+
import SubHeader from '@bigbinary/neeto-molecules/v2/SubHeader';
|
|
21
28
|
import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
22
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
23
29
|
import HelpPopover from '@bigbinary/neeto-molecules/v2/HelpPopover';
|
|
24
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
25
30
|
import NeetoHeader from '@bigbinary/neeto-molecules/v2/Header';
|
|
26
|
-
import '@tanstack/react-query';
|
|
27
31
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
28
|
-
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
29
32
|
import 'axios';
|
|
30
33
|
|
|
31
|
-
var
|
|
32
|
-
|
|
34
|
+
var isBlankHtml = function isBlankHtml(html) {
|
|
35
|
+
return !html || html.replace(/<[^>]*>/g, "").trim() === "";
|
|
33
36
|
};
|
|
34
37
|
var ADD_EMAILS_FORM_VALDATION_SCHEMA = yup.object().shape({
|
|
35
38
|
emails: yup.array().test("are-all-emails-valid", t("neetoAccessControl.inputs.validation.emailAddress"), function (emails) {
|
|
36
39
|
return emails.every(prop("valid"));
|
|
37
40
|
})
|
|
38
41
|
});
|
|
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
|
-
resetForm();
|
|
64
|
-
},
|
|
65
|
-
onError: function onError() {
|
|
66
|
-
return setSubmitting(false);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
return /*#__PURE__*/jsxs(Form, {
|
|
71
|
-
className: "mb-5 flex w-full gap-x-3",
|
|
72
|
-
formikProps: {
|
|
73
|
-
initialValues: ADD_EMAILS_FORM_INIT_VALUES,
|
|
74
|
-
onSubmit: handleAddEmails,
|
|
75
|
-
validationSchema: ADD_EMAILS_FORM_VALDATION_SCHEMA
|
|
76
|
-
},
|
|
77
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
78
|
-
className: "grow",
|
|
79
|
-
children: /*#__PURE__*/jsx(MultiEmailInput, {
|
|
80
|
-
dataTestId: "emails",
|
|
81
|
-
helpText: t("neetoAccessControl.addEmails.helpText"),
|
|
82
|
-
label: t("neetoAccessControl.titles.emails"),
|
|
83
|
-
name: "emails",
|
|
84
|
-
placeholder: t("neetoAccessControl.addEmails.placeholder"),
|
|
85
|
-
ref: emailsInputRef
|
|
86
|
-
})
|
|
87
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
88
|
-
className: "mt-[25px] shrink-0 self-start whitespace-nowrap",
|
|
89
|
-
"data-testid": "invite-emails-button",
|
|
90
|
-
label: t("neetoAccessControl.buttons.invite"),
|
|
91
|
-
type: "submit"
|
|
92
|
-
})]
|
|
93
|
-
});
|
|
42
|
+
var ADD_EMAILS_WITH_EMAIL_FORM_VALIDATION_SCHEMA = ADD_EMAILS_FORM_VALDATION_SCHEMA.shape({
|
|
43
|
+
subject: yup.string().when("skipEmail", {
|
|
44
|
+
is: false,
|
|
45
|
+
then: function then(schema) {
|
|
46
|
+
return schema.trim().required(t("neetoAccessControl.inputs.validation.subjectRequired")).max(255, t("neetoAccessControl.inputs.validation.subjectMaxLength", {
|
|
47
|
+
length: 255
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
message: yup.string().when("skipEmail", {
|
|
52
|
+
is: false,
|
|
53
|
+
then: function then(schema) {
|
|
54
|
+
return schema.test("message-present", t("neetoAccessControl.inputs.validation.messageRequired"), function (message) {
|
|
55
|
+
return !isBlankHtml(message);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
var TABS = {
|
|
61
|
+
ADD_PEOPLE: "addPeople",
|
|
62
|
+
INVITED: "invited"
|
|
63
|
+
};
|
|
64
|
+
var INVITATION_STATUS = {
|
|
65
|
+
PENDING: "pending"
|
|
94
66
|
};
|
|
67
|
+
var EDITOR_DEFAULTS = ["bold", "italic", "underline", "bullet-list"];
|
|
68
|
+
var SEARCH_DEBOUNCE_DELAY = 300;
|
|
95
69
|
|
|
70
|
+
var normalizeHtml = function normalizeHtml(html) {
|
|
71
|
+
return (html !== null && html !== void 0 ? html : "").replace(/>\s+</g, "><").trim();
|
|
72
|
+
};
|
|
96
73
|
var defaultColumnData = function defaultColumnData(_ref) {
|
|
97
|
-
var
|
|
74
|
+
var onRevoke = _ref.onRevoke,
|
|
75
|
+
onResend = _ref.onResend,
|
|
76
|
+
canResend = _ref.canResend;
|
|
98
77
|
return [{
|
|
99
78
|
header: t("neetoAccessControl.titles.emails"),
|
|
100
79
|
meta: {
|
|
@@ -108,6 +87,7 @@ var defaultColumnData = function defaultColumnData(_ref) {
|
|
|
108
87
|
row = _ref2.row;
|
|
109
88
|
var email = getValue();
|
|
110
89
|
var inviteData = row.original;
|
|
90
|
+
var isPending = inviteData.status === INVITATION_STATUS.PENDING;
|
|
111
91
|
return /*#__PURE__*/jsxs("div", {
|
|
112
92
|
className: "flex items-center justify-between gap-x-3",
|
|
113
93
|
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
@@ -123,14 +103,21 @@ var defaultColumnData = function defaultColumnData(_ref) {
|
|
|
123
103
|
className: "w-max",
|
|
124
104
|
position: "bottom-end"
|
|
125
105
|
},
|
|
126
|
-
menuItems: [{
|
|
127
|
-
key: "
|
|
128
|
-
label: t("neetoAccessControl.labels.
|
|
106
|
+
menuItems: [].concat(_toConsumableArray(canResend && isPending ? [{
|
|
107
|
+
key: "resend",
|
|
108
|
+
label: t("neetoAccessControl.labels.resendInvitation"),
|
|
109
|
+
"data-testid": "invitation-resend-menu-item",
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
return onResend(inviteData);
|
|
112
|
+
}
|
|
113
|
+
}] : []), [{
|
|
114
|
+
key: "revoke",
|
|
115
|
+
label: t("neetoAccessControl.labels.revokeAccess"),
|
|
129
116
|
"data-testid": "invitation-delete-menu-item",
|
|
130
117
|
onClick: function onClick() {
|
|
131
|
-
return
|
|
118
|
+
return onRevoke(inviteData);
|
|
132
119
|
}
|
|
133
|
-
}]
|
|
120
|
+
}])
|
|
134
121
|
})]
|
|
135
122
|
});
|
|
136
123
|
}
|
|
@@ -143,8 +130,21 @@ var defaultColumnData = function defaultColumnData(_ref) {
|
|
|
143
130
|
id: "status",
|
|
144
131
|
size: 75,
|
|
145
132
|
cell: function cell(_ref3) {
|
|
146
|
-
var getValue = _ref3.getValue
|
|
147
|
-
|
|
133
|
+
var getValue = _ref3.getValue,
|
|
134
|
+
row = _ref3.row;
|
|
135
|
+
var status = getValue();
|
|
136
|
+
var isNotEmailed = status === INVITATION_STATUS.PENDING && row.original.emailSent === false;
|
|
137
|
+
return /*#__PURE__*/jsxs("div", {
|
|
138
|
+
className: "flex flex-col",
|
|
139
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
140
|
+
children: humanize(status)
|
|
141
|
+
}), isNotEmailed && /*#__PURE__*/jsx(Typography, {
|
|
142
|
+
className: "text-muted-foreground",
|
|
143
|
+
"data-testid": "invitation-no-email-sent-text",
|
|
144
|
+
variant: "body3",
|
|
145
|
+
children: t("neetoAccessControl.labels.noEmailSent")
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
148
|
}
|
|
149
149
|
}];
|
|
150
150
|
};
|
|
@@ -153,18 +153,390 @@ var mergeByKey = function mergeByKey(key, a, b) {
|
|
|
153
153
|
return values(merge);
|
|
154
154
|
};
|
|
155
155
|
var renderColumnData = function renderColumnData(_ref4) {
|
|
156
|
-
var
|
|
156
|
+
var onRevoke = _ref4.onRevoke,
|
|
157
|
+
onResend = _ref4.onResend,
|
|
158
|
+
_ref4$canResend = _ref4.canResend,
|
|
159
|
+
canResend = _ref4$canResend === void 0 ? false : _ref4$canResend,
|
|
157
160
|
_ref4$extraColumnsDat = _ref4.extraColumnsData,
|
|
158
161
|
extraColumnsData = _ref4$extraColumnsDat === void 0 ? [] : _ref4$extraColumnsDat;
|
|
159
162
|
return mergeByKey("id", defaultColumnData({
|
|
160
|
-
|
|
163
|
+
onRevoke: onRevoke,
|
|
164
|
+
onResend: onResend,
|
|
165
|
+
canResend: canResend
|
|
161
166
|
}), extraColumnsData);
|
|
162
167
|
};
|
|
168
|
+
var buildEmailValues = function buildEmailValues(emails) {
|
|
169
|
+
return emails.map(function (email) {
|
|
170
|
+
return {
|
|
171
|
+
label: email,
|
|
172
|
+
value: email,
|
|
173
|
+
valid: true
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
var isEmailEdited = function isEmailEdited(_ref5, defaults) {
|
|
178
|
+
var subject = _ref5.subject,
|
|
179
|
+
message = _ref5.message;
|
|
180
|
+
return subject !== defaults.defaultSubject || normalizeHtml(message) !== normalizeHtml(defaults.defaultMessage);
|
|
181
|
+
};
|
|
182
|
+
var buildTemplatePayload = function buildTemplatePayload(_ref6, defaults) {
|
|
183
|
+
var subject = _ref6.subject,
|
|
184
|
+
message = _ref6.message;
|
|
185
|
+
return isEmailEdited({
|
|
186
|
+
subject: subject,
|
|
187
|
+
message: message
|
|
188
|
+
}, defaults) ? {
|
|
189
|
+
invitationEmailSubject: subject,
|
|
190
|
+
invitationEmailMessage: message
|
|
191
|
+
} : {
|
|
192
|
+
invitationEmailSubject: null,
|
|
193
|
+
invitationEmailMessage: null
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
var EmailTemplate = function EmailTemplate(_ref) {
|
|
198
|
+
var invitationEmailProps = _ref.invitationEmailProps,
|
|
199
|
+
translationContext = _ref.translationContext;
|
|
200
|
+
var FormikEditor = invitationEmailProps.FormikEditor,
|
|
201
|
+
_invitationEmailProps = invitationEmailProps.variables,
|
|
202
|
+
variables = _invitationEmailProps === void 0 ? [] : _invitationEmailProps,
|
|
203
|
+
_invitationEmailProps2 = invitationEmailProps.defaultSubject,
|
|
204
|
+
defaultSubject = _invitationEmailProps2 === void 0 ? "" : _invitationEmailProps2,
|
|
205
|
+
_invitationEmailProps3 = invitationEmailProps.defaultMessage,
|
|
206
|
+
defaultMessage = _invitationEmailProps3 === void 0 ? "" : _invitationEmailProps3,
|
|
207
|
+
buttonLabel = invitationEmailProps.buttonLabel;
|
|
208
|
+
var _useState = useState(0),
|
|
209
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
210
|
+
editorKey = _useState2[0],
|
|
211
|
+
setEditorKey = _useState2[1];
|
|
212
|
+
var subjectRef = useRef(null);
|
|
213
|
+
var _useTranslation = useTranslation(),
|
|
214
|
+
t = _useTranslation.t;
|
|
215
|
+
var _useFormikContext = useFormikContext(),
|
|
216
|
+
values = _useFormikContext.values,
|
|
217
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
218
|
+
var insertSubjectVariable = function insertSubjectVariable(_ref2) {
|
|
219
|
+
var _values$subject, _subjectRef$current$s, _subjectRef$current;
|
|
220
|
+
var key = _ref2.key,
|
|
221
|
+
category = _ref2.category;
|
|
222
|
+
var subject = (_values$subject = values.subject) !== null && _values$subject !== void 0 ? _values$subject : "";
|
|
223
|
+
var position = (_subjectRef$current$s = (_subjectRef$current = subjectRef.current) === null || _subjectRef$current === void 0 ? void 0 : _subjectRef$current.selectionEnd) !== null && _subjectRef$current$s !== void 0 ? _subjectRef$current$s : subject.length;
|
|
224
|
+
var variable = category ? "".concat(category, ".").concat(key) : key;
|
|
225
|
+
var before = subject.slice(0, position);
|
|
226
|
+
var separator = before === "" || /\s$/.test(before) ? "" : " ";
|
|
227
|
+
setFieldValue("subject", "".concat(before).concat(separator, "{{").concat(variable, "}}").concat(subject.slice(position)));
|
|
228
|
+
};
|
|
229
|
+
var handleResetToDefault = function handleResetToDefault() {
|
|
230
|
+
setFieldValue("subject", defaultSubject);
|
|
231
|
+
setFieldValue("message", defaultMessage);
|
|
232
|
+
setEditorKey(function (key) {
|
|
233
|
+
return key + 1;
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
return /*#__PURE__*/jsxs("div", {
|
|
237
|
+
className: "w-full rounded-lg border",
|
|
238
|
+
"data-testid": "invitation-email-section",
|
|
239
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
240
|
+
className: "bg-muted/70 border-b px-4 py-2.5",
|
|
241
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
242
|
+
variant: "body2",
|
|
243
|
+
weight: "semibold",
|
|
244
|
+
children: t("neetoAccessControl.titles.invitationEmail")
|
|
245
|
+
})
|
|
246
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
247
|
+
className: "flex flex-col gap-y-4 p-4",
|
|
248
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
249
|
+
dataTestId: "invitation-email-subject",
|
|
250
|
+
label: t("neetoAccessControl.labels.subject"),
|
|
251
|
+
name: "subject",
|
|
252
|
+
ref: subjectRef,
|
|
253
|
+
suffix: /*#__PURE__*/jsx("div", {
|
|
254
|
+
className: "me-2 inline-flex",
|
|
255
|
+
children: /*#__PURE__*/jsx(DynamicVariables, {
|
|
256
|
+
variables: variables,
|
|
257
|
+
buttonProps: {
|
|
258
|
+
className: "self-center"
|
|
259
|
+
},
|
|
260
|
+
onVariableClick: insertSubjectVariable
|
|
261
|
+
})
|
|
262
|
+
})
|
|
263
|
+
}), /*#__PURE__*/createElement(FormikEditor, {
|
|
264
|
+
variables: variables,
|
|
265
|
+
contentAttributes: {
|
|
266
|
+
spellcheck: "false"
|
|
267
|
+
},
|
|
268
|
+
"data-testid": "invitation-email-message",
|
|
269
|
+
defaults: EDITOR_DEFAULTS,
|
|
270
|
+
key: editorKey,
|
|
271
|
+
label: t("neetoAccessControl.labels.message"),
|
|
272
|
+
menuType: "fixed",
|
|
273
|
+
name: "message",
|
|
274
|
+
size: "medium"
|
|
275
|
+
}), buttonLabel && /*#__PURE__*/jsxs("div", {
|
|
276
|
+
className: "flex flex-col items-start gap-y-1.5",
|
|
277
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
278
|
+
className: "text-muted-foreground",
|
|
279
|
+
variant: "body2",
|
|
280
|
+
children: t("neetoAccessControl.invitations.buttonPreview", {
|
|
281
|
+
context: translationContext
|
|
282
|
+
})
|
|
283
|
+
}), /*#__PURE__*/jsx("span", {
|
|
284
|
+
className: "rounded-md bg-neutral-800 px-3.5 py-1.5 text-sm font-medium text-white",
|
|
285
|
+
"data-testid": "invitation-email-button-preview",
|
|
286
|
+
children: buttonLabel
|
|
287
|
+
})]
|
|
288
|
+
}), isEmailEdited(values, {
|
|
289
|
+
defaultSubject: defaultSubject,
|
|
290
|
+
defaultMessage: defaultMessage
|
|
291
|
+
}) && /*#__PURE__*/jsx(Typography, {
|
|
292
|
+
className: "text-muted-foreground border-t pt-3",
|
|
293
|
+
variant: "body2",
|
|
294
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
295
|
+
i18nKey: "neetoAccessControl.invitations.editedEmail",
|
|
296
|
+
components: {
|
|
297
|
+
button: /*#__PURE__*/jsx(Button, {
|
|
298
|
+
"data-testid": "reset-invitation-email-button",
|
|
299
|
+
variant: "link",
|
|
300
|
+
onClick: handleResetToDefault
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
})]
|
|
305
|
+
})]
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var AddEmails = function AddEmails(_ref) {
|
|
310
|
+
var _ref$isSetup = _ref.isSetup,
|
|
311
|
+
isSetup = _ref$isSetup === void 0 ? false : _ref$isSetup,
|
|
312
|
+
initialValues = _ref.initialValues,
|
|
313
|
+
invitationEmailProps = _ref.invitationEmailProps,
|
|
314
|
+
translationContext = _ref.translationContext,
|
|
315
|
+
onSubmit = _ref.onSubmit,
|
|
316
|
+
onCancel = _ref.onCancel;
|
|
317
|
+
var _useTranslation = useTranslation(),
|
|
318
|
+
t = _useTranslation.t;
|
|
319
|
+
var emailsInputRef = useRef();
|
|
320
|
+
var isReady = function isReady(_ref2) {
|
|
321
|
+
var emails = _ref2.emails;
|
|
322
|
+
return isNotEmpty(emails) && emails.every(prop("valid"));
|
|
323
|
+
};
|
|
324
|
+
var renderFields = function renderFields(values, isSubmitting) {
|
|
325
|
+
return /*#__PURE__*/jsxs("div", {
|
|
326
|
+
className: "flex w-full flex-col gap-y-6 pb-6",
|
|
327
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
328
|
+
className: "flex w-full gap-x-3",
|
|
329
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
330
|
+
className: "grow",
|
|
331
|
+
children: /*#__PURE__*/jsx(MultiEmailInput, {
|
|
332
|
+
dataTestId: "emails",
|
|
333
|
+
helpText: t("neetoAccessControl.addEmails.helpText"),
|
|
334
|
+
label: t("neetoAccessControl.titles.emails"),
|
|
335
|
+
name: "emails",
|
|
336
|
+
placeholder: t("neetoAccessControl.addEmails.placeholder"),
|
|
337
|
+
ref: emailsInputRef
|
|
338
|
+
})
|
|
339
|
+
}), !isSetup &&
|
|
340
|
+
/*#__PURE__*/
|
|
341
|
+
// Cancel button is not required in this case
|
|
342
|
+
// eslint-disable-next-line @bigbinary/neeto/use-neetoui-action-block-in-formik-forms
|
|
343
|
+
jsx(Button, {
|
|
344
|
+
className: "mt-[25px] shrink-0 self-start whitespace-nowrap",
|
|
345
|
+
"data-testid": "invite-emails-button",
|
|
346
|
+
disabled: !isReady(values) || isSubmitting,
|
|
347
|
+
loading: isSubmitting,
|
|
348
|
+
type: "submit",
|
|
349
|
+
label: values.skipEmail ? t("neetoAccessControl.buttons.add") : t("neetoAccessControl.buttons.invite")
|
|
350
|
+
})]
|
|
351
|
+
}), invitationEmailProps && /*#__PURE__*/jsxs(Fragment, {
|
|
352
|
+
children: [/*#__PURE__*/jsx(Checkbox, {
|
|
353
|
+
dataTestId: "skip-invitation-email-checkbox",
|
|
354
|
+
label: t("neetoAccessControl.invitations.skipEmail.label"),
|
|
355
|
+
name: "skipEmail",
|
|
356
|
+
helpText: t("neetoAccessControl.invitations.skipEmail.helpText", {
|
|
357
|
+
context: translationContext
|
|
358
|
+
})
|
|
359
|
+
}), !values.skipEmail && /*#__PURE__*/jsx(EmailTemplate, {
|
|
360
|
+
invitationEmailProps: invitationEmailProps,
|
|
361
|
+
translationContext: translationContext
|
|
362
|
+
})]
|
|
363
|
+
})]
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
return /*#__PURE__*/jsx(Form, {
|
|
367
|
+
className: "flex min-h-0 w-full flex-1 flex-col",
|
|
368
|
+
formikProps: {
|
|
369
|
+
initialValues: initialValues,
|
|
370
|
+
onSubmit: onSubmit,
|
|
371
|
+
validationSchema: invitationEmailProps ? ADD_EMAILS_WITH_EMAIL_FORM_VALIDATION_SCHEMA : ADD_EMAILS_FORM_VALDATION_SCHEMA
|
|
372
|
+
},
|
|
373
|
+
children: function children(_ref3) {
|
|
374
|
+
var values = _ref3.values,
|
|
375
|
+
isSubmitting = _ref3.isSubmitting;
|
|
376
|
+
return isSetup ? /*#__PURE__*/jsxs(Fragment, {
|
|
377
|
+
children: [/*#__PURE__*/jsx(Sheet.Body, {
|
|
378
|
+
className: "pt-2",
|
|
379
|
+
children: renderFields(values, isSubmitting)
|
|
380
|
+
}), /*#__PURE__*/jsx(Sheet.Footer, {
|
|
381
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
382
|
+
cancelButtonProps: {
|
|
383
|
+
onClick: onCancel
|
|
384
|
+
},
|
|
385
|
+
submitButtonProps: {
|
|
386
|
+
"data-testid": "stage-invitations-button",
|
|
387
|
+
disabled: !isReady(values) || isSubmitting
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
})]
|
|
391
|
+
}) : renderFields(values, isSubmitting);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
var InvitedList = function InvitedList(_ref) {
|
|
397
|
+
var configurationId = _ref.configurationId,
|
|
398
|
+
ownerType = _ref.ownerType,
|
|
399
|
+
ownerId = _ref.ownerId,
|
|
400
|
+
isOpen = _ref.isOpen,
|
|
401
|
+
invitationsCount = _ref.invitationsCount,
|
|
402
|
+
_ref$showSearch = _ref.showSearch,
|
|
403
|
+
showSearch = _ref$showSearch === void 0 ? true : _ref$showSearch,
|
|
404
|
+
_ref$canResend = _ref.canResend,
|
|
405
|
+
canResend = _ref$canResend === void 0 ? false : _ref$canResend,
|
|
406
|
+
_ref$extraColumnsData = _ref.extraColumnsData,
|
|
407
|
+
extraColumnsData = _ref$extraColumnsData === void 0 ? [] : _ref$extraColumnsData,
|
|
408
|
+
selectedEmails = _ref.selectedEmails,
|
|
409
|
+
setSelectedEmails = _ref.setSelectedEmails,
|
|
410
|
+
_onRevoke = _ref.onRevoke,
|
|
411
|
+
onResend = _ref.onResend;
|
|
412
|
+
var _useState = useState(DEFAULT_PAGE_INDEX),
|
|
413
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
414
|
+
page = _useState2[0],
|
|
415
|
+
setPage = _useState2[1];
|
|
416
|
+
var _useState3 = useState(""),
|
|
417
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
418
|
+
searchTerm = _useState4[0],
|
|
419
|
+
setSearchTerm = _useState4[1];
|
|
420
|
+
var _useTranslation = useTranslation(),
|
|
421
|
+
t = _useTranslation.t;
|
|
422
|
+
var debouncedSearchTerm = useDebounce(searchTerm.trim(), SEARCH_DEBOUNCE_DELAY);
|
|
423
|
+
var _useListInvitations = useListInvitations({
|
|
424
|
+
neetoAccessControlConfigurationId: configurationId,
|
|
425
|
+
ownerType: ownerType,
|
|
426
|
+
ownerId: ownerId,
|
|
427
|
+
page: page,
|
|
428
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
429
|
+
searchTerm: debouncedSearchTerm || undefined
|
|
430
|
+
}, {
|
|
431
|
+
enabled: isOpen,
|
|
432
|
+
placeholderData: keepPreviousData
|
|
433
|
+
}),
|
|
434
|
+
_useListInvitations$d = _useListInvitations.data,
|
|
435
|
+
_useListInvitations$d2 = _useListInvitations$d === void 0 ? {} : _useListInvitations$d,
|
|
436
|
+
_useListInvitations$d3 = _useListInvitations$d2.invitations,
|
|
437
|
+
invitations = _useListInvitations$d3 === void 0 ? [] : _useListInvitations$d3,
|
|
438
|
+
_useListInvitations$d4 = _useListInvitations$d2.totalCount,
|
|
439
|
+
totalCount = _useListInvitations$d4 === void 0 ? 0 : _useListInvitations$d4,
|
|
440
|
+
isFetching = _useListInvitations.isFetching,
|
|
441
|
+
isLoading = _useListInvitations.isLoading;
|
|
442
|
+
var handleSearch = function handleSearch(event) {
|
|
443
|
+
setSearchTerm(event.target.value);
|
|
444
|
+
setPage(DEFAULT_PAGE_INDEX);
|
|
445
|
+
};
|
|
446
|
+
var isSearching = isNotEmpty(debouncedSearchTerm);
|
|
447
|
+
var emailsCount = invitationsCount !== null && invitationsCount !== void 0 ? invitationsCount : totalCount;
|
|
448
|
+
if (isLoading) {
|
|
449
|
+
return /*#__PURE__*/jsx("div", {
|
|
450
|
+
className: "flex h-full w-full items-center justify-center",
|
|
451
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
if (isEmpty(invitations) && !isSearching) {
|
|
455
|
+
return /*#__PURE__*/jsx("div", {
|
|
456
|
+
className: "flex h-full w-full justify-center",
|
|
457
|
+
children: /*#__PURE__*/jsx(Empty, {
|
|
458
|
+
icon: Users,
|
|
459
|
+
title: t("neetoAccessControl.labels.noOneInvitedYet")
|
|
460
|
+
})
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return /*#__PURE__*/jsxs("div", {
|
|
464
|
+
className: "flex w-full flex-col gap-y-4 pb-6",
|
|
465
|
+
children: [showSearch && /*#__PURE__*/jsx(Input$1, {
|
|
466
|
+
"aria-label": t("neetoAccessControl.labels.searchEmails"),
|
|
467
|
+
dataTestId: "search-invitations-input",
|
|
468
|
+
placeholder: t("neetoAccessControl.labels.searchEmails"),
|
|
469
|
+
prefix: /*#__PURE__*/jsx(Search, {
|
|
470
|
+
className: "size-4"
|
|
471
|
+
}),
|
|
472
|
+
type: "search",
|
|
473
|
+
value: searchTerm,
|
|
474
|
+
onChange: handleSearch
|
|
475
|
+
}), /*#__PURE__*/jsx(SubHeader, {
|
|
476
|
+
leftActionBlock: isEmpty(selectedEmails) ? /*#__PURE__*/jsx(Typography, {
|
|
477
|
+
className: "min-h-8",
|
|
478
|
+
variant: "h6",
|
|
479
|
+
children: t("neetoAccessControl.titles.emailsWithCount", {
|
|
480
|
+
count: emailsCount
|
|
481
|
+
})
|
|
482
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
483
|
+
className: "flex items-center gap-x-4",
|
|
484
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
485
|
+
variant: "h6",
|
|
486
|
+
children: t("neetoAccessControl.titles.selectedEmailsWithCount", {
|
|
487
|
+
selectedCount: selectedEmails.length,
|
|
488
|
+
count: emailsCount
|
|
489
|
+
})
|
|
490
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
491
|
+
"data-testid": "bulk-delete-invitations-button",
|
|
492
|
+
label: t("neetoAccessControl.labels.revokeAccess"),
|
|
493
|
+
size: "sm",
|
|
494
|
+
variant: "outline",
|
|
495
|
+
onClick: function onClick() {
|
|
496
|
+
return _onRevoke(selectedEmails);
|
|
497
|
+
}
|
|
498
|
+
})]
|
|
499
|
+
})
|
|
500
|
+
}), isEmpty(invitations) ? /*#__PURE__*/jsx(Empty, {
|
|
501
|
+
icon: Search,
|
|
502
|
+
title: t("neetoAccessControl.labels.noMatchingInvitations")
|
|
503
|
+
}) : /*#__PURE__*/jsx(DataTable, {
|
|
504
|
+
totalCount: totalCount,
|
|
505
|
+
enableRowSelection: true,
|
|
506
|
+
fixedHeight: true,
|
|
507
|
+
currentPage: page,
|
|
508
|
+
data: invitations,
|
|
509
|
+
enableColumnFreeze: false,
|
|
510
|
+
getRowId: function getRowId(_ref2) {
|
|
511
|
+
var id = _ref2.id;
|
|
512
|
+
return String(id);
|
|
513
|
+
},
|
|
514
|
+
loading: isFetching,
|
|
515
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
516
|
+
selectedRowKeys: selectedEmails.map(function (_ref3) {
|
|
517
|
+
var id = _ref3.id;
|
|
518
|
+
return String(id);
|
|
519
|
+
}),
|
|
520
|
+
columns: renderColumnData({
|
|
521
|
+
canResend: canResend,
|
|
522
|
+
extraColumnsData: extraColumnsData,
|
|
523
|
+
onResend: onResend,
|
|
524
|
+
onRevoke: function onRevoke(invitation) {
|
|
525
|
+
return _onRevoke([invitation]);
|
|
526
|
+
}
|
|
527
|
+
}),
|
|
528
|
+
onPageChange: setPage,
|
|
529
|
+
onRowSelect: function onRowSelect(_, selectedRows) {
|
|
530
|
+
return setSelectedEmails(selectedRows);
|
|
531
|
+
}
|
|
532
|
+
})]
|
|
533
|
+
});
|
|
534
|
+
};
|
|
163
535
|
|
|
164
536
|
function ownKeys$4(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; }
|
|
165
537
|
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
166
538
|
var Invitations$1 = function Invitations(_ref) {
|
|
167
|
-
var
|
|
539
|
+
var _ref2, _emailTemplate$subjec, _ref3, _emailTemplate$messag, _stagedInvitations$em, _emailsToRevoke$;
|
|
168
540
|
var _ref$extraColumnsData = _ref.extraColumnsData,
|
|
169
541
|
extraColumnsData = _ref$extraColumnsData === void 0 ? [] : _ref$extraColumnsData,
|
|
170
542
|
configurationId = _ref.configurationId,
|
|
@@ -179,172 +551,279 @@ var Invitations$1 = function Invitations(_ref) {
|
|
|
179
551
|
_ref$inviteButtonProp = _ref.inviteButtonProps,
|
|
180
552
|
inviteButtonProps = _ref$inviteButtonProp === void 0 ? {} : _ref$inviteButtonProp,
|
|
181
553
|
_ref$onDestroyInvitat = _ref.onDestroyInvitationsSuccess,
|
|
182
|
-
onDestroyInvitationsSuccess = _ref$onDestroyInvitat === void 0 ? noop : _ref$onDestroyInvitat
|
|
183
|
-
|
|
554
|
+
onDestroyInvitationsSuccess = _ref$onDestroyInvitat === void 0 ? noop : _ref$onDestroyInvitat,
|
|
555
|
+
_ref$isSetup = _ref.isSetup,
|
|
556
|
+
isSetup = _ref$isSetup === void 0 ? false : _ref$isSetup,
|
|
557
|
+
_ref$defaultTab = _ref.defaultTab,
|
|
558
|
+
defaultTab = _ref$defaultTab === void 0 ? TABS.ADD_PEOPLE : _ref$defaultTab,
|
|
559
|
+
invitationsCount = _ref.invitationsCount,
|
|
560
|
+
invitationEmailProps = _ref.invitationEmailProps,
|
|
561
|
+
_ref$emailTemplate = _ref.emailTemplate,
|
|
562
|
+
emailTemplate = _ref$emailTemplate === void 0 ? {} : _ref$emailTemplate,
|
|
563
|
+
stagedInvitations = _ref.stagedInvitations,
|
|
564
|
+
_ref$onStage = _ref.onStage,
|
|
565
|
+
onStage = _ref$onStage === void 0 ? noop : _ref$onStage,
|
|
566
|
+
translationContext = _ref.translationContext;
|
|
567
|
+
var _useState = useState(defaultTab),
|
|
184
568
|
_useState2 = _slicedToArray(_useState, 2),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var _useState3 = useState(
|
|
569
|
+
activeTab = _useState2[0],
|
|
570
|
+
setActiveTab = _useState2[1];
|
|
571
|
+
var _useState3 = useState([]),
|
|
188
572
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var _useState5 = useState(
|
|
573
|
+
selectedEmails = _useState4[0],
|
|
574
|
+
setSelectedEmails = _useState4[1];
|
|
575
|
+
var _useState5 = useState([]),
|
|
192
576
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
193
|
-
|
|
194
|
-
|
|
577
|
+
emailsToRevoke = _useState6[0],
|
|
578
|
+
setEmailsToRevoke = _useState6[1];
|
|
195
579
|
var _useTranslation = useTranslation(),
|
|
196
580
|
t = _useTranslation.t;
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}),
|
|
219
|
-
deleteEmailInvites = _useBulkDestroyInvita.mutate,
|
|
220
|
-
isPending = _useBulkDestroyInvita.isPending;
|
|
221
|
-
var handleOnClose = function handleOnClose() {
|
|
222
|
-
onClose();
|
|
581
|
+
var mutationParams = {
|
|
582
|
+
configurationId: configurationId,
|
|
583
|
+
ownerType: ownerType,
|
|
584
|
+
ownerId: ownerId,
|
|
585
|
+
config: {
|
|
586
|
+
showToastr: false
|
|
587
|
+
},
|
|
588
|
+
withConfiguration: true
|
|
589
|
+
};
|
|
590
|
+
var _useBulkCreateInvitat = useBulkCreateInvitations(mutationParams),
|
|
591
|
+
createInvitations = _useBulkCreateInvitat.mutateAsync;
|
|
592
|
+
var _useBulkDestroyInvita = useBulkDestroyInvitations(mutationParams),
|
|
593
|
+
revokeInvitations = _useBulkDestroyInvita.mutate,
|
|
594
|
+
isRevoking = _useBulkDestroyInvita.isPending;
|
|
595
|
+
var _useResendInvitations = useResendInvitations(mutationParams),
|
|
596
|
+
resendInvitations = _useResendInvitations.mutate,
|
|
597
|
+
isResending = _useResendInvitations.isPending,
|
|
598
|
+
resendingPayload = _useResendInvitations.variables;
|
|
599
|
+
useEffect(function () {
|
|
600
|
+
if (!isOpen) return;
|
|
601
|
+
setActiveTab(defaultTab);
|
|
223
602
|
setSelectedEmails([]);
|
|
603
|
+
}, [isOpen, defaultTab]);
|
|
604
|
+
var showTabs = !isSetup && !hideAddEmailsForm;
|
|
605
|
+
var templateValues = {
|
|
606
|
+
subject: (_ref2 = (_emailTemplate$subjec = emailTemplate.subject) !== null && _emailTemplate$subjec !== void 0 ? _emailTemplate$subjec : invitationEmailProps === null || invitationEmailProps === void 0 ? void 0 : invitationEmailProps.defaultSubject) !== null && _ref2 !== void 0 ? _ref2 : "",
|
|
607
|
+
message: (_ref3 = (_emailTemplate$messag = emailTemplate.message) !== null && _emailTemplate$messag !== void 0 ? _emailTemplate$messag : invitationEmailProps === null || invitationEmailProps === void 0 ? void 0 : invitationEmailProps.defaultMessage) !== null && _ref3 !== void 0 ? _ref3 : ""
|
|
224
608
|
};
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
609
|
+
var addEmailsInitialValues = isSetup ? _objectSpread$4({
|
|
610
|
+
emails: buildEmailValues((_stagedInvitations$em = stagedInvitations === null || stagedInvitations === void 0 ? void 0 : stagedInvitations.emails) !== null && _stagedInvitations$em !== void 0 ? _stagedInvitations$em : []),
|
|
611
|
+
skipEmail: stagedInvitations ? !stagedInvitations.sendEmail : false
|
|
612
|
+
}, templateValues) : _objectSpread$4({
|
|
613
|
+
emails: [],
|
|
614
|
+
skipEmail: false
|
|
615
|
+
}, templateValues);
|
|
616
|
+
var handleStage = function handleStage(_ref4) {
|
|
617
|
+
var emails = _ref4.emails,
|
|
618
|
+
skipEmail = _ref4.skipEmail,
|
|
619
|
+
subject = _ref4.subject,
|
|
620
|
+
message = _ref4.message;
|
|
621
|
+
onStage(_objectSpread$4({
|
|
622
|
+
emails: pluck("value", emails),
|
|
623
|
+
sendEmail: !skipEmail
|
|
624
|
+
}, invitationEmailProps && !skipEmail ? buildTemplatePayload({
|
|
625
|
+
subject: subject,
|
|
626
|
+
message: message
|
|
627
|
+
}, invitationEmailProps) : {}));
|
|
628
|
+
onClose();
|
|
629
|
+
};
|
|
630
|
+
var handleInvite = /*#__PURE__*/function () {
|
|
631
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5, _ref6) {
|
|
632
|
+
var emails, skipEmail, subject, message, resetForm, sendEmail, payload, _yield$createInvitati, _yield$createInvitati2, invitedEmails, count;
|
|
633
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
634
|
+
while (1) switch (_context.prev = _context.next) {
|
|
635
|
+
case 0:
|
|
636
|
+
emails = _ref5.emails, skipEmail = _ref5.skipEmail, subject = _ref5.subject, message = _ref5.message;
|
|
637
|
+
resetForm = _ref6.resetForm;
|
|
638
|
+
sendEmail = !skipEmail;
|
|
639
|
+
payload = {
|
|
640
|
+
emails: pluck("value", emails),
|
|
641
|
+
sendEmail: sendEmail
|
|
642
|
+
};
|
|
643
|
+
if (invitationEmailProps && sendEmail) {
|
|
644
|
+
payload.configuration = buildTemplatePayload({
|
|
645
|
+
subject: subject,
|
|
646
|
+
message: message
|
|
647
|
+
}, invitationEmailProps);
|
|
648
|
+
}
|
|
649
|
+
_context.prev = 5;
|
|
650
|
+
_context.next = 8;
|
|
651
|
+
return createInvitations(payload);
|
|
652
|
+
case 8:
|
|
653
|
+
_yield$createInvitati = _context.sent;
|
|
654
|
+
_yield$createInvitati2 = _yield$createInvitati.invitedEmails;
|
|
655
|
+
invitedEmails = _yield$createInvitati2 === void 0 ? [] : _yield$createInvitati2;
|
|
656
|
+
count = invitedEmails.length;
|
|
657
|
+
if (count > 0) {
|
|
658
|
+
Toastr.success(t("neetoAccessControl.toasts.".concat(sendEmail ? "invited" : "added"), {
|
|
659
|
+
count: count
|
|
660
|
+
}));
|
|
661
|
+
}
|
|
662
|
+
resetForm({
|
|
663
|
+
values: {
|
|
664
|
+
emails: [],
|
|
665
|
+
skipEmail: skipEmail,
|
|
666
|
+
subject: subject,
|
|
667
|
+
message: message
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
_context.next = 19;
|
|
671
|
+
break;
|
|
672
|
+
case 16:
|
|
673
|
+
_context.prev = 16;
|
|
674
|
+
_context.t0 = _context["catch"](5);
|
|
675
|
+
Toastr.error(_context.t0);
|
|
676
|
+
case 19:
|
|
677
|
+
case "end":
|
|
678
|
+
return _context.stop();
|
|
679
|
+
}
|
|
680
|
+
}, _callee, null, [[5, 16]]);
|
|
681
|
+
}));
|
|
682
|
+
return function handleInvite(_x, _x2) {
|
|
683
|
+
return _ref7.apply(this, arguments);
|
|
228
684
|
};
|
|
229
|
-
|
|
685
|
+
}();
|
|
686
|
+
var handleRevoke = function handleRevoke() {
|
|
687
|
+
var count = emailsToRevoke.length;
|
|
688
|
+
revokeInvitations({
|
|
689
|
+
emails: pluck("email", emailsToRevoke)
|
|
690
|
+
}, {
|
|
230
691
|
onSuccess: function onSuccess() {
|
|
692
|
+
Toastr.success(t("neetoAccessControl.toasts.revoked", {
|
|
693
|
+
count: count
|
|
694
|
+
}));
|
|
231
695
|
setSelectedEmails([]);
|
|
232
|
-
|
|
696
|
+
setEmailsToRevoke([]);
|
|
233
697
|
onDestroyInvitationsSuccess();
|
|
234
|
-
}
|
|
698
|
+
},
|
|
699
|
+
onError: Toastr.error
|
|
235
700
|
});
|
|
236
701
|
};
|
|
237
|
-
var
|
|
238
|
-
|
|
239
|
-
|
|
702
|
+
var handleResend = function handleResend(_ref8) {
|
|
703
|
+
var _resendingPayload$ema;
|
|
704
|
+
var email = _ref8.email;
|
|
705
|
+
if (isResending && includes(email, (_resendingPayload$ema = resendingPayload === null || resendingPayload === void 0 ? void 0 : resendingPayload.emails) !== null && _resendingPayload$ema !== void 0 ? _resendingPayload$ema : [])) return;
|
|
706
|
+
resendInvitations({
|
|
707
|
+
emails: [email]
|
|
708
|
+
}, {
|
|
709
|
+
onSuccess: function onSuccess() {
|
|
710
|
+
return Toastr.success(t("neetoAccessControl.toasts.resent", {
|
|
711
|
+
email: email
|
|
712
|
+
}));
|
|
713
|
+
},
|
|
714
|
+
onError: Toastr.error
|
|
715
|
+
});
|
|
716
|
+
};
|
|
717
|
+
var description = isSetup ? t("neetoAccessControl.invitations.description.setup", {
|
|
718
|
+
context: translationContext
|
|
719
|
+
}) : showTabs && t("neetoAccessControl.invitations.description.".concat(activeTab), {
|
|
720
|
+
context: translationContext
|
|
721
|
+
});
|
|
722
|
+
var invitedList = /*#__PURE__*/jsx(InvitedList, {
|
|
723
|
+
configurationId: configurationId,
|
|
724
|
+
extraColumnsData: extraColumnsData,
|
|
725
|
+
invitationsCount: invitationsCount,
|
|
726
|
+
isOpen: isOpen,
|
|
727
|
+
ownerId: ownerId,
|
|
728
|
+
ownerType: ownerType,
|
|
729
|
+
selectedEmails: selectedEmails,
|
|
730
|
+
setSelectedEmails: setSelectedEmails,
|
|
731
|
+
canResend: !!invitationEmailProps,
|
|
732
|
+
onResend: handleResend,
|
|
733
|
+
onRevoke: setEmailsToRevoke
|
|
734
|
+
});
|
|
735
|
+
var inviteButton = isNotEmpty(inviteButtonProps) && /*#__PURE__*/jsx("div", {
|
|
736
|
+
className: "flex w-full justify-end",
|
|
737
|
+
children: /*#__PURE__*/jsx(Button, _objectSpread$4({}, inviteButtonProps))
|
|
738
|
+
});
|
|
739
|
+
var renderBody = function renderBody() {
|
|
740
|
+
if (isSetup) {
|
|
741
|
+
return /*#__PURE__*/jsx(AddEmails, {
|
|
742
|
+
invitationEmailProps: invitationEmailProps,
|
|
743
|
+
translationContext: translationContext,
|
|
744
|
+
isSetup: true,
|
|
745
|
+
initialValues: addEmailsInitialValues,
|
|
746
|
+
onCancel: onClose,
|
|
747
|
+
onSubmit: handleStage
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
if (!showTabs) {
|
|
751
|
+
return /*#__PURE__*/jsxs(Sheet.Body, {
|
|
752
|
+
className: "space-y-4 pt-2",
|
|
753
|
+
children: [inviteButton, invitedList]
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return /*#__PURE__*/jsxs(Tabs, {
|
|
757
|
+
className: "flex min-h-0 flex-1 flex-col gap-0",
|
|
758
|
+
value: activeTab,
|
|
759
|
+
onValueChange: setActiveTab,
|
|
760
|
+
children: [/*#__PURE__*/jsxs(Tabs.List, {
|
|
761
|
+
className: "mx-6 shrink-0",
|
|
762
|
+
variant: "line",
|
|
763
|
+
children: [/*#__PURE__*/jsx(Tabs.Item, {
|
|
764
|
+
dataTestid: "add-people-tab",
|
|
765
|
+
value: TABS.ADD_PEOPLE,
|
|
766
|
+
children: t("neetoAccessControl.titles.addPeople")
|
|
767
|
+
}), /*#__PURE__*/jsx(Tabs.Item, {
|
|
768
|
+
dataTestid: "invited-tab",
|
|
769
|
+
value: TABS.INVITED,
|
|
770
|
+
children: isNil(invitationsCount) ? t("neetoAccessControl.titles.invited") : t("neetoAccessControl.titles.invitedWithCount", {
|
|
771
|
+
count: invitationsCount
|
|
772
|
+
})
|
|
773
|
+
})]
|
|
774
|
+
}), /*#__PURE__*/jsxs(Sheet.Body, {
|
|
775
|
+
className: "space-y-4 pt-4",
|
|
776
|
+
children: [inviteButton, /*#__PURE__*/jsx(Tabs.Content, {
|
|
777
|
+
className: "w-full",
|
|
778
|
+
value: TABS.ADD_PEOPLE,
|
|
779
|
+
children: /*#__PURE__*/jsx(AddEmails, {
|
|
780
|
+
invitationEmailProps: invitationEmailProps,
|
|
781
|
+
translationContext: translationContext,
|
|
782
|
+
initialValues: addEmailsInitialValues,
|
|
783
|
+
onSubmit: handleInvite
|
|
784
|
+
})
|
|
785
|
+
}), /*#__PURE__*/jsx(Tabs.Content, {
|
|
786
|
+
className: "h-full w-full",
|
|
787
|
+
value: TABS.INVITED,
|
|
788
|
+
children: invitedList
|
|
789
|
+
})]
|
|
790
|
+
})]
|
|
791
|
+
});
|
|
240
792
|
};
|
|
241
793
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
242
794
|
children: [/*#__PURE__*/jsxs(Sheet, {
|
|
243
795
|
isOpen: isOpen,
|
|
796
|
+
onClose: onClose,
|
|
244
797
|
size: "large",
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
children: /*#__PURE__*/jsx(Sheet.Title, {
|
|
798
|
+
children: [/*#__PURE__*/jsxs(Sheet.Header, {
|
|
799
|
+
children: [/*#__PURE__*/jsx(Sheet.Title, {
|
|
248
800
|
children: t("neetoAccessControl.titles.invitations")
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
children: [isNotEmpty(inviteButtonProps) && /*#__PURE__*/jsx("div", {
|
|
253
|
-
className: "flex w-full justify-end",
|
|
254
|
-
children: /*#__PURE__*/jsx(Button$1, _objectSpread$4({}, inviteButtonProps))
|
|
255
|
-
}), !hideAddEmailsForm && /*#__PURE__*/jsx(AddEmails, {
|
|
256
|
-
configurationId: configurationId,
|
|
257
|
-
ownerId: ownerId,
|
|
258
|
-
ownerType: ownerType
|
|
259
|
-
}), isNotEmpty(invitations) ? /*#__PURE__*/jsxs(Fragment, {
|
|
260
|
-
children: [/*#__PURE__*/jsx(SubHeader, {
|
|
261
|
-
leftActionBlock: isEmpty(selectedEmails) ? /*#__PURE__*/jsx(Typography, {
|
|
262
|
-
className: "min-h-8",
|
|
263
|
-
variant: "h6",
|
|
264
|
-
children: t("neetoAccessControl.titles.emailsWithCount", {
|
|
265
|
-
count: totalCount
|
|
266
|
-
})
|
|
267
|
-
}) : /*#__PURE__*/jsxs("div", {
|
|
268
|
-
className: "flex items-center gap-x-4",
|
|
269
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
270
|
-
variant: "h6",
|
|
271
|
-
children: t("neetoAccessControl.titles.selectedEmailsWithCount", {
|
|
272
|
-
selectedCount: selectedEmails.length,
|
|
273
|
-
count: totalCount
|
|
274
|
-
})
|
|
275
|
-
}), /*#__PURE__*/jsx(Tooltip, {
|
|
276
|
-
content: t("neetoAccessControl.labels.delete"),
|
|
277
|
-
children: /*#__PURE__*/jsx(Button$1, {
|
|
278
|
-
"aria-label": t("neetoAccessControl.labels.delete"),
|
|
279
|
-
"data-testid": "bulk-delete-invitations-button",
|
|
280
|
-
icon: Trash2,
|
|
281
|
-
variant: "outline",
|
|
282
|
-
onClick: function onClick() {
|
|
283
|
-
return setShowDeleteAlert(true);
|
|
284
|
-
}
|
|
285
|
-
})
|
|
286
|
-
})]
|
|
287
|
-
})
|
|
288
|
-
}), /*#__PURE__*/jsx(DataTable, {
|
|
289
|
-
totalCount: totalCount,
|
|
290
|
-
enableRowSelection: true,
|
|
291
|
-
fixedHeight: true,
|
|
292
|
-
currentPage: page,
|
|
293
|
-
data: invitations,
|
|
294
|
-
enableColumnFreeze: false,
|
|
295
|
-
getRowId: function getRowId(_ref2) {
|
|
296
|
-
var id = _ref2.id;
|
|
297
|
-
return String(id);
|
|
298
|
-
},
|
|
299
|
-
loading: isFetching,
|
|
300
|
-
pageSize: DEFAULT_PAGE_SIZE,
|
|
301
|
-
selectedRowKeys: selectedEmails.map(function (_ref3) {
|
|
302
|
-
var id = _ref3.id;
|
|
303
|
-
return String(id);
|
|
304
|
-
}),
|
|
305
|
-
columns: renderColumnData({
|
|
306
|
-
onDelete: handleDeleteAction,
|
|
307
|
-
extraColumnsData: extraColumnsData
|
|
308
|
-
}),
|
|
309
|
-
onPageChange: function onPageChange(index) {
|
|
310
|
-
return setPage(index);
|
|
311
|
-
},
|
|
312
|
-
onRowSelect: function onRowSelect(_, selectedRows) {
|
|
313
|
-
return setSelectedEmails(selectedRows);
|
|
314
|
-
}
|
|
315
|
-
})]
|
|
316
|
-
}) : /*#__PURE__*/jsxs("div", {
|
|
317
|
-
className: "flex h-full w-full justify-center",
|
|
318
|
-
children: [!isLoading && /*#__PURE__*/jsx(Empty, {
|
|
319
|
-
icon: Users,
|
|
320
|
-
title: t("neetoAccessControl.labels.noInvitations")
|
|
321
|
-
}), isLoading && /*#__PURE__*/jsx("div", {
|
|
322
|
-
className: "flex h-full w-full items-center justify-center",
|
|
323
|
-
children: /*#__PURE__*/jsx(Spinner, {})
|
|
324
|
-
})]
|
|
801
|
+
}), description && /*#__PURE__*/jsx(Sheet.Description, {
|
|
802
|
+
"data-testid": "invitations-pane-description",
|
|
803
|
+
children: description
|
|
325
804
|
})]
|
|
326
|
-
})]
|
|
805
|
+
}), renderBody()]
|
|
327
806
|
}), /*#__PURE__*/jsx(Alert, {
|
|
328
|
-
isOpen:
|
|
329
|
-
isSubmitting:
|
|
330
|
-
submitButtonLabel: t("neetoAccessControl.labels.
|
|
807
|
+
isOpen: isNotEmpty(emailsToRevoke),
|
|
808
|
+
isSubmitting: isRevoking,
|
|
809
|
+
submitButtonLabel: t("neetoAccessControl.labels.revokeAccess"),
|
|
810
|
+
title: t("neetoAccessControl.alerts.revokeAccess.title"),
|
|
331
811
|
message: /*#__PURE__*/jsx(Trans, {
|
|
332
|
-
components:
|
|
812
|
+
components: {
|
|
333
813
|
strong: /*#__PURE__*/jsx("strong", {})
|
|
334
|
-
}
|
|
335
|
-
|
|
814
|
+
},
|
|
815
|
+
context: translationContext,
|
|
816
|
+
count: emailsToRevoke.length,
|
|
817
|
+
i18nKey: "neetoAccessControl.alerts.revokeAccess.message",
|
|
336
818
|
values: {
|
|
337
|
-
count:
|
|
338
|
-
email: (
|
|
819
|
+
count: emailsToRevoke.length,
|
|
820
|
+
email: (_emailsToRevoke$ = emailsToRevoke[0]) === null || _emailsToRevoke$ === void 0 ? void 0 : _emailsToRevoke$.email
|
|
339
821
|
}
|
|
340
822
|
}),
|
|
341
|
-
title: t("neetoAccessControl.alerts.deleteInviation.title", {
|
|
342
|
-
count: selectedEmails.length
|
|
343
|
-
}),
|
|
344
823
|
onClose: function onClose() {
|
|
345
|
-
return
|
|
824
|
+
return setEmailsToRevoke([]);
|
|
346
825
|
},
|
|
347
|
-
onSubmit:
|
|
826
|
+
onSubmit: handleRevoke
|
|
348
827
|
})]
|
|
349
828
|
});
|
|
350
829
|
};
|
|
@@ -391,13 +870,19 @@ var DEFAULT_CONFIGURATION_VALUES = {
|
|
|
391
870
|
password: "",
|
|
392
871
|
allowedKeywords: [""]
|
|
393
872
|
};
|
|
873
|
+
var INVITATION_FIELDS = ["invitationsCount", "invitationEmailSubject", "invitationEmailMessage"];
|
|
394
874
|
|
|
395
875
|
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; }
|
|
396
876
|
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), true).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; }
|
|
397
|
-
var
|
|
398
|
-
var
|
|
399
|
-
|
|
400
|
-
|
|
877
|
+
var buildVariableTag = function buildVariableTag(_ref) {
|
|
878
|
+
var key = _ref.key,
|
|
879
|
+
label = _ref.label;
|
|
880
|
+
return "<span data-variable=\"\" class=\"neeto-editor-variable\" data-id=\"".concat(key, "\" data-label=\"").concat(label, "\">{{").concat(key, "}}</span>");
|
|
881
|
+
};
|
|
882
|
+
var renderOneTimeLinkLabel = function renderOneTimeLinkLabel(_ref2) {
|
|
883
|
+
var translationContext = _ref2.translationContext,
|
|
884
|
+
transProps = _ref2.transProps,
|
|
885
|
+
oneTimeLinkHelpText = _ref2.oneTimeLinkHelpText;
|
|
401
886
|
return /*#__PURE__*/jsxs(Typography, {
|
|
402
887
|
as: "span",
|
|
403
888
|
className: "inline-flex items-center gap-2",
|
|
@@ -411,6 +896,25 @@ var renderOneTimeLinkLabel = function renderOneTimeLinkLabel(_ref) {
|
|
|
411
896
|
})]
|
|
412
897
|
});
|
|
413
898
|
};
|
|
899
|
+
var renderSetupNote = function renderSetupNote(stagedInvitations) {
|
|
900
|
+
return stagedInvitations ? /*#__PURE__*/jsx(Callout, {
|
|
901
|
+
"data-testid": "staged-invitations-note",
|
|
902
|
+
variant: "info",
|
|
903
|
+
children: /*#__PURE__*/jsxs(Typography, {
|
|
904
|
+
variant: "body2",
|
|
905
|
+
children: [/*#__PURE__*/jsx("strong", {
|
|
906
|
+
children: t("neetoAccessControl.invitations.stagedCount", {
|
|
907
|
+
count: stagedInvitations.emails.length
|
|
908
|
+
})
|
|
909
|
+
}), " ", stagedInvitations.sendEmail ? t("neetoAccessControl.invitations.willGetEmail") : t("neetoAccessControl.invitations.wontGetEmail")]
|
|
910
|
+
})
|
|
911
|
+
}) : /*#__PURE__*/jsx(Typography, {
|
|
912
|
+
className: "text-muted-foreground",
|
|
913
|
+
"data-testid": "add-at-least-one-email-text",
|
|
914
|
+
variant: "body2",
|
|
915
|
+
children: t("neetoAccessControl.invitations.addAtLeastOne")
|
|
916
|
+
});
|
|
917
|
+
};
|
|
414
918
|
var buildConfigurationInitialValues = function buildConfigurationInitialValues(configuration) {
|
|
415
919
|
if (configuration.auth === AUTH.NO) {
|
|
416
920
|
return DEFAULT_CONFIGURATION_VALUES;
|
|
@@ -418,12 +922,12 @@ var buildConfigurationInitialValues = function buildConfigurationInitialValues(c
|
|
|
418
922
|
if (isEmpty(configuration.allowedKeywords)) {
|
|
419
923
|
configuration.allowedKeywords.push("");
|
|
420
924
|
}
|
|
421
|
-
return configuration;
|
|
925
|
+
return omit(INVITATION_FIELDS, configuration);
|
|
422
926
|
};
|
|
423
|
-
var removeKeyword = function removeKeyword(
|
|
424
|
-
var arrayHelpers =
|
|
425
|
-
index =
|
|
426
|
-
allowedKeywords =
|
|
927
|
+
var removeKeyword = function removeKeyword(_ref3) {
|
|
928
|
+
var arrayHelpers = _ref3.arrayHelpers,
|
|
929
|
+
index = _ref3.index,
|
|
930
|
+
allowedKeywords = _ref3.allowedKeywords;
|
|
427
931
|
if (allowedKeywords.length === 1) {
|
|
428
932
|
arrayHelpers.remove(index);
|
|
429
933
|
arrayHelpers.push("");
|
|
@@ -444,12 +948,31 @@ var buildPayload = function buildPayload(values) {
|
|
|
444
948
|
}
|
|
445
949
|
return payload;
|
|
446
950
|
};
|
|
447
|
-
var
|
|
448
|
-
|
|
951
|
+
var buildEmailTemplate = function buildEmailTemplate(configuration, stagedInvitations) {
|
|
952
|
+
return stagedInvitations !== null && stagedInvitations !== void 0 && stagedInvitations.sendEmail && has("invitationEmailSubject", stagedInvitations) ? {
|
|
953
|
+
subject: stagedInvitations.invitationEmailSubject,
|
|
954
|
+
message: stagedInvitations.invitationEmailMessage
|
|
955
|
+
} : {
|
|
956
|
+
subject: configuration.invitationEmailSubject,
|
|
957
|
+
message: configuration.invitationEmailMessage
|
|
958
|
+
};
|
|
959
|
+
};
|
|
960
|
+
var buildSetupToastMessage = function buildSetupToastMessage(_ref4) {
|
|
961
|
+
var count = _ref4.count,
|
|
962
|
+
sendEmail = _ref4.sendEmail;
|
|
963
|
+
if (count === 0) return t("neetoAccessControl.toasts.updated");
|
|
964
|
+
return sendEmail ? t("neetoAccessControl.toasts.updatedAndInvited", {
|
|
965
|
+
count: count
|
|
966
|
+
}) : t("neetoAccessControl.toasts.updatedAndAdded", {
|
|
967
|
+
count: count
|
|
968
|
+
});
|
|
969
|
+
};
|
|
970
|
+
var renderLabelWithViewInvitation = function renderLabelWithViewInvitation(_ref5) {
|
|
971
|
+
var onViewInvites = _ref5.onViewInvites;
|
|
449
972
|
return /*#__PURE__*/jsx(Trans, {
|
|
450
973
|
i18nKey: "neetoAccessControl.auth.invitedWithViewButton",
|
|
451
974
|
components: {
|
|
452
|
-
button: /*#__PURE__*/jsx(Button
|
|
975
|
+
button: /*#__PURE__*/jsx(Button, {
|
|
453
976
|
className: "mt-1",
|
|
454
977
|
"data-testid": "view-invites-button",
|
|
455
978
|
size: "sm",
|
|
@@ -459,12 +982,50 @@ var renderLabelWithViewInvitation = function renderLabelWithViewInvitation(_ref3
|
|
|
459
982
|
}
|
|
460
983
|
});
|
|
461
984
|
};
|
|
462
|
-
var
|
|
463
|
-
var
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
985
|
+
var renderInviteOnlyLabel = function renderInviteOnlyLabel(_ref6) {
|
|
986
|
+
var label = _ref6.label,
|
|
987
|
+
isSavedInviteOnly = _ref6.isSavedInviteOnly,
|
|
988
|
+
invitationsCount = _ref6.invitationsCount,
|
|
989
|
+
stagedInvitations = _ref6.stagedInvitations,
|
|
990
|
+
onOpenInvitations = _ref6.onOpenInvitations;
|
|
991
|
+
return /*#__PURE__*/jsxs("span", {
|
|
992
|
+
className: "flex flex-col gap-y-2",
|
|
993
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
994
|
+
className: "inline-flex flex-wrap items-center gap-x-2",
|
|
995
|
+
children: [label, /*#__PURE__*/jsx(Button, {
|
|
996
|
+
"data-testid": "add-people-button",
|
|
997
|
+
label: t("neetoAccessControl.buttons.addPeople"),
|
|
998
|
+
size: "sm",
|
|
999
|
+
variant: "link",
|
|
1000
|
+
onClick: function onClick() {
|
|
1001
|
+
return onOpenInvitations(TABS.ADD_PEOPLE);
|
|
1002
|
+
}
|
|
1003
|
+
}), isSavedInviteOnly && /*#__PURE__*/jsxs(Fragment, {
|
|
1004
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1005
|
+
"aria-hidden": true,
|
|
1006
|
+
className: "text-muted-foreground",
|
|
1007
|
+
children: "\xB7"
|
|
1008
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1009
|
+
"data-testid": "view-invites-button",
|
|
1010
|
+
size: "sm",
|
|
1011
|
+
variant: "link",
|
|
1012
|
+
label: t("neetoAccessControl.titles.invitedWithCount", {
|
|
1013
|
+
count: invitationsCount !== null && invitationsCount !== void 0 ? invitationsCount : 0
|
|
1014
|
+
}),
|
|
1015
|
+
onClick: function onClick() {
|
|
1016
|
+
return onOpenInvitations(TABS.INVITED);
|
|
1017
|
+
}
|
|
1018
|
+
})]
|
|
1019
|
+
})]
|
|
1020
|
+
}), !isSavedInviteOnly && renderSetupNote(stagedInvitations)]
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
1023
|
+
var getAuthOptions = function getAuthOptions(_ref7) {
|
|
1024
|
+
var translationContext = _ref7.translationContext,
|
|
1025
|
+
transProps = _ref7.transProps,
|
|
1026
|
+
_ref7$showOneTimeLink = _ref7.showOneTimeLinkOption,
|
|
1027
|
+
showOneTimeLinkOption = _ref7$showOneTimeLink === void 0 ? false : _ref7$showOneTimeLink,
|
|
1028
|
+
oneTimeLinkHelpText = _ref7.oneTimeLinkHelpText;
|
|
468
1029
|
return [{
|
|
469
1030
|
label: /*#__PURE__*/jsx(Trans, _objectSpread$3({
|
|
470
1031
|
context: translationContext,
|
|
@@ -510,6 +1071,25 @@ var getAuthOptions = function getAuthOptions(_ref4) {
|
|
|
510
1071
|
"data-testid": "access-control-one-time-link-only-radio-input"
|
|
511
1072
|
}] : []));
|
|
512
1073
|
};
|
|
1074
|
+
var withDefaultInvitationEmail = function withDefaultInvitationEmail(invitationEmailProps, defaultInvitationEmail) {
|
|
1075
|
+
if (!invitationEmailProps) return invitationEmailProps;
|
|
1076
|
+
var _invitationEmailProps = invitationEmailProps.variables,
|
|
1077
|
+
variables = _invitationEmailProps === void 0 ? [] : _invitationEmailProps;
|
|
1078
|
+
var _ref8 = defaultInvitationEmail !== null && defaultInvitationEmail !== void 0 ? defaultInvitationEmail : {},
|
|
1079
|
+
_ref8$subject = _ref8.subject,
|
|
1080
|
+
subject = _ref8$subject === void 0 ? "" : _ref8$subject,
|
|
1081
|
+
_ref8$message = _ref8.message,
|
|
1082
|
+
message = _ref8$message === void 0 ? "" : _ref8$message;
|
|
1083
|
+
return _objectSpread$3(_objectSpread$3({}, invitationEmailProps), {}, {
|
|
1084
|
+
defaultSubject: subject,
|
|
1085
|
+
defaultMessage: message.replace(/{{\s*([\w.]+)\s*}}/g, function (tag, key) {
|
|
1086
|
+
var variable = findBy({
|
|
1087
|
+
key: key
|
|
1088
|
+
}, variables);
|
|
1089
|
+
return variable ? buildVariableTag(variable) : tag;
|
|
1090
|
+
})
|
|
1091
|
+
});
|
|
1092
|
+
};
|
|
513
1093
|
|
|
514
1094
|
var AllowedKeywords = withT(function (_ref) {
|
|
515
1095
|
var t = _ref.t,
|
|
@@ -541,7 +1121,7 @@ var AllowedKeywords = withT(function (_ref) {
|
|
|
541
1121
|
className: "w-full",
|
|
542
1122
|
name: "".concat(name, ".").concat(index),
|
|
543
1123
|
placeholder: t("neetoAccessControl.inputs.placeholders.enterKeyword"),
|
|
544
|
-
suffix: showDeleteButton && /*#__PURE__*/jsx(Button
|
|
1124
|
+
suffix: showDeleteButton && /*#__PURE__*/jsx(Button, {
|
|
545
1125
|
"data-testid": "allowed-keyword-delete-button",
|
|
546
1126
|
icon: Trash2,
|
|
547
1127
|
size: "sm",
|
|
@@ -556,7 +1136,7 @@ var AllowedKeywords = withT(function (_ref) {
|
|
|
556
1136
|
})
|
|
557
1137
|
})
|
|
558
1138
|
}, index);
|
|
559
|
-
}), /*#__PURE__*/jsx(Button
|
|
1139
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
560
1140
|
"data-testid": "add-allowed-keyword-button",
|
|
561
1141
|
icon: Plus,
|
|
562
1142
|
iconPosition: "left",
|
|
@@ -570,23 +1150,37 @@ var AllowedKeywords = withT(function (_ref) {
|
|
|
570
1150
|
});
|
|
571
1151
|
});
|
|
572
1152
|
|
|
573
|
-
var _excluded = ["savedAuth", "onViewInvites", "label"];
|
|
1153
|
+
var _excluded$1 = ["savedAuth", "onViewInvites", "inviteOnlyProps", "label"];
|
|
574
1154
|
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; }
|
|
575
1155
|
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), true).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; }
|
|
576
1156
|
var AuthOption = function AuthOption(_ref) {
|
|
577
1157
|
var savedAuth = _ref.savedAuth,
|
|
578
1158
|
onViewInvites = _ref.onViewInvites,
|
|
1159
|
+
inviteOnlyProps = _ref.inviteOnlyProps,
|
|
579
1160
|
label = _ref.label,
|
|
580
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
581
|
-
var
|
|
1161
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
1162
|
+
var _useFormikContext = useFormikContext(),
|
|
1163
|
+
values = _useFormikContext.values;
|
|
1164
|
+
var isInviteOnlyOption = props.value === AUTH.INVITED;
|
|
1165
|
+
var isSavedInviteOnly = isInviteOnlyOption && savedAuth === AUTH.INVITED;
|
|
1166
|
+
var renderLabel = function renderLabel() {
|
|
1167
|
+
if (!isInviteOnlyOption) return label;
|
|
1168
|
+
if (inviteOnlyProps !== null && inviteOnlyProps !== void 0 && inviteOnlyProps.supportsSetup) {
|
|
1169
|
+
return values.auth === AUTH.INVITED ? renderInviteOnlyLabel(_objectSpread$2({
|
|
1170
|
+
label: label,
|
|
1171
|
+
isSavedInviteOnly: isSavedInviteOnly
|
|
1172
|
+
}, inviteOnlyProps)) : label;
|
|
1173
|
+
}
|
|
1174
|
+
return isSavedInviteOnly ? renderLabelWithViewInvitation({
|
|
1175
|
+
onViewInvites: onViewInvites
|
|
1176
|
+
}) : label;
|
|
1177
|
+
};
|
|
582
1178
|
return /*#__PURE__*/jsx(RadioGroup.Item, _objectSpread$2(_objectSpread$2({}, props), {}, {
|
|
583
1179
|
className: classNames({
|
|
584
|
-
"items-start":
|
|
1180
|
+
"items-start": isInviteOnlyOption
|
|
585
1181
|
}),
|
|
586
1182
|
id: props.value,
|
|
587
|
-
label:
|
|
588
|
-
onViewInvites: onViewInvites
|
|
589
|
-
}) : label
|
|
1183
|
+
label: renderLabel()
|
|
590
1184
|
}));
|
|
591
1185
|
};
|
|
592
1186
|
|
|
@@ -610,46 +1204,69 @@ var Header = function Header(_ref) {
|
|
|
610
1204
|
}));
|
|
611
1205
|
};
|
|
612
1206
|
|
|
1207
|
+
var _excluded = ["emails", "sendEmail"];
|
|
613
1208
|
function ownKeys(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; }
|
|
614
1209
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
615
|
-
var
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
1210
|
+
var InviteOnlySelectionWatcher = function InviteOnlySelectionWatcher(_ref) {
|
|
1211
|
+
var auth = _ref.auth,
|
|
1212
|
+
onChange = _ref.onChange;
|
|
1213
|
+
var previousAuth = useRef(auth);
|
|
1214
|
+
var onChangeRef = useRef(onChange);
|
|
1215
|
+
onChangeRef.current = onChange;
|
|
1216
|
+
useEffect(function () {
|
|
1217
|
+
if (previousAuth.current === auth) return;
|
|
1218
|
+
previousAuth.current = auth;
|
|
1219
|
+
onChangeRef.current(auth);
|
|
1220
|
+
}, [auth]);
|
|
1221
|
+
return null;
|
|
1222
|
+
};
|
|
1223
|
+
var Configuration = function Configuration(_ref2) {
|
|
1224
|
+
var ownerId = _ref2.ownerId,
|
|
1225
|
+
ownerType = _ref2.ownerType,
|
|
1226
|
+
onReset = _ref2.onReset,
|
|
1227
|
+
_ref2$onSuccess = _ref2.onSuccess,
|
|
1228
|
+
_onSuccess = _ref2$onSuccess === void 0 ? noop : _ref2$onSuccess,
|
|
1229
|
+
headerProps = _ref2.headerProps,
|
|
1230
|
+
className = _ref2.className,
|
|
1231
|
+
_ref2$handleCancel = _ref2.handleCancel,
|
|
1232
|
+
handleCancel = _ref2$handleCancel === void 0 ? noop : _ref2$handleCancel,
|
|
1233
|
+
_ref2$onConfiguration = _ref2.onConfigurationChangedToInviteOnly,
|
|
1234
|
+
onConfigurationChangedToInviteOnly = _ref2$onConfiguration === void 0 ? noop : _ref2$onConfiguration,
|
|
1235
|
+
_ref2$invitationsTabl = _ref2.invitationsTableExtraColumnsData,
|
|
1236
|
+
invitationsTableExtraColumnsData = _ref2$invitationsTabl === void 0 ? [] : _ref2$invitationsTabl,
|
|
1237
|
+
_ref2$hideAddEmailsFr = _ref2.hideAddEmailsFromInvitationPane,
|
|
1238
|
+
hideAddEmailsFromInvitationPane = _ref2$hideAddEmailsFr === void 0 ? false : _ref2$hideAddEmailsFr,
|
|
1239
|
+
_ref2$enableNavigatio = _ref2.enableNavigationBlocking,
|
|
1240
|
+
enableNavigationBlocking = _ref2$enableNavigatio === void 0 ? false : _ref2$enableNavigatio,
|
|
1241
|
+
_ref2$onDestroyInvita = _ref2.onDestroyInvitationsSuccess,
|
|
1242
|
+
onDestroyInvitationsSuccess = _ref2$onDestroyInvita === void 0 ? noop : _ref2$onDestroyInvita,
|
|
1243
|
+
_ref2$inviteButtonPro = _ref2.inviteButtonProps,
|
|
1244
|
+
inviteButtonProps = _ref2$inviteButtonPro === void 0 ? {} : _ref2$inviteButtonPro,
|
|
1245
|
+
_ref2$additionalField = _ref2.additionalFieldsInitialValues,
|
|
1246
|
+
additionalFieldsInitialValues = _ref2$additionalField === void 0 ? {} : _ref2$additionalField,
|
|
1247
|
+
children = _ref2.children,
|
|
1248
|
+
fieldsWrapper = _ref2.fieldsWrapper,
|
|
1249
|
+
translationContext = _ref2.translationContext,
|
|
1250
|
+
_ref2$transProps = _ref2.transProps,
|
|
1251
|
+
transProps = _ref2$transProps === void 0 ? {} : _ref2$transProps,
|
|
1252
|
+
_ref2$groupSignInOpti = _ref2.groupSignInOptions,
|
|
1253
|
+
groupSignInOptions = _ref2$groupSignInOpti === void 0 ? false : _ref2$groupSignInOpti,
|
|
1254
|
+
_ref2$showOneTimeLink = _ref2.showOneTimeLinkOption,
|
|
1255
|
+
showOneTimeLinkOption = _ref2$showOneTimeLink === void 0 ? false : _ref2$showOneTimeLink,
|
|
1256
|
+
oneTimeLinkHelpText = _ref2.oneTimeLinkHelpText,
|
|
1257
|
+
invitationEmailProps = _ref2.invitationEmailProps;
|
|
649
1258
|
var _useState = useState(false),
|
|
650
1259
|
_useState2 = _slicedToArray(_useState, 2),
|
|
651
1260
|
showInvitationsPane = _useState2[0],
|
|
652
1261
|
setShowInvitationsPane = _useState2[1];
|
|
1262
|
+
var _useState3 = useState(TABS.ADD_PEOPLE),
|
|
1263
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1264
|
+
invitationsPaneTab = _useState4[0],
|
|
1265
|
+
setInvitationsPaneTab = _useState4[1];
|
|
1266
|
+
var _useState5 = useState(null),
|
|
1267
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1268
|
+
stagedInvitations = _useState6[0],
|
|
1269
|
+
setStagedInvitations = _useState6[1];
|
|
653
1270
|
var FieldsWrapper = fieldsWrapper || Fragment$1;
|
|
654
1271
|
var _useTranslation = useTranslation(),
|
|
655
1272
|
t = _useTranslation.t;
|
|
@@ -659,9 +1276,15 @@ var Configuration = function Configuration(_ref) {
|
|
|
659
1276
|
}),
|
|
660
1277
|
_useShowConfiguration2 = _useShowConfiguration.data,
|
|
661
1278
|
configuration = _useShowConfiguration2 === void 0 ? {} : _useShowConfiguration2,
|
|
662
|
-
isLoading = _useShowConfiguration.isLoading
|
|
663
|
-
|
|
1279
|
+
isLoading = _useShowConfiguration.isLoading;
|
|
1280
|
+
var emailProps = useMemo(function () {
|
|
1281
|
+
return withDefaultInvitationEmail(invitationEmailProps, configuration.defaultInvitationEmail);
|
|
1282
|
+
}, [invitationEmailProps, configuration.defaultInvitationEmail]);
|
|
664
1283
|
var configurationInitialValues = mergeLeft(buildConfigurationInitialValues(configuration), additionalFieldsInitialValues);
|
|
1284
|
+
var supportsSetup = !hideAddEmailsFromInvitationPane;
|
|
1285
|
+
var savedAuth = configuration === null || configuration === void 0 ? void 0 : configuration.auth;
|
|
1286
|
+
var isSavedInviteOnly = savedAuth === AUTH.INVITED;
|
|
1287
|
+
var isSetup = supportsSetup && !isSavedInviteOnly;
|
|
665
1288
|
var _useUpdateConfigurati = useUpdateConfiguration({
|
|
666
1289
|
ownerId: ownerId,
|
|
667
1290
|
ownerType: ownerType
|
|
@@ -670,16 +1293,108 @@ var Configuration = function Configuration(_ref) {
|
|
|
670
1293
|
var _values$configuration = values.configuration,
|
|
671
1294
|
_values$configuration2 = _values$configuration === void 0 ? {} : _values$configuration,
|
|
672
1295
|
auth = _values$configuration2.auth;
|
|
673
|
-
if (auth === AUTH.INVITED) {
|
|
1296
|
+
if (auth === AUTH.INVITED && (!supportsSetup || onConfigurationChangedToInviteOnly !== noop)) {
|
|
674
1297
|
handleShowInvitations();
|
|
675
1298
|
}
|
|
676
1299
|
_onSuccess(values);
|
|
677
1300
|
}
|
|
678
1301
|
}),
|
|
679
1302
|
updateConfiguration = _useUpdateConfigurati.mutateAsync;
|
|
1303
|
+
var _useCreateConfigurati = useCreateConfigurationInvitations({
|
|
1304
|
+
ownerId: ownerId,
|
|
1305
|
+
ownerType: ownerType
|
|
1306
|
+
}),
|
|
1307
|
+
createInvitations = _useCreateConfigurati.mutateAsync;
|
|
1308
|
+
var saveWithStagedInvitations = /*#__PURE__*/function () {
|
|
1309
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
|
|
1310
|
+
var emails, sendEmail, emailTemplate, config, invitedEmails, _yield$updateConfigur, _yield$updateConfigur2, _yield$updateConfigur3, savedConfiguration, _yield$createInvitati, _yield$createInvitati2;
|
|
1311
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1312
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1313
|
+
case 0:
|
|
1314
|
+
emails = stagedInvitations.emails, sendEmail = stagedInvitations.sendEmail, emailTemplate = _objectWithoutProperties(stagedInvitations, _excluded);
|
|
1315
|
+
config = {
|
|
1316
|
+
showToastr: false
|
|
1317
|
+
};
|
|
1318
|
+
_context.prev = 2;
|
|
1319
|
+
invitedEmails = [];
|
|
1320
|
+
if (!invitationEmailProps) {
|
|
1321
|
+
_context.next = 12;
|
|
1322
|
+
break;
|
|
1323
|
+
}
|
|
1324
|
+
_context.next = 7;
|
|
1325
|
+
return updateConfiguration({
|
|
1326
|
+
payload: _objectSpread(_objectSpread(_objectSpread({}, payload), emailTemplate), {}, {
|
|
1327
|
+
invitations: {
|
|
1328
|
+
emails: emails,
|
|
1329
|
+
sendEmail: sendEmail
|
|
1330
|
+
}
|
|
1331
|
+
}),
|
|
1332
|
+
config: config
|
|
1333
|
+
});
|
|
1334
|
+
case 7:
|
|
1335
|
+
_yield$updateConfigur = _context.sent;
|
|
1336
|
+
_yield$updateConfigur2 = _yield$updateConfigur.invitedEmails;
|
|
1337
|
+
invitedEmails = _yield$updateConfigur2 === void 0 ? [] : _yield$updateConfigur2;
|
|
1338
|
+
_context.next = 21;
|
|
1339
|
+
break;
|
|
1340
|
+
case 12:
|
|
1341
|
+
_context.next = 14;
|
|
1342
|
+
return updateConfiguration({
|
|
1343
|
+
payload: payload,
|
|
1344
|
+
config: config
|
|
1345
|
+
});
|
|
1346
|
+
case 14:
|
|
1347
|
+
_yield$updateConfigur3 = _context.sent;
|
|
1348
|
+
savedConfiguration = _yield$updateConfigur3.configuration;
|
|
1349
|
+
_context.next = 18;
|
|
1350
|
+
return createInvitations({
|
|
1351
|
+
configurationId: savedConfiguration.id,
|
|
1352
|
+
payload: {
|
|
1353
|
+
emails: emails
|
|
1354
|
+
},
|
|
1355
|
+
config: config
|
|
1356
|
+
});
|
|
1357
|
+
case 18:
|
|
1358
|
+
_yield$createInvitati = _context.sent;
|
|
1359
|
+
_yield$createInvitati2 = _yield$createInvitati.invitedEmails;
|
|
1360
|
+
invitedEmails = _yield$createInvitati2 === void 0 ? [] : _yield$createInvitati2;
|
|
1361
|
+
case 21:
|
|
1362
|
+
setStagedInvitations(null);
|
|
1363
|
+
Toastr.success(buildSetupToastMessage({
|
|
1364
|
+
count: invitedEmails.length,
|
|
1365
|
+
sendEmail: sendEmail
|
|
1366
|
+
}));
|
|
1367
|
+
_context.next = 28;
|
|
1368
|
+
break;
|
|
1369
|
+
case 25:
|
|
1370
|
+
_context.prev = 25;
|
|
1371
|
+
_context.t0 = _context["catch"](2);
|
|
1372
|
+
Toastr.error(_context.t0);
|
|
1373
|
+
case 28:
|
|
1374
|
+
case "end":
|
|
1375
|
+
return _context.stop();
|
|
1376
|
+
}
|
|
1377
|
+
}, _callee, null, [[2, 25]]);
|
|
1378
|
+
}));
|
|
1379
|
+
return function saveWithStagedInvitations(_x) {
|
|
1380
|
+
return _ref3.apply(this, arguments);
|
|
1381
|
+
};
|
|
1382
|
+
}();
|
|
680
1383
|
var handleSubmit = function handleSubmit(values) {
|
|
681
1384
|
var payload = mergeLeft(buildPayload(values), pick(keys(additionalFieldsInitialValues), values));
|
|
682
|
-
|
|
1385
|
+
if (values.auth === AUTH.INVITED && stagedInvitations) {
|
|
1386
|
+
return saveWithStagedInvitations(payload);
|
|
1387
|
+
}
|
|
1388
|
+
return updateConfiguration({
|
|
1389
|
+
payload: payload
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
var handleReset = function handleReset() {
|
|
1393
|
+
setStagedInvitations(null);
|
|
1394
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1395
|
+
args[_key] = arguments[_key];
|
|
1396
|
+
}
|
|
1397
|
+
onReset === null || onReset === void 0 || onReset.apply(void 0, args);
|
|
683
1398
|
};
|
|
684
1399
|
var authOptions = getAuthOptions({
|
|
685
1400
|
translationContext: translationContext,
|
|
@@ -690,7 +1405,21 @@ var Configuration = function Configuration(_ref) {
|
|
|
690
1405
|
var authValues = pluck("value", authOptions);
|
|
691
1406
|
var isGrouped = groupSignInOptions && authValues.includes(AUTH.SESSION) && authValues.includes(AUTH.EMAIL);
|
|
692
1407
|
var handleViewInvites = function handleViewInvites() {
|
|
693
|
-
|
|
1408
|
+
setInvitationsPaneTab(TABS.INVITED);
|
|
1409
|
+
setShowInvitationsPane(true);
|
|
1410
|
+
};
|
|
1411
|
+
var handleOpenInvitations = function handleOpenInvitations(tab) {
|
|
1412
|
+
setInvitationsPaneTab(tab);
|
|
1413
|
+
setShowInvitationsPane(true);
|
|
1414
|
+
};
|
|
1415
|
+
var handleAuthChange = function handleAuthChange(auth) {
|
|
1416
|
+
if (auth !== AUTH.INVITED) {
|
|
1417
|
+
setStagedInvitations(null);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
if (supportsSetup && !isSavedInviteOnly && !stagedInvitations) {
|
|
1421
|
+
handleOpenInvitations(TABS.ADD_PEOPLE);
|
|
1422
|
+
}
|
|
694
1423
|
};
|
|
695
1424
|
var optionFor = function optionFor(value) {
|
|
696
1425
|
return findBy({
|
|
@@ -698,8 +1427,31 @@ var Configuration = function Configuration(_ref) {
|
|
|
698
1427
|
}, authOptions);
|
|
699
1428
|
};
|
|
700
1429
|
var savedAuthProps = {
|
|
701
|
-
savedAuth:
|
|
702
|
-
onViewInvites: handleViewInvites
|
|
1430
|
+
savedAuth: savedAuth,
|
|
1431
|
+
onViewInvites: handleViewInvites,
|
|
1432
|
+
inviteOnlyProps: {
|
|
1433
|
+
supportsSetup: supportsSetup,
|
|
1434
|
+
stagedInvitations: stagedInvitations,
|
|
1435
|
+
invitationsCount: configuration.invitationsCount,
|
|
1436
|
+
onOpenInvitations: handleOpenInvitations
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
var getSubmitButtonProps = function getSubmitButtonProps(_ref4, _ref5) {
|
|
1440
|
+
var auth = _ref4.auth;
|
|
1441
|
+
var dirty = _ref5.dirty,
|
|
1442
|
+
isSubmitting = _ref5.isSubmitting;
|
|
1443
|
+
if (auth !== AUTH.INVITED) return {};
|
|
1444
|
+
if (!supportsSetup) {
|
|
1445
|
+
return {
|
|
1446
|
+
label: t("neetoAccessControl.buttons.saveChangesAndInvite")
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
var needsPeople = !isSavedInviteOnly && !stagedInvitations;
|
|
1450
|
+
return _objectSpread({
|
|
1451
|
+
disabled: isSubmitting || !dirty || needsPeople
|
|
1452
|
+
}, (stagedInvitations === null || stagedInvitations === void 0 ? void 0 : stagedInvitations.sendEmail) && {
|
|
1453
|
+
label: t("neetoAccessControl.buttons.saveChangesAndInvite")
|
|
1454
|
+
});
|
|
703
1455
|
};
|
|
704
1456
|
var handleShowInvitations = onConfigurationChangedToInviteOnly === noop ? handleViewInvites : onConfigurationChangedToInviteOnly;
|
|
705
1457
|
return /*#__PURE__*/jsxs(Container, {
|
|
@@ -717,22 +1469,28 @@ var Configuration = function Configuration(_ref) {
|
|
|
717
1469
|
initialValues: configurationInitialValues,
|
|
718
1470
|
validationSchema: CONFIGURATION_VALIDATION_SCHEMA,
|
|
719
1471
|
onSubmit: handleSubmit,
|
|
720
|
-
onReset:
|
|
1472
|
+
onReset: handleReset,
|
|
721
1473
|
enableReinitialize: true
|
|
722
1474
|
},
|
|
723
|
-
children: function children(
|
|
724
|
-
var values =
|
|
725
|
-
setFieldValue =
|
|
1475
|
+
children: function children(_ref6) {
|
|
1476
|
+
var values = _ref6.values,
|
|
1477
|
+
setFieldValue = _ref6.setFieldValue,
|
|
1478
|
+
dirty = _ref6.dirty,
|
|
1479
|
+
isSubmitting = _ref6.isSubmitting;
|
|
726
1480
|
return /*#__PURE__*/jsxs(CardLayout, {
|
|
727
1481
|
actionBlock: /*#__PURE__*/jsx(ActionBlock, {
|
|
728
1482
|
cancelButtonProps: {
|
|
729
1483
|
onClick: handleCancel
|
|
730
1484
|
},
|
|
731
|
-
submitButtonProps: values
|
|
732
|
-
|
|
733
|
-
|
|
1485
|
+
submitButtonProps: getSubmitButtonProps(values, {
|
|
1486
|
+
dirty: dirty,
|
|
1487
|
+
isSubmitting: isSubmitting
|
|
1488
|
+
})
|
|
734
1489
|
}),
|
|
735
|
-
children: [/*#__PURE__*/
|
|
1490
|
+
children: [/*#__PURE__*/jsx(InviteOnlySelectionWatcher, {
|
|
1491
|
+
auth: values.auth,
|
|
1492
|
+
onChange: handleAuthChange
|
|
1493
|
+
}), /*#__PURE__*/jsxs(FieldsWrapper, {
|
|
736
1494
|
children: [isGrouped ? /*#__PURE__*/jsxs("div", {
|
|
737
1495
|
className: "space-y-4",
|
|
738
1496
|
children: [/*#__PURE__*/jsxs(RadioGroup, {
|
|
@@ -810,16 +1568,24 @@ var Configuration = function Configuration(_ref) {
|
|
|
810
1568
|
}
|
|
811
1569
|
}), /*#__PURE__*/jsx(Invitations$1, {
|
|
812
1570
|
inviteButtonProps: inviteButtonProps,
|
|
1571
|
+
isSetup: isSetup,
|
|
813
1572
|
onDestroyInvitationsSuccess: onDestroyInvitationsSuccess,
|
|
814
1573
|
ownerId: ownerId,
|
|
815
1574
|
ownerType: ownerType,
|
|
1575
|
+
stagedInvitations: stagedInvitations,
|
|
1576
|
+
translationContext: translationContext,
|
|
816
1577
|
configurationId: configuration.id,
|
|
1578
|
+
defaultTab: invitationsPaneTab,
|
|
1579
|
+
emailTemplate: buildEmailTemplate(configuration, stagedInvitations),
|
|
817
1580
|
extraColumnsData: invitationsTableExtraColumnsData,
|
|
818
1581
|
hideAddEmailsForm: hideAddEmailsFromInvitationPane,
|
|
819
|
-
|
|
1582
|
+
invitationEmailProps: emailProps,
|
|
1583
|
+
invitationsCount: configuration.invitationsCount,
|
|
1584
|
+
isOpen: showInvitationsPane && (isSetup || isPresent(configuration.id)) && !isLoading,
|
|
820
1585
|
onClose: function onClose() {
|
|
821
1586
|
return setShowInvitationsPane(false);
|
|
822
|
-
}
|
|
1587
|
+
},
|
|
1588
|
+
onStage: setStagedInvitations
|
|
823
1589
|
}), children]
|
|
824
1590
|
})]
|
|
825
1591
|
});
|