@nocobase/client 0.8.1-alpha.4 → 0.9.0-alpha.2
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/es/acl/ACLProvider.d.ts +16 -2
- package/es/acl/ACLProvider.js +271 -100
- package/es/acl/Configuration/ConfigureCenter.d.ts +2 -0
- package/es/acl/Configuration/ConfigureCenter.js +254 -0
- package/es/acl/Configuration/MenuConfigure.js +2 -2
- package/es/acl/Configuration/PermisionProvider.d.ts +4 -0
- package/es/acl/Configuration/PermisionProvider.js +132 -0
- package/es/acl/Configuration/RoleConfigure.js +98 -23
- package/es/acl/Configuration/RoleTable.d.ts +1 -1
- package/es/acl/Configuration/RoleTable.js +6 -3
- package/es/acl/Configuration/RolesResourcesActions.js +2 -2
- package/es/acl/Configuration/index.d.ts +1 -0
- package/es/acl/Configuration/index.js +2 -1
- package/es/acl/Configuration/schemas/roleCollections.js +41 -13
- package/es/acl/Configuration/schemas/roles.js +42 -2
- package/es/acl/Configuration/schemas/scopes.js +2 -0
- package/es/acl/index.d.ts +1 -0
- package/es/acl/index.js +2 -1
- package/es/acl/style.less +10 -0
- package/es/antd-config-provider/index.d.ts +3 -1
- package/es/antd-config-provider/index.js +25 -6
- package/es/antd-config-provider/loadConstrueLocale.d.ts +1 -0
- package/es/antd-config-provider/loadConstrueLocale.js +293 -0
- package/es/api-client/APIClient.js +5 -0
- package/es/block-provider/FormBlockProvider.js +5 -2
- package/es/block-provider/KanbanBlockProvider.js +3 -3
- package/es/block-provider/SharedFilterProvider.d.ts +1 -0
- package/es/block-provider/SharedFilterProvider.js +22 -6
- package/es/collection-manager/CollectionHistoryProvider.js +14 -2
- package/es/collection-manager/hooks/useCollection.d.ts +1 -0
- package/es/collection-manager/hooks/useCollection.js +10 -0
- package/es/collection-manager/interfaces/index.d.ts +0 -1
- package/es/collection-manager/interfaces/index.js +0 -1
- package/es/collection-manager/interfaces/o2m.js +1 -0
- package/es/collection-manager/interfaces/properties/operators.js +7 -0
- package/es/collection-manager/interfaces/subTable.js +1 -0
- package/es/collection-manager/templates/calendar.js +5 -0
- package/es/formula/Expression.d.ts +2 -0
- package/es/formula/Expression.js +296 -0
- package/es/formula/Result.d.ts +2 -0
- package/es/formula/Result.js +91 -0
- package/es/formula/index.d.ts +6 -0
- package/es/formula/index.js +8 -0
- package/es/i18n/i18n.js +7 -12
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -2
- package/es/locale/en_US.d.ts +108 -28
- package/es/locale/en_US.js +108 -28
- package/es/locale/index.d.ts +201 -4
- package/es/locale/index.js +191 -58
- package/es/locale/ja_JP.d.ts +4 -0
- package/es/locale/ja_JP.js +4 -0
- package/es/locale/zh_CN.d.ts +11 -1
- package/es/locale/zh_CN.js +12 -2
- package/es/plugin-manager/PluginManager.js +19 -13
- package/es/pm/PluginManagerLink.js +38 -43
- package/es/pm/index.d.ts +1 -0
- package/es/pm/index.js +84 -35
- package/es/record-provider/index.d.ts +1 -0
- package/es/record-provider/index.js +7 -4
- package/es/route-switch/antd/admin-layout/index.d.ts +1 -0
- package/es/route-switch/antd/admin-layout/index.js +4 -6
- package/es/schema-component/antd/action/Action.js +19 -16
- package/es/schema-component/antd/association-filter/AssociationFilter.Item.js +24 -23
- package/es/schema-component/antd/cron/Cron.d.ts +0 -1
- package/es/schema-component/antd/cron/Cron.js +16 -19
- package/es/schema-component/antd/cron/locale/index.d.ts +37 -0
- package/es/schema-component/antd/cron/locale/index.js +6 -0
- package/es/schema-component/antd/filter/useFilterActionProps.js +17 -23
- package/es/schema-component/antd/form-item/FormItem.js +5 -4
- package/es/schema-component/antd/index.d.ts +1 -2
- package/es/schema-component/antd/index.js +1 -2
- package/es/schema-component/antd/page/FixedBlock.d.ts +1 -1
- package/es/schema-component/antd/page/FixedBlock.js +70 -21
- package/es/schema-component/antd/page/Page.js +15 -10
- package/es/schema-component/antd/remote-select/RemoteSelect.js +12 -2
- package/es/schema-component/antd/table/Table.Array.js +1 -1
- package/es/schema-component/antd/table-v2/Table.js +13 -6
- package/es/schema-component/antd/table-v2/TableBlockDesigner.js +24 -8
- package/es/schema-component/hooks/useDesignable.d.ts +1 -1
- package/es/schema-component/hooks/useDesignable.js +45 -16
- package/es/schema-component/hooks/useFieldTitle.js +3 -1
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
- package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
- package/es/schema-initializer/utils.js +6 -9
- package/es/schema-templates/BlockTemplate.js +2 -2
- package/es/schema-templates/SchemaTemplateManagerProvider.js +1 -1
- package/es/system-settings/SystemSettingsShortcut.js +1 -1
- package/lib/acl/ACLProvider.d.ts +16 -2
- package/lib/acl/ACLProvider.js +283 -102
- package/lib/acl/Configuration/ConfigureCenter.d.ts +2 -0
- package/lib/acl/Configuration/ConfigureCenter.js +278 -0
- package/lib/acl/Configuration/MenuConfigure.js +3 -3
- package/lib/acl/Configuration/PermisionProvider.d.ts +4 -0
- package/lib/acl/Configuration/PermisionProvider.js +156 -0
- package/lib/acl/Configuration/RoleConfigure.js +107 -23
- package/lib/acl/Configuration/RoleTable.d.ts +1 -1
- package/lib/acl/Configuration/RoleTable.js +8 -4
- package/lib/acl/Configuration/RolesResourcesActions.js +2 -2
- package/lib/acl/Configuration/index.d.ts +1 -0
- package/lib/acl/Configuration/index.js +15 -1
- package/lib/acl/Configuration/schemas/roleCollections.js +41 -13
- package/lib/acl/Configuration/schemas/roles.js +47 -2
- package/lib/acl/Configuration/schemas/scopes.js +2 -0
- package/lib/acl/index.d.ts +1 -0
- package/lib/acl/index.js +3 -1
- package/lib/acl/style.less +10 -0
- package/lib/antd-config-provider/index.d.ts +3 -1
- package/lib/antd-config-provider/index.js +40 -6
- package/lib/antd-config-provider/loadConstrueLocale.d.ts +1 -0
- package/lib/antd-config-provider/loadConstrueLocale.js +304 -0
- package/lib/api-client/APIClient.js +5 -0
- package/lib/block-provider/FormBlockProvider.js +9 -3
- package/lib/block-provider/KanbanBlockProvider.js +3 -3
- package/lib/block-provider/SharedFilterProvider.d.ts +1 -0
- package/lib/block-provider/SharedFilterProvider.js +26 -7
- package/lib/collection-manager/CollectionHistoryProvider.js +14 -1
- package/lib/collection-manager/hooks/useCollection.d.ts +1 -0
- package/lib/collection-manager/hooks/useCollection.js +10 -0
- package/lib/collection-manager/interfaces/index.d.ts +0 -1
- package/lib/collection-manager/interfaces/index.js +0 -13
- package/lib/collection-manager/interfaces/o2m.js +1 -0
- package/lib/collection-manager/interfaces/properties/operators.js +7 -0
- package/lib/collection-manager/interfaces/subTable.js +1 -0
- package/lib/collection-manager/templates/calendar.js +5 -0
- package/lib/formula/Expression.d.ts +2 -0
- package/lib/formula/Expression.js +319 -0
- package/lib/formula/Result.d.ts +2 -0
- package/lib/formula/Result.js +114 -0
- package/lib/formula/index.d.ts +6 -0
- package/lib/formula/index.js +22 -0
- package/lib/i18n/i18n.js +7 -14
- package/lib/index.d.ts +2 -1
- package/lib/index.js +26 -13
- package/lib/locale/en_US.d.ts +108 -28
- package/lib/locale/en_US.js +108 -28
- package/lib/locale/index.d.ts +201 -4
- package/lib/locale/index.js +197 -67
- package/lib/locale/ja_JP.d.ts +4 -0
- package/lib/locale/ja_JP.js +4 -0
- package/lib/locale/zh_CN.d.ts +11 -1
- package/lib/locale/zh_CN.js +12 -2
- package/lib/plugin-manager/PluginManager.js +20 -13
- package/lib/pm/PluginManagerLink.js +37 -43
- package/lib/pm/index.d.ts +1 -0
- package/lib/pm/index.js +90 -35
- package/lib/record-provider/index.d.ts +1 -0
- package/lib/record-provider/index.js +7 -4
- package/lib/route-switch/antd/admin-layout/index.d.ts +1 -0
- package/lib/route-switch/antd/admin-layout/index.js +5 -4
- package/lib/schema-component/antd/action/Action.js +19 -16
- package/lib/schema-component/antd/association-filter/AssociationFilter.Item.js +22 -21
- package/lib/schema-component/antd/cron/Cron.d.ts +0 -1
- package/lib/schema-component/antd/cron/Cron.js +19 -24
- package/lib/schema-component/antd/cron/locale/index.d.ts +37 -0
- package/lib/schema-component/antd/cron/locale/index.js +18 -0
- package/lib/schema-component/antd/filter/useFilterActionProps.js +16 -23
- package/lib/schema-component/antd/form-item/FormItem.js +6 -4
- package/lib/schema-component/antd/index.d.ts +1 -2
- package/lib/schema-component/antd/index.js +8 -21
- package/lib/schema-component/antd/page/FixedBlock.d.ts +1 -1
- package/lib/schema-component/antd/page/FixedBlock.js +71 -21
- package/lib/schema-component/antd/page/Page.js +14 -9
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +18 -3
- package/lib/schema-component/antd/table/Table.Array.js +1 -1
- package/lib/schema-component/antd/table-v2/Table.js +14 -6
- package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +25 -8
- package/lib/schema-component/hooks/useDesignable.d.ts +1 -1
- package/lib/schema-component/hooks/useDesignable.js +47 -18
- package/lib/schema-component/hooks/useFieldTitle.js +4 -1
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.d.ts +3 -0
- package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +1 -0
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -0
- package/lib/schema-initializer/utils.js +6 -9
- package/lib/schema-templates/BlockTemplate.js +2 -2
- package/lib/schema-templates/SchemaTemplateManagerProvider.js +1 -1
- package/lib/system-settings/SystemSettingsShortcut.js +1 -1
- package/package.json +6 -11
- package/es/collection-manager/interfaces/formula.d.ts +0 -2
- package/es/collection-manager/interfaces/formula.js +0 -74
- package/es/schema-component/antd/formula-input/Compute.d.ts +0 -3
- package/es/schema-component/antd/formula-input/Compute.js +0 -55
- package/es/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
- package/es/schema-component/antd/formula-input/FormulaInput.js +0 -167
- package/es/schema-component/antd/formula-input/index.d.ts +0 -1
- package/es/schema-component/antd/formula-input/index.js +0 -7
- package/lib/collection-manager/interfaces/formula.d.ts +0 -2
- package/lib/collection-manager/interfaces/formula.js +0 -83
- package/lib/schema-component/antd/formula-input/Compute.d.ts +0 -3
- package/lib/schema-component/antd/formula-input/Compute.js +0 -79
- package/lib/schema-component/antd/formula-input/FormulaInput.d.ts +0 -3
- package/lib/schema-component/antd/formula-input/FormulaInput.js +0 -191
- package/lib/schema-component/antd/formula-input/index.d.ts +0 -1
- package/lib/schema-component/antd/formula-input/index.js +0 -18
package/lib/acl/ACLProvider.js
CHANGED
|
@@ -5,7 +5,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.useACLFieldWhitelist = exports.useACLContext = exports.useACLActionParamsContext = exports.default = exports.ACLRolesCheckProvider = exports.ACLProvider = exports.ACLMenuItemProvider = exports.ACLContext = exports.ACLCollectionProvider = exports.ACLCollectionFieldProvider = exports.ACLActionProvider = exports.ACLActionParamsContext = void 0;
|
|
9
|
+
exports.useACLRoleContext = useACLRoleContext;
|
|
10
|
+
exports.useRoleRecheck = exports.useRecordPkValue = exports.useACLRolesCheck = void 0;
|
|
9
11
|
|
|
10
12
|
var _react = require("@formily/react");
|
|
11
13
|
|
|
@@ -17,8 +19,12 @@ var _reactRouterDom = require("react-router-dom");
|
|
|
17
19
|
|
|
18
20
|
var _apiClient = require("../api-client");
|
|
19
21
|
|
|
22
|
+
var _BlockProvider = require("../block-provider/BlockProvider");
|
|
23
|
+
|
|
20
24
|
var _collectionManager = require("../collection-manager");
|
|
21
25
|
|
|
26
|
+
var _ResourceActionProvider = require("../collection-manager/ResourceActionProvider");
|
|
27
|
+
|
|
22
28
|
var _recordProvider = require("../record-provider");
|
|
23
29
|
|
|
24
30
|
var _schemaComponent = require("../schema-component");
|
|
@@ -27,6 +33,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
33
|
|
|
28
34
|
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; }
|
|
29
35
|
|
|
36
|
+
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
37
|
+
|
|
38
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
|
+
|
|
30
46
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
47
|
|
|
32
48
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -39,13 +55,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
39
55
|
|
|
40
56
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
57
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
|
-
|
|
46
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
|
-
|
|
48
|
-
var ACLContext = /*#__PURE__*/(0, _react2.createContext)(null);
|
|
58
|
+
var ACLContext = /*#__PURE__*/(0, _react2.createContext)({});
|
|
49
59
|
exports.ACLContext = ACLContext;
|
|
50
60
|
|
|
51
61
|
var ACLProvider = function ACLProvider(props) {
|
|
@@ -61,7 +71,39 @@ var ACLProvider = function ACLProvider(props) {
|
|
|
61
71
|
|
|
62
72
|
exports.ACLProvider = ACLProvider;
|
|
63
73
|
|
|
74
|
+
var getRouteUrl = function getRouteUrl(props) {
|
|
75
|
+
var _props$children;
|
|
76
|
+
|
|
77
|
+
if (props === null || props === void 0 ? void 0 : props.match) {
|
|
78
|
+
return props.match;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return props && getRouteUrl(props === null || props === void 0 ? void 0 : (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.props);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var getRouteAclCheck = function getRouteAclCheck(match, snippets) {
|
|
85
|
+
var _params$name;
|
|
86
|
+
|
|
87
|
+
var url = match.url,
|
|
88
|
+
params = match.params;
|
|
89
|
+
|
|
90
|
+
if (url === '/admin/pm/list' || (params === null || params === void 0 ? void 0 : params.pluginName) || (params === null || params === void 0 ? void 0 : (_params$name = params.name) === null || _params$name === void 0 ? void 0 : _params$name.includes('settings'))) {
|
|
91
|
+
var pmAclCheck = url === '/admin/pm/list' && snippets.includes('pm');
|
|
92
|
+
var pluginTabByName = params === null || params === void 0 ? void 0 : params.name.split('/');
|
|
93
|
+
pluginTabByName.shift();
|
|
94
|
+
var pluginName = params.pluginName || pluginTabByName[0];
|
|
95
|
+
var tabName = params.tabName || pluginTabByName[1];
|
|
96
|
+
var pluginTabSnippet = pluginName && tabName && "!pm.".concat(pluginName, ".").concat(tabName);
|
|
97
|
+
var pluginTabAclCheck = pluginTabSnippet && !snippets.includes(pluginTabSnippet);
|
|
98
|
+
return pmAclCheck || pluginTabAclCheck;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return true;
|
|
102
|
+
};
|
|
103
|
+
|
|
64
104
|
var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
|
|
105
|
+
var route = getRouteUrl(props.children.props);
|
|
106
|
+
|
|
65
107
|
var _useDesignable = (0, _schemaComponent.useDesignable)(),
|
|
66
108
|
setDesignable = _useDesignable.setDesignable;
|
|
67
109
|
|
|
@@ -70,16 +112,16 @@ var ACLRolesCheckProvider = function ACLRolesCheckProvider(props) {
|
|
|
70
112
|
url: 'roles:check'
|
|
71
113
|
}, {
|
|
72
114
|
onSuccess: function onSuccess(data) {
|
|
73
|
-
var _data$data, _data$data2
|
|
115
|
+
var _data$data, _data$data2;
|
|
74
116
|
|
|
75
|
-
if (!(data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.
|
|
117
|
+
if (!(data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.snippets.includes('ui.*'))) {
|
|
76
118
|
setDesignable(false);
|
|
77
119
|
}
|
|
78
120
|
|
|
79
|
-
if ((data === null || data === void 0 ? void 0 : (_data$
|
|
80
|
-
var _data$
|
|
121
|
+
if ((data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.role) !== api.auth.role) {
|
|
122
|
+
var _data$data3;
|
|
81
123
|
|
|
82
|
-
api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$
|
|
124
|
+
api.auth.setRole(data === null || data === void 0 ? void 0 : (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.role);
|
|
83
125
|
}
|
|
84
126
|
}
|
|
85
127
|
});
|
|
@@ -105,11 +147,10 @@ var useRoleRecheck = function useRoleRecheck() {
|
|
|
105
147
|
var ctx = (0, _react2.useContext)(ACLContext);
|
|
106
148
|
|
|
107
149
|
var _useACLRoleContext = useACLRoleContext(),
|
|
108
|
-
allowAll = _useACLRoleContext.allowAll
|
|
109
|
-
allowConfigure = _useACLRoleContext.allowConfigure;
|
|
150
|
+
allowAll = _useACLRoleContext.allowAll;
|
|
110
151
|
|
|
111
152
|
return function () {
|
|
112
|
-
if (allowAll
|
|
153
|
+
if (allowAll) {
|
|
113
154
|
return;
|
|
114
155
|
}
|
|
115
156
|
|
|
@@ -124,108 +165,172 @@ var useACLContext = function useACLContext() {
|
|
|
124
165
|
};
|
|
125
166
|
|
|
126
167
|
exports.useACLContext = useACLContext;
|
|
168
|
+
var ACLActionParamsContext = /*#__PURE__*/(0, _react2.createContext)({});
|
|
169
|
+
exports.ACLActionParamsContext = ACLActionParamsContext;
|
|
127
170
|
|
|
128
|
-
var
|
|
171
|
+
var useACLRolesCheck = function useACLRolesCheck() {
|
|
129
172
|
var _ctx$data;
|
|
130
173
|
|
|
131
174
|
var ctx = (0, _react2.useContext)(ACLContext);
|
|
132
|
-
var data = (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
|
|
133
|
-
return _objectSpread(_objectSpread({}, data), {}, {
|
|
134
|
-
getActionParams: function getActionParams(path, _ref) {
|
|
135
|
-
var _data$actionAlias, _data$resources, _data$actions, _data$strategy;
|
|
175
|
+
var data = ctx === null || ctx === void 0 ? void 0 : (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : _ctx$data.data;
|
|
136
176
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var _path$split = path.split(':'),
|
|
141
|
-
_path$split2 = _slicedToArray(_path$split, 2),
|
|
142
|
-
resourceName = _path$split2[0],
|
|
143
|
-
act = _path$split2[1];
|
|
144
|
-
|
|
145
|
-
var currentAction = (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[act]) || act;
|
|
146
|
-
var hasResource = data === null || data === void 0 ? void 0 : (_data$resources = data.resources) === null || _data$resources === void 0 ? void 0 : _data$resources.includes(resourceName);
|
|
147
|
-
var params = data === null || data === void 0 ? void 0 : (_data$actions = data.actions) === null || _data$actions === void 0 ? void 0 : _data$actions["".concat(resourceName, ":").concat(currentAction)];
|
|
148
|
-
|
|
149
|
-
if (hasResource) {
|
|
150
|
-
if (!skipOwnCheck && (params === null || params === void 0 ? void 0 : params.own)) {
|
|
151
|
-
return isOwn ? params : null;
|
|
152
|
-
}
|
|
177
|
+
var getActionAlias = function getActionAlias(actionPath) {
|
|
178
|
+
var _data$actionAlias;
|
|
153
179
|
|
|
154
|
-
|
|
155
|
-
|
|
180
|
+
var actionName = actionPath.split(':').pop();
|
|
181
|
+
return (data === null || data === void 0 ? void 0 : (_data$actionAlias = data.actionAlias) === null || _data$actionAlias === void 0 ? void 0 : _data$actionAlias[actionName]) || actionName;
|
|
182
|
+
};
|
|
156
183
|
|
|
157
|
-
|
|
158
|
-
|
|
184
|
+
return {
|
|
185
|
+
data: data,
|
|
186
|
+
getActionAlias: getActionAlias,
|
|
187
|
+
inResources: function inResources(resourceName) {
|
|
188
|
+
var _data$resources, _data$resources$inclu;
|
|
189
|
+
|
|
190
|
+
return data === null || data === void 0 ? void 0 : (_data$resources = data.resources) === null || _data$resources === void 0 ? void 0 : (_data$resources$inclu = _data$resources.includes) === null || _data$resources$inclu === void 0 ? void 0 : _data$resources$inclu.call(_data$resources, resourceName);
|
|
191
|
+
},
|
|
192
|
+
getResourceActionParams: function getResourceActionParams(actionPath) {
|
|
193
|
+
var _data$actions, _data$actions2;
|
|
194
|
+
|
|
195
|
+
var _actionPath$split = actionPath.split(':'),
|
|
196
|
+
_actionPath$split2 = _slicedToArray(_actionPath$split, 1),
|
|
197
|
+
resourceName = _actionPath$split2[0];
|
|
198
|
+
|
|
199
|
+
var actionAlias = getActionAlias(actionPath);
|
|
200
|
+
return (data === null || data === void 0 ? void 0 : (_data$actions = data.actions) === null || _data$actions === void 0 ? void 0 : _data$actions["".concat(resourceName, ":").concat(actionAlias)]) || (data === null || data === void 0 ? void 0 : (_data$actions2 = data.actions) === null || _data$actions2 === void 0 ? void 0 : _data$actions2[actionPath]);
|
|
201
|
+
},
|
|
202
|
+
getStrategyActionParams: function getStrategyActionParams(actionPath) {
|
|
203
|
+
var _data$strategy, _data$strategy$action;
|
|
204
|
+
|
|
205
|
+
var actionAlias = getActionAlias(actionPath);
|
|
206
|
+
var strategyAction = data === null || data === void 0 ? void 0 : (_data$strategy = data.strategy) === null || _data$strategy === void 0 ? void 0 : (_data$strategy$action = _data$strategy.actions) === null || _data$strategy$action === void 0 ? void 0 : _data$strategy$action.find(function (action) {
|
|
159
207
|
var _action$split = action.split(':'),
|
|
160
208
|
_action$split2 = _slicedToArray(_action$split, 1),
|
|
161
209
|
value = _action$split2[0];
|
|
162
210
|
|
|
163
|
-
return value ===
|
|
211
|
+
return value === actionAlias;
|
|
164
212
|
});
|
|
213
|
+
return strategyAction ? {} : null;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
};
|
|
165
217
|
|
|
166
|
-
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
218
|
+
exports.useACLRolesCheck = useACLRolesCheck;
|
|
169
219
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
220
|
+
var getIgnoreScope = function getIgnoreScope() {
|
|
221
|
+
var _schema$xAclAction;
|
|
173
222
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
223
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
224
|
+
var schema = options.schema,
|
|
225
|
+
recordPkValue = options.recordPkValue;
|
|
226
|
+
var ignoreScope = false;
|
|
177
227
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
228
|
+
if (options.ignoreScope) {
|
|
229
|
+
ignoreScope = true;
|
|
230
|
+
}
|
|
181
231
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
232
|
+
if (schema === null || schema === void 0 ? void 0 : schema['x-acl-ignore-scope']) {
|
|
233
|
+
ignoreScope = true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (schema === null || schema === void 0 ? void 0 : (_schema$xAclAction = schema['x-acl-action-props']) === null || _schema$xAclAction === void 0 ? void 0 : _schema$xAclAction['skipScopeCheck']) {
|
|
237
|
+
ignoreScope = true;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (!recordPkValue) {
|
|
241
|
+
ignoreScope = true;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return ignoreScope;
|
|
185
245
|
};
|
|
186
246
|
|
|
187
|
-
|
|
247
|
+
var useAllowedActions = function useAllowedActions() {
|
|
248
|
+
var _result$service, _result$service$data, _result$service$data$;
|
|
188
249
|
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
250
|
+
var result = (0, _BlockProvider.useBlockRequestContext)() || {
|
|
251
|
+
service: (0, _ResourceActionProvider.useResourceActionContext)()
|
|
252
|
+
};
|
|
253
|
+
return result === null || result === void 0 ? void 0 : (_result$service = result.service) === null || _result$service === void 0 ? void 0 : (_result$service$data = _result$service.data) === null || _result$service$data === void 0 ? void 0 : (_result$service$data$ = _result$service$data.meta) === null || _result$service$data$ === void 0 ? void 0 : _result$service$data$.allowedActions;
|
|
254
|
+
};
|
|
193
255
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
256
|
+
var useResourceName = function useResourceName() {
|
|
257
|
+
var _result$props, _result$service2, _result$service2$defa;
|
|
197
258
|
|
|
198
|
-
|
|
259
|
+
var result = (0, _BlockProvider.useBlockRequestContext)() || {
|
|
260
|
+
service: (0, _ResourceActionProvider.useResourceActionContext)()
|
|
261
|
+
};
|
|
262
|
+
return (result === null || result === void 0 ? void 0 : (_result$props = result.props) === null || _result$props === void 0 ? void 0 : _result$props.resource) || (result === null || result === void 0 ? void 0 : (_result$service2 = result.service) === null || _result$service2 === void 0 ? void 0 : (_result$service2$defa = _result$service2.defaultRequest) === null || _result$service2$defa === void 0 ? void 0 : _result$service2$defa.resource);
|
|
199
263
|
};
|
|
200
264
|
|
|
201
|
-
|
|
202
|
-
var
|
|
265
|
+
function useACLRoleContext() {
|
|
266
|
+
var _useACLRolesCheck = useACLRolesCheck(),
|
|
267
|
+
data = _useACLRolesCheck.data,
|
|
268
|
+
getActionAlias = _useACLRolesCheck.getActionAlias,
|
|
269
|
+
inResources = _useACLRolesCheck.inResources,
|
|
270
|
+
getResourceActionParams = _useACLRolesCheck.getResourceActionParams,
|
|
271
|
+
getStrategyActionParams = _useACLRolesCheck.getStrategyActionParams;
|
|
203
272
|
|
|
204
|
-
var
|
|
205
|
-
var _fieldSchema$xAclAc;
|
|
273
|
+
var allowedActions = useAllowedActions();
|
|
206
274
|
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
allowConfigure = _useACLRoleContext3.allowConfigure,
|
|
210
|
-
getActionParams = _useACLRoleContext3.getActionParams;
|
|
275
|
+
var verifyScope = function verifyScope(actionName, recordPkValue) {
|
|
276
|
+
var actionAlias = getActionAlias(actionName);
|
|
211
277
|
|
|
212
|
-
|
|
213
|
-
|
|
278
|
+
if (!Array.isArray(allowedActions === null || allowedActions === void 0 ? void 0 : allowedActions[actionAlias])) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
214
281
|
|
|
215
|
-
|
|
282
|
+
return allowedActions[actionAlias].includes(recordPkValue);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
286
|
+
parseAction: function parseAction(actionPath) {
|
|
287
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
288
|
+
|
|
289
|
+
var _actionPath$split3 = actionPath.split(':'),
|
|
290
|
+
_actionPath$split4 = _slicedToArray(_actionPath$split3, 2),
|
|
291
|
+
resourceName = _actionPath$split4[0],
|
|
292
|
+
actionName = _actionPath$split4[1];
|
|
293
|
+
|
|
294
|
+
if (!getIgnoreScope(options)) {
|
|
295
|
+
var r = verifyScope(actionName, options.recordPkValue);
|
|
296
|
+
|
|
297
|
+
if (r !== null) {
|
|
298
|
+
return r ? {} : null;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (data === null || data === void 0 ? void 0 : data.allowAll) {
|
|
303
|
+
return {};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (inResources(resourceName)) {
|
|
307
|
+
return getResourceActionParams(actionPath);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return getStrategyActionParams(actionPath);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
var ACLCollectionProvider = function ACLCollectionProvider(props) {
|
|
316
|
+
var _useACLRoleContext2 = useACLRoleContext(),
|
|
317
|
+
allowAll = _useACLRoleContext2.allowAll,
|
|
318
|
+
parseAction = _useACLRoleContext2.parseAction;
|
|
319
|
+
|
|
320
|
+
var schema = (0, _react.useFieldSchema)();
|
|
321
|
+
|
|
322
|
+
if (allowAll) {
|
|
216
323
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
217
324
|
}
|
|
218
325
|
|
|
219
|
-
var
|
|
220
|
-
var skipScopeCheck = (_fieldSchema$xAclAc = fieldSchema['x-acl-action-props']) === null || _fieldSchema$xAclAc === void 0 ? void 0 : _fieldSchema$xAclAc.skipScopeCheck;
|
|
326
|
+
var actionPath = schema['x-acl-action'];
|
|
221
327
|
|
|
222
|
-
if (!
|
|
328
|
+
if (!actionPath) {
|
|
223
329
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
224
330
|
}
|
|
225
331
|
|
|
226
|
-
var params =
|
|
227
|
-
|
|
228
|
-
skipOwnCheck: skipScopeCheck === false ? false : true
|
|
332
|
+
var params = parseAction(actionPath, {
|
|
333
|
+
schema: schema
|
|
229
334
|
});
|
|
230
335
|
|
|
231
336
|
if (!params) {
|
|
@@ -239,30 +344,48 @@ var ACLCollectionProvider = function ACLCollectionProvider(props) {
|
|
|
239
344
|
|
|
240
345
|
exports.ACLCollectionProvider = ACLCollectionProvider;
|
|
241
346
|
|
|
242
|
-
var
|
|
243
|
-
|
|
347
|
+
var useACLActionParamsContext = function useACLActionParamsContext() {
|
|
348
|
+
return (0, _react2.useContext)(ACLActionParamsContext);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
exports.useACLActionParamsContext = useACLActionParamsContext;
|
|
244
352
|
|
|
353
|
+
var useRecordPkValue = function useRecordPkValue() {
|
|
245
354
|
var _useCollection = (0, _collectionManager.useCollection)(),
|
|
246
|
-
|
|
355
|
+
getPrimaryKey = _useCollection.getPrimaryKey;
|
|
247
356
|
|
|
248
|
-
var
|
|
249
|
-
var
|
|
357
|
+
var record = (0, _recordProvider.useRecord)();
|
|
358
|
+
var primaryKey = getPrimaryKey();
|
|
359
|
+
return record === null || record === void 0 ? void 0 : record[primaryKey];
|
|
360
|
+
};
|
|
250
361
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
362
|
+
exports.useRecordPkValue = useRecordPkValue;
|
|
363
|
+
|
|
364
|
+
var ACLActionProvider = function ACLActionProvider(props) {
|
|
365
|
+
var recordPkValue = useRecordPkValue();
|
|
366
|
+
var resource = useResourceName();
|
|
367
|
+
|
|
368
|
+
var _useACLRoleContext3 = useACLRoleContext(),
|
|
369
|
+
parseAction = _useACLRoleContext3.parseAction;
|
|
370
|
+
|
|
371
|
+
var schema = (0, _react.useFieldSchema)();
|
|
372
|
+
var actionPath = schema['x-acl-action'];
|
|
255
373
|
|
|
256
|
-
if (!
|
|
374
|
+
if (!actionPath && resource && schema['x-action']) {
|
|
375
|
+
actionPath = "".concat(resource, ":").concat(schema['x-action']);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (!actionPath.includes(':')) {
|
|
379
|
+
actionPath = "".concat(resource, ":").concat(actionPath);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (!actionPath) {
|
|
257
383
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
258
384
|
}
|
|
259
385
|
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var params = getActionParams(path, {
|
|
264
|
-
skipOwnCheck: skipScopeCheck,
|
|
265
|
-
isOwn: isOwn
|
|
386
|
+
var params = parseAction(actionPath, {
|
|
387
|
+
schema: schema,
|
|
388
|
+
recordPkValue: recordPkValue
|
|
266
389
|
});
|
|
267
390
|
|
|
268
391
|
if (!params) {
|
|
@@ -276,7 +399,65 @@ var ACLActionProvider = function ACLActionProvider(props) {
|
|
|
276
399
|
|
|
277
400
|
exports.ACLActionProvider = ACLActionProvider;
|
|
278
401
|
|
|
402
|
+
var useACLFieldWhitelist = function useACLFieldWhitelist() {
|
|
403
|
+
var params = (0, _react2.useContext)(ACLActionParamsContext);
|
|
404
|
+
var whitelist = [].concat((params === null || params === void 0 ? void 0 : params.whitelist) || []).concat((params === null || params === void 0 ? void 0 : params.fields) || []).concat((params === null || params === void 0 ? void 0 : params.appends) || []);
|
|
405
|
+
return {
|
|
406
|
+
whitelist: whitelist,
|
|
407
|
+
schemaInWhitelist: function schemaInWhitelist(fieldSchema) {
|
|
408
|
+
if (whitelist.length === 0) {
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (!fieldSchema) {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (!fieldSchema['x-collection-field']) {
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
var _fieldSchema$xCollec = fieldSchema['x-collection-field'].split('.'),
|
|
421
|
+
_fieldSchema$xCollec2 = _toArray(_fieldSchema$xCollec),
|
|
422
|
+
keys = _fieldSchema$xCollec2.slice(1);
|
|
423
|
+
|
|
424
|
+
return whitelist === null || whitelist === void 0 ? void 0 : whitelist.includes(keys.join('.'));
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
exports.useACLFieldWhitelist = useACLFieldWhitelist;
|
|
430
|
+
|
|
279
431
|
var ACLCollectionFieldProvider = function ACLCollectionFieldProvider(props) {
|
|
432
|
+
var fieldSchema = (0, _react.useFieldSchema)();
|
|
433
|
+
var field = (0, _react.useField)();
|
|
434
|
+
|
|
435
|
+
var _useACLRoleContext4 = useACLRoleContext(),
|
|
436
|
+
allowAll = _useACLRoleContext4.allowAll;
|
|
437
|
+
|
|
438
|
+
if (allowAll) {
|
|
439
|
+
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (!fieldSchema['x-collection-field']) {
|
|
443
|
+
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
var _useACLFieldWhitelist = useACLFieldWhitelist(),
|
|
447
|
+
whitelist = _useACLFieldWhitelist.whitelist;
|
|
448
|
+
|
|
449
|
+
var allowed = whitelist.length > 0 ? whitelist.includes(fieldSchema.name) : true;
|
|
450
|
+
(0, _react2.useEffect)(function () {
|
|
451
|
+
if (!allowed) {
|
|
452
|
+
field.required = false;
|
|
453
|
+
field.display = 'hidden';
|
|
454
|
+
}
|
|
455
|
+
}, [allowed]);
|
|
456
|
+
|
|
457
|
+
if (!allowed) {
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
280
461
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
281
462
|
};
|
|
282
463
|
|
|
@@ -285,13 +466,13 @@ exports.ACLCollectionFieldProvider = ACLCollectionFieldProvider;
|
|
|
285
466
|
var ACLMenuItemProvider = function ACLMenuItemProvider(props) {
|
|
286
467
|
var _useACLRoleContext5 = useACLRoleContext(),
|
|
287
468
|
allowAll = _useACLRoleContext5.allowAll,
|
|
288
|
-
allowConfigure = _useACLRoleContext5.allowConfigure,
|
|
289
469
|
_useACLRoleContext5$a = _useACLRoleContext5.allowMenuItemIds,
|
|
290
|
-
allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a
|
|
470
|
+
allowMenuItemIds = _useACLRoleContext5$a === void 0 ? [] : _useACLRoleContext5$a,
|
|
471
|
+
snippets = _useACLRoleContext5.snippets;
|
|
291
472
|
|
|
292
473
|
var fieldSchema = (0, _react.useFieldSchema)();
|
|
293
474
|
|
|
294
|
-
if (allowAll ||
|
|
475
|
+
if (allowAll || snippets.includes('ui.*')) {
|
|
295
476
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, props.children);
|
|
296
477
|
}
|
|
297
478
|
|