orc-shared 5.7.0-dev.13 → 5.7.0-dev.15

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.
Files changed (28) hide show
  1. package/dist/actions/requestsApi.js +743 -140
  2. package/dist/actions/scopes.js +25 -1
  3. package/dist/buildStore.js +2 -0
  4. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +7 -3
  5. package/dist/components/MaterialUI/Inputs/InputBase.js +6 -1
  6. package/dist/components/Provision.js +2 -1
  7. package/dist/components/ScopeExtendedConfigurationLoader.js +83 -0
  8. package/dist/content/icons/orckestra-icon.svg +11 -5
  9. package/dist/reducers/scopesExtendedConfiguration.js +68 -0
  10. package/dist/selectors/scopeExtendedConfiguration.js +56 -0
  11. package/package.json +1 -1
  12. package/src/actions/requestsApi.js +511 -89
  13. package/src/actions/scopes.js +25 -1
  14. package/src/actions/scopes.test.js +34 -0
  15. package/src/buildStore.js +2 -0
  16. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +9 -3
  17. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +29 -0
  18. package/src/components/MaterialUI/Inputs/InputBase.js +8 -5
  19. package/src/components/MaterialUI/Inputs/InputBase.test.js +160 -110
  20. package/src/components/Provision.js +2 -0
  21. package/src/components/Provision.test.js +7 -0
  22. package/src/components/ScopeExtendedConfigurationLoader.js +22 -0
  23. package/src/components/ScopeExtendedConfigurationLoader.test.js +71 -0
  24. package/src/content/icons/orckestra-icon.svg +11 -5
  25. package/src/reducers/scopesExtendedConfiguration.js +16 -0
  26. package/src/reducers/scopesExtendedConfiguration.test.js +31 -0
  27. package/src/selectors/scopeExtendedConfiguration.js +9 -0
  28. package/src/selectors/scopeExtendedConfiguration.test.js +45 -0
@@ -1,6 +1,11 @@
1
1
  import { makeActionTypes } from "./makeApiAction";
2
2
  import makeOrcApiAction from "./makeOrcApiAction";
3
- import { getApplicationModules, getUserScopeRequest, getUserScopeTreeRequest } from "./requestsApi";
3
+ import {
4
+ getApplicationModules,
5
+ getUserScopeRequest,
6
+ getUserScopeTreeRequest,
7
+ getScopeExtendedConfigurationRequest,
8
+ } from "./requestsApi";
4
9
  import { overtureModule } from "../constants";
5
10
 
6
11
  export const validateOvertureApplication = () => {
@@ -60,3 +65,22 @@ export const applicationScopeHasChanged = (previousScope, newScope, moduleName)
60
65
  },
61
66
  };
62
67
  };
68
+
69
+ export const GET_SCOPE_EXTENDED_CONFIGURATION = "GET_SCOPE_EXTENDED_CONFIGURATION";
70
+
71
+ export const [
72
+ GET_SCOPE_EXTENDED_CONFIGURATION_REQUEST,
73
+ GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS,
74
+ GET_SCOPE_EXTENDED_CONFIGURATION_FAILURE,
75
+ ] = makeActionTypes(GET_SCOPE_EXTENDED_CONFIGURATION);
76
+
77
+ export const getScopeExtendedConfiguration = scope =>
78
+ makeOrcApiAction(
79
+ GET_SCOPE_EXTENDED_CONFIGURATION,
80
+ getScopeExtendedConfigurationRequest.buildUrl(scope),
81
+ getScopeExtendedConfigurationRequest.verb,
82
+ {
83
+ bailout: false,
84
+ meta: { scope },
85
+ },
86
+ );
@@ -12,6 +12,7 @@ import {
12
12
  GET_APPLICATION_MODULES_REQUEST,
13
13
  GET_APPLICATION_MODULES_SUCCESS,
14
14
  GET_APPLICATION_MODULES_FAILURE,
15
+ getScopeExtendedConfiguration,
15
16
  } from "./scopes";
16
17
 
17
18
  jest.mock("../utils/buildUrl", () => {
@@ -150,3 +151,36 @@ describe("applicationScopeHasChanged", () => {
150
151
  });
151
152
  });
152
153
  });
154
+
155
+ describe("getScopeExtendedConfiguration", () => {
156
+ it("creates a RSAA to fetch a scope extended configuration", () => {
157
+ expect(getScopeExtendedConfiguration, "when called with", ["zeScope"], "to exhaustively satisfy", {
158
+ [RSAA]: {
159
+ types: [
160
+ {
161
+ type: "GET_SCOPE_EXTENDED_CONFIGURATION_REQUEST",
162
+ meta: { scope: "zeScope" },
163
+ },
164
+ {
165
+ type: "GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS",
166
+ meta: { scope: "zeScope" },
167
+ },
168
+ {
169
+ type: "GET_SCOPE_EXTENDED_CONFIGURATION_FAILURE",
170
+ meta: { scope: "zeScope" },
171
+ },
172
+ ],
173
+ endpoint: 'URL: scopes/zeScope/extendedConfiguration ""',
174
+ method: "GET",
175
+ body: undefined,
176
+ credentials: "include",
177
+ bailout: false,
178
+ headers: {
179
+ Accept: "application/json; charset=utf-8",
180
+ "Content-Type": "application/json",
181
+ },
182
+ options: { redirect: "follow" },
183
+ },
184
+ });
185
+ });
186
+ });
package/src/buildStore.js CHANGED
@@ -11,6 +11,7 @@ import localeFactory, { cultureByDefault } from "./reducers/localeFactory";
11
11
  import navigationReducer from "./reducers/navigation";
12
12
  import requestReducer from "./reducers/request";
13
13
  import scopesReducer from "./reducers/scopes";
14
+ import scopesExtendedConfigurationReducer from "./reducers/scopesExtendedConfiguration";
14
15
  import settingsReducer from "./reducers/settings";
15
16
  import toastReducer from "./reducers/toasts";
16
17
  import viewReducer from "./reducers/view";
@@ -59,6 +60,7 @@ const buildStore = (reducers, devOptions = {}) => {
59
60
  router: connectRouter(history),
60
61
  requests: requestReducer,
61
62
  scopes: scopesReducer,
63
+ scopesExtendedConfiguration: scopesExtendedConfigurationReducer,
62
64
  settings: settingsReducer,
63
65
  toasts: toastReducer,
64
66
  versionInfo: versionInfoReducer,
@@ -77,7 +77,7 @@ const InformationItemChildren = ({
77
77
  return <MultipleLinesText textProps={multipleLinesTextProps} children={value} tooltipClasses={tooltipClasses} />;
78
78
  };
79
79
 
80
- const InformationItemHeader = ({ classes, label, headerIcon }) => {
80
+ const InformationItemHeader = ({ classes, label, headerIcon, headerIconClassName }) => {
81
81
  const formattedLabel = typeof label === "object" ? <FormattedMessage {...label} /> : label;
82
82
  const headerText = (formattedLabel && <Typography className={classes.title} children={formattedLabel} />) ?? null;
83
83
 
@@ -85,7 +85,7 @@ const InformationItemHeader = ({ classes, label, headerIcon }) => {
85
85
  return (
86
86
  <div className={classes.headerRoot}>
87
87
  <div className={classes.headerTextContainer}>{headerText}</div>
88
- <div className={classes.headerIconContainer}>{headerIcon}</div>
88
+ <div className={classNames(classes.headerIconContainer, headerIconClassName)}>{headerIcon}</div>
89
89
  </div>
90
90
  );
91
91
  }
@@ -99,6 +99,7 @@ const InformationItem = ({
99
99
  required,
100
100
  error,
101
101
  headerIcon = undefined,
102
+ headerIconClassName = undefined,
102
103
  showNotAvailable = false,
103
104
  marginTop = 0,
104
105
  isMaxLineCountEnabled,
@@ -109,7 +110,12 @@ const InformationItem = ({
109
110
 
110
111
  return (
111
112
  <div className={classes.container}>
112
- <InformationItemHeader classes={classes} label={label} headerIcon={headerIcon} />
113
+ <InformationItemHeader
114
+ classes={classes}
115
+ label={label}
116
+ headerIcon={headerIcon}
117
+ headerIconClassName={headerIconClassName}
118
+ />
113
119
  <InformationItemChildren
114
120
  classes={classes}
115
121
  children={children}
@@ -315,4 +315,33 @@ describe("Information Item", () => {
315
315
 
316
316
  expect(component, "when mounted", "to satisfy", expected);
317
317
  });
318
+
319
+ it("Renders Information Item properly with a header icon and custom header icon class", () => {
320
+ const label = "label";
321
+ const value = "value";
322
+
323
+ const component = (
324
+ <IntlProvider locale="en-US">
325
+ <InformationItem label={label} headerIcon={<span>the header icon</span>} headerIconClassName="CustomClass">
326
+ {value}
327
+ </InformationItem>
328
+ </IntlProvider>
329
+ );
330
+
331
+ const expected = (
332
+ <div>
333
+ <div>
334
+ <div>
335
+ <Typography children={label} />
336
+ </div>
337
+ <div className={"CustomClass"}>
338
+ <span>the header icon</span>
339
+ </div>
340
+ </div>
341
+ <MultipleLinesText>{value}</MultipleLinesText>
342
+ </div>
343
+ );
344
+
345
+ expect(component, "when mounted", "to satisfy", expected);
346
+ });
318
347
  });
@@ -146,12 +146,15 @@ const InputBase = ({ inputProps }) => {
146
146
  inputAttributes.min = -2147483648;
147
147
  }
148
148
 
149
+ const decimalScale = numericInputProps?.decimalScale ?? 0;
150
+
151
+ const lengthForMin = Math.trunc(inputAttributes.min).toString().length;
152
+ const lengthForMax = Math.trunc(inputAttributes.max).toString().length;
153
+
154
+ inputAttributes.maxLength = Math.max(lengthForMin, lengthForMax) + (decimalScale > 0 ? decimalScale + 1 : 0);
155
+
149
156
  inputAttributes.isAllowed = val => {
150
- return (
151
- val.value === "" ||
152
- val.value === "-" ||
153
- (val.floatValue >= inputAttributes.min && val.floatValue <= inputAttributes.max)
154
- );
157
+ return val.value === "" || val.value === "-" || val.value !== null;
155
158
  };
156
159
  }
157
160
 
@@ -436,6 +436,166 @@ describe("AdvancedNumericInput", () => {
436
436
  expect(advInput.props().decimalScale, "to be", 2);
437
437
  });
438
438
 
439
+ it("Renders InputBase component as advanced numeric input without min max", () => {
440
+ const inputProps = new InputBaseProps();
441
+ const aLabel = "aLabel";
442
+ const aValue = "value";
443
+
444
+ inputProps.set(InputBaseProps.propNames.update, update);
445
+ inputProps.set(InputBaseProps.propNames.value, aValue);
446
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
447
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
448
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
449
+
450
+ const component = <InputBase inputProps={inputProps} />;
451
+
452
+ const mountedComponent = mount(component);
453
+
454
+ const advInput = mountedComponent.find("AdvancedNumericInput");
455
+ expect(advInput.props().decimalScale, "to be", 2);
456
+ expect(advInput.props().min, "to be", -2147483648);
457
+ expect(advInput.props().max, "to be", 2147483647);
458
+ expect(advInput.props().maxLength, "to be", 14);
459
+ });
460
+
461
+ it("Renders InputBase component as advanced numeric input without min", () => {
462
+ const inputProps = new InputBaseProps();
463
+ const aLabel = "aLabel";
464
+ const aValue = "value";
465
+
466
+ inputProps.set(InputBaseProps.propNames.update, update);
467
+ inputProps.set(InputBaseProps.propNames.value, aValue);
468
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
469
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
470
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
471
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { max: 122 });
472
+
473
+ const component = <InputBase inputProps={inputProps} />;
474
+
475
+ const mountedComponent = mount(component);
476
+
477
+ const advInput = mountedComponent.find("AdvancedNumericInput");
478
+ expect(advInput.props().decimalScale, "to be", 0);
479
+ expect(advInput.props().min, "to be", -2147483648);
480
+ expect(advInput.props().max, "to be", 122);
481
+ expect(advInput.props().maxLength, "to be", 11);
482
+ });
483
+
484
+ it("Renders InputBase component as advanced numeric input without max", () => {
485
+ const inputProps = new InputBaseProps();
486
+ const aLabel = "aLabel";
487
+ const aValue = "value";
488
+
489
+ inputProps.set(InputBaseProps.propNames.update, update);
490
+ inputProps.set(InputBaseProps.propNames.value, aValue);
491
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
492
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
493
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
494
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -9.9 });
495
+
496
+ const component = <InputBase inputProps={inputProps} />;
497
+
498
+ const mountedComponent = mount(component);
499
+
500
+ const advInput = mountedComponent.find("AdvancedNumericInput");
501
+ expect(advInput.props().decimalScale, "to be", 2);
502
+ expect(advInput.props().min, "to be", -9.9);
503
+ expect(advInput.props().max, "to be", 2147483647);
504
+ expect(advInput.props().maxLength, "to be", 13);
505
+ });
506
+
507
+ it("Renders InputBase component as advanced numeric input with negative min positive max", () => {
508
+ const inputProps = new InputBaseProps();
509
+ const aLabel = "aLabel";
510
+ const aValue = "value";
511
+
512
+ inputProps.set(InputBaseProps.propNames.update, update);
513
+ inputProps.set(InputBaseProps.propNames.value, aValue);
514
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
515
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
516
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 1 });
517
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -999.9, max: 9.8 });
518
+
519
+ const component = <InputBase inputProps={inputProps} />;
520
+
521
+ const mountedComponent = mount(component);
522
+
523
+ const advInput = mountedComponent.find("AdvancedNumericInput");
524
+ expect(advInput.props().decimalScale, "to be", 1);
525
+ expect(advInput.props().min, "to be", -999.9);
526
+ expect(advInput.props().max, "to be", 9.8);
527
+ expect(advInput.props().maxLength, "to be", 6);
528
+ });
529
+
530
+ it("Renders InputBase component as advanced numeric input with negative min large positive max", () => {
531
+ const inputProps = new InputBaseProps();
532
+ const aLabel = "aLabel";
533
+ const aValue = "value";
534
+
535
+ inputProps.set(InputBaseProps.propNames.update, update);
536
+ inputProps.set(InputBaseProps.propNames.value, aValue);
537
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
538
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
539
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 1 });
540
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -9.9, max: 99999.8 });
541
+
542
+ const component = <InputBase inputProps={inputProps} />;
543
+
544
+ const mountedComponent = mount(component);
545
+
546
+ const advInput = mountedComponent.find("AdvancedNumericInput");
547
+ expect(advInput.props().decimalScale, "to be", 1);
548
+ expect(advInput.props().min, "to be", -9.9);
549
+ expect(advInput.props().max, "to be", 99999.8);
550
+ expect(advInput.props().maxLength, "to be", 7);
551
+ });
552
+
553
+ it("Renders InputBase component as advanced numeric input with negative min negative max", () => {
554
+ const inputProps = new InputBaseProps();
555
+ const aLabel = "aLabel";
556
+ const aValue = "value";
557
+
558
+ inputProps.set(InputBaseProps.propNames.update, update);
559
+ inputProps.set(InputBaseProps.propNames.value, aValue);
560
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
561
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
562
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 3 });
563
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -99.9, max: -9.8 });
564
+
565
+ const component = <InputBase inputProps={inputProps} />;
566
+
567
+ const mountedComponent = mount(component);
568
+
569
+ const advInput = mountedComponent.find("AdvancedNumericInput");
570
+ expect(advInput.props().decimalScale, "to be", 3);
571
+ expect(advInput.props().min, "to be", -99.9);
572
+ expect(advInput.props().max, "to be", -9.8);
573
+ expect(advInput.props().maxLength, "to be", 7);
574
+ });
575
+
576
+ it("Renders InputBase component as advanced numeric input with positive min positive max", () => {
577
+ const inputProps = new InputBaseProps();
578
+ const aLabel = "aLabel";
579
+ const aValue = "value";
580
+
581
+ inputProps.set(InputBaseProps.propNames.update, update);
582
+ inputProps.set(InputBaseProps.propNames.value, aValue);
583
+ inputProps.set(InputBaseProps.propNames.label, aLabel);
584
+ inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
585
+ inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 5 });
586
+ inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 9.9, max: 99.8 });
587
+
588
+ const component = <InputBase inputProps={inputProps} />;
589
+
590
+ const mountedComponent = mount(component);
591
+
592
+ const advInput = mountedComponent.find("AdvancedNumericInput");
593
+ expect(advInput.props().decimalScale, "to be", 5);
594
+ expect(advInput.props().min, "to be", 9.9);
595
+ expect(advInput.props().max, "to be", 99.8);
596
+ expect(advInput.props().maxLength, "to be", 8);
597
+ });
598
+
439
599
  it("Change advanced numeric input value", () => {
440
600
  const inputProps = new InputBaseProps();
441
601
  const aLabel = "aLabel";
@@ -686,116 +846,6 @@ describe("AdvancedNumericInput", () => {
686
846
  // no idea what to assert here, this test is mostly for code coverage
687
847
  });
688
848
 
689
- it("Change advanced numeric input value with min value out of default bounds", () => {
690
- const inputProps = new InputBaseProps();
691
- const aLabel = "aLabel";
692
- const aValue = "12.2";
693
- const metadata = {
694
- test: "value",
695
- };
696
-
697
- inputProps.set(InputBaseProps.propNames.update, update);
698
- inputProps.set(InputBaseProps.propNames.value, aValue);
699
- inputProps.set(InputBaseProps.propNames.label, aLabel);
700
- inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
701
- inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
702
- inputProps.set(InputBaseProps.propNames.metadata, metadata);
703
-
704
- const component = <InputBase inputProps={inputProps} />;
705
- const mountedComponent = mount(component);
706
- const input = mountedComponent.find("input");
707
- input.simulate("change", { target: { value: "-3147483648", focus: noop } });
708
-
709
- expect(update, "not to have calls satisfying", [{ args: ["-3147483648", metadata] }]);
710
-
711
- input.simulate("change", { target: { value: "-111", focus: noop } });
712
- expect(update, "to have calls satisfying", [{ args: ["-111", metadata] }]);
713
- });
714
-
715
- it("Change advanced numeric input value with min value out of specified bounds", () => {
716
- const inputProps = new InputBaseProps();
717
- const aLabel = "aLabel";
718
- const aValue = "12.2";
719
- const metadata = {
720
- test: "value",
721
- };
722
-
723
- inputProps.set(InputBaseProps.propNames.update, update);
724
- inputProps.set(InputBaseProps.propNames.value, aValue);
725
- inputProps.set(InputBaseProps.propNames.label, aLabel);
726
- inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
727
- inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
728
- inputProps.set(InputBaseProps.propNames.metadata, metadata);
729
- inputProps.set(InputBaseProps.propNames.inputAttributes, {
730
- min: -100,
731
- });
732
-
733
- const component = <InputBase inputProps={inputProps} />;
734
- const mountedComponent = mount(component);
735
- const input = mountedComponent.find("input");
736
- input.simulate("change", { target: { value: "-2000", focus: noop } });
737
-
738
- expect(update, "not to have calls satisfying", [{ args: ["-2000", metadata] }]);
739
-
740
- input.simulate("change", { target: { value: "-11", focus: noop } });
741
- expect(update, "to have calls satisfying", [{ args: ["-11", metadata] }]);
742
- });
743
-
744
- it("Change advanced numeric input value with max value out of default bounds", () => {
745
- const inputProps = new InputBaseProps();
746
- const aLabel = "aLabel";
747
- const aValue = "12.2";
748
- const metadata = {
749
- test: "value",
750
- };
751
-
752
- inputProps.set(InputBaseProps.propNames.update, update);
753
- inputProps.set(InputBaseProps.propNames.value, aValue);
754
- inputProps.set(InputBaseProps.propNames.label, aLabel);
755
- inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
756
- inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
757
- inputProps.set(InputBaseProps.propNames.metadata, metadata);
758
-
759
- const component = <InputBase inputProps={inputProps} />;
760
- const mountedComponent = mount(component);
761
- const input = mountedComponent.find("input");
762
- input.simulate("change", { target: { value: "3147483648", focus: noop } });
763
-
764
- expect(update, "not to have calls satisfying", [{ args: ["3147483648", metadata] }]);
765
-
766
- input.simulate("change", { target: { value: "111", focus: noop } });
767
- expect(update, "to have calls satisfying", [{ args: ["111", metadata] }]);
768
- });
769
-
770
- it("Change advanced numeric input value with max value out of specified bounds", () => {
771
- const inputProps = new InputBaseProps();
772
- const aLabel = "aLabel";
773
- const aValue = "12.2";
774
- const metadata = {
775
- test: "value",
776
- };
777
-
778
- inputProps.set(InputBaseProps.propNames.update, update);
779
- inputProps.set(InputBaseProps.propNames.value, aValue);
780
- inputProps.set(InputBaseProps.propNames.label, aLabel);
781
- inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
782
- inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
783
- inputProps.set(InputBaseProps.propNames.metadata, metadata);
784
- inputProps.set(InputBaseProps.propNames.inputAttributes, {
785
- max: 100,
786
- });
787
-
788
- const component = <InputBase inputProps={inputProps} />;
789
- const mountedComponent = mount(component);
790
- const input = mountedComponent.find("input");
791
- input.simulate("change", { target: { value: "2000", focus: noop } });
792
-
793
- expect(update, "not to have calls satisfying", [{ args: ["2000", metadata] }]);
794
-
795
- input.simulate("change", { target: { value: "11", focus: noop } });
796
- expect(update, "to have calls satisfying", [{ args: ["11", metadata] }]);
797
- });
798
-
799
849
  it("Change advanced numeric input value: dash is allowed", () => {
800
850
  const inputProps = new InputBaseProps();
801
851
  const aLabel = "aLabel";
@@ -11,6 +11,7 @@ import Head from "./Head";
11
11
  import I18n from "./I18n";
12
12
  import InternetExplorerWarningMessage from "./InternetExplorerWarningMessage";
13
13
  import Culture from "./Culture";
14
+ import ScopeExtendedConfigurationLoader from "./ScopeExtendedConfigurationLoader";
14
15
 
15
16
  const GlobalStyle = createGlobalStyle`
16
17
  html {
@@ -53,6 +54,7 @@ const Provision = ({ store, theme = {}, muiTheme, children }) => {
53
54
  <InternetExplorerWarningMessage />
54
55
  </I18n>
55
56
  </DevPages>
57
+ <ScopeExtendedConfigurationLoader />
56
58
  </React.Fragment>
57
59
  </Authenticate>
58
60
  </React.Fragment>
@@ -54,6 +54,13 @@ const fakeStore = {
54
54
  loadedModulesScope: ["moduleA", "moduleB"],
55
55
  modules: ["moduleA", "moduleB"],
56
56
  },
57
+ navigation: {
58
+ route: {
59
+ match: { path: "/:scope/TheModuleName/:entityId", params: { scope: "TheOldScope", entityId: "loaderId" } },
60
+ },
61
+ moduleTabs: {},
62
+ config: { prependPath: "/:scope/", prependHref: "/Scope1/" },
63
+ },
57
64
  }),
58
65
  replaceReducer: () => {},
59
66
  };
@@ -0,0 +1,22 @@
1
+ import { useEffect, useState } from "react";
2
+ import useScopeData from "./Scope/useScopeData";
3
+ import { useDispatch } from "react-redux";
4
+ import { getScopeExtendedConfiguration } from "../actions/scopes";
5
+
6
+ const ScopeExtendedConfigurationLoader = () => {
7
+ const [currentScope] = useScopeData();
8
+ const dispatch = useDispatch();
9
+
10
+ const [localScopeValue, setLocalScopeValue] = useState();
11
+
12
+ useEffect(() => {
13
+ if (currentScope.id !== localScopeValue) {
14
+ setLocalScopeValue(currentScope.id);
15
+ dispatch(getScopeExtendedConfiguration(currentScope.id));
16
+ }
17
+ }, [currentScope.id, dispatch, localScopeValue]);
18
+
19
+ return null;
20
+ };
21
+
22
+ export default ScopeExtendedConfigurationLoader;
@@ -0,0 +1,71 @@
1
+ import React from "react";
2
+ import Immutable from "immutable";
3
+ import { Provider } from "react-redux";
4
+ import { ThemeProvider } from "styled-components";
5
+ import ScopeExtendedConfigurationLoader from "./ScopeExtendedConfigurationLoader";
6
+ import { mount } from "enzyme";
7
+ import { getScopeExtendedConfiguration } from "../actions/scopes";
8
+ import sinon from "sinon";
9
+
10
+ jest.mock("../utils/buildUrl", () => {
11
+ const modExport = {};
12
+ modExport.loadConfig = () => Promise.resolve({});
13
+ modExport.buildUrl = (path = [], params = "") => "URL: " + path.join("/") + " " + JSON.stringify(params);
14
+ return modExport;
15
+ });
16
+
17
+ describe("ScopeExtendedConfigurationLoader", () => {
18
+ let state, store;
19
+
20
+ beforeEach(() => {
21
+ state = Immutable.fromJS({
22
+ locale: {
23
+ locale: "en-US",
24
+ },
25
+ authentication: {
26
+ name: "foo@bar.com",
27
+ },
28
+ requests: {},
29
+ scopes: {
30
+ TheOldScope: {
31
+ id: "TheOldScope",
32
+ name: { "en-CA": "Test 1", "en-US": "TheOldScope" },
33
+ children: ["test2"],
34
+ },
35
+ },
36
+ settings: {
37
+ defaultScope: "aDefaultScope",
38
+ loadedModulesScope: ["moduleA", "moduleB"],
39
+ modules: ["moduleA", "moduleB"],
40
+ },
41
+ navigation: {
42
+ route: {
43
+ match: { path: "/:scope/TheModuleName/:entityId", params: { scope: "TheOldScope", entityId: "loaderId" } },
44
+ },
45
+ moduleTabs: {},
46
+ config: { prependPath: "/:scope/", prependHref: "/Scope1/" },
47
+ },
48
+ });
49
+ store = state => ({
50
+ subscribe: () => {},
51
+ getState: () => state,
52
+ dispatch: sinon.spy().named("dispatch"),
53
+ });
54
+ });
55
+
56
+ it("dispatch request to get extended configuration", () => {
57
+ const theStore = store(state);
58
+
59
+ const component = (
60
+ <Provider store={theStore}>
61
+ <ThemeProvider theme={{}}>
62
+ <ScopeExtendedConfigurationLoader />
63
+ </ThemeProvider>
64
+ </Provider>
65
+ );
66
+
67
+ mount(component);
68
+
69
+ expect(theStore.dispatch, "to have calls satisfying", [{ args: [getScopeExtendedConfiguration("TheOldScope")] }]);
70
+ });
71
+ });
@@ -1,5 +1,11 @@
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>
1
+ <svg width="354" height="354" viewBox="0 0 354 354" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2_1387)">
3
+ <path d="M0 241.41C0 175.92 50.53 129.43 119.66 129.43C188.79 129.43 238.91 175.92 238.91 241.41C238.91 306.9 188.78 353.38 119.66 353.38C50.54 353.38 0 306.9 0 241.41ZM175.04 241.41C175.04 203.81 151.19 181.18 119.66 181.18C88.13 181.18 63.87 203.82 63.87 241.41C63.87 279 88.13 301.64 119.66 301.64C151.19 301.64 175.04 279 175.04 241.41Z" fill="black"/>
4
+ <path d="M353.14 165.06H275.66C275.66 116.77 236.37 77.48 188.08 77.48V0C279.1 0 353.15 74.05 353.15 165.06H353.14Z" fill="#E00600"/>
5
+ </g>
6
+ <defs>
7
+ <clipPath id="clip0_2_1387">
8
+ <rect width="353.14" height="353.38" fill="white"/>
9
+ </clipPath>
10
+ </defs>
11
+ </svg>
@@ -0,0 +1,16 @@
1
+ import Immutable from "immutable";
2
+ import { GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS } from "../actions/scopes";
3
+
4
+ const initialState = Immutable.fromJS({});
5
+
6
+ const scopesExtendedConfigurationReducer = (state = initialState, action) => {
7
+ switch (action.type) {
8
+ case GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS: {
9
+ return state.set(action.meta.scope, Immutable.fromJS(action.payload));
10
+ }
11
+ default:
12
+ return state;
13
+ }
14
+ };
15
+
16
+ export default scopesExtendedConfigurationReducer;
@@ -0,0 +1,31 @@
1
+ import Immutable from "immutable";
2
+ import { GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS } from "../actions/scopes";
3
+ import reducer from "./scopesExtendedConfiguration";
4
+
5
+ describe("scopesExtendedConfiguration", () => {
6
+ it("behaves as a reducer should", () => expect(reducer, "to be a reducer with initial state", {}));
7
+
8
+ it("save scope info to store", () => {
9
+ const oldState = Immutable.Map({
10
+ TheScope: { extConfig: 789 },
11
+ anotherScope: { extConfig: 456 },
12
+ });
13
+ const action = {
14
+ type: GET_SCOPE_EXTENDED_CONFIGURATION_SUCCESS,
15
+ meta: {
16
+ scope: "TheScope",
17
+ },
18
+ payload: {
19
+ extConfig: 123,
20
+ },
21
+ };
22
+ const newState = reducer(oldState, action);
23
+ return expect(newState, "not to be", oldState).and(
24
+ "to satisfy",
25
+ Immutable.fromJS({
26
+ TheScope: { extConfig: 123 },
27
+ anotherScope: { extConfig: 456 },
28
+ }),
29
+ );
30
+ });
31
+ });