@bigbinary/neeto-access-control-frontend 1.3.2 → 1.3.4
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 +9 -0
- package/dist/index.cjs.js +156 -157
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +108 -76
- package/dist/index.js.map +1 -1
- package/package.json +53 -51
- package/types.d.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import { useRef, useState, createElement } from 'react';
|
|
3
|
+
import { useRef, useState, createElement, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import { truncate, humanize, isNotEmpty, noop
|
|
5
|
+
import { truncate, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
6
6
|
import Container from '@bigbinary/neeto-molecules/Container';
|
|
7
7
|
import Scrollable from '@bigbinary/neeto-molecules/Scrollable';
|
|
8
|
-
import Label from '@bigbinary/neetoui/Label';
|
|
9
8
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
10
9
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
11
10
|
import Form from '@bigbinary/neetoui/formik/Form';
|
|
12
11
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
13
12
|
import Radio from '@bigbinary/neetoui/formik/Radio';
|
|
13
|
+
import { prop, pluck, mergeDeepRight, indexBy, values, isEmpty, equals, pick, reject, pipe, trim, mergeLeft, keys } from 'ramda';
|
|
14
14
|
import { useTranslation, Trans } from 'react-i18next';
|
|
15
15
|
import { DEFAULT_STALE_TIME, DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/constants';
|
|
16
16
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
@@ -22,7 +22,6 @@ import NoData from '@bigbinary/neetoui/NoData';
|
|
|
22
22
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
23
23
|
import Table from '@bigbinary/neetoui/Table';
|
|
24
24
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
25
|
-
import { prop, pluck, mergeDeepRight, indexBy, values, isEmpty, equals, pick, reject, pipe, trim } from 'ramda';
|
|
26
25
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
27
26
|
import { useQuery } from '@tanstack/react-query';
|
|
28
27
|
import { useMutationWithInvalidation, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
@@ -35,6 +34,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
35
34
|
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
36
35
|
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
37
36
|
import { FieldArray } from 'formik';
|
|
37
|
+
import Label from '@bigbinary/neetoui/Label';
|
|
38
38
|
import NeetoHeader from '@bigbinary/neeto-molecules/Header';
|
|
39
39
|
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
40
40
|
|
|
@@ -76,14 +76,14 @@ var QUERY_KEYS = {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
var _excluded = ["ownerId", "ownerType"];
|
|
79
|
-
function ownKeys$
|
|
80
|
-
function _objectSpread$
|
|
79
|
+
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; }
|
|
80
|
+
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), !0).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; }
|
|
81
81
|
var ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1 = QUERY_KEYS.ACCESS_CONTROL_CONFIGURATION_INVITATIONS;
|
|
82
82
|
var useListInvitations = function useListInvitations(_ref, options) {
|
|
83
83
|
var ownerId = _ref.ownerId,
|
|
84
84
|
ownerType = _ref.ownerType,
|
|
85
85
|
otherParams = _objectWithoutProperties(_ref, _excluded);
|
|
86
|
-
return useQuery(_objectSpread$
|
|
86
|
+
return useQuery(_objectSpread$4({
|
|
87
87
|
queryKey: [ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId, otherParams],
|
|
88
88
|
queryFn: function queryFn() {
|
|
89
89
|
return invitationsApi.list(otherParams);
|
|
@@ -100,7 +100,7 @@ var useBulkCreateInvitations = function useBulkCreateInvitations(_ref2, options)
|
|
|
100
100
|
configurationId: configurationId,
|
|
101
101
|
payload: payload
|
|
102
102
|
});
|
|
103
|
-
}, _objectSpread$
|
|
103
|
+
}, _objectSpread$4({
|
|
104
104
|
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId]]
|
|
105
105
|
}, options));
|
|
106
106
|
};
|
|
@@ -113,7 +113,7 @@ var useBulkDestroyInvitations = function useBulkDestroyInvitations(_ref3, option
|
|
|
113
113
|
configurationId: configurationId,
|
|
114
114
|
payload: payload
|
|
115
115
|
});
|
|
116
|
-
}, _objectSpread$
|
|
116
|
+
}, _objectSpread$4({
|
|
117
117
|
keysToInvalidate: [[ACCESS_CONTROL_CONFIGURATION_INVITATIONS$1, ownerType, ownerId]]
|
|
118
118
|
}, options));
|
|
119
119
|
};
|
|
@@ -236,6 +236,8 @@ var renderColumnData = function renderColumnData(_ref2) {
|
|
|
236
236
|
}), extraColumnsData);
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
+
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; }
|
|
240
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
239
241
|
var Invitations$1 = function Invitations(_ref) {
|
|
240
242
|
var _selectedEmails$;
|
|
241
243
|
var _ref$extraColumnsData = _ref.extraColumnsData,
|
|
@@ -249,6 +251,8 @@ var Invitations$1 = function Invitations(_ref) {
|
|
|
249
251
|
onClose = _ref.onClose,
|
|
250
252
|
_ref$hideAddEmailsFor = _ref.hideAddEmailsForm,
|
|
251
253
|
hideAddEmailsForm = _ref$hideAddEmailsFor === void 0 ? false : _ref$hideAddEmailsFor,
|
|
254
|
+
_ref$inviteButtonProp = _ref.inviteButtonProps,
|
|
255
|
+
inviteButtonProps = _ref$inviteButtonProp === void 0 ? {} : _ref$inviteButtonProp,
|
|
252
256
|
_ref$onDestroyInvitat = _ref.onDestroyInvitationsSuccess,
|
|
253
257
|
onDestroyInvitationsSuccess = _ref$onDestroyInvitat === void 0 ? noop : _ref$onDestroyInvitat;
|
|
254
258
|
var _useState = useState([]),
|
|
@@ -321,8 +325,11 @@ var Invitations$1 = function Invitations(_ref) {
|
|
|
321
325
|
children: t("neetoAccessControl.titles.invitations")
|
|
322
326
|
})
|
|
323
327
|
}), /*#__PURE__*/jsxs(Pane.Body, {
|
|
324
|
-
className: "pt-2",
|
|
325
|
-
children: [
|
|
328
|
+
className: "space-y-4 pt-2",
|
|
329
|
+
children: [isNotEmpty(inviteButtonProps) && /*#__PURE__*/jsx("div", {
|
|
330
|
+
className: "flex w-full justify-end",
|
|
331
|
+
children: /*#__PURE__*/jsx(Button$1, _objectSpread$3({}, inviteButtonProps))
|
|
332
|
+
}), !hideAddEmailsForm && /*#__PURE__*/jsx(AddEmails, {
|
|
326
333
|
configurationId: configurationId,
|
|
327
334
|
ownerId: ownerId,
|
|
328
335
|
ownerType: ownerType
|
|
@@ -473,26 +480,6 @@ var AUTH = {
|
|
|
473
480
|
SESSION: "session",
|
|
474
481
|
INVITED: "invited"
|
|
475
482
|
};
|
|
476
|
-
var AUTH_OPTIONS = [{
|
|
477
|
-
label: t("neetoAccessControl.auth.no"),
|
|
478
|
-
value: AUTH.NO,
|
|
479
|
-
"data-cy": hyphenate(t("neetoAccessControl.auth.no"))
|
|
480
|
-
}, {
|
|
481
|
-
label: t("neetoAccessControl.auth.basic"),
|
|
482
|
-
value: AUTH.BASIC,
|
|
483
|
-
"data-cy": hyphenate(t("neetoAccessControl.auth.basic"))
|
|
484
|
-
}, {
|
|
485
|
-
label: t("neetoAccessControl.auth.invited"),
|
|
486
|
-
value: AUTH.INVITED
|
|
487
|
-
}, {
|
|
488
|
-
label: t("neetoAccessControl.auth.email"),
|
|
489
|
-
value: AUTH.EMAIL,
|
|
490
|
-
"data-cy": hyphenate(t("neetoAccessControl.auth.email"))
|
|
491
|
-
}, {
|
|
492
|
-
label: t("neetoAccessControl.auth.session"),
|
|
493
|
-
value: AUTH.SESSION,
|
|
494
|
-
"data-cy": hyphenate(t("neetoAccessControl.auth.session"))
|
|
495
|
-
}];
|
|
496
483
|
var CONFIGURATION_VALIDATION_SCHEMA = yup.object({
|
|
497
484
|
auth: yup.string().required(t("neetoAccessControl.inputs.validation.authRequired")),
|
|
498
485
|
password: yup.string().nullable().when("auth", {
|
|
@@ -557,6 +544,41 @@ var renderLabelWithViewInvitation = function renderLabelWithViewInvitation(_ref2
|
|
|
557
544
|
}
|
|
558
545
|
});
|
|
559
546
|
};
|
|
547
|
+
var getAuthOptions = function getAuthOptions(_ref3) {
|
|
548
|
+
var translationContext = _ref3.translationContext,
|
|
549
|
+
t = _ref3.t;
|
|
550
|
+
return [{
|
|
551
|
+
label: t("neetoAccessControl.auth.no", {
|
|
552
|
+
context: translationContext
|
|
553
|
+
}),
|
|
554
|
+
value: AUTH.NO,
|
|
555
|
+
"data-cy": "access-control-public-access-radio-input"
|
|
556
|
+
}, {
|
|
557
|
+
label: t("neetoAccessControl.auth.basic", {
|
|
558
|
+
context: translationContext
|
|
559
|
+
}),
|
|
560
|
+
value: AUTH.BASIC,
|
|
561
|
+
"data-cy": "access-control-password-protected-radio-input"
|
|
562
|
+
}, {
|
|
563
|
+
label: t("neetoAccessControl.auth.invited", {
|
|
564
|
+
context: translationContext
|
|
565
|
+
}),
|
|
566
|
+
value: AUTH.INVITED,
|
|
567
|
+
"data-cy": "access-control-only-invited-people-radio-input"
|
|
568
|
+
}, {
|
|
569
|
+
label: t("neetoAccessControl.auth.email", {
|
|
570
|
+
context: translationContext
|
|
571
|
+
}),
|
|
572
|
+
value: AUTH.EMAIL,
|
|
573
|
+
"data-cy": "access-control-secure-by-email-patterns-radio-input"
|
|
574
|
+
}, {
|
|
575
|
+
label: t("neetoAccessControl.auth.session", {
|
|
576
|
+
context: translationContext
|
|
577
|
+
}),
|
|
578
|
+
value: AUTH.SESSION,
|
|
579
|
+
"data-cy": "access-control-logged-in-members-only-radio-input"
|
|
580
|
+
}];
|
|
581
|
+
};
|
|
560
582
|
|
|
561
583
|
var AllowedKeywords = withT(function (_ref) {
|
|
562
584
|
var t = _ref.t,
|
|
@@ -649,11 +671,18 @@ var Configuration = function Configuration(_ref) {
|
|
|
649
671
|
hideAddEmailsFromInvitationPane = _ref$hideAddEmailsFro === void 0 ? false : _ref$hideAddEmailsFro,
|
|
650
672
|
_ref$onDestroyInvitat = _ref.onDestroyInvitationsSuccess,
|
|
651
673
|
onDestroyInvitationsSuccess = _ref$onDestroyInvitat === void 0 ? noop : _ref$onDestroyInvitat,
|
|
652
|
-
|
|
674
|
+
_ref$inviteButtonProp = _ref.inviteButtonProps,
|
|
675
|
+
inviteButtonProps = _ref$inviteButtonProp === void 0 ? {} : _ref$inviteButtonProp,
|
|
676
|
+
_ref$additionalFields = _ref.additionalFieldsInitialValues,
|
|
677
|
+
additionalFieldsInitialValues = _ref$additionalFields === void 0 ? {} : _ref$additionalFields,
|
|
678
|
+
children = _ref.children,
|
|
679
|
+
fieldsWrapper = _ref.fieldsWrapper,
|
|
680
|
+
translationContext = _ref.translationContext;
|
|
653
681
|
var _useState = useState(false),
|
|
654
682
|
_useState2 = _slicedToArray(_useState, 2),
|
|
655
|
-
|
|
656
|
-
|
|
683
|
+
showInvitationsPane = _useState2[0],
|
|
684
|
+
setShowInvitationsPane = _useState2[1];
|
|
685
|
+
var FieldsWrapper = fieldsWrapper || Fragment$1;
|
|
657
686
|
var _useTranslation = useTranslation(),
|
|
658
687
|
t = _useTranslation.t;
|
|
659
688
|
var _useShowConfiguration = useShowConfiguration({
|
|
@@ -664,7 +693,7 @@ var Configuration = function Configuration(_ref) {
|
|
|
664
693
|
configuration = _useShowConfiguration2 === void 0 ? {} : _useShowConfiguration2,
|
|
665
694
|
isLoading = _useShowConfiguration.isLoading,
|
|
666
695
|
isFetching = _useShowConfiguration.isFetching;
|
|
667
|
-
var configurationInitialValues = buildConfigurationInitialValues(configuration);
|
|
696
|
+
var configurationInitialValues = mergeLeft(buildConfigurationInitialValues(configuration), additionalFieldsInitialValues);
|
|
668
697
|
var _useUpdateConfigurati = useUpdateConfiguration({
|
|
669
698
|
ownerId: ownerId,
|
|
670
699
|
ownerType: ownerType
|
|
@@ -682,7 +711,7 @@ var Configuration = function Configuration(_ref) {
|
|
|
682
711
|
updateConfiguration = _useUpdateConfigurati.mutate;
|
|
683
712
|
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
684
713
|
var setSubmitting = _ref2.setSubmitting;
|
|
685
|
-
var payload = buildPayload(values);
|
|
714
|
+
var payload = mergeLeft(buildPayload(values), pick(keys(additionalFieldsInitialValues), values));
|
|
686
715
|
updateConfiguration(payload, {
|
|
687
716
|
onSettled: function onSettled() {
|
|
688
717
|
return setSubmitting(false);
|
|
@@ -690,7 +719,7 @@ var Configuration = function Configuration(_ref) {
|
|
|
690
719
|
});
|
|
691
720
|
};
|
|
692
721
|
var handleShowInvitations = onConfigurationChangedToInviteOnly === noop ? function () {
|
|
693
|
-
return
|
|
722
|
+
return setShowInvitationsPane(true);
|
|
694
723
|
} : onConfigurationChangedToInviteOnly;
|
|
695
724
|
return /*#__PURE__*/jsxs(Container, {
|
|
696
725
|
children: [/*#__PURE__*/jsx(Header, {
|
|
@@ -712,44 +741,46 @@ var Configuration = function Configuration(_ref) {
|
|
|
712
741
|
children: function children(_ref3) {
|
|
713
742
|
var values = _ref3.values;
|
|
714
743
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
715
|
-
children: [/*#__PURE__*/
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
"items-start": (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED
|
|
726
|
-
}),
|
|
727
|
-
label: (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED ? renderLabelWithViewInvitation({
|
|
728
|
-
onViewInvites: function onViewInvites() {
|
|
729
|
-
return setShowInviationsPane(true);
|
|
730
|
-
}
|
|
731
|
-
}) : props.label,
|
|
732
|
-
labelProps: {
|
|
744
|
+
children: [/*#__PURE__*/jsxs(FieldsWrapper, {
|
|
745
|
+
children: [/*#__PURE__*/jsx(Radio, {
|
|
746
|
+
stacked: true,
|
|
747
|
+
name: "auth",
|
|
748
|
+
children: getAuthOptions({
|
|
749
|
+
translationContext: translationContext,
|
|
750
|
+
t: t
|
|
751
|
+
}).map(function (props) {
|
|
752
|
+
return /*#__PURE__*/createElement(Radio.Item, _objectSpread(_objectSpread({}, props), {}, {
|
|
753
|
+
key: props.value,
|
|
733
754
|
className: classNames({
|
|
734
|
-
"
|
|
735
|
-
})
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
755
|
+
"items-start": (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED
|
|
756
|
+
}),
|
|
757
|
+
label: (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED ? renderLabelWithViewInvitation({
|
|
758
|
+
onViewInvites: function onViewInvites() {
|
|
759
|
+
return setShowInvitationsPane(true);
|
|
760
|
+
}
|
|
761
|
+
}) : props.label,
|
|
762
|
+
labelProps: {
|
|
763
|
+
className: classNames({
|
|
764
|
+
"flex flex-col items-start justify-start": (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === props.value && (configuration === null || configuration === void 0 ? void 0 : configuration.auth) === AUTH.INVITED
|
|
765
|
+
})
|
|
766
|
+
}
|
|
767
|
+
}));
|
|
768
|
+
})
|
|
769
|
+
}), values.auth === AUTH.BASIC && /*#__PURE__*/jsx("div", {
|
|
770
|
+
className: "space-y-4 pb-2",
|
|
771
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
772
|
+
autoFocus: true,
|
|
773
|
+
required: true,
|
|
774
|
+
unlimitedChars: true,
|
|
775
|
+
className: "w-7/12",
|
|
776
|
+
label: t("neetoAccessControl.inputs.labels.password"),
|
|
777
|
+
name: "password",
|
|
778
|
+
placeholder: t("neetoAccessControl.inputs.placeholders.enterPassword")
|
|
779
|
+
})
|
|
780
|
+
}), values.auth === AUTH.EMAIL && /*#__PURE__*/jsx(AllowedKeywords, {
|
|
781
|
+
label: t("neetoAccessControl.inputs.labels.keywords"),
|
|
782
|
+
name: "allowedKeywords"
|
|
783
|
+
})]
|
|
753
784
|
}), /*#__PURE__*/jsx(ActionBlock, {
|
|
754
785
|
cancelButtonProps: {
|
|
755
786
|
onClick: handleCancel
|
|
@@ -761,15 +792,16 @@ var Configuration = function Configuration(_ref) {
|
|
|
761
792
|
});
|
|
762
793
|
}
|
|
763
794
|
}), /*#__PURE__*/jsx(Invitations$1, {
|
|
795
|
+
inviteButtonProps: inviteButtonProps,
|
|
764
796
|
onDestroyInvitationsSuccess: onDestroyInvitationsSuccess,
|
|
765
797
|
ownerId: ownerId,
|
|
766
798
|
ownerType: ownerType,
|
|
767
799
|
configurationId: configuration.id,
|
|
768
800
|
extraColumnsData: invitationsTableExtraColumnsData,
|
|
769
801
|
hideAddEmailsForm: hideAddEmailsFromInvitationPane,
|
|
770
|
-
isOpen:
|
|
802
|
+
isOpen: showInvitationsPane && !isFetching,
|
|
771
803
|
onClose: function onClose() {
|
|
772
|
-
return
|
|
804
|
+
return setShowInvitationsPane(false);
|
|
773
805
|
}
|
|
774
806
|
}), children]
|
|
775
807
|
})]
|