@wix/entity-advanced-permissions 1.804.0 → 1.806.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/EmptyState/EmptyState.js +9 -7
- package/dist/cjs/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/cjs/components/EmptyState/EmptyState.spec.js +49 -46
- package/dist/cjs/components/EmptyState/EmptyState.spec.js.map +1 -1
- package/dist/cjs/components/EntityAdvancedPermissions.js +68 -95
- package/dist/cjs/components/EntityAdvancedPermissions.js.map +1 -1
- package/dist/cjs/components/EntityAdvancedPermissionsState.js +4 -5
- package/dist/cjs/components/EntityAdvancedPermissionsState.js.map +1 -1
- package/dist/cjs/components/NotifyBox/NotifyBox.js +16 -14
- package/dist/cjs/components/NotifyBox/NotifyBox.js.map +1 -1
- package/dist/cjs/components/PermissionsDropdown/PermissionsDropdown.js +13 -18
- package/dist/cjs/components/PermissionsDropdown/PermissionsDropdown.js.map +1 -1
- package/dist/cjs/components/PermissionsDropdown/PermissionsDropdown.spec.js +135 -128
- package/dist/cjs/components/PermissionsDropdown/PermissionsDropdown.spec.js.map +1 -1
- package/dist/cjs/components/PermissionsList/Avatar.js +6 -4
- package/dist/cjs/components/PermissionsList/Avatar.js.map +1 -1
- package/dist/cjs/components/PermissionsList/AvatarRole.js +11 -8
- package/dist/cjs/components/PermissionsList/AvatarRole.js.map +1 -1
- package/dist/cjs/components/PermissionsList/PermissionsList.js +25 -27
- package/dist/cjs/components/PermissionsList/PermissionsList.js.map +1 -1
- package/dist/cjs/components/PermissionsList/PermissionsList.spec.js +133 -126
- package/dist/cjs/components/PermissionsList/PermissionsList.spec.js.map +1 -1
- package/dist/cjs/components/PermissionsList/ViewRow.js +11 -8
- package/dist/cjs/components/PermissionsList/ViewRow.js.map +1 -1
- package/dist/cjs/components/SearchEntity/DashboardMultiSelect.js +12 -14
- package/dist/cjs/components/SearchEntity/DashboardMultiSelect.js.map +1 -1
- package/dist/cjs/components/SearchEntity/SearchEntity.js +24 -21
- package/dist/cjs/components/SearchEntity/SearchEntity.js.map +1 -1
- package/dist/cjs/components/SearchEntity/SearchEntity.spec.js +17 -16
- package/dist/cjs/components/SearchEntity/SearchEntity.spec.js.map +1 -1
- package/dist/cjs/components/SearchEntity/SearchReplacmentsComponents.js +11 -6
- package/dist/cjs/components/SearchEntity/SearchReplacmentsComponents.js.map +1 -1
- package/dist/statics/entity-advanced-permissions.umd.js +230 -254
- package/dist/statics/entity-advanced-permissions.umd.js.map +1 -1
- package/dist/statics/entity-advanced-permissions.umd.min.js +5 -5
- package/dist/statics/entity-advanced-permissions.umd.min.js.map +1 -1
- package/dist/statics/manifest.json +2 -2
- package/dist/statics/manifest.min.json +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
|
@@ -12,13 +12,15 @@ var _jsxFileName = "/home/builduser/work/4775e43efb305866/packages/entity-advanc
|
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
14
|
function EmptyState(props) {
|
|
15
|
-
const
|
|
16
|
-
mobile
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const {
|
|
16
|
+
mobile
|
|
17
|
+
} = (0, _react.useContext)(_wixUiTpa.TPAComponentsContext);
|
|
18
|
+
const {
|
|
19
|
+
mainTitle,
|
|
20
|
+
description,
|
|
21
|
+
className,
|
|
22
|
+
isDashboard = false
|
|
23
|
+
} = props;
|
|
22
24
|
if (isDashboard) {
|
|
23
25
|
const wsrEmptyStateTitle = /*#__PURE__*/_react.default.createElement(_wixStyleReact.Text, {
|
|
24
26
|
size: 'medium',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EmptyState","props","
|
|
1
|
+
{"version":3,"names":["EmptyState","props","mobile","useContext","TPAComponentsContext","mainTitle","description","className","isDashboard","wsrEmptyStateTitle","wsrEmptyStateDescription","st","classes","emptyStateWsr","emptyState","TextTypography","smallTitle","he","decode","runningText"],"sources":["../../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport he from 'he';\nimport { Text, TextTypography } from 'wix-ui-tpa';\nimport { classes, st } from './EmptyState.st.css';\nimport { TPAComponentsContext } from 'wix-ui-tpa';\nimport { EmptyState as WSREmptyState, Box, Text as WSRText } from 'wix-style-react';\n\nexport interface EmptyStateProps {\n mainTitle: string;\n description: string;\n className?: string;\n isDashboard?: boolean;\n}\n\nfunction EmptyState(props: EmptyStateProps) {\n const { mobile } = useContext(TPAComponentsContext);\n const { mainTitle, description, className, isDashboard = false } = props;\n\n if (isDashboard) {\n const wsrEmptyStateTitle = <WSRText size={'medium'} weight={'bold'}> {mainTitle} </WSRText>;\n const wsrEmptyStateDescription = <WSRText size={'medium'}> {description} </WSRText>;\n return (\n <Box className={st(classes.emptyStateWsr)} >\n <WSREmptyState\n theme={'page-no-border'}\n title={wsrEmptyStateTitle}\n align={'center'}\n subtitle={wsrEmptyStateDescription}\n />\n </Box>\n );\n }\n\n return (\n <div className={st(classes.emptyState, { mobile }, className)}>\n <Text\n typography={TextTypography.smallTitle}\n className={st(classes.mainTitle)}\n >\n {he.decode(mainTitle)}\n </Text>\n <Text\n typography={TextTypography.runningText}\n className={st(classes.description)}\n >\n {he.decode(description)}\n </Text>\n </div>\n );\n}\n\nexport default EmptyState;\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AAEA;AAAoF;AAAA;AAAA;AASpF,SAASA,UAAU,CAACC,KAAsB,EAAE;EAC1C,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,iBAAU,EAACC,8BAAoB,CAAC;EACnD,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,SAAS;IAAEC,WAAW,GAAG;EAAM,CAAC,GAAGP,KAAK;EAExE,IAAIO,WAAW,EAAE;IACf,MAAMC,kBAAkB,gBAAG,6BAAC,mBAAO;MAAC,IAAI,EAAE,QAAS;MAAC,MAAM,EAAE,MAAO;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,QAAGJ,SAAS,MAAY;IAC3F,MAAMK,wBAAwB,gBAAG,6BAAC,mBAAO;MAAC,IAAI,EAAE,QAAS;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,QAAGJ,WAAW,MAAY;IACnF,oBACE,6BAAC,kBAAG;MAAC,SAAS,EAAE,IAAAK,gBAAE,EAACC,qBAAO,CAACC,aAAa,CAAE;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,gBACxC,6BAAC,yBAAa;MACZ,KAAK,EAAE,gBAAiB;MACxB,KAAK,EAAEJ,kBAAmB;MAC1B,KAAK,EAAE,QAAS;MAChB,QAAQ,EAAEC,wBAAyB;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,EACnC,CACE;EAEV;EAEA,oBACE;IAAK,SAAS,EAAE,IAAAC,gBAAE,EAACC,qBAAO,CAACE,UAAU,EAAE;MAAEZ;IAAO,CAAC,EAAEK,SAAS,CAAE;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,gBAC5D,6BAAC,cAAI;IACH,UAAU,EAAEQ,wBAAc,CAACC,UAAW;IACtC,SAAS,EAAE,IAAAL,gBAAE,EAACC,qBAAO,CAACP,SAAS,CAAE;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,GAEhCY,WAAE,CAACC,MAAM,CAACb,SAAS,CAAC,CAChB,eACP,6BAAC,cAAI;IACH,UAAU,EAAEU,wBAAc,CAACI,WAAY;IACvC,SAAS,EAAE,IAAAR,gBAAE,EAACC,qBAAO,CAACN,WAAW,CAAE;IAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAAA,GAElCW,WAAE,CAACC,MAAM,CAACZ,WAAW,CAAC,CAClB,CACH;AAEV;AAAC,eAEcN,UAAU;AAAA"}
|
|
@@ -9,19 +9,20 @@ var _jsxFileName = "/home/builduser/work/4775e43efb305866/packages/entity-advanc
|
|
|
9
9
|
describe('Test Empty State component', () => {
|
|
10
10
|
it('renders properly', () => {
|
|
11
11
|
var _container$firstChild;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
const {
|
|
13
|
+
getByText,
|
|
14
|
+
container
|
|
15
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
|
|
16
|
+
mainTitle: 'Main title text',
|
|
17
|
+
description: 'description test',
|
|
18
|
+
className: 'CustomClass',
|
|
19
|
+
__self: void 0,
|
|
20
|
+
__source: {
|
|
21
|
+
fileName: _jsxFileName,
|
|
22
|
+
lineNumber: 9,
|
|
23
|
+
columnNumber: 7
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
25
26
|
expect(getByText('Main title text')).toBeTruthy();
|
|
26
27
|
expect(getByText('description test')).toBeTruthy();
|
|
27
28
|
|
|
@@ -29,44 +30,46 @@ describe('Test Empty State component', () => {
|
|
|
29
30
|
expect(container == null ? void 0 : (_container$firstChild = container.firstChild) == null ? void 0 : _container$firstChild.className).toContain('CustomClass');
|
|
30
31
|
});
|
|
31
32
|
it('decodes properly', () => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const {
|
|
34
|
+
getByText
|
|
35
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
|
|
36
|
+
mainTitle: 'Main title ≠',
|
|
37
|
+
description: 'description ≠',
|
|
38
|
+
__self: void 0,
|
|
39
|
+
__source: {
|
|
40
|
+
fileName: _jsxFileName,
|
|
41
|
+
lineNumber: 25,
|
|
42
|
+
columnNumber: 7
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
43
45
|
expect(getByText('Main title ≠')).toBeTruthy();
|
|
44
46
|
expect(getByText('description ≠')).toBeTruthy();
|
|
45
47
|
});
|
|
46
48
|
it('Mobile class added', () => {
|
|
47
49
|
var _container$firstChild2;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
const {
|
|
51
|
+
container,
|
|
52
|
+
debug
|
|
53
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_wixUiTpa.TPAComponentsProvider, {
|
|
54
|
+
value: {
|
|
55
|
+
mobile: true
|
|
56
|
+
},
|
|
57
|
+
__self: void 0,
|
|
58
|
+
__source: {
|
|
59
|
+
fileName: _jsxFileName,
|
|
60
|
+
lineNumber: 37,
|
|
61
|
+
columnNumber: 7
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
|
|
64
|
+
mainTitle: 'Main title',
|
|
65
|
+
description: 'description',
|
|
66
|
+
__self: void 0,
|
|
67
|
+
__source: {
|
|
68
|
+
fileName: _jsxFileName,
|
|
69
|
+
lineNumber: 38,
|
|
70
|
+
columnNumber: 9
|
|
71
|
+
}
|
|
72
|
+
})));
|
|
70
73
|
|
|
71
74
|
// @ts-ignore
|
|
72
75
|
expect(container == null ? void 0 : (_container$firstChild2 = container.firstChild) == null ? void 0 : _container$firstChild2.className).toContain('--mobile');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","it","
|
|
1
|
+
{"version":3,"names":["describe","it","getByText","container","render","expect","toBeTruthy","firstChild","className","toContain","debug","mobile"],"sources":["../../../../src/components/EmptyState/EmptyState.spec.tsx"],"sourcesContent":["import React from 'react';\nimport { render, fireEvent } from '@testing-library/react';\nimport EmptyState from './EmptyState.tsx';\nimport { TPAComponentsProvider } from 'wix-ui-tpa';\n\ndescribe('Test Empty State component', () => {\n it('renders properly', () => {\n const { getByText, container } = render(\n <EmptyState\n mainTitle={'Main title text'}\n description={'description test'}\n className={'CustomClass'}\n />,\n );\n\n expect(getByText('Main title text')).toBeTruthy();\n expect(getByText('description test')).toBeTruthy();\n\n // @ts-ignore\n expect(container?.firstChild?.className).toContain('CustomClass');\n });\n\n it('decodes properly', () => {\n const { getByText } = render(\n <EmptyState\n mainTitle={'Main title ≠'}\n description={'description ≠'}\n />,\n );\n\n expect(getByText('Main title ≠')).toBeTruthy();\n expect(getByText('description ≠')).toBeTruthy();\n });\n\n it('Mobile class added', () => {\n const { container, debug } = render(\n <TPAComponentsProvider value={{ mobile: true }}>\n <EmptyState mainTitle={'Main title'} description={'description'} />\n </TPAComponentsProvider>,\n );\n\n // @ts-ignore\n expect(container?.firstChild?.className).toContain('--mobile');\n });\n});\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AAAmD;AAEnDA,QAAQ,CAAC,4BAA4B,EAAE,MAAM;EAC3CC,EAAE,CAAC,kBAAkB,EAAE,MAAM;IAAA;IAC3B,MAAM;MAAEC,SAAS;MAAEC;IAAU,CAAC,GAAG,IAAAC,cAAM,gBACrC,6BAAC,mBAAU;MACT,SAAS,EAAE,iBAAkB;MAC7B,WAAW,EAAE,kBAAmB;MAChC,SAAS,EAAE,aAAc;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,EACzB,CACH;IAEDC,MAAM,CAACH,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAACI,UAAU,EAAE;IACjDD,MAAM,CAACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAACI,UAAU,EAAE;;IAElD;IACAD,MAAM,CAACF,SAAS,6CAATA,SAAS,CAAEI,UAAU,qBAArB,sBAAuBC,SAAS,CAAC,CAACC,SAAS,CAAC,aAAa,CAAC;EACnE,CAAC,CAAC;EAEFR,EAAE,CAAC,kBAAkB,EAAE,MAAM;IAC3B,MAAM;MAAEC;IAAU,CAAC,GAAG,IAAAE,cAAM,gBAC1B,6BAAC,mBAAU;MACT,SAAS,EAAE,iBAAkB;MAC7B,WAAW,EAAE,kBAAmB;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,EAChC,CACH;IAEDC,MAAM,CAACH,SAAS,CAAC,cAAc,CAAC,CAAC,CAACI,UAAU,EAAE;IAC9CD,MAAM,CAACH,SAAS,CAAC,eAAe,CAAC,CAAC,CAACI,UAAU,EAAE;EACjD,CAAC,CAAC;EAEFL,EAAE,CAAC,oBAAoB,EAAE,MAAM;IAAA;IAC7B,MAAM;MAAEE,SAAS;MAAEO;IAAM,CAAC,GAAG,IAAAN,cAAM,gBACjC,6BAAC,+BAAqB;MAAC,KAAK,EAAE;QAAEO,MAAM,EAAE;MAAK,CAAE;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,gBAC7C,6BAAC,mBAAU;MAAC,SAAS,EAAE,YAAa;MAAC,WAAW,EAAE,aAAc;MAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA,EAAG,CAC7C,CACzB;;IAED;IACAN,MAAM,CAACF,SAAS,8CAATA,SAAS,CAAEI,UAAU,qBAArB,uBAAuBC,SAAS,CAAC,CAACC,SAAS,CAAC,UAAU,CAAC;EAChE,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -30,92 +30,60 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
30
30
|
const STEP_1 = 1;
|
|
31
31
|
const STEP_2 = 2;
|
|
32
32
|
function EntityAdvancedPermissions(props) {
|
|
33
|
-
const
|
|
34
|
-
removePermissionCode =
|
|
35
|
-
entityTitle
|
|
36
|
-
entityId
|
|
37
|
-
className
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
_props$labels$numberO = _props$labels.numberOfResultsMessage,
|
|
83
|
-
numberOfResultsMessage = _props$labels$numberO === void 0 ? '{0} results' : _props$labels$numberO,
|
|
84
|
-
_props$labels$pressDe = _props$labels.pressDeleteToRemoveMessage,
|
|
85
|
-
pressDeleteToRemoveMessage = _props$labels$pressDe === void 0 ? '{0}: press delete to remove' : _props$labels$pressDe,
|
|
86
|
-
_props$labels$selectP = _props$labels.selectPermissionLabel,
|
|
87
|
-
selectPermissionLabel = _props$labels$selectP === void 0 ? 'Select permission' : _props$labels$selectP,
|
|
88
|
-
_props$labels$saveSuc = _props$labels.saveSuccessMessage,
|
|
89
|
-
saveSuccessMessage = _props$labels$saveSuc === void 0 ? 'Permissions successfully added' : _props$labels$saveSuc,
|
|
90
|
-
_props$labels$permiss = _props$labels.permissionRemovedMessage,
|
|
91
|
-
permissionRemovedMessage = _props$labels$permiss === void 0 ? 'Permission successfully removed' : _props$labels$permiss,
|
|
92
|
-
_props$labels$doneLab = _props$labels.doneLabel,
|
|
93
|
-
doneLabel = _props$labels$doneLab === void 0 ? 'Done' : _props$labels$doneLab,
|
|
94
|
-
_props$isModal = props.isModal,
|
|
95
|
-
isModal = _props$isModal === void 0 ? true : _props$isModal,
|
|
96
|
-
queryFunction = props.queryFunction,
|
|
97
|
-
onClose = props.onClose,
|
|
98
|
-
_props$availablePermi = props.availablePermissions,
|
|
99
|
-
availablePermissions = _props$availablePermi === void 0 ? _EntityAdvancedPermissionsTypes.DefaultPermissions : _props$availablePermi,
|
|
100
|
-
onSave = props.onSave,
|
|
101
|
-
items = props.items,
|
|
102
|
-
_props$direction = props.direction,
|
|
103
|
-
direction = _props$direction === void 0 ? _EntityAdvancedPermissionsTypes.Direction.LTR : _props$direction,
|
|
104
|
-
loading = props.loading,
|
|
105
|
-
_props$mobile = props.mobile,
|
|
106
|
-
mobile = _props$mobile === void 0 ? false : _props$mobile,
|
|
107
|
-
preloadRoles = props.preloadRoles,
|
|
108
|
-
_props$theme = props.theme,
|
|
109
|
-
theme = _props$theme === void 0 ? _EntityAdvancedPermissionsTypes.Theme.SITE : _props$theme,
|
|
110
|
-
_props$isSitePublishe = props.isSitePublished,
|
|
111
|
-
isSitePublished = _props$isSitePublishe === void 0 ? 'true' : _props$isSitePublishe;
|
|
33
|
+
const {
|
|
34
|
+
removePermissionCode = 'NONE',
|
|
35
|
+
entityTitle,
|
|
36
|
+
entityId,
|
|
37
|
+
className,
|
|
38
|
+
validateChanges = () => '',
|
|
39
|
+
labels: {
|
|
40
|
+
title = 'Manage Permissions',
|
|
41
|
+
secondTitle = 'Add Permissions',
|
|
42
|
+
cancel,
|
|
43
|
+
save,
|
|
44
|
+
add = 'Add',
|
|
45
|
+
loadingMessage = 'Loading',
|
|
46
|
+
searchPlaceHolder = 'Add roles & members...',
|
|
47
|
+
allOptionsSelected = 'You’ve selected all your members.',
|
|
48
|
+
noOptionsMessage = 'We couldn’t find any matches. Try another search.',
|
|
49
|
+
backButtonLabel,
|
|
50
|
+
checkBoxNotifyLabel = 'Notify people',
|
|
51
|
+
notifyMessagePlaceholder = 'Add A Message (Optional)',
|
|
52
|
+
notifyMessageLabel = 'Add A Message',
|
|
53
|
+
notifyLabelHint = 'Notifications will be sent by email and show in the members area.',
|
|
54
|
+
closeAriaLabel = 'Close',
|
|
55
|
+
backAriaLabel = 'Back',
|
|
56
|
+
emptyStateTitle = 'Only Admins Can Access This Folder',
|
|
57
|
+
emptyStateDescription = 'Add permissions to share this folder with site members, subscription plans and more.',
|
|
58
|
+
buttonAddNotify = 'Add & Notify',
|
|
59
|
+
step1SaveError = 'This action didn’t work out, try again later or close the window to continue without saving.',
|
|
60
|
+
step2SaveError = 'There was a problem saving changes. Please try again later.',
|
|
61
|
+
rolesListError = 'There was a problem loading permissions. Wait a moment and try again.',
|
|
62
|
+
numberOfResultsMessage = '{0} results',
|
|
63
|
+
pressDeleteToRemoveMessage = '{0}: press delete to remove',
|
|
64
|
+
selectPermissionLabel = 'Select permission',
|
|
65
|
+
saveSuccessMessage = 'Permissions successfully added',
|
|
66
|
+
permissionRemovedMessage = 'Permission successfully removed',
|
|
67
|
+
doneLabel = 'Done'
|
|
68
|
+
},
|
|
69
|
+
isModal = true,
|
|
70
|
+
queryFunction,
|
|
71
|
+
onClose,
|
|
72
|
+
availablePermissions = _EntityAdvancedPermissionsTypes.DefaultPermissions,
|
|
73
|
+
onSave,
|
|
74
|
+
items,
|
|
75
|
+
direction = _EntityAdvancedPermissionsTypes.Direction.LTR,
|
|
76
|
+
loading,
|
|
77
|
+
mobile = false,
|
|
78
|
+
preloadRoles,
|
|
79
|
+
theme = _EntityAdvancedPermissionsTypes.Theme.SITE,
|
|
80
|
+
isSitePublished = 'true'
|
|
81
|
+
} = props;
|
|
112
82
|
const isDashboard = theme === _EntityAdvancedPermissionsTypes.Theme.DASHBOARD;
|
|
113
83
|
const Provider = isDashboard ? _wixStyleReact.WixStyleReactProvider : _wixUiTpa.TPAComponentsProvider;
|
|
114
84
|
const searchEntityRef = /*#__PURE__*/(0, _react.createRef)();
|
|
115
85
|
const step2Permissions = (availablePermissions || []).filter(permission => !(permission.divider || permission.id === removePermissionCode));
|
|
116
|
-
const
|
|
117
|
-
step = _useState[0],
|
|
118
|
-
setStep = _useState[1];
|
|
86
|
+
const [step, setStep] = (0, _react.useState)(STEP_1);
|
|
119
87
|
const defaultPermissionId = availablePermissions.length ? availablePermissions[0].id : '';
|
|
120
88
|
const setFocus = () => {
|
|
121
89
|
if (searchEntityRef.current) {
|
|
@@ -132,9 +100,7 @@ function EntityAdvancedPermissions(props) {
|
|
|
132
100
|
saveState: _wixUiTpa.StatesButtonStates.IDLE,
|
|
133
101
|
pendingSave: false
|
|
134
102
|
};
|
|
135
|
-
const
|
|
136
|
-
advancedPermissionState = _useReducer[0],
|
|
137
|
-
setAdvancedPermissionState = _useReducer[1];
|
|
103
|
+
const [advancedPermissionState, setAdvancedPermissionState] = (0, _react.useReducer)(_EntityAdvancedPermissionsState.advancedPermissionReducer, defaultState);
|
|
138
104
|
const closeCallback = () => onClose ? onClose({
|
|
139
105
|
closeReason: _EntityAdvancedPermissionsTypes.CloseReason.Cancel,
|
|
140
106
|
availabilityStatus: advancedPermissionState.availabilityStatus
|
|
@@ -183,11 +149,13 @@ function EntityAdvancedPermissions(props) {
|
|
|
183
149
|
type: _EntityAdvancedPermissionsState.SET_ERROR_MESSAGE,
|
|
184
150
|
errorMessage: ''
|
|
185
151
|
});
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
152
|
+
const {
|
|
153
|
+
roleToPermission,
|
|
154
|
+
notify,
|
|
155
|
+
notifyMessage,
|
|
156
|
+
selectedRoles,
|
|
157
|
+
chosenPermission
|
|
158
|
+
} = advancedPermissionState;
|
|
191
159
|
const step2RolesToPermissions = new Map();
|
|
192
160
|
(selectedRoles || []).forEach(({
|
|
193
161
|
value
|
|
@@ -208,9 +176,10 @@ function EntityAdvancedPermissions(props) {
|
|
|
208
176
|
};
|
|
209
177
|
if (onSave) {
|
|
210
178
|
try {
|
|
211
|
-
const
|
|
212
|
-
responseStatus
|
|
213
|
-
availabilityStatus
|
|
179
|
+
const {
|
|
180
|
+
responseStatus,
|
|
181
|
+
availabilityStatus
|
|
182
|
+
} = await onSave(saveData);
|
|
214
183
|
if (responseStatus === _EntityAdvancedPermissionsTypes.ResponseStatus.Success) {
|
|
215
184
|
setAdvancedPermissionState({
|
|
216
185
|
type: _EntityAdvancedPermissionsState.RESET,
|
|
@@ -253,7 +222,9 @@ function EntityAdvancedPermissions(props) {
|
|
|
253
222
|
}
|
|
254
223
|
};
|
|
255
224
|
const savesStep1Silently = () => {
|
|
256
|
-
const
|
|
225
|
+
const {
|
|
226
|
+
roleToPermission
|
|
227
|
+
} = advancedPermissionState;
|
|
257
228
|
if (roleToPermission !== undefined && roleToPermission.size > 0) {
|
|
258
229
|
const saveData = {
|
|
259
230
|
entityId,
|
|
@@ -357,7 +328,9 @@ function EntityAdvancedPermissions(props) {
|
|
|
357
328
|
};
|
|
358
329
|
const updatedItems = items.map(item => {
|
|
359
330
|
var _advancedPermissionSt;
|
|
360
|
-
const
|
|
331
|
+
const {
|
|
332
|
+
id
|
|
333
|
+
} = item;
|
|
361
334
|
const roleToPermission = (_advancedPermissionSt = advancedPermissionState.roleToPermission) == null ? void 0 : _advancedPermissionSt.get(id);
|
|
362
335
|
if (roleToPermission !== undefined) {
|
|
363
336
|
return {
|