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