orc-shared 1.2.0-dev.1 → 1.2.0-dev.13
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/actions/applications.js +1 -1
- package/dist/actions/authentication.js +1 -1
- package/dist/actions/countries.js +1 -1
- package/dist/actions/locale.js +1 -1
- package/dist/actions/makeApiAction.js +3 -3
- package/dist/actions/makeOrcApiAction.js +2 -2
- package/dist/actions/metadata.js +3 -3
- package/dist/actions/modules.js +63 -1
- package/dist/actions/navigation.js +3 -3
- package/dist/actions/requestsApi.js +8 -8
- package/dist/actions/scopes.js +59 -22
- package/dist/actions/timezones.js +1 -1
- package/dist/actions/toasts.js +1 -1
- package/dist/actions/versionInfo.js +1 -1
- package/dist/actions/view.js +1 -1
- package/dist/buildStore.js +3 -3
- package/dist/components/AppFrame/About.js +11 -6
- package/dist/components/AppFrame/MenuItem.js +6 -15
- package/dist/components/AppFrame/Preferences.js +3 -3
- package/dist/components/AppFrame/Sidebar.js +20 -9
- package/dist/components/AppFrame/Topbar.js +1 -1
- package/dist/components/ApplicationModuleLoader.js +143 -0
- package/dist/components/Authenticate.js +13 -13
- package/dist/components/CategoryList.js +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/DropMenu/Menu.js +1 -1
- package/dist/components/DropMenu/index.js +1 -1
- package/dist/components/Form/FieldList.js +3 -3
- package/dist/components/Form/Form.js +1 -1
- package/dist/components/Form/Inputs/Button.js +1 -1
- package/dist/components/Form/Inputs/FieldButtons.js +1 -1
- package/dist/components/Form/Inputs/Number.js +1 -1
- package/dist/components/Form/Inputs/ReadOnly.js +1 -1
- package/dist/components/Form/Inputs/SmallButton.js +1 -1
- package/dist/components/Form/Inputs/Text.js +1 -1
- package/dist/components/Form/Inputs/Time.js +1 -1
- package/dist/components/Form/Inputs/Toggles.js +1 -1
- package/dist/components/Form/Inputs/Translation.js +3 -3
- package/dist/components/List/HeadCell.js +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/List/Row.js +1 -1
- package/dist/components/List/enhanceColumnDefs.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/Table.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +3 -3
- package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
- package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/InputBase.js +42 -5
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +2 -2
- package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Switch.js +3 -3
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/TimePicker.js +1 -1
- package/dist/components/MaterialUI/Inputs/createInput.js +3 -3
- package/dist/components/MaterialUI/Inputs/index.js +1 -1
- package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/ExternalLink.js +113 -0
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +8 -2
- package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +1 -1
- package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +7 -2
- package/dist/components/MaterialUI/textProps.js +1 -1
- package/dist/components/Modules.js +126 -41
- package/dist/components/MultiSelector.js +1 -1
- package/dist/components/Navigation/Bar.js +3 -3
- package/dist/components/Navigation/Tab.js +1 -1
- package/dist/components/Navigation/useNavigationState.js +3 -3
- package/dist/components/Placeholder.js +1 -1
- package/dist/components/Routing/FullPage.js +3 -1
- package/dist/components/Routing/Page.js +5 -3
- package/dist/components/Routing/Segment.js +1 -1
- package/dist/components/Routing/SegmentPage.js +1 -1
- package/dist/components/Routing/withWaypointing.js +8 -4
- package/dist/components/Scope/ScopeNode.js +1 -1
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +3 -3
- package/dist/components/Scope/useScopeConfirmationModalState.js +7 -16
- package/dist/components/Scope/useScopeData.js +4 -13
- package/dist/components/Scope/useScopeSelect.js +1 -1
- package/dist/components/Selector.js +1 -1
- package/dist/components/Spritesheet.js +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/ToastList.js +1 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Treeview/Label.js +1 -1
- package/dist/components/Treeview/Leaf.js +1 -1
- package/dist/components/Treeview/Node.js +3 -3
- package/dist/components/Treeview/index.js +2 -2
- package/dist/components/Treeview/settings.js +1 -1
- package/dist/constants.js +19 -2
- package/dist/content/icons/lock.svg +3 -0
- package/dist/content/icons/orckestra-icon.svg +5 -0
- package/dist/content/icons/unlock.svg +3 -0
- package/dist/content/iconsSheet.svg +11 -0
- package/dist/content/orckestra-logo-white.png +0 -0
- package/dist/getThemeOverrides.js +2 -2
- package/dist/hocs/withInfiniteScroll.js +1 -1
- package/dist/hocs/withUpdateHandler.js +2 -2
- package/dist/hooks/useDispatchWithModulesData.js +1 -1
- package/dist/hooks/useEditState.js +3 -3
- package/dist/hooks/useEntityLoader.js +2 -2
- package/dist/hooks/useFullEntityEditState.js +3 -3
- package/dist/hooks/useLabelMessage.js +3 -3
- package/dist/hooks/useMultipleFieldEditState.js +2 -2
- package/dist/hooks/useNavigationHandler.js +1 -1
- package/dist/hooks/useNotificationRequestState.js +2 -2
- package/dist/hooks/useSelectorAndUnwrap.js +1 -1
- package/dist/reducers/metadata.js +1 -1
- package/dist/reducers/modules.js +39 -1
- package/dist/reducers/scopes.js +27 -0
- package/dist/reducers/settings.js +31 -2
- package/dist/schemas/countries.js +1 -1
- package/dist/schemas/definitions.js +1 -1
- package/dist/schemas/metadata.js +1 -1
- package/dist/schemas/productDefinitions.js +1 -1
- package/dist/schemas/timezones.js +1 -1
- package/dist/selectors/applications.js +1 -1
- package/dist/selectors/authentication.js +57 -18
- package/dist/selectors/countries.js +1 -1
- package/dist/selectors/locale.js +1 -1
- package/dist/selectors/metadata.js +16 -6
- package/dist/selectors/modules.js +15 -1
- package/dist/selectors/navigation.js +1 -1
- package/dist/selectors/requests.js +1 -1
- package/dist/selectors/scope.js +8 -1
- package/dist/selectors/settings.js +13 -1
- package/dist/selectors/versionInfo.js +1 -1
- package/dist/selectors/view.js +1 -1
- package/dist/spawnerMiddleware.js +1 -1
- package/dist/utils/displayModeHelper.js +1 -1
- package/dist/utils/flatten.js +2 -2
- package/dist/utils/localizationHelper.js +1 -1
- package/dist/utils/mapHelper.js +1 -1
- package/dist/utils/modelValidationHelper.js +1 -1
- package/dist/utils/parseHelper.js +1 -1
- package/dist/utils/propertyHelper.js +2 -2
- package/dist/utils/propertyValidator.js +1 -1
- package/dist/utils/setTranslation.js +27 -1
- package/dist/utils/setTranslationWithFallback.js +31 -2
- package/dist/utils/testUtils.js +2 -1
- package/dist/utils/unwrapImmutable.js +1 -1
- package/dist/utils/urlHelper.js +1 -1
- package/package.json +6 -5
- package/src/actions/modules.js +30 -0
- package/src/actions/modules.test.js +50 -1
- package/src/actions/scopes.js +33 -7
- package/src/actions/scopes.test.js +84 -14
- package/src/components/AppFrame/About.js +10 -3
- package/src/components/AppFrame/AppFrame.test.js +9 -0
- package/src/components/AppFrame/MenuItem.js +3 -5
- package/src/components/AppFrame/MenuItem.test.js +2 -24
- package/src/components/AppFrame/Sidebar.js +11 -12
- package/src/components/AppFrame/Sidebar.test.js +18 -0
- package/src/components/ApplicationModuleLoader.js +52 -0
- package/src/components/ApplicationModuleLoader.test.js +149 -0
- package/src/components/Authenticate.js +5 -4
- package/src/components/Authenticate.test.js +23 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +7 -1
- package/src/components/MaterialUI/Inputs/InputBase.js +19 -2
- package/src/components/MaterialUI/Inputs/InputBase.test.js +68 -0
- package/src/components/MaterialUI/Navigation/ExternalLink.js +25 -0
- package/src/components/MaterialUI/Navigation/ExternalLink.test.js +26 -0
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +5 -1
- package/src/components/MaterialUI/muiThemes.js +5 -0
- package/src/components/Modules.js +103 -20
- package/src/components/Modules.test.js +315 -28
- package/src/components/Provision.test.js +34 -0
- package/src/components/Routing/FullPage.js +2 -1
- package/src/components/Routing/FullPage.test.js +23 -0
- package/src/components/Routing/Page.js +2 -2
- package/src/components/Routing/Page.test.js +20 -0
- package/src/components/Routing/Segment.js +1 -1
- package/src/components/Routing/withWaypointing.js +2 -2
- package/src/components/Routing/withWaypointing.test.js +33 -5
- package/src/components/Scope/Scope.test.js +4 -0
- package/src/components/Scope/useScopeConfirmationModalState.js +5 -16
- package/src/components/Scope/useScopeConfirmationModalState.test.js +39 -13
- package/src/components/Scope/useScopeData.js +0 -3
- package/src/components/Scope/useScopeData.test.js +0 -27
- package/src/constants.js +15 -0
- package/src/content/icons/lock.svg +3 -0
- package/src/content/icons/orckestra-icon.svg +5 -0
- package/src/content/icons/unlock.svg +3 -0
- package/src/content/iconsSheet.svg +11 -0
- package/src/content/orckestra-logo-white.png +0 -0
- package/src/hocs/withScopeData.test.js +0 -31
- package/src/reducers/modules.js +48 -2
- package/src/reducers/modules.test.js +117 -2
- package/src/reducers/scopes.js +30 -0
- package/src/reducers/scopes.test.js +45 -1
- package/src/reducers/settings.js +26 -2
- package/src/reducers/settings.test.js +74 -6
- package/src/selectors/authentication.js +53 -27
- package/src/selectors/authentication.test.js +600 -12
- package/src/selectors/metadata.js +18 -7
- package/src/selectors/metadata.test.js +221 -283
- package/src/selectors/modules.js +7 -0
- package/src/selectors/modules.test.js +16 -1
- package/src/selectors/scope.js +3 -1
- package/src/selectors/scope.test.js +5 -0
- package/src/selectors/settings.js +6 -0
- package/src/translations/en-US.json +1 -1
- package/src/translations/fr-CA.json +1 -1
- package/src/utils/setTranslation.js +16 -1
- package/src/utils/setTranslation.test.js +24 -0
- package/src/utils/setTranslationWithFallback.js +18 -1
- package/src/utils/setTranslationWithFallback.test.js +108 -0
|
@@ -6,8 +6,47 @@ import {
|
|
|
6
6
|
hasEditorPermissions,
|
|
7
7
|
hasAdministratorPermissions,
|
|
8
8
|
hasReaderPermissions,
|
|
9
|
+
hasEditorPermissionsForScope,
|
|
10
|
+
hasAdministratorPermissionsForScope,
|
|
11
|
+
hasReaderPermissionsForScope,
|
|
9
12
|
} from "./authentication";
|
|
10
13
|
|
|
14
|
+
const state = {
|
|
15
|
+
navigation: {
|
|
16
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
17
|
+
},
|
|
18
|
+
settings: { defaultScope: "Global" },
|
|
19
|
+
locale: {
|
|
20
|
+
locale: "fr",
|
|
21
|
+
supportedLocales: ["en", "fr"],
|
|
22
|
+
},
|
|
23
|
+
scopes: {
|
|
24
|
+
Global: {
|
|
25
|
+
name: { en: "Global", fr: "Global" },
|
|
26
|
+
id: "Global",
|
|
27
|
+
children: ["MyScope"],
|
|
28
|
+
currency: {
|
|
29
|
+
displayName: {
|
|
30
|
+
en: "Euro",
|
|
31
|
+
fr: "Euro",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultCulture: "en-US",
|
|
35
|
+
},
|
|
36
|
+
MyScope: {
|
|
37
|
+
name: { en: "First child", fr: "Premier fils" },
|
|
38
|
+
id: "FirstChild",
|
|
39
|
+
children: ["ChildScope"],
|
|
40
|
+
parentScopeId: "Global",
|
|
41
|
+
},
|
|
42
|
+
ChildScope: {
|
|
43
|
+
name: { en: "First grandchild", fr: "Premier petit-fils" },
|
|
44
|
+
id: "FirstGrandchild",
|
|
45
|
+
parentScopeId: "MyScope",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
11
50
|
describe("selectCurrentUsername", () => {
|
|
12
51
|
it("Gets the logged in username", () =>
|
|
13
52
|
expect(
|
|
@@ -142,10 +181,7 @@ describe("hasEditorPermissions", () => {
|
|
|
142
181
|
[
|
|
143
182
|
Immutable.fromJS({
|
|
144
183
|
authentication: { rolesClaimsValues: claims },
|
|
145
|
-
|
|
146
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
147
|
-
},
|
|
148
|
-
settings: { defaultScope: "Global" },
|
|
184
|
+
...state,
|
|
149
185
|
}),
|
|
150
186
|
],
|
|
151
187
|
"to equal",
|
|
@@ -212,6 +248,34 @@ describe("hasEditorPermissions", () => {
|
|
|
212
248
|
);
|
|
213
249
|
});
|
|
214
250
|
|
|
251
|
+
it("Retrieves true if user has editor permissions just in specified scope with permission on parents", () => {
|
|
252
|
+
const claims = Immutable.fromJS({
|
|
253
|
+
Orders: {
|
|
254
|
+
MyScope: {
|
|
255
|
+
Editor: true,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
expect(
|
|
261
|
+
hasEditorPermissions,
|
|
262
|
+
"when called with",
|
|
263
|
+
["Orders"],
|
|
264
|
+
"called with",
|
|
265
|
+
[
|
|
266
|
+
Immutable.fromJS({
|
|
267
|
+
authentication: { rolesClaimsValues: claims },
|
|
268
|
+
...state,
|
|
269
|
+
navigation: {
|
|
270
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
271
|
+
},
|
|
272
|
+
}),
|
|
273
|
+
],
|
|
274
|
+
"to equal",
|
|
275
|
+
true,
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
215
279
|
it("Retrieves false if app roles claims are null", () => {
|
|
216
280
|
expect(
|
|
217
281
|
hasEditorPermissions,
|
|
@@ -233,6 +297,164 @@ describe("hasEditorPermissions", () => {
|
|
|
233
297
|
});
|
|
234
298
|
});
|
|
235
299
|
|
|
300
|
+
describe("hasEditorPermissionsForScope", () => {
|
|
301
|
+
it("Retrieves true if user has editor permissions in specified group", () => {
|
|
302
|
+
const claims = Immutable.fromJS({
|
|
303
|
+
Orders: {
|
|
304
|
+
"*": {
|
|
305
|
+
Editor: true,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
expect(
|
|
311
|
+
hasEditorPermissionsForScope,
|
|
312
|
+
"when called with",
|
|
313
|
+
["Global", "Orders"],
|
|
314
|
+
"called with",
|
|
315
|
+
[
|
|
316
|
+
Immutable.fromJS({
|
|
317
|
+
authentication: { rolesClaimsValues: claims },
|
|
318
|
+
}),
|
|
319
|
+
],
|
|
320
|
+
"to equal",
|
|
321
|
+
true,
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("Retrieves false if user has not editor permissions in specified group", () => {
|
|
326
|
+
const claims = Immutable.fromJS({
|
|
327
|
+
Orders: {
|
|
328
|
+
"*": {
|
|
329
|
+
Editor: false,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
expect(
|
|
335
|
+
hasEditorPermissionsForScope,
|
|
336
|
+
"when called with",
|
|
337
|
+
["Global", "Orders"],
|
|
338
|
+
"called with",
|
|
339
|
+
[
|
|
340
|
+
Immutable.fromJS({
|
|
341
|
+
authentication: { rolesClaimsValues: claims },
|
|
342
|
+
...state,
|
|
343
|
+
}),
|
|
344
|
+
],
|
|
345
|
+
"to equal",
|
|
346
|
+
false,
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("Retrieves true if user hasn't global editor permissions but, has in current scope in specified group", () => {
|
|
351
|
+
const claims = Immutable.fromJS({
|
|
352
|
+
Orders: {
|
|
353
|
+
"*": {
|
|
354
|
+
Editor: false,
|
|
355
|
+
},
|
|
356
|
+
MyScope: {
|
|
357
|
+
Editor: true,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
expect(
|
|
363
|
+
hasEditorPermissionsForScope,
|
|
364
|
+
"when called with",
|
|
365
|
+
["MyScope", "Orders"],
|
|
366
|
+
"called with",
|
|
367
|
+
[
|
|
368
|
+
Immutable.fromJS({
|
|
369
|
+
authentication: { rolesClaimsValues: claims },
|
|
370
|
+
navigation: {
|
|
371
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
372
|
+
},
|
|
373
|
+
settings: { defaultScope: "Global" },
|
|
374
|
+
}),
|
|
375
|
+
],
|
|
376
|
+
"to equal",
|
|
377
|
+
true,
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("Retrieves true if user has editor permissions just in specified scope", () => {
|
|
382
|
+
const claims = Immutable.fromJS({
|
|
383
|
+
Orders: {
|
|
384
|
+
MyScope: {
|
|
385
|
+
Editor: true,
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
expect(
|
|
391
|
+
hasEditorPermissionsForScope,
|
|
392
|
+
"when called with",
|
|
393
|
+
["MyScope", "Orders"],
|
|
394
|
+
"called with",
|
|
395
|
+
[
|
|
396
|
+
Immutable.fromJS({
|
|
397
|
+
authentication: { rolesClaimsValues: claims },
|
|
398
|
+
navigation: {
|
|
399
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
400
|
+
},
|
|
401
|
+
settings: { defaultScope: "Global" },
|
|
402
|
+
}),
|
|
403
|
+
],
|
|
404
|
+
"to equal",
|
|
405
|
+
true,
|
|
406
|
+
);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it("Retrieves true if user has editor permissions just in specified scope with permission on parents", () => {
|
|
410
|
+
const claims = Immutable.fromJS({
|
|
411
|
+
Orders: {
|
|
412
|
+
MyScope: {
|
|
413
|
+
Editor: true,
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
expect(
|
|
419
|
+
hasEditorPermissionsForScope,
|
|
420
|
+
"when called with",
|
|
421
|
+
["ChildScope", "Orders"],
|
|
422
|
+
"called with",
|
|
423
|
+
[
|
|
424
|
+
Immutable.fromJS({
|
|
425
|
+
authentication: { rolesClaimsValues: claims },
|
|
426
|
+
...state,
|
|
427
|
+
navigation: {
|
|
428
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
429
|
+
},
|
|
430
|
+
}),
|
|
431
|
+
],
|
|
432
|
+
"to equal",
|
|
433
|
+
true,
|
|
434
|
+
);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
438
|
+
expect(
|
|
439
|
+
hasEditorPermissionsForScope,
|
|
440
|
+
"when called with",
|
|
441
|
+
["Global", "Orders"],
|
|
442
|
+
"called with",
|
|
443
|
+
[
|
|
444
|
+
Immutable.fromJS({
|
|
445
|
+
authentication: { rolesClaimsValues: {} },
|
|
446
|
+
navigation: {
|
|
447
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
448
|
+
},
|
|
449
|
+
settings: { defaultScope: "Global" },
|
|
450
|
+
}),
|
|
451
|
+
],
|
|
452
|
+
"to equal",
|
|
453
|
+
false,
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
|
|
236
458
|
describe("hasAdministratorPermissions", () => {
|
|
237
459
|
it("Retrieves true if user has global administrator permissions in specified group", () => {
|
|
238
460
|
const claims = Immutable.fromJS({
|
|
@@ -279,10 +501,7 @@ describe("hasAdministratorPermissions", () => {
|
|
|
279
501
|
[
|
|
280
502
|
Immutable.fromJS({
|
|
281
503
|
authentication: { rolesClaimsValues: claims },
|
|
282
|
-
|
|
283
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
284
|
-
},
|
|
285
|
-
settings: { defaultScope: "Global" },
|
|
504
|
+
...state,
|
|
286
505
|
}),
|
|
287
506
|
],
|
|
288
507
|
"to equal",
|
|
@@ -349,6 +568,34 @@ describe("hasAdministratorPermissions", () => {
|
|
|
349
568
|
);
|
|
350
569
|
});
|
|
351
570
|
|
|
571
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
572
|
+
const claims = Immutable.fromJS({
|
|
573
|
+
Orders: {
|
|
574
|
+
MyScope: {
|
|
575
|
+
Administrator: true,
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
expect(
|
|
581
|
+
hasAdministratorPermissions,
|
|
582
|
+
"when called with",
|
|
583
|
+
["Orders"],
|
|
584
|
+
"called with",
|
|
585
|
+
[
|
|
586
|
+
Immutable.fromJS({
|
|
587
|
+
authentication: { rolesClaimsValues: claims },
|
|
588
|
+
...state,
|
|
589
|
+
navigation: {
|
|
590
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
591
|
+
},
|
|
592
|
+
}),
|
|
593
|
+
],
|
|
594
|
+
"to equal",
|
|
595
|
+
true,
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
|
|
352
599
|
it("Retrieves false if app roles claims are null", () => {
|
|
353
600
|
expect(
|
|
354
601
|
hasAdministratorPermissions,
|
|
@@ -370,6 +617,164 @@ describe("hasAdministratorPermissions", () => {
|
|
|
370
617
|
});
|
|
371
618
|
});
|
|
372
619
|
|
|
620
|
+
describe("hasAdministratorPermissionsForScope", () => {
|
|
621
|
+
it("Retrieves true if user has administrator permissions in specified group", () => {
|
|
622
|
+
const claims = Immutable.fromJS({
|
|
623
|
+
Orders: {
|
|
624
|
+
"*": {
|
|
625
|
+
Administrator: true,
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
expect(
|
|
631
|
+
hasAdministratorPermissionsForScope,
|
|
632
|
+
"when called with",
|
|
633
|
+
["Global", "Orders"],
|
|
634
|
+
"called with",
|
|
635
|
+
[
|
|
636
|
+
Immutable.fromJS({
|
|
637
|
+
authentication: { rolesClaimsValues: claims },
|
|
638
|
+
}),
|
|
639
|
+
],
|
|
640
|
+
"to equal",
|
|
641
|
+
true,
|
|
642
|
+
);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
it("Retrieves false if user has not administrator permissions in specified group", () => {
|
|
646
|
+
const claims = Immutable.fromJS({
|
|
647
|
+
Orders: {
|
|
648
|
+
"*": {
|
|
649
|
+
Administrator: false,
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
expect(
|
|
655
|
+
hasAdministratorPermissionsForScope,
|
|
656
|
+
"when called with",
|
|
657
|
+
["Global", "Orders"],
|
|
658
|
+
"called with",
|
|
659
|
+
[
|
|
660
|
+
Immutable.fromJS({
|
|
661
|
+
authentication: { rolesClaimsValues: claims },
|
|
662
|
+
...state,
|
|
663
|
+
}),
|
|
664
|
+
],
|
|
665
|
+
"to equal",
|
|
666
|
+
false,
|
|
667
|
+
);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it("Retrieves true if user hasn't global administrator permissions but, has in current scope in specified group", () => {
|
|
671
|
+
const claims = Immutable.fromJS({
|
|
672
|
+
Orders: {
|
|
673
|
+
"*": {
|
|
674
|
+
Administrator: false,
|
|
675
|
+
},
|
|
676
|
+
MyScope: {
|
|
677
|
+
Administrator: true,
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
expect(
|
|
683
|
+
hasAdministratorPermissionsForScope,
|
|
684
|
+
"when called with",
|
|
685
|
+
["MyScope", "Orders"],
|
|
686
|
+
"called with",
|
|
687
|
+
[
|
|
688
|
+
Immutable.fromJS({
|
|
689
|
+
authentication: { rolesClaimsValues: claims },
|
|
690
|
+
navigation: {
|
|
691
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
692
|
+
},
|
|
693
|
+
settings: { defaultScope: "Global" },
|
|
694
|
+
}),
|
|
695
|
+
],
|
|
696
|
+
"to equal",
|
|
697
|
+
true,
|
|
698
|
+
);
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
it("Retrieves true if user has administrator permissions just in specified scope", () => {
|
|
702
|
+
const claims = Immutable.fromJS({
|
|
703
|
+
Orders: {
|
|
704
|
+
MyScope: {
|
|
705
|
+
Administrator: true,
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
expect(
|
|
711
|
+
hasAdministratorPermissionsForScope,
|
|
712
|
+
"when called with",
|
|
713
|
+
["MyScope", "Orders"],
|
|
714
|
+
"called with",
|
|
715
|
+
[
|
|
716
|
+
Immutable.fromJS({
|
|
717
|
+
authentication: { rolesClaimsValues: claims },
|
|
718
|
+
navigation: {
|
|
719
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
720
|
+
},
|
|
721
|
+
settings: { defaultScope: "Global" },
|
|
722
|
+
}),
|
|
723
|
+
],
|
|
724
|
+
"to equal",
|
|
725
|
+
true,
|
|
726
|
+
);
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
730
|
+
const claims = Immutable.fromJS({
|
|
731
|
+
Orders: {
|
|
732
|
+
MyScope: {
|
|
733
|
+
Administrator: true,
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
expect(
|
|
739
|
+
hasAdministratorPermissionsForScope,
|
|
740
|
+
"when called with",
|
|
741
|
+
["ChildScope", "Orders"],
|
|
742
|
+
"called with",
|
|
743
|
+
[
|
|
744
|
+
Immutable.fromJS({
|
|
745
|
+
authentication: { rolesClaimsValues: claims },
|
|
746
|
+
...state,
|
|
747
|
+
navigation: {
|
|
748
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
749
|
+
},
|
|
750
|
+
}),
|
|
751
|
+
],
|
|
752
|
+
"to equal",
|
|
753
|
+
true,
|
|
754
|
+
);
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
758
|
+
expect(
|
|
759
|
+
hasAdministratorPermissionsForScope,
|
|
760
|
+
"when called with",
|
|
761
|
+
["Global", "Orders"],
|
|
762
|
+
"called with",
|
|
763
|
+
[
|
|
764
|
+
Immutable.fromJS({
|
|
765
|
+
authentication: { rolesClaimsValues: {} },
|
|
766
|
+
navigation: {
|
|
767
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
768
|
+
},
|
|
769
|
+
settings: { defaultScope: "Global" },
|
|
770
|
+
}),
|
|
771
|
+
],
|
|
772
|
+
"to equal",
|
|
773
|
+
false,
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
|
|
373
778
|
describe("hasReaderPermissions", () => {
|
|
374
779
|
it("Retrieves true if user has reader permissions in specified group", () => {
|
|
375
780
|
const claims = Immutable.fromJS({
|
|
@@ -416,10 +821,7 @@ describe("hasReaderPermissions", () => {
|
|
|
416
821
|
[
|
|
417
822
|
Immutable.fromJS({
|
|
418
823
|
authentication: { rolesClaimsValues: claims },
|
|
419
|
-
|
|
420
|
-
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
421
|
-
},
|
|
422
|
-
settings: { defaultScope: "Global" },
|
|
824
|
+
...state,
|
|
423
825
|
}),
|
|
424
826
|
],
|
|
425
827
|
"to equal",
|
|
@@ -486,6 +888,34 @@ describe("hasReaderPermissions", () => {
|
|
|
486
888
|
);
|
|
487
889
|
});
|
|
488
890
|
|
|
891
|
+
it("Retrieves true if user has reader permissions just in specified scope with permission on parents", () => {
|
|
892
|
+
const claims = Immutable.fromJS({
|
|
893
|
+
Orders: {
|
|
894
|
+
MyScope: {
|
|
895
|
+
Reader: true,
|
|
896
|
+
},
|
|
897
|
+
},
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
expect(
|
|
901
|
+
hasReaderPermissions,
|
|
902
|
+
"when called with",
|
|
903
|
+
["Orders"],
|
|
904
|
+
"called with",
|
|
905
|
+
[
|
|
906
|
+
Immutable.fromJS({
|
|
907
|
+
authentication: { rolesClaimsValues: claims },
|
|
908
|
+
...state,
|
|
909
|
+
navigation: {
|
|
910
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
911
|
+
},
|
|
912
|
+
}),
|
|
913
|
+
],
|
|
914
|
+
"to equal",
|
|
915
|
+
true,
|
|
916
|
+
);
|
|
917
|
+
});
|
|
918
|
+
|
|
489
919
|
it("Retrieves false if app roles claims are null", () => {
|
|
490
920
|
expect(
|
|
491
921
|
hasReaderPermissions,
|
|
@@ -506,3 +936,161 @@ describe("hasReaderPermissions", () => {
|
|
|
506
936
|
);
|
|
507
937
|
});
|
|
508
938
|
});
|
|
939
|
+
|
|
940
|
+
describe("hasReaderPermissionsForScope", () => {
|
|
941
|
+
it("Retrieves true if user has administrator permissions in specified group", () => {
|
|
942
|
+
const claims = Immutable.fromJS({
|
|
943
|
+
Orders: {
|
|
944
|
+
"*": {
|
|
945
|
+
Reader: true,
|
|
946
|
+
},
|
|
947
|
+
},
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
expect(
|
|
951
|
+
hasReaderPermissionsForScope,
|
|
952
|
+
"when called with",
|
|
953
|
+
["Global", "Orders"],
|
|
954
|
+
"called with",
|
|
955
|
+
[
|
|
956
|
+
Immutable.fromJS({
|
|
957
|
+
authentication: { rolesClaimsValues: claims },
|
|
958
|
+
}),
|
|
959
|
+
],
|
|
960
|
+
"to equal",
|
|
961
|
+
true,
|
|
962
|
+
);
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
it("Retrieves false if user has not administrator permissions in specified group", () => {
|
|
966
|
+
const claims = Immutable.fromJS({
|
|
967
|
+
Orders: {
|
|
968
|
+
"*": {
|
|
969
|
+
Reader: false,
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
expect(
|
|
975
|
+
hasReaderPermissionsForScope,
|
|
976
|
+
"when called with",
|
|
977
|
+
["Global", "Orders"],
|
|
978
|
+
"called with",
|
|
979
|
+
[
|
|
980
|
+
Immutable.fromJS({
|
|
981
|
+
authentication: { rolesClaimsValues: claims },
|
|
982
|
+
...state,
|
|
983
|
+
}),
|
|
984
|
+
],
|
|
985
|
+
"to equal",
|
|
986
|
+
false,
|
|
987
|
+
);
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
it("Retrieves true if user hasn't global administrator permissions but, has in current scope in specified group", () => {
|
|
991
|
+
const claims = Immutable.fromJS({
|
|
992
|
+
Orders: {
|
|
993
|
+
"*": {
|
|
994
|
+
Reader: false,
|
|
995
|
+
},
|
|
996
|
+
MyScope: {
|
|
997
|
+
Reader: true,
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
expect(
|
|
1003
|
+
hasReaderPermissionsForScope,
|
|
1004
|
+
"when called with",
|
|
1005
|
+
["MyScope", "Orders"],
|
|
1006
|
+
"called with",
|
|
1007
|
+
[
|
|
1008
|
+
Immutable.fromJS({
|
|
1009
|
+
authentication: { rolesClaimsValues: claims },
|
|
1010
|
+
navigation: {
|
|
1011
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
1012
|
+
},
|
|
1013
|
+
settings: { defaultScope: "Global" },
|
|
1014
|
+
}),
|
|
1015
|
+
],
|
|
1016
|
+
"to equal",
|
|
1017
|
+
true,
|
|
1018
|
+
);
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
it("Retrieves true if user has administrator permissions just in specified scope", () => {
|
|
1022
|
+
const claims = Immutable.fromJS({
|
|
1023
|
+
Orders: {
|
|
1024
|
+
MyScope: {
|
|
1025
|
+
Reader: true,
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
expect(
|
|
1031
|
+
hasReaderPermissionsForScope,
|
|
1032
|
+
"when called with",
|
|
1033
|
+
["MyScope", "Orders"],
|
|
1034
|
+
"called with",
|
|
1035
|
+
[
|
|
1036
|
+
Immutable.fromJS({
|
|
1037
|
+
authentication: { rolesClaimsValues: claims },
|
|
1038
|
+
navigation: {
|
|
1039
|
+
route: { location: {}, match: { params: { scope: "MyScope" } } },
|
|
1040
|
+
},
|
|
1041
|
+
settings: { defaultScope: "Global" },
|
|
1042
|
+
}),
|
|
1043
|
+
],
|
|
1044
|
+
"to equal",
|
|
1045
|
+
true,
|
|
1046
|
+
);
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
it("Retrieves true if user has administrator permissions just in specified scope with permission on parents", () => {
|
|
1050
|
+
const claims = Immutable.fromJS({
|
|
1051
|
+
Orders: {
|
|
1052
|
+
MyScope: {
|
|
1053
|
+
Reader: true,
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
expect(
|
|
1059
|
+
hasReaderPermissionsForScope,
|
|
1060
|
+
"when called with",
|
|
1061
|
+
["ChildScope", "Orders"],
|
|
1062
|
+
"called with",
|
|
1063
|
+
[
|
|
1064
|
+
Immutable.fromJS({
|
|
1065
|
+
authentication: { rolesClaimsValues: claims },
|
|
1066
|
+
...state,
|
|
1067
|
+
navigation: {
|
|
1068
|
+
route: { location: {}, match: { params: { scope: "ChildScope" } } },
|
|
1069
|
+
},
|
|
1070
|
+
}),
|
|
1071
|
+
],
|
|
1072
|
+
"to equal",
|
|
1073
|
+
true,
|
|
1074
|
+
);
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
it("Retrieves false if app roles claims are null", () => {
|
|
1078
|
+
expect(
|
|
1079
|
+
hasReaderPermissionsForScope,
|
|
1080
|
+
"when called with",
|
|
1081
|
+
["Global", "Orders"],
|
|
1082
|
+
"called with",
|
|
1083
|
+
[
|
|
1084
|
+
Immutable.fromJS({
|
|
1085
|
+
authentication: { rolesClaimsValues: {} },
|
|
1086
|
+
navigation: {
|
|
1087
|
+
route: { location: {}, match: { params: { scope: "Global" } } },
|
|
1088
|
+
},
|
|
1089
|
+
settings: { defaultScope: "Global" },
|
|
1090
|
+
}),
|
|
1091
|
+
],
|
|
1092
|
+
"to equal",
|
|
1093
|
+
false,
|
|
1094
|
+
);
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
@@ -46,8 +46,10 @@ export const namedLookupSelector = memoize((moduleName, lookupName) =>
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
export const namedLookupValuesSelector = memoize((moduleName, lookupName) =>
|
|
49
|
-
createSelector(namedLookupSelector(moduleName, lookupName), currentLocaleOrDefault, (
|
|
50
|
-
(
|
|
49
|
+
createSelector(namedLookupSelector(moduleName, lookupName), currentLocaleOrDefault, (lookup, locale) =>
|
|
50
|
+
(lookup.get("values") || Immutable.Map()).map(lookupValue =>
|
|
51
|
+
setTranslationWithFallbackField(locale, lookupValue, "name", "displayName"),
|
|
52
|
+
),
|
|
51
53
|
),
|
|
52
54
|
);
|
|
53
55
|
|
|
@@ -157,7 +159,8 @@ const definitionEntityAttributes = memoize((moduleName, entityName) =>
|
|
|
157
159
|
),
|
|
158
160
|
);
|
|
159
161
|
|
|
160
|
-
const filterIsBuiltInAttributes = isBuiltIn => attributes =>
|
|
162
|
+
const filterIsBuiltInAttributes = isBuiltIn => attributes =>
|
|
163
|
+
attributes.filter(a => a.get("isBuiltIn") === isBuiltIn).sortBy(x => x.get("displayOrder"));
|
|
161
164
|
|
|
162
165
|
export const definitionEntityCustomAttributesSelector = memoize((moduleName, entityName) =>
|
|
163
166
|
createSelector(definitionEntityAttributes(moduleName, entityName), filterIsBuiltInAttributes(false)),
|
|
@@ -204,11 +207,15 @@ export const groupedCustomAttributesDefinitionSelector = memoize((moduleName, en
|
|
|
204
207
|
})
|
|
205
208
|
.set(
|
|
206
209
|
"baseAttributes",
|
|
207
|
-
group
|
|
210
|
+
group
|
|
211
|
+
.filter(i => i.get("dataType") !== attributeDataType.entityReference)
|
|
212
|
+
.sortBy(x => x.get("displayOrder")),
|
|
208
213
|
)
|
|
209
214
|
.set(
|
|
210
215
|
"profileAttributes",
|
|
211
|
-
group
|
|
216
|
+
group
|
|
217
|
+
.filter(i => i.get("dataType") === attributeDataType.entityReference)
|
|
218
|
+
.sortBy(x => x.get("displayOrder")),
|
|
212
219
|
);
|
|
213
220
|
})
|
|
214
221
|
.sortBy(x => x.get("displayOrder")),
|
|
@@ -220,8 +227,12 @@ export const customAttributesDefinitionSelector = memoize((moduleName, profileEn
|
|
|
220
227
|
mappedDefinitionEntity(moduleName, profileEntityName),
|
|
221
228
|
customAttributesSelector(moduleName, profileEntityName),
|
|
222
229
|
(definition, attributes) => {
|
|
223
|
-
const profileAttributes = attributes
|
|
224
|
-
|
|
230
|
+
const profileAttributes = attributes
|
|
231
|
+
?.filter(a => a.get("dataType") === attributeDataType.entityReference)
|
|
232
|
+
.sortBy(x => x.get("displayOrder"));
|
|
233
|
+
const baseAttributes = attributes
|
|
234
|
+
?.filter(a => a.get("dataType") !== attributeDataType.entityReference)
|
|
235
|
+
.sortBy(x => x.get("displayOrder"));
|
|
225
236
|
return definition.set("baseAttributes", baseAttributes).set("profileAttributes", profileAttributes);
|
|
226
237
|
},
|
|
227
238
|
),
|