orc-shared 1.2.0-dev.1 → 1.2.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +1 -1
- package/dist/actions/metadata.js +1 -1
- package/dist/actions/modules.js +63 -1
- package/dist/actions/navigation.js +1 -1
- 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 +1 -1
- package/dist/components/AppFrame/About.js +4 -3
- package/dist/components/AppFrame/MenuItem.js +6 -15
- package/dist/components/AppFrame/Preferences.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/MaterialUI/DataDisplay/List.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +1 -1
- 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 +1 -1
- package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
- 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 +1 -1
- 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/SelectProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
- 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 +1 -1
- 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/Surfaces/expansionPanelProps.js +1 -1
- package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +5 -0
- 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 +1 -1
- package/dist/components/Navigation/Tab.js +1 -1
- package/dist/components/Navigation/useNavigationState.js +1 -1
- 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 +6 -2
- package/dist/components/Scope/ScopeNode.js +1 -1
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +1 -1
- 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 +1 -1
- package/dist/components/Treeview/settings.js +1 -1
- package/dist/constants.js +19 -2
- package/dist/content/icons/orckestra-icon.svg +5 -0
- package/dist/content/iconsSheet.svg +8 -0
- package/dist/content/orckestra-logo-white.png +0 -0
- package/dist/hocs/withInfiniteScroll.js +1 -1
- package/dist/hooks/useDispatchWithModulesData.js +1 -1
- package/dist/hooks/useEditState.js +1 -1
- package/dist/hooks/useFullEntityEditState.js +1 -1
- package/dist/hooks/useLabelMessage.js +1 -1
- package/dist/hooks/useNavigationHandler.js +1 -1
- 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 +1 -1
- 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 +7 -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/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/setTranslationWithFallback.js +1 -1
- 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 +2 -2
- 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/Navigation/ExternalLink.js +25 -0
- package/src/components/MaterialUI/Navigation/ExternalLink.test.js +26 -0
- 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/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/orckestra-icon.svg +5 -0
- package/src/content/iconsSheet.svg +8 -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/modules.js +7 -0
- package/src/selectors/modules.test.js +16 -1
- package/src/selectors/scope.js +2 -0
- package/src/selectors/scope.test.js +5 -0
- package/src/selectors/settings.js +6 -0
|
@@ -6,7 +6,7 @@ import { Router, Route } from "react-router-dom";
|
|
|
6
6
|
import { mount, act } from "unexpected-reaction";
|
|
7
7
|
import sinon from "sinon";
|
|
8
8
|
import { PropStruct } from "../../utils/testUtils";
|
|
9
|
-
import { setRoute, mapHref } from "../../actions/navigation";
|
|
9
|
+
import { setRoute, mapHref, setCurrentPrependPath } from "../../actions/navigation";
|
|
10
10
|
import withWaypointing from "./withWaypointing";
|
|
11
11
|
|
|
12
12
|
describe("withWaypointing", () => {
|
|
@@ -22,6 +22,7 @@ describe("withWaypointing", () => {
|
|
|
22
22
|
params: { some: "meep" },
|
|
23
23
|
isExact: true,
|
|
24
24
|
},
|
|
25
|
+
modulePrependPath: "foo",
|
|
25
26
|
},
|
|
26
27
|
},
|
|
27
28
|
requests: {
|
|
@@ -94,6 +95,21 @@ describe("withWaypointing", () => {
|
|
|
94
95
|
})
|
|
95
96
|
.then(() => expect(store.dispatch, "to have calls satisfying", [])));
|
|
96
97
|
|
|
98
|
+
it("does not render the component if the component is not visible", () =>
|
|
99
|
+
expect(withWaypointing, "called with", [PropStruct, false])
|
|
100
|
+
.then(EnhancedView => {
|
|
101
|
+
return expect(
|
|
102
|
+
<Provider store={store}>
|
|
103
|
+
<Router history={history}>
|
|
104
|
+
<Route path="/feep/:some" component={EnhancedView} />
|
|
105
|
+
</Router>
|
|
106
|
+
</Provider>,
|
|
107
|
+
"when mounted",
|
|
108
|
+
"to be null",
|
|
109
|
+
);
|
|
110
|
+
})
|
|
111
|
+
.then(() => expect(store.dispatch, "to have calls satisfying", [])));
|
|
112
|
+
|
|
97
113
|
it("does fire action if path parameters different", () =>
|
|
98
114
|
expect(withWaypointing, "called with", [PropStruct])
|
|
99
115
|
.then(EnhancedView => {
|
|
@@ -128,7 +144,7 @@ describe("withWaypointing", () => {
|
|
|
128
144
|
));
|
|
129
145
|
|
|
130
146
|
it("does fire action if path parameters different and with custom props", () =>
|
|
131
|
-
expect(withWaypointing, "called with", [PropStruct, { foo: 123 }])
|
|
147
|
+
expect(withWaypointing, "called with", [PropStruct, true, { foo: 123 }])
|
|
132
148
|
.then(EnhancedView => {
|
|
133
149
|
history.replace("/feep/moof");
|
|
134
150
|
return expect(
|
|
@@ -161,7 +177,7 @@ describe("withWaypointing", () => {
|
|
|
161
177
|
));
|
|
162
178
|
|
|
163
179
|
it("does not fire action if route match is not exact with custom props", () =>
|
|
164
|
-
expect(withWaypointing, "called with", [PropStruct, { foo: 123 }])
|
|
180
|
+
expect(withWaypointing, "called with", [PropStruct, true, { foo: 123 }])
|
|
165
181
|
.then(EnhancedView => {
|
|
166
182
|
history.replace("/feep/meep/mef");
|
|
167
183
|
return expect(
|
|
@@ -201,16 +217,28 @@ describe("withWaypointing", () => {
|
|
|
201
217
|
return expect(
|
|
202
218
|
<Provider store={store}>
|
|
203
219
|
<Router history={history}>
|
|
204
|
-
<Route
|
|
220
|
+
<Route
|
|
221
|
+
path="/foo/bar"
|
|
222
|
+
render={props => <EnhancedView {...props} mapFrom="/foo" modulePrependPath="foo" />}
|
|
223
|
+
/>
|
|
205
224
|
</Router>
|
|
206
225
|
</Provider>,
|
|
207
226
|
"when mounted",
|
|
208
227
|
"to satisfy",
|
|
209
|
-
<PropStruct
|
|
228
|
+
<PropStruct
|
|
229
|
+
history="__ignore"
|
|
230
|
+
location="__ignore"
|
|
231
|
+
match="__ignore"
|
|
232
|
+
mapFrom="/foo"
|
|
233
|
+
modulePrependPath="__ignore"
|
|
234
|
+
/>,
|
|
210
235
|
);
|
|
211
236
|
})
|
|
212
237
|
.then(() =>
|
|
213
238
|
expect(store.dispatch, "to have calls satisfying", [
|
|
239
|
+
{
|
|
240
|
+
args: [setCurrentPrependPath("foo")],
|
|
241
|
+
},
|
|
214
242
|
{
|
|
215
243
|
args: [mapHref("/foo", "/foo/bar")],
|
|
216
244
|
},
|
|
@@ -6,8 +6,7 @@ import { applicationScopeHasChanged } from "../../actions/scopes";
|
|
|
6
6
|
import useScopeData from "./useScopeData";
|
|
7
7
|
import { hasUnsavedDataSelector } from "../../selectors/view";
|
|
8
8
|
import { scopeConfirmationDialogTypes } from "../../constants";
|
|
9
|
-
import {
|
|
10
|
-
import UrlPattern from "url-pattern";
|
|
9
|
+
import { setNewScopeAndModuleName } from "../../actions/modules";
|
|
11
10
|
|
|
12
11
|
const ExecuteClosingTabHandlerActions = async closingTabHandlerActions => {
|
|
13
12
|
if (closingTabHandlerActions.length <= 0) return Promise.resolve();
|
|
@@ -19,23 +18,13 @@ const ExecuteClosingTabHandlerActions = async closingTabHandlerActions => {
|
|
|
19
18
|
|
|
20
19
|
const useApplicationScopeChanger = closingTabHandlerActions => {
|
|
21
20
|
const dispatch = useDispatch();
|
|
22
|
-
const history = useHistory();
|
|
23
21
|
const moduleName = useSelectorAndUnwrap(selectCurrentModuleName);
|
|
24
22
|
|
|
25
23
|
return (previousScope, newScope) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// did not find a more reliable way to get the URL for the first tab of the module
|
|
31
|
-
const pattern = new UrlPattern(`/:scope/${moduleName}`);
|
|
32
|
-
const href = pattern.stringify(params);
|
|
33
|
-
|
|
34
|
-
history.push(href);
|
|
35
|
-
|
|
36
|
-
ExecuteClosingTabHandlerActions(closingTabHandlerActions).then(() =>
|
|
37
|
-
dispatch(applicationScopeHasChanged(previousScope, newScope)),
|
|
38
|
-
);
|
|
24
|
+
ExecuteClosingTabHandlerActions(closingTabHandlerActions).then(() => {
|
|
25
|
+
dispatch(setNewScopeAndModuleName(newScope, moduleName));
|
|
26
|
+
dispatch(applicationScopeHasChanged(previousScope, newScope));
|
|
27
|
+
});
|
|
39
28
|
};
|
|
40
29
|
};
|
|
41
30
|
|
|
@@ -4,8 +4,8 @@ import sinon from "sinon";
|
|
|
4
4
|
import { TestWrapper } from "../../utils/testUtils";
|
|
5
5
|
import useScopeConfirmationModalState from "./useScopeConfirmationModalState";
|
|
6
6
|
import { mount } from "enzyme";
|
|
7
|
-
import { createMemoryHistory } from "history";
|
|
8
7
|
import { APPLICATION_SCOPE_HAS_CHANGED } from "../../actions/scopes";
|
|
8
|
+
import { SET_NEW_SCOPE_AND_MODULE_NAME } from "../../actions/modules";
|
|
9
9
|
|
|
10
10
|
jest.mock("../../utils/buildUrl", () => {
|
|
11
11
|
const modExport = {};
|
|
@@ -35,13 +35,9 @@ const TestComp = () => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
describe("useScopeConfirmationModalState", () => {
|
|
38
|
-
let state, store
|
|
38
|
+
let state, store;
|
|
39
39
|
|
|
40
40
|
beforeEach(() => {
|
|
41
|
-
history = createMemoryHistory({ initialEntries: ["/TestScope/demos?arg=data"] });
|
|
42
|
-
sinon.spy(history, "push");
|
|
43
|
-
history.push.named("history.push");
|
|
44
|
-
|
|
45
41
|
state = Immutable.fromJS({
|
|
46
42
|
input: {},
|
|
47
43
|
locale: {
|
|
@@ -170,7 +166,7 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
170
166
|
|
|
171
167
|
it("selecting a new scope without active tabs changes the scope", async () => {
|
|
172
168
|
const component = (
|
|
173
|
-
<TestWrapper provider={{ store }}
|
|
169
|
+
<TestWrapper provider={{ store }}>
|
|
174
170
|
<TestComp />
|
|
175
171
|
</TestWrapper>
|
|
176
172
|
);
|
|
@@ -183,8 +179,18 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
183
179
|
|
|
184
180
|
await new Promise(resolve => setTimeout(resolve, 10));
|
|
185
181
|
|
|
186
|
-
expect(history.push, "to have calls satisfying", [{ args: ["/newScope/TheModuleName"] }]);
|
|
187
182
|
expect(store.dispatch, "to have calls satisfying", [
|
|
183
|
+
{
|
|
184
|
+
args: [
|
|
185
|
+
{
|
|
186
|
+
type: SET_NEW_SCOPE_AND_MODULE_NAME,
|
|
187
|
+
payload: {
|
|
188
|
+
scope: "newScope",
|
|
189
|
+
moduleName: "TheModuleName",
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
188
194
|
{
|
|
189
195
|
args: [
|
|
190
196
|
{
|
|
@@ -227,7 +233,7 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
227
233
|
openTabs();
|
|
228
234
|
|
|
229
235
|
const component = (
|
|
230
|
-
<TestWrapper provider={{ store }}
|
|
236
|
+
<TestWrapper provider={{ store }}>
|
|
231
237
|
<TestComp />
|
|
232
238
|
</TestWrapper>
|
|
233
239
|
);
|
|
@@ -248,8 +254,18 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
248
254
|
isModalOpened = mountedComponent.find("#isModalOpened").text();
|
|
249
255
|
expect(isModalOpened, "to equal", "false");
|
|
250
256
|
|
|
251
|
-
expect(history.push, "to have calls satisfying", [{ args: ["/newScope/TheModuleName"] }]);
|
|
252
257
|
expect(store.dispatch, "to have calls satisfying", [
|
|
258
|
+
{
|
|
259
|
+
args: [
|
|
260
|
+
{
|
|
261
|
+
type: SET_NEW_SCOPE_AND_MODULE_NAME,
|
|
262
|
+
payload: {
|
|
263
|
+
scope: "newScope",
|
|
264
|
+
moduleName: "TheModuleName",
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
},
|
|
253
269
|
{
|
|
254
270
|
args: [
|
|
255
271
|
{
|
|
@@ -281,7 +297,7 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
281
297
|
openTabs();
|
|
282
298
|
|
|
283
299
|
const component = (
|
|
284
|
-
<TestWrapper provider={{ store }}
|
|
300
|
+
<TestWrapper provider={{ store }}>
|
|
285
301
|
<TestComp />
|
|
286
302
|
</TestWrapper>
|
|
287
303
|
);
|
|
@@ -309,9 +325,19 @@ describe("useScopeConfirmationModalState", () => {
|
|
|
309
325
|
{ args: [null, true] },
|
|
310
326
|
]);
|
|
311
327
|
|
|
312
|
-
expect(
|
|
313
|
-
expect(store.dispatch.callCount, "to be", 1);
|
|
328
|
+
expect(store.dispatch.callCount, "to be", 2);
|
|
314
329
|
expect(store.dispatch, "to have calls satisfying", [
|
|
330
|
+
{
|
|
331
|
+
args: [
|
|
332
|
+
{
|
|
333
|
+
type: SET_NEW_SCOPE_AND_MODULE_NAME,
|
|
334
|
+
payload: {
|
|
335
|
+
scope: "newScope",
|
|
336
|
+
moduleName: "TheModuleName",
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
315
341
|
{
|
|
316
342
|
args: [
|
|
317
343
|
{
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useSelector } from "react-redux";
|
|
2
|
-
import useLoader from "../../hooks/useLoader";
|
|
3
2
|
import { unwrapImmutable } from "../../utils";
|
|
4
3
|
import { currentScopeSelector, scopeGetter } from "../../selectors/scope";
|
|
5
|
-
import { getScopes } from "../../actions/scopes";
|
|
6
4
|
|
|
7
5
|
const buildDefaultNodeState = (current, getScope) => {
|
|
8
6
|
let node = current;
|
|
@@ -16,7 +14,6 @@ const buildDefaultNodeState = (current, getScope) => {
|
|
|
16
14
|
const useScopeData = () => {
|
|
17
15
|
const currentScope = unwrapImmutable(useSelector(currentScopeSelector));
|
|
18
16
|
const getScope = useSelector(scopeGetter);
|
|
19
|
-
useLoader(getScopes(), () => currentScope.name);
|
|
20
17
|
const defaultNodeState = buildDefaultNodeState(currentScope, getScope);
|
|
21
18
|
return [currentScope, defaultNodeState, getScope];
|
|
22
19
|
};
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
3
|
import { MemoryRouter } from "react-router-dom";
|
|
4
4
|
import Immutable from "immutable";
|
|
5
|
-
import { RSAA } from "redux-api-middleware";
|
|
6
5
|
import sinon from "sinon";
|
|
7
6
|
import { PropStruct } from "../../utils/testUtils";
|
|
8
7
|
import useScopeData from "./useScopeData";
|
|
@@ -122,30 +121,4 @@ describe("useScopeData", () => {
|
|
|
122
121
|
)
|
|
123
122
|
|
|
124
123
|
.then(() => expect(store.dispatch, "was not called")));
|
|
125
|
-
|
|
126
|
-
it("loads scopes if it has none", () => {
|
|
127
|
-
state = state.setIn(["scopes"], Immutable.Map());
|
|
128
|
-
return expect(
|
|
129
|
-
<Provider store={store}>
|
|
130
|
-
<MemoryRouter>
|
|
131
|
-
<TestComp />
|
|
132
|
-
</MemoryRouter>
|
|
133
|
-
</Provider>,
|
|
134
|
-
"when mounted",
|
|
135
|
-
"to be a",
|
|
136
|
-
"DOMElement",
|
|
137
|
-
).then(() =>
|
|
138
|
-
expect(store.dispatch, "to have calls satisfying", [
|
|
139
|
-
{
|
|
140
|
-
args: [
|
|
141
|
-
{
|
|
142
|
-
[RSAA]: {
|
|
143
|
-
types: ["GET_SCOPES_REQUEST", "GET_SCOPES_SUCCESS", "GET_SCOPES_FAILURE"],
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
]),
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
124
|
});
|
package/src/constants.js
CHANGED
|
@@ -23,6 +23,7 @@ export const roleGroups = {
|
|
|
23
23
|
Shopping: "Shopping",
|
|
24
24
|
Search: "Search",
|
|
25
25
|
Profiles: "Profiles",
|
|
26
|
+
Locations: "Locations",
|
|
26
27
|
Orchestrator: "Orchestrator",
|
|
27
28
|
PriceManagement: "PriceManagement",
|
|
28
29
|
UserManagement: "UserManagement",
|
|
@@ -73,6 +74,20 @@ export const attributeDataType = {
|
|
|
73
74
|
customType: "CustomType",
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
// It is intended that some of them have a different value of its keys
|
|
78
|
+
export const overtureModule = {
|
|
79
|
+
System: "System",
|
|
80
|
+
Products: "Product",
|
|
81
|
+
Customers: "Customer",
|
|
82
|
+
Orders: "Order",
|
|
83
|
+
Marketing: "Marketing",
|
|
84
|
+
Report: "Reports",
|
|
85
|
+
Administration: "Administration",
|
|
86
|
+
UserManagement: "UserManagement",
|
|
87
|
+
PriceManagement: "PriceManagement",
|
|
88
|
+
Locations: "Location",
|
|
89
|
+
};
|
|
90
|
+
|
|
76
91
|
export const definitionType = {
|
|
77
92
|
shared: "Shared",
|
|
78
93
|
embedded: "Embedded",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="260" height="260" viewBox="0 0 260 260">
|
|
2
|
+
<path d="M1.11,125.62C1.11,74.94,40.22,39,93.72,39S186,74.94,186,125.62s-38.79,86.66-92.29,86.66S1.11,176.3,1.11,125.62Zm135.47,0c0-29.1-18.46-46.62-42.86-46.62S50.54,96.52,50.54,125.62s18.77,46.62,43.18,46.62S136.58,154.72,136.58,125.62Z" fill="#000000"/>
|
|
3
|
+
<circle id="ac06531b-599d-4b05-a30e-b1c94e55ddff" data-name="fullLogo" cx="227.6" cy="181.13" r="31.29" fill="#000000" opacity="0.33"/>
|
|
4
|
+
<circle id="af2ef0cf-5c47-4a93-b3be-f4e8ec48b016" data-name="fullLogo" cx="227.6" cy="181.13" r="31.29" fill="#e00600"/>
|
|
5
|
+
</svg>
|
|
@@ -122,6 +122,9 @@
|
|
|
122
122
|
<symbol id="icon-dropdown-chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
123
123
|
<polyline fill="none" stroke-linecap="round" stroke-linejoin="round" points="9 3 5 7 1 3"/>
|
|
124
124
|
</symbol>
|
|
125
|
+
<symbol id="icon-open-in-new-tab" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
126
|
+
<path stroke="none" fill-rule="evenodd" d="M8.4375,6.25 L7.8125,6.25 C7.63991102,6.25 7.5,6.38991102 7.5,6.5625 L7.5,8.75 L1.25,8.75 L1.25,2.5 L4.0625,2.5 C4.23508898,2.5 4.375,2.36008898 4.375,2.1875 L4.375,1.5625 C4.375,1.38991102 4.23508898,1.25 4.0625,1.25 L0.9375,1.25 C0.419733047,1.25 0,1.66973305 0,2.1875 L0,9.0625 C0,9.58026695 0.419733047,10 0.9375,10 L7.8125,10 C8.33026695,10 8.75,9.58026695 8.75,9.0625 L8.75,6.5625 C8.75,6.38991102 8.61008898,6.25 8.4375,6.25 Z M9.53125,0 L7.03125,0 C6.61386719,0 6.40527344,0.506054688 6.69921875,0.80078125 L7.39707031,1.49863281 L2.63671875,6.25722656 C2.54845882,6.34518057 2.49884911,6.46465556 2.49884911,6.58925781 C2.49884911,6.71386007 2.54845882,6.83333506 2.63671875,6.92128906 L3.07949219,7.36328125 C3.16744619,7.45154118 3.28692118,7.50115089 3.41152344,7.50115089 C3.53612569,7.50115089 3.65560068,7.45154118 3.74355469,7.36328125 L8.5015625,2.60390625 L9.19921875,3.30078125 C9.4921875,3.59375 10,3.38867188 10,2.96875 L10,0.46875 C10,0.209866524 9.79013348,0 9.53125,0 Z"/>
|
|
127
|
+
</symbol>
|
|
125
128
|
<symbol id="icon-dropdown-chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
126
129
|
<polyline fill="none" stroke-linecap="round" stroke-linejoin="round" points="9 3 5 7 1 3" transform="rotate(-90 5 5)"/>
|
|
127
130
|
</symbol>
|
|
@@ -355,6 +358,11 @@
|
|
|
355
358
|
<path d="M19.28 2.46A12 12 0 1 0 24 12a12 12 0 0 0-4.72-9.54zm-11 16.09A10.86 10.86 0 0 1 7.9 5.92h0a5.25 5.25 0 0 1 4.17-2.33c3.33 0 6 3.78 6 8.44s-2.71 8.45-6 8.45a5.09 5.09 0 0 1-3.83-1.92z" fill="url(#OperaA)"/>
|
|
356
359
|
<path d="M24,12a12,12,0,0,1-4.72,9.54,9.15,9.15,0,0,1-3.61.75,9.34,9.34,0,0,1-7.42-3.74,5.09,5.09,0,0,0,3.83,1.92c3.33,0,6-3.78,6-8.45s-2.71-8.44-6-8.44A5.25,5.25,0,0,0,7.91,5.91a9.41,9.41,0,0,1,7.76-4.2,9.15,9.15,0,0,1,3.61.75A12,12,0,0,1,24,12Z" fill="url(#OperaB)"/>
|
|
357
360
|
</symbol>
|
|
361
|
+
<symbol id="icon-orckestra-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 260">
|
|
362
|
+
<path stroke="none" d="M1.11,125.62C1.11,74.94,40.22,39,93.72,39S186,74.94,186,125.62s-38.79,86.66-92.29,86.66S1.11,176.3,1.11,125.62Zm135.47,0c0-29.1-18.46-46.62-42.86-46.62S50.54,96.52,50.54,125.62s18.77,46.62,43.18,46.62S136.58,154.72,136.58,125.62Z" />
|
|
363
|
+
<circle id="ac06531b-599d-4b05-a30e-b1c94e55ddff" data-name="fullLogo" cx="227.6" cy="181.13" r="31.29" fill="#000000" opacity="0.33"/>
|
|
364
|
+
<circle id="af2ef0cf-5c47-4a93-b3be-f4e8ec48b016" data-name="fullLogo" cx="227.6" cy="181.13" r="31.29" fill="#e00600"/>
|
|
365
|
+
</symbol>
|
|
358
366
|
<symbol id="icon-orders-settings" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
359
367
|
<path stroke="none" d="M12.1212737,0.0149273899 L12.1993631,0.0414649719 L23.6993631,5.04146497 C23.7267178,5.05378722 23.7458342,5.06406299 23.7642168,5.07551155 L23.6993631,5.04146497 C23.7308114,5.05513816 23.7601438,5.07165577 23.78719,5.09058546 C23.8752368,5.15228138 23.9440986,5.24234048 23.9776191,5.35045242 C23.9802724,5.36045426 23.9832498,5.37111525 23.9858736,5.38187225 C23.9952103,5.41944845 24,5.45894924 24,5.5 L23.9953562,5.43148585 C23.9967469,5.44147074 23.9978376,5.45151191 23.998623,5.46159578 L24,5.5 L24,18.5 C24,18.6960717 23.8853986,18.8740482 23.7069015,18.9551832 L23.7069015,18.9551832 L12.7069015,23.9551832 C12.6983028,23.9590917 12.6896739,23.9627354 12.6810221,23.9661191 C12.6644847,23.9727264 12.6477069,23.9782939 12.6306305,23.982966 C12.620519,23.9856515 12.6101188,23.9881575 12.5997187,23.9903149 C12.572237,23.9960541 12.5437253,23.9994522 12.5148271,24.0003058 C12.5014662,24.0007477 12.488556,24.0006156 12.4757251,23.9999825 C12.4670436,23.999429 12.4607455,23.9989604 12.4544383,23.998368 C12.4364185,23.9967958 12.4185026,23.9941212 12.4008462,23.9904983 L12.3904992,23.9880981 L12.3904992,23.9880981 L12.3744849,23.9843374 C12.3533008,23.9787756 12.3325557,23.9718389 12.3123792,23.9636106 L12.3076923,23.9615385 L8.11432939,22.2143039 C7.85942874,22.1080953 7.73889002,21.8153584 7.84509862,21.5604578 C7.93950627,21.3338794 8.1812943,21.2134636 8.41288432,21.2640954 L8.49894478,21.291227 L12,22.75 L12,10.833 L1,6.25 L1,18.166 L1.66956979,18.4456541 C1.89614815,18.5400617 2.01656399,18.7818498 1.96593211,19.0134398 L1.93880056,19.0995002 C1.84439291,19.3260786 1.60260489,19.4464944 1.37101486,19.3958626 L1.28495441,19.368731 L0.307692308,18.9615385 C0.147986477,18.8949944 0.0360024157,18.7517347 0.0072662723,18.5850485 L0,18.5 L0,5.5 L0.000261662773,5.48059656 C0.000995508743,5.46203925 0.00276487427,5.44359664 0.00553689598,5.42535217 L0,5.5 C0,5.45998969 0.00456440138,5.4214232 0.0131339416,5.38467337 C0.0169397718,5.36998047 0.0211530399,5.35526567 0.0260244955,5.34077917 C0.0315748534,5.32261012 0.0387562627,5.30467967 0.0468964169,5.287344 C0.0491575156,5.28372548 0.051376597,5.27915382 0.053665113,5.27461569 C0.0628828278,5.25536515 0.0731857541,5.2378939 0.0844589219,5.22118267 C0.0896903619,5.2139764 0.0953028029,5.20607213 0.101150512,5.19832596 C0.114371261,5.1805673 0.128643394,5.16419047 0.143874622,5.14882541 C0.146734857,5.14594128 0.149900432,5.14280918 0.153111875,5.13971631 C0.200589899,5.09587346 0.246688688,5.0654823 0.296626138,5.04311459 L0.300636944,5.04146497 L11.8006369,0.0414649719 C11.9023643,-0.00276433146 12.0151307,-0.0116101921 12.1212737,0.0149273899 Z M3.97267123,15.0674776 C4.99377958,14.0472295 6.49125771,13.7663134 7.79554839,14.3190245 C8.12583688,14.4589887 8.20563603,14.8909416 7.94715575,15.1396753 L7.94715575,15.1396753 L6.60445396,16.431939 L6.60445396,17.425939 L7.59945396,17.425939 L8.89175427,16.0840962 C9.11989856,15.8471313 9.50199604,15.8946635 9.67172912,16.1588147 L9.67172912,16.1588147 L9.71247951,16.2361756 C10.2637941,17.540178 9.98468461,19.0093693 8.96326123,20.0299316 C8.04649024,20.9482486 6.71990797,21.2687813 5.5110051,20.9206164 L5.5110051,20.9206164 L5.43745396,20.895939 L2.83943318,23.4947737 C2.78560777,23.5472916 2.70868751,23.6111734 2.61009303,23.677149 L2.61009303,23.677149 L2.50432643,23.7434792 C1.90095763,24.0980698 1.20669408,24.1124825 0.593239927,23.5478093 L0.593239927,23.5478093 L0.534281025,23.4913673 L0.371442461,23.3092933 C-0.0880238492,22.7287303 -0.0530937435,22.0865148 0.280581463,21.5245821 C0.369628975,21.3746198 0.460405096,21.2622765 0.532845501,21.1888084 L0.532845501,21.1888084 L3.11945396,18.593939 L3.09509424,18.5190572 C2.76429265,17.3749038 3.02480991,16.1295108 3.82573255,15.2237099 L3.82573255,15.2237099 Z M6.50756303,15.0417845 C5.9022234,15.023285 5.30214145,15.2291843 4.82046621,15.6440275 L4.82046621,15.6440275 L4.67962899,15.7747333 C3.95513926,16.4992231 3.76002654,17.5874199 4.15767782,18.5288513 C4.23675546,18.716066 4.1946478,18.9325193 4.05115362,19.076436 L4.05115362,19.076436 L1.24298032,21.8928684 L1.17219893,21.9847138 L1.14041764,22.0351521 C0.9885,22.2909922 0.983930789,22.5088263 1.20978842,22.7516687 L1.20978842,22.7516687 L1.25514704,22.7976512 L1.35159492,22.878993 C1.5660328,23.0353152 1.76744252,23.0166323 1.99765898,22.8813376 L1.99765898,22.8813376 L2.08955554,22.8211801 C2.11340753,22.8037557 2.12980084,22.7900519 2.13669993,22.7833468 L2.13669993,22.7833468 L4.95438617,19.9656606 C5.09835629,19.8216905 5.31524648,19.7793979 5.50275955,19.8587304 C6.43792725,20.2543782 7.52764107,20.0525662 8.25600574,19.3229738 C8.7594648,18.8199389 9.0097268,18.1735652 8.98910375,17.5162583 L8.98910375,17.5162583 L8.98345396,17.429939 L8.1720744,18.273412 C8.09667101,18.3517306 7.99836307,18.4027964 7.89247687,18.4200899 L7.89247687,18.4200899 L7.81188076,18.4266259 L6.10396414,18.4266259 C5.82782176,18.4266259 5.60396414,18.2027683 5.60396414,17.9266259 L5.60396414,17.9266259 L5.60396414,16.2194617 C5.60396414,16.0835213 5.65931519,15.9534408 5.75726863,15.8591809 L5.75726863,15.8591809 L6.60045396,15.047939 Z M23,6.276 L13,10.821 L13,22.723 L23,18.177 L23,6.276 Z M3.64605009,9.5215423 L3.7236068,9.5527864 L9.7236068,12.5527864 C9.86476681,12.6233664 9.96259986,12.75536 9.99128976,12.9069957 L10,13 L10,14.5410822 C10,14.8172245 9.77614237,15.0410822 9.5,15.0410822 C9.25454011,15.0410822 9.05039163,14.864207 9.00805567,14.6309578 L9,14.5410822 L9,13.309 L4,10.809 L4,13.9778457 C4,14.2233056 3.82312484,14.4274541 3.58987563,14.46979 L3.5,14.4778457 C3.25454011,14.4778457 3.05039163,14.3009705 3.00805567,14.0677213 L3,13.9778457 L3,10 C3,9.65690061 3.3332929,9.424522 3.64605009,9.5215423 Z M7.175,3.143 L1.776,5.49 L12.491,9.954 L17.098,7.86 L7.175,3.143 Z M12,1.045 L8.392,2.614 L18.289,7.319 L22.269,5.51 L12,1.045 Z"/>
|
|
360
368
|
</symbol>
|
|
Binary file
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
3
|
import { MemoryRouter } from "react-router-dom";
|
|
4
4
|
import Immutable from "immutable";
|
|
5
|
-
import { RSAA } from "redux-api-middleware";
|
|
6
5
|
import sinon from "sinon";
|
|
7
6
|
import { PropStruct, spyOnConsole } from "../utils/testUtils";
|
|
8
7
|
import withScopeData from "./withScopeData";
|
|
@@ -142,34 +141,4 @@ describe("withScopeData", () => {
|
|
|
142
141
|
),
|
|
143
142
|
)
|
|
144
143
|
.then(() => expect(store.dispatch, "was not called")));
|
|
145
|
-
|
|
146
|
-
it("loads scopes if it has none", () => {
|
|
147
|
-
state = state.setIn(["scopes"], Immutable.Map());
|
|
148
|
-
return expect(withScopeData, "when called with", [TestComp])
|
|
149
|
-
.then(Comp =>
|
|
150
|
-
expect(
|
|
151
|
-
<Provider store={store}>
|
|
152
|
-
<MemoryRouter>
|
|
153
|
-
<Comp />
|
|
154
|
-
</MemoryRouter>
|
|
155
|
-
</Provider>,
|
|
156
|
-
"when mounted",
|
|
157
|
-
"to be a",
|
|
158
|
-
"DOMElement",
|
|
159
|
-
),
|
|
160
|
-
)
|
|
161
|
-
.then(() =>
|
|
162
|
-
expect(store.dispatch, "to have calls satisfying", [
|
|
163
|
-
{
|
|
164
|
-
args: [
|
|
165
|
-
{
|
|
166
|
-
[RSAA]: {
|
|
167
|
-
types: ["GET_SCOPES_REQUEST", "GET_SCOPES_SUCCESS", "GET_SCOPES_FAILURE"],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
]),
|
|
173
|
-
);
|
|
174
|
-
});
|
|
175
144
|
});
|
package/src/reducers/modules.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import Immutable from "immutable";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
INITIALIZE_FIRST_MODULE_SCOPE,
|
|
4
|
+
SET_MODULE_AS_VISIBLE,
|
|
5
|
+
SET_MODULES_STRUCTURE,
|
|
6
|
+
SET_NEW_SCOPE_AND_MODULE_NAME,
|
|
7
|
+
SET_ROUTING_PERFORMED,
|
|
8
|
+
} from "../actions/modules";
|
|
3
9
|
import { infoBar } from "./../constants";
|
|
4
10
|
|
|
5
|
-
const initialState = Immutable.
|
|
11
|
+
const initialState = Immutable.fromJS({
|
|
12
|
+
tree: {},
|
|
13
|
+
visibleModules: [],
|
|
14
|
+
lastScopeAndModuleSelection: {
|
|
15
|
+
scope: null,
|
|
16
|
+
moduleName: null,
|
|
17
|
+
routingPerformed: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
6
20
|
|
|
7
21
|
const viewStateReducer = (state = initialState, action) => {
|
|
8
22
|
switch (action.type) {
|
|
@@ -32,6 +46,38 @@ const viewStateReducer = (state = initialState, action) => {
|
|
|
32
46
|
|
|
33
47
|
return state.set("tree", Immutable.fromJS(modulesTree));
|
|
34
48
|
}
|
|
49
|
+
|
|
50
|
+
case INITIALIZE_FIRST_MODULE_SCOPE: {
|
|
51
|
+
return state.setIn(["lastScopeAndModuleSelection", "scope"], action.payload);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
case SET_MODULE_AS_VISIBLE: {
|
|
55
|
+
const visibleModules = state.get("visibleModules").toJS();
|
|
56
|
+
visibleModules.push(action.payload);
|
|
57
|
+
|
|
58
|
+
return state.set("visibleModules", Immutable.fromJS(visibleModules));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
case SET_NEW_SCOPE_AND_MODULE_NAME: {
|
|
62
|
+
const lastScopeAndModuleSelection = state.get("lastScopeAndModuleSelection").toJS();
|
|
63
|
+
|
|
64
|
+
if (action.payload.scope !== lastScopeAndModuleSelection.scope) {
|
|
65
|
+
state = state.set("visibleModules", Immutable.fromJS([]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return state.set(
|
|
69
|
+
"lastScopeAndModuleSelection",
|
|
70
|
+
Immutable.fromJS({
|
|
71
|
+
moduleName: action.payload.moduleName,
|
|
72
|
+
scope: action.payload.scope,
|
|
73
|
+
routingPerformed: false,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case SET_ROUTING_PERFORMED:
|
|
79
|
+
return state.setIn(["lastScopeAndModuleSelection", "routingPerformed"], true);
|
|
80
|
+
|
|
35
81
|
default:
|
|
36
82
|
return state;
|
|
37
83
|
}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import Immutable from "immutable";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
initializeFirstModuleScope,
|
|
4
|
+
setModuleAsVisible,
|
|
5
|
+
setModulesStructure,
|
|
6
|
+
setNewScopeAndModuleName,
|
|
7
|
+
setRoutingPerformed,
|
|
8
|
+
} from "../actions/modules";
|
|
3
9
|
import modulesReducer from "./modules";
|
|
4
10
|
|
|
5
11
|
describe("View state reducer", () => {
|
|
6
|
-
|
|
12
|
+
const initialState = {
|
|
13
|
+
tree: {},
|
|
14
|
+
visibleModules: [],
|
|
15
|
+
lastScopeAndModuleSelection: {
|
|
16
|
+
scope: null,
|
|
17
|
+
moduleName: null,
|
|
18
|
+
routingPerformed: true,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it("behaves as a reducer should", () => expect(modulesReducer, "to be a reducer with initial state", initialState));
|
|
7
23
|
|
|
8
24
|
it("Sets module structure correctly", () => {
|
|
9
25
|
const oldState = Immutable.Map({});
|
|
@@ -92,4 +108,103 @@ describe("View state reducer", () => {
|
|
|
92
108
|
const newState = modulesReducer(oldState, action);
|
|
93
109
|
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS({ tree: modules }));
|
|
94
110
|
});
|
|
111
|
+
|
|
112
|
+
it("Initialize first scope", () => {
|
|
113
|
+
const oldState = Immutable.fromJS(initialState);
|
|
114
|
+
|
|
115
|
+
const expected = {
|
|
116
|
+
...initialState,
|
|
117
|
+
lastScopeAndModuleSelection: {
|
|
118
|
+
...initialState.lastScopeAndModuleSelection,
|
|
119
|
+
scope: "firstScope",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const action = initializeFirstModuleScope("firstScope");
|
|
124
|
+
const newState = modulesReducer(oldState, action);
|
|
125
|
+
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS(expected));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("Add a visible module into the array", () => {
|
|
129
|
+
const oldState = Immutable.fromJS({
|
|
130
|
+
...initialState,
|
|
131
|
+
visibleModules: ["moduleReality"],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const expected = {
|
|
135
|
+
...initialState,
|
|
136
|
+
visibleModules: ["moduleReality", "moduleMatrix"],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const action = setModuleAsVisible("moduleMatrix");
|
|
140
|
+
const newState = modulesReducer(oldState, action);
|
|
141
|
+
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS(expected));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("set a new scope and module for eventual redirection", () => {
|
|
145
|
+
const oldState = Immutable.fromJS({
|
|
146
|
+
...initialState,
|
|
147
|
+
lastScopeAndModuleSelection: {
|
|
148
|
+
scope: "aScope",
|
|
149
|
+
moduleName: null,
|
|
150
|
+
routingPerformed: true,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const expected = {
|
|
155
|
+
...initialState,
|
|
156
|
+
lastScopeAndModuleSelection: {
|
|
157
|
+
scope: "aScope",
|
|
158
|
+
moduleName: "moduleMatrix",
|
|
159
|
+
routingPerformed: false,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const action = setNewScopeAndModuleName("aScope", "moduleMatrix");
|
|
164
|
+
const newState = modulesReducer(oldState, action);
|
|
165
|
+
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS(expected));
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("set a new scope and module for eventual redirection and reinitialize visible modules", () => {
|
|
169
|
+
const oldState = Immutable.fromJS({
|
|
170
|
+
...initialState,
|
|
171
|
+
visibleModules: ["moduleReality"],
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const expected = {
|
|
175
|
+
...initialState,
|
|
176
|
+
lastScopeAndModuleSelection: {
|
|
177
|
+
scope: "newScope",
|
|
178
|
+
moduleName: "moduleMatrix",
|
|
179
|
+
routingPerformed: false,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const action = setNewScopeAndModuleName("newScope", "moduleMatrix");
|
|
184
|
+
const newState = modulesReducer(oldState, action);
|
|
185
|
+
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS(expected));
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("set routing was perform on scope and module", () => {
|
|
189
|
+
const oldState = Immutable.fromJS({
|
|
190
|
+
...initialState,
|
|
191
|
+
lastScopeAndModuleSelection: {
|
|
192
|
+
scope: "aScope",
|
|
193
|
+
moduleName: "aModule",
|
|
194
|
+
routingPerformed: false,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
const expected = {
|
|
198
|
+
...initialState,
|
|
199
|
+
lastScopeAndModuleSelection: {
|
|
200
|
+
scope: "aScope",
|
|
201
|
+
moduleName: "aModule",
|
|
202
|
+
routingPerformed: true,
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const action = setRoutingPerformed();
|
|
207
|
+
const newState = modulesReducer(oldState, action);
|
|
208
|
+
return expect(newState, "not to be", oldState).and("to equal", Immutable.fromJS(expected));
|
|
209
|
+
});
|
|
95
210
|
});
|
package/src/reducers/scopes.js
CHANGED
|
@@ -8,7 +8,37 @@ const initialState = Immutable.fromJS({});
|
|
|
8
8
|
const scopeReducer = (state = initialState, action) => {
|
|
9
9
|
switch (action.type) {
|
|
10
10
|
case GET_SCOPES_SUCCESS: {
|
|
11
|
+
const loadedScopes = state.toJS();
|
|
11
12
|
const normalizedScopes = normalize(action.payload, scopeSchema);
|
|
13
|
+
|
|
14
|
+
if (Object.keys(loadedScopes).length > 0) {
|
|
15
|
+
const addedScope = {};
|
|
16
|
+
|
|
17
|
+
Object.values(normalizedScopes.entities.scopes).forEach(scope => {
|
|
18
|
+
if (!loadedScopes[scope.id]) {
|
|
19
|
+
loadedScopes[scope.id] = scope;
|
|
20
|
+
addedScope[scope.id] = scope;
|
|
21
|
+
} else if (scope.isAuthorizedScope) {
|
|
22
|
+
loadedScopes[scope.id] = scope;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
Object.values(addedScope).forEach(scope => {
|
|
27
|
+
const parentScope = loadedScopes[scope.parentScopeId];
|
|
28
|
+
|
|
29
|
+
if (parentScope) {
|
|
30
|
+
if (!parentScope.children.includes(scope.id)) {
|
|
31
|
+
parentScope.children.push(scope.id);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
// Should not happen, but for safety
|
|
35
|
+
delete loadedScopes[scope.id];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return state.merge(Immutable.fromJS(loadedScopes));
|
|
40
|
+
}
|
|
41
|
+
|
|
12
42
|
return state.merge(Immutable.fromJS(normalizedScopes.entities.scopes));
|
|
13
43
|
}
|
|
14
44
|
default:
|