@commercetools-frontend/permissions 20.12.3 → 21.0.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/README.md
CHANGED
|
@@ -4,294 +4,4 @@
|
|
|
4
4
|
<a href="https://www.npmjs.com/package/@commercetools-frontend/permissions"><img src="https://badgen.net/npm/v/@commercetools-frontend/permissions" alt="Latest release (latest dist-tag)" /></a> <a href="https://www.npmjs.com/package/@commercetools-frontend/permissions"><img src="https://badgen.net/npm/v/@commercetools-frontend/permissions/next" alt="Latest release (next dist-tag)" /></a> <a href="https://bundlephobia.com/result?p=@commercetools-frontend/permissions"><img src="https://badgen.net/bundlephobia/minzip/@commercetools-frontend/permissions" alt="Minified + GZipped size" /></a> <a href="https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE"><img src="https://badgen.net/github/license/commercetools/merchant-center-application-kit" alt="GitHub license" /></a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- `useIsAuthorized()`
|
|
10
|
-
- `injectAuthorized()`
|
|
11
|
-
- `<RestrictedByPermissions>`
|
|
12
|
-
- `branchOnPermissions()`
|
|
13
|
-
|
|
14
|
-
## Install
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
$ npm install --save @commercetools-frontend/permissions
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Available permissions
|
|
21
|
-
|
|
22
|
-
A `Permission` is represented as a `String` with a prefix of `View` or `Manage`, followed by one of the following resource names:
|
|
23
|
-
|
|
24
|
-
- `Products`
|
|
25
|
-
- `Categories`
|
|
26
|
-
- `Customers`
|
|
27
|
-
- `CustomerGroups`
|
|
28
|
-
- `Orders`
|
|
29
|
-
- `ProductDiscounts`
|
|
30
|
-
- `CartDiscounts`
|
|
31
|
-
- `DiscountCodes`
|
|
32
|
-
- `ProjectSettings`
|
|
33
|
-
- `ProductTypes`
|
|
34
|
-
- `DeveloperSettings`
|
|
35
|
-
|
|
36
|
-
We recommend to put the permissions used by your application into a `constants.js` file.
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
// constants.js
|
|
40
|
-
export const PERMISSIONS = {
|
|
41
|
-
ViewProducts: 'ViewProducts',
|
|
42
|
-
ManageProducts: 'ManageProducts',
|
|
43
|
-
ViewOrders: 'ViewOrders',
|
|
44
|
-
ManageProductTypes: 'ManageProductTypes',
|
|
45
|
-
ViewProductTypes: 'ViewProductTypes',
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Available action rights
|
|
50
|
-
|
|
51
|
-
An `ActionRight` is represented as an object with the shape `{ group: string, name: string }`. The `group` relates to the permission while the `name` is the action right itself. Currently the following action rights for the `group: 'products'` exist:
|
|
52
|
-
|
|
53
|
-
- `PublishProducts`
|
|
54
|
-
- `UnpublishProducts`
|
|
55
|
-
- `AddPrices`
|
|
56
|
-
- `EditPrices`
|
|
57
|
-
- `DeletePrices`
|
|
58
|
-
- `DeleteProducts`
|
|
59
|
-
- `AddProducts`
|
|
60
|
-
|
|
61
|
-
We recommend to put the action rights used by your application into a `constants.js` file.
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
export const ACTION_RIGHTS = {
|
|
65
|
-
PublishProducts: { group: 'products', name: 'PublishProducts' },
|
|
66
|
-
UnpublishProducts: { group: 'products', name: 'UnpublishProducts' },
|
|
67
|
-
AddPrices: { group: 'products', name: 'AddPrices' },
|
|
68
|
-
EditPrices: { group: 'products', name: 'EditPrices' },
|
|
69
|
-
DeletePrices: { group: 'products', name: 'DeletePrices' },
|
|
70
|
-
DeleteProducts: { group: 'products', name: 'DeleteProducts' },
|
|
71
|
-
AddProducts: { group: 'products', name: 'AddProducts' },
|
|
72
|
-
};
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Available dataFences
|
|
76
|
-
|
|
77
|
-
> This is a **beta** feature and should be used with caution. For more information, please [open an issue](https://github.com/commercetools/merchant-center-application-kit/issues/new/choose).
|
|
78
|
-
|
|
79
|
-
A `DataFence` is represented as an object with the shape `{ group: string, name: string, type: string }`, where:
|
|
80
|
-
|
|
81
|
-
- `type`: is one of `['store']`
|
|
82
|
-
- `name`: is the `Permission` value
|
|
83
|
-
- `group`: is one of the resource types (e.g. `orders`)
|
|
84
|
-
|
|
85
|
-
- `ViewOrders`
|
|
86
|
-
- `ManageOrders`
|
|
87
|
-
|
|
88
|
-
We recommend to put the dataFences used by your application into a `constants.js` file.
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
export const DATA_FENCES = {
|
|
92
|
-
ViewOrders: {
|
|
93
|
-
type: 'store',
|
|
94
|
-
group: 'orders',
|
|
95
|
-
name: 'ViewOrders',
|
|
96
|
-
},
|
|
97
|
-
ManageOrders: {
|
|
98
|
-
type: 'store',
|
|
99
|
-
group: 'orders',
|
|
100
|
-
name: 'ManageOrders',
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## `useIsAuthorized(options)`
|
|
106
|
-
|
|
107
|
-
```js
|
|
108
|
-
useIsAutorized(options: HookOptions): boolean
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Named arguments
|
|
112
|
-
|
|
113
|
-
- `demandedPermissions`: an array of `Permission`, requested for the child component to
|
|
114
|
-
be allowed to render
|
|
115
|
-
- `demandedAtionRights`: (_optional_) an array of action rights (mentioned above)
|
|
116
|
-
- `demandedDataFences`: (_optional_) an array of `DataFence` (mentioned above)
|
|
117
|
-
- `selectDataFenceData`: (_optional_ unless `dataFences` is specified) the function is called on each specified `dataFence` and should return the mapped value specific to the data fence. The function usually contains a switch-case logic based on the data fence `type`, with the return value based on the `props`. For example, with `type: 'order'`, the return value would be something like `ownProps.order.storeRef.key`.
|
|
118
|
-
- `shouldMatchSomePermissions`: (_optional_) determines if _some_ or _every_ requested permission should match (default `false`)
|
|
119
|
-
|
|
120
|
-
### Example
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
const Test = () => {
|
|
124
|
-
const canManageProducts = useIsAuthorized({
|
|
125
|
-
demandedPermissions: ['ManageProducts'],
|
|
126
|
-
});
|
|
127
|
-
if (canManageProducts) {
|
|
128
|
-
return <span>{'Authorized'}</span>;
|
|
129
|
-
}
|
|
130
|
-
return <span>{'Not authorized'}</span>;
|
|
131
|
-
};
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## `injectAuthorized(permissions, [options])`
|
|
135
|
-
|
|
136
|
-
Like `branchOnPermissions`, but without the `FallbackComponent`.
|
|
137
|
-
|
|
138
|
-
> This is meant to be used in cases where only the `isAuthorized` prop is needed
|
|
139
|
-
> to be injected.
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
injectAuthorized(
|
|
143
|
-
permissions: [Permissions.ManageOrders],
|
|
144
|
-
options: ?Object
|
|
145
|
-
): HoC
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Arguments
|
|
149
|
-
|
|
150
|
-
- `permissions`: an array of `Permission`, requested for the child component to
|
|
151
|
-
be allowed to render
|
|
152
|
-
- `options` (_optional_)
|
|
153
|
-
- `shouldMatchSomePermissions`: (_optional_) determines if _some_ or _every_ requested permission should match
|
|
154
|
-
(default `false`)
|
|
155
|
-
- `actionRights`: (_optional_) an array of action rights (mentioned above)
|
|
156
|
-
- `dataFences`: (_optional_) an array of `DataFence` (mentioned above)
|
|
157
|
-
- `getSelectDataFenceData`: (_optional_ unless `dataFences` is specified) the function is called with the component `props` and must return a new function that will be called on each specified `dataFence` and should return the mapped value specific to the data fence. The returned function usually contains a switch-case logic based on the data fence `type`, with the return value based on the `props`. For example, with `type: 'order'`, the return value would be something like `ownProps.order.storeRef.key`.
|
|
158
|
-
|
|
159
|
-
### Example
|
|
160
|
-
|
|
161
|
-
```js
|
|
162
|
-
const InputField = (props) => (
|
|
163
|
-
<Input
|
|
164
|
-
//...
|
|
165
|
-
disabled={!props.isAuthorized}
|
|
166
|
-
/>
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
injectAuthorized([Permissions.ViewProducts, Permissions.ViewOrders])(
|
|
170
|
-
InputField
|
|
171
|
-
);
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## `<RestrictedByPermissions>`
|
|
175
|
-
|
|
176
|
-
A React component that will render its children if the requested permissions
|
|
177
|
-
match, otherwise a fallback component.
|
|
178
|
-
|
|
179
|
-
> This is the React version of the `branchOnPermissions` HoC.
|
|
180
|
-
|
|
181
|
-
```js
|
|
182
|
-
<RestrictedByPermissions permissions={[]} unauthorizedComponent={Unauthorized}>
|
|
183
|
-
<MyAuthorizedComponent />
|
|
184
|
-
</RestrictedByPermissions>
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Props
|
|
188
|
-
|
|
189
|
-
- `permissions`: an array of `Permission`, requested by the component
|
|
190
|
-
- `actionRights`: (_optional_) an array of `ActionRight`, requested by the component
|
|
191
|
-
- `dataFences`: (_optional_) an array of `DataFence`, requested by the component
|
|
192
|
-
- `selectDataFenceData`: (_optional_ unless `dataFences` is specified) the function is called on each specified `dataFence` and should return the mapped value specific to the data fence. The function usually contains a switch-case logic based on the data fence `type`, with the return value based on the `props`. For example, with `type: 'order'`, the return value would be something like `ownProps.order.storeRef.key`.
|
|
193
|
-
- `unauthorizedComponent`: (_optional_) a function return an React element to be
|
|
194
|
-
rendered in case the permissions don't match
|
|
195
|
-
- `render`: (_optional_) a function returning an React element or a node to be
|
|
196
|
-
rendered in case the permissions match
|
|
197
|
-
- Note: when a function is passed it will get an invoked with an object
|
|
198
|
-
containing `isAuthorized` e.g. `({ isAuthorized }) => <div />`
|
|
199
|
-
- `children`: (_optional_) a function returning an React element or a node to be
|
|
200
|
-
rendered in case the permissions match
|
|
201
|
-
- Note: when a function is passed it will get an invoked with an object
|
|
202
|
-
containing `isAuthorized` e.g. `({ isAuthorized }) => <div />`
|
|
203
|
-
- `shouldMatchSomePermissions`: (_optional_) determines if _some_ or _every_
|
|
204
|
-
requested permission should match (default `false`)
|
|
205
|
-
|
|
206
|
-
### Examples
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
const Unauthorized = () => <p>{'No permissions to see this'}</p>;
|
|
210
|
-
const Dashboard = () => {
|
|
211
|
-
const canViewProducts = useIsAuthorized({
|
|
212
|
-
demandedPermissions: ['ViewProducts'],
|
|
213
|
-
});
|
|
214
|
-
const canViewOrders = useIsAuthorized({
|
|
215
|
-
demandedPermissions: ['ViewOrders'],
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
return (
|
|
219
|
-
<div>
|
|
220
|
-
{canViewProducts ? <TopFiveProducts /> : <Unauthorized />}
|
|
221
|
-
<RevenueChart isDisabled={!canViewOrders || !canViewProducts} />}
|
|
222
|
-
</div>
|
|
223
|
-
);
|
|
224
|
-
};
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## `branchOnPermissions(permissions, [FallbackComponent], [options])`
|
|
228
|
-
|
|
229
|
-
A HoC that will render a fallback component if the requested permissions don't
|
|
230
|
-
match with the user permissions.
|
|
231
|
-
|
|
232
|
-
```js
|
|
233
|
-
branchOnPermissions(
|
|
234
|
-
permissions: [Permission],
|
|
235
|
-
unauthorizedComponent: ?UnauthorizedComponent,
|
|
236
|
-
options?: {
|
|
237
|
-
shouldMatchSomePermissions: boolean,
|
|
238
|
-
actionRights?: [ActionRight],
|
|
239
|
-
dataFences?: [DataFence],
|
|
240
|
-
getSelectDataFenceData?: ownProps => func
|
|
241
|
-
}
|
|
242
|
-
): HoC
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### Arguments
|
|
246
|
-
|
|
247
|
-
- `permissions`: an array of `Permission`, requested by the component
|
|
248
|
-
- `UnauthorizedComponent`: (_optional_) a reference to a React component to be
|
|
249
|
-
rendered in case the permissions don't match
|
|
250
|
-
- `options` (_optional_)
|
|
251
|
-
- `shouldMatchSomePermissions`: determines if _some_ or _every_ requested permission should match
|
|
252
|
-
(default `false`)
|
|
253
|
-
- `actionRights`: an array of `ActionRight` (mentioned above)
|
|
254
|
-
- `dataFences`: an array of `DataFence` (mentioned above)
|
|
255
|
-
- `getSelectDataFenceData`: (_optional_ unless `dataFences` is specified) the function is called with the component `props` and must return a new function that will be called on each specified `dataFence` and should return the mapped value specific to the data fence. The returned function usually contains a switch-case logic based on the data fence `type`, with the return value based on the `props`. For example, with `type: 'order'`, the return value would be something like `ownProps.order.storeRef.key`.
|
|
256
|
-
|
|
257
|
-
### Example
|
|
258
|
-
|
|
259
|
-
```js
|
|
260
|
-
// Only render a component when the user has the requested permissions
|
|
261
|
-
const TopFiveProducts = () =>
|
|
262
|
-
// ...
|
|
263
|
-
|
|
264
|
-
branchOnPermissions(['ViewProducts', 'ViewOrders'])(TopFiveProducts);
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
```js
|
|
268
|
-
// Only render a component when the user has the the requested dataFence
|
|
269
|
-
const LastOrder = ({ order : { store: "Germany" }}) =>
|
|
270
|
-
// ...
|
|
271
|
-
|
|
272
|
-
branchOnPermissions([], options: {
|
|
273
|
-
dataFences: [
|
|
274
|
-
{
|
|
275
|
-
name: 'ManageOrders',
|
|
276
|
-
group: 'orders',
|
|
277
|
-
type: 'store'
|
|
278
|
-
}
|
|
279
|
-
],
|
|
280
|
-
getSelectDataFenceData: ownProps => (demandedDataFence) => {
|
|
281
|
-
switch (demandedDataFence.type) {
|
|
282
|
-
case 'store':
|
|
283
|
-
return [ownProps.order.storeRef.key];
|
|
284
|
-
default:
|
|
285
|
-
return null
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
})(LastOrder);
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
```js
|
|
292
|
-
// Render a different component when the user doesn't have the requested permissions
|
|
293
|
-
const ReadOnlyInput = () => // ...
|
|
294
|
-
const Input = () => // ...
|
|
295
|
-
|
|
296
|
-
branchOnPermissions(['ViewProducts'], ReadOnlyInput)(Input)
|
|
297
|
-
```
|
|
7
|
+
Check out the [documentation](https://docs.commercetools.com/custom-applications/api-reference/commercetools-frontend-permissions) for more information.
|
|
@@ -53,7 +53,7 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
|
53
53
|
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
54
54
|
|
|
55
55
|
// NOTE: This string will be replaced on build time with the package version.
|
|
56
|
-
var version = "
|
|
56
|
+
var version = "21.0.0";
|
|
57
57
|
|
|
58
58
|
// Build the permission key from the definition to match it to the format coming from the API.
|
|
59
59
|
var toCanCase = function toCanCase(permissionName) {
|
|
@@ -356,9 +356,9 @@ var getDisplayName = function getDisplayName(Component) {
|
|
|
356
356
|
return Component.displayName || Component.name || 'Component';
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
359
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
360
360
|
|
|
361
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
361
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
362
362
|
var defaultProps = {
|
|
363
363
|
shouldMatchSomePermissions: false
|
|
364
364
|
};
|
|
@@ -481,9 +481,9 @@ RestrictedByPermissions.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
481
481
|
} : {};
|
|
482
482
|
RestrictedByPermissions.displayName = 'RestrictedByPermissions';
|
|
483
483
|
|
|
484
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
484
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
485
485
|
|
|
486
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
486
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
487
487
|
|
|
488
488
|
var branchOnPermissions = function branchOnPermissions(demandedPermissions, FallbackComponent) {
|
|
489
489
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
@@ -52,7 +52,7 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
|
52
52
|
var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
|
|
53
53
|
|
|
54
54
|
// NOTE: This string will be replaced on build time with the package version.
|
|
55
|
-
var version = "
|
|
55
|
+
var version = "21.0.0";
|
|
56
56
|
|
|
57
57
|
// Build the permission key from the definition to match it to the format coming from the API.
|
|
58
58
|
var toCanCase = function toCanCase(permissionName) {
|
|
@@ -354,9 +354,9 @@ var getDisplayName = function getDisplayName(Component) {
|
|
|
354
354
|
return Component.displayName || Component.name || 'Component';
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
357
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
358
358
|
|
|
359
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
359
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
360
360
|
var defaultProps = {
|
|
361
361
|
shouldMatchSomePermissions: false
|
|
362
362
|
};
|
|
@@ -458,9 +458,9 @@ var RestrictedByPermissions = function RestrictedByPermissions(props) {
|
|
|
458
458
|
RestrictedByPermissions.propTypes = {};
|
|
459
459
|
RestrictedByPermissions.displayName = 'RestrictedByPermissions';
|
|
460
460
|
|
|
461
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
461
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
462
462
|
|
|
463
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
463
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
464
464
|
|
|
465
465
|
var branchOnPermissions = function branchOnPermissions(demandedPermissions, FallbackComponent) {
|
|
466
466
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
@@ -26,7 +26,7 @@ import upperFirst from 'lodash/upperFirst';
|
|
|
26
26
|
import { jsx, Fragment } from '@emotion/react/jsx-runtime';
|
|
27
27
|
|
|
28
28
|
// NOTE: This string will be replaced on build time with the package version.
|
|
29
|
-
var version = "
|
|
29
|
+
var version = "21.0.0";
|
|
30
30
|
|
|
31
31
|
// Build the permission key from the definition to match it to the format coming from the API.
|
|
32
32
|
var toCanCase = function toCanCase(permissionName) {
|
|
@@ -329,9 +329,9 @@ var getDisplayName = function getDisplayName(Component) {
|
|
|
329
329
|
return Component.displayName || Component.name || 'Component';
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
332
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
333
333
|
|
|
334
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
334
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
335
335
|
var defaultProps = {
|
|
336
336
|
shouldMatchSomePermissions: false
|
|
337
337
|
};
|
|
@@ -454,9 +454,9 @@ RestrictedByPermissions.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
454
454
|
} : {};
|
|
455
455
|
RestrictedByPermissions.displayName = 'RestrictedByPermissions';
|
|
456
456
|
|
|
457
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
457
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
458
458
|
|
|
459
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
459
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
460
460
|
|
|
461
461
|
var branchOnPermissions = function branchOnPermissions(demandedPermissions, FallbackComponent) {
|
|
462
462
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/permissions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0",
|
|
4
4
|
"description": "React components to declaratively handle MC permissions",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"url": "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
9
9
|
"directory": "packages/permissions"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
11
|
+
"homepage": "https://docs.commercetools.com/custom-applications/api-reference/commercetools-frontend-permissions",
|
|
12
12
|
"keywords": ["javascript", "frontend", "react", "toolkit"],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"module": "dist/commercetools-frontend-permissions.esm.js",
|
|
19
19
|
"files": ["dist", "package.json", "LICENSE", "README.md"],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@babel/runtime": "7.16.
|
|
22
|
-
"@babel/runtime-corejs3": "7.16.
|
|
23
|
-
"@commercetools-frontend/application-shell-connectors": "
|
|
24
|
-
"@commercetools-frontend/sentry": "
|
|
21
|
+
"@babel/runtime": "^7.16.7",
|
|
22
|
+
"@babel/runtime-corejs3": "^7.16.8",
|
|
23
|
+
"@commercetools-frontend/application-shell-connectors": "21.0.0",
|
|
24
|
+
"@commercetools-frontend/sentry": "21.0.0",
|
|
25
25
|
"@emotion/react": "11.7.1",
|
|
26
26
|
"@types/lodash": "^4.14.178",
|
|
27
27
|
"@types/prop-types": "^15.7.4",
|
|
28
|
-
"@types/react": "^17.0.
|
|
28
|
+
"@types/react": "^17.0.38",
|
|
29
29
|
"lodash": "4.17.21",
|
|
30
|
-
"prop-types": "15.
|
|
30
|
+
"prop-types": "15.8.1",
|
|
31
31
|
"tiny-invariant": "1.2.0",
|
|
32
32
|
"tiny-warning": "1.0.3"
|
|
33
33
|
},
|