orc-shared 5.4.0-dev.0 → 5.5.1-dev.1

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 (129) hide show
  1. package/dist/actions/makeApiAction.js +2 -2
  2. package/dist/actions/makeOrcApiAction.js +2 -2
  3. package/dist/actions/metadata.js +2 -2
  4. package/dist/actions/navigation.js +16 -3
  5. package/dist/actions/tasks.js +170 -0
  6. package/dist/buildStore.js +5 -3
  7. package/dist/components/AppFrame/About.js +2 -2
  8. package/dist/components/AppFrame/Preferences.js +2 -3
  9. package/dist/components/AppFrame/Sidebar.js +4 -8
  10. package/dist/components/Form/FieldList.js +5 -6
  11. package/dist/components/Form/Inputs/Text.js +0 -1
  12. package/dist/components/Form/Inputs/Translation.js +2 -2
  13. package/dist/components/List/enhanceColumnDefs.js +2 -2
  14. package/dist/components/MaterialUI/DataDisplay/Modal.js +5 -5
  15. package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
  16. package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +2 -2
  17. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +13 -5
  18. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +2 -2
  19. package/dist/components/MaterialUI/DataDisplay/TableProps.js +2 -2
  20. package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -2
  21. package/dist/components/MaterialUI/DataDisplay/TransferList.js +4 -5
  22. package/dist/components/MaterialUI/DataDisplay/chipProps.js +2 -2
  23. package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +2 -2
  24. package/dist/components/MaterialUI/DataDisplay/dividerProps.js +2 -2
  25. package/dist/components/MaterialUI/DataDisplay/modalProps.js +2 -2
  26. package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +2 -2
  27. package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
  28. package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +2 -2
  29. package/dist/components/MaterialUI/Inputs/Checkbox.js +5 -6
  30. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +7 -8
  31. package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +2 -2
  32. package/dist/components/MaterialUI/Inputs/CheckboxProps.js +2 -2
  33. package/dist/components/MaterialUI/Inputs/DatePicker.js +2 -2
  34. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +2 -2
  35. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +43 -46
  36. package/dist/components/MaterialUI/Inputs/RadioProps.js +2 -2
  37. package/dist/components/MaterialUI/Inputs/Select.js +3 -4
  38. package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -2
  39. package/dist/components/MaterialUI/Inputs/StandaloneRadio.js +4 -5
  40. package/dist/components/MaterialUI/Inputs/Switch.js +2 -2
  41. package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -2
  42. package/dist/components/MaterialUI/Inputs/createInput.js +5 -6
  43. package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +2 -2
  44. package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +2 -2
  45. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +2 -3
  46. package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -2
  47. package/dist/components/MaterialUI/Surfaces/paperProps.js +2 -2
  48. package/dist/components/MaterialUI/componentProps.js +2 -2
  49. package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
  50. package/dist/components/MaterialUI/muiThemes.js +12 -13
  51. package/dist/components/MaterialUI/textProps.js +2 -2
  52. package/dist/components/Navigation/Bar.js +2 -2
  53. package/dist/components/Navigation/index.js +1 -0
  54. package/dist/components/Navigation/useNavigationState.js +2 -2
  55. package/dist/components/Routing/Page.js +4 -1
  56. package/dist/components/Routing/SegmentPage.js +5 -2
  57. package/dist/components/Routing/SubPage.js +21 -8
  58. package/dist/components/Routing/withWaypointing.js +2 -2
  59. package/dist/components/Scope/index.js +2 -2
  60. package/dist/components/TaskDetailsModal.js +191 -0
  61. package/dist/components/Treeview/Node.js +2 -2
  62. package/dist/components/Treeview/index.js +2 -2
  63. package/dist/constants.js +18 -2
  64. package/dist/content/iconsSheet.svg +22 -0
  65. package/dist/content/orckestra-logo-white.png +0 -0
  66. package/dist/getThemeOverrides.js +2 -2
  67. package/dist/hocs/withToggle.js +3 -4
  68. package/dist/hocs/withUpdateHandler.js +2 -2
  69. package/dist/hooks/useEditState.js +6 -4
  70. package/dist/hooks/useEntityLoader.js +2 -2
  71. package/dist/hooks/useFullEntityEditState.js +2 -2
  72. package/dist/hooks/useLabelMessage.js +2 -2
  73. package/dist/hooks/useMultipleFieldEditState.js +2 -2
  74. package/dist/hooks/useNotificationRequestState.js +2 -2
  75. package/dist/reducers/navigation.js +16 -0
  76. package/dist/reducers/request.js +4 -0
  77. package/dist/reducers/tasks.js +98 -0
  78. package/dist/selectors/authentication.js +15 -1
  79. package/dist/selectors/metadata.js +2 -2
  80. package/dist/selectors/modules.js +2 -2
  81. package/dist/selectors/tasks.js +64 -0
  82. package/dist/sharedMessages.js +17 -1
  83. package/dist/utils/flatten.js +2 -2
  84. package/dist/utils/modelValidationHelper.js +7 -8
  85. package/dist/utils/propertyHelper.js +33 -0
  86. package/dist/utils/stripKey.js +2 -2
  87. package/package.json +1 -1
  88. package/src/actions/navigation.js +7 -0
  89. package/src/actions/navigation.test.js +12 -0
  90. package/src/actions/tasks.js +77 -0
  91. package/src/actions/tasks.test.js +169 -0
  92. package/src/buildStore.js +2 -0
  93. package/src/components/AppFrame/About.test.js +3 -3
  94. package/src/components/AppFrame/Sidebar.js +4 -3
  95. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +15 -3
  96. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +2 -1
  97. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +39 -27
  98. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +39 -34
  99. package/src/components/MaterialUI/hocs/withDeferredTooltip.js +2 -1
  100. package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +52 -0
  101. package/src/components/Routing/Page.js +12 -1
  102. package/src/components/Routing/SegmentPage.js +13 -1
  103. package/src/components/Routing/SubPage.js +21 -9
  104. package/src/components/Routing/SubPage.test.js +213 -0
  105. package/src/components/TaskDetailsModal.js +132 -0
  106. package/src/components/TaskDetailsModal.test.js +317 -0
  107. package/src/components/Text.test.js +44 -59
  108. package/src/constants.js +15 -0
  109. package/src/content/iconsSheet.svg +22 -0
  110. package/src/content/orckestra-logo-white.png +0 -0
  111. package/src/hooks/useEditState.js +12 -2
  112. package/src/hooks/useEditState.test.js +1 -1
  113. package/src/hooks/useLabelMessage.test.js +16 -10
  114. package/src/reducers/navigation.js +24 -0
  115. package/src/reducers/navigation.test.js +38 -0
  116. package/src/reducers/request.js +4 -0
  117. package/src/reducers/request.test.js +11 -0
  118. package/src/reducers/tasks.js +56 -0
  119. package/src/reducers/tasks.test.js +404 -0
  120. package/src/selectors/authentication.js +13 -0
  121. package/src/selectors/authentication.test.js +322 -0
  122. package/src/selectors/tasks.js +16 -0
  123. package/src/selectors/tasks.test.js +60 -0
  124. package/src/sharedMessages.js +17 -1
  125. package/src/translations/en-US.json +16 -12
  126. package/src/translations/fr-CA.json +16 -12
  127. package/src/utils/propertyHelper.js +38 -0
  128. package/src/utils/propertyHelper.test.js +160 -0
  129. package/src/utils/timezoneHelper.test.js +4 -2
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import { Provider } from "react-redux";
3
- import { IntlProvider } from "react-intl";
4
2
  import Text, { Placeholder } from "./Text";
3
+ import { createMuiTheme, TestWrapper } from "../utils/testUtils";
4
+
5
+ const theme = createMuiTheme();
5
6
 
6
7
  describe("Text", () => {
7
8
  let state, store;
@@ -16,11 +17,9 @@ describe("Text", () => {
16
17
 
17
18
  it("renders a simple message", () =>
18
19
  expect(
19
- <Provider store={store}>
20
- <IntlProvider locale="en">
21
- <Text message="Test message" />
22
- </IntlProvider>
23
- </Provider>,
20
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
21
+ <Text message="Test message" />
22
+ </TestWrapper>,
24
23
  "when mounted",
25
24
  "to satisfy",
26
25
  "Test message",
@@ -28,11 +27,9 @@ describe("Text", () => {
28
27
 
29
28
  it("renders an empty string", () =>
30
29
  expect(
31
- <Provider store={store}>
32
- <IntlProvider locale="en">
33
- <Text message="" />
34
- </IntlProvider>
35
- </Provider>,
30
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
31
+ <Text message="" />
32
+ </TestWrapper>,
36
33
  "when mounted",
37
34
  "to satisfy",
38
35
  "",
@@ -40,11 +37,9 @@ describe("Text", () => {
40
37
 
41
38
  it("renders a translated message", () =>
42
39
  expect(
43
- <Provider store={store}>
44
- <IntlProvider locale="en">
45
- <Text message={{ id: "test.msg", defaultMessage: "Test message" }} />
46
- </IntlProvider>
47
- </Provider>,
40
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
41
+ <Text message={{ id: "test.msg", defaultMessage: "Test message" }} />
42
+ </TestWrapper>,
48
43
  "when mounted",
49
44
  "to satisfy",
50
45
  "Test message",
@@ -52,17 +47,15 @@ describe("Text", () => {
52
47
 
53
48
  it("renders a translated message with values", () =>
54
49
  expect(
55
- <Provider store={store}>
56
- <IntlProvider locale="en">
57
- <Text
58
- message={{
59
- id: "test.msg",
60
- defaultMessage: "Test message {foo}",
61
- values: { foo: 3 },
62
- }}
63
- />
64
- </IntlProvider>
65
- </Provider>,
50
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
51
+ <Text
52
+ message={{
53
+ id: "test.msg",
54
+ defaultMessage: "Test message {foo}",
55
+ values: { foo: 3 },
56
+ }}
57
+ />
58
+ </TestWrapper>,
66
59
  "when mounted",
67
60
  "to satisfy",
68
61
  "Test message 3",
@@ -70,17 +63,15 @@ describe("Text", () => {
70
63
 
71
64
  it("renders a translated message with a value selector", () =>
72
65
  expect(
73
- <Provider store={store}>
74
- <IntlProvider locale="en">
75
- <Text
76
- message={{
77
- id: "test.msg",
78
- defaultMessage: "Test message {foo}",
79
- values: state => state.dataVal,
80
- }}
81
- />
82
- </IntlProvider>
83
- </Provider>,
66
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
67
+ <Text
68
+ message={{
69
+ id: "test.msg",
70
+ defaultMessage: "Test message {foo}",
71
+ values: state => state.dataVal,
72
+ }}
73
+ />
74
+ </TestWrapper>,
84
75
  "when mounted",
85
76
  "to satisfy",
86
77
  "Test message 3",
@@ -88,16 +79,14 @@ describe("Text", () => {
88
79
 
89
80
  it("renders a translated message missing its values as a placeholder", () =>
90
81
  expect(
91
- <Provider store={store}>
92
- <IntlProvider locale="en">
93
- <Text
94
- message={{
95
- id: "test.msg",
96
- defaultMessage: "Test message {foo}",
97
- }}
98
- />
99
- </IntlProvider>
100
- </Provider>,
82
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
83
+ <Text
84
+ message={{
85
+ id: "test.msg",
86
+ defaultMessage: "Test message {foo}",
87
+ }}
88
+ />
89
+ </TestWrapper>,
101
90
  "when mounted",
102
91
  "to satisfy",
103
92
  <Placeholder />,
@@ -105,11 +94,9 @@ describe("Text", () => {
105
94
 
106
95
  it("renders an error", () =>
107
96
  expect(
108
- <Provider store={store}>
109
- <IntlProvider locale="en">
110
- <Text message="Test message" error={{ message: "This failed" }} />
111
- </IntlProvider>
112
- </Provider>,
97
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
98
+ <Text message="Test message" error={{ message: "This failed" }} />
99
+ </TestWrapper>,
113
100
  "when mounted",
114
101
  "to satisfy",
115
102
  <span
@@ -126,11 +113,9 @@ describe("Text", () => {
126
113
 
127
114
  it("renders an error if no message given", () =>
128
115
  expect(
129
- <Provider store={store}>
130
- <IntlProvider locale="en">
131
- <Text />
132
- </IntlProvider>
133
- </Provider>,
116
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
117
+ <Text />
118
+ </TestWrapper>,
134
119
  "when mounted",
135
120
  "to satisfy",
136
121
  <span
package/src/constants.js CHANGED
@@ -13,11 +13,13 @@ export const platformRoles = {
13
13
  Administrator: "Administrator",
14
14
  Editor: "Editor",
15
15
  Reader: "Reader",
16
+ Recipient: "Recipient",
16
17
  };
17
18
 
18
19
  export const roleGroups = {
19
20
  Products: "Products",
20
21
  Orders: "Orders",
22
+ OrderReturn: "OrderReturn",
21
23
  Marketing: "Marketing",
22
24
  Analytics: "Analytics",
23
25
  Shopping: "Shopping",
@@ -105,3 +107,16 @@ export const requestStateOperationMap = {
105
107
  fetch: "fetches",
106
108
  update: "updates",
107
109
  };
110
+
111
+ export const taskStatuses = {
112
+ created: "Created",
113
+ waitingToRun: "WaitingToRun",
114
+ running: "Running",
115
+ ranToCompletion: "RanToCompletion",
116
+ canceled: "Canceled",
117
+ faulted: "Faulted",
118
+ idle: "Idle",
119
+ waitingToCancel: "WaitingToCancel",
120
+ ignored: "Ignored",
121
+ queuedForSequence: "QueuedForSequence",
122
+ };
@@ -708,4 +708,26 @@
708
708
  <polygon fill="#FFF" points="9.6 12 16 8.4 9.6 4.8"/>
709
709
  </g>
710
710
  </symbol>
711
+ <symbol id="icon-barcode" viewBox="0 0 25 20" xmlns="http://www.w3.org/2000/svg">
712
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M1.00031 16.0315C1.27645 16.0315 1.50031 16.2554 1.50031 16.5315V19.0005H3.96931C4.24545 19.0005 4.46931 19.2244 4.46931 19.5005C4.46931 19.7766 4.24545 20.0005 3.96931 20.0005H1.00031C0.724163 20.0005 0.500305 19.7766 0.500305 19.5005V16.5315C0.500305 16.2554 0.724163 16.0315 1.00031 16.0315Z" fill="#333333"/>
713
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0.5 0.500244C0.5 0.224102 0.723858 0.000244141 1 0.000244141H3.969C4.24514 0.000244141 4.469 0.224102 4.469 0.500244C4.469 0.776386 4.24514 1.00024 3.969 1.00024H1.5V3.46924C1.5 3.74539 1.27614 3.96924 1 3.96924C0.723858 3.96924 0.5 3.74539 0.5 3.46924V0.500244Z" fill="#333333"/>
714
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M20.5313 0.5C20.5313 0.223858 20.7552 0 21.0313 0H24.0003C24.2765 0 24.5003 0.223858 24.5003 0.5V3.469C24.5003 3.74514 24.2765 3.969 24.0003 3.969C23.7242 3.969 23.5003 3.74514 23.5003 3.469V1H21.0313C20.7552 1 20.5313 0.776142 20.5313 0.5Z" fill="#333333"/>
715
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M24.0005 16.0312C24.2766 16.0312 24.5005 16.2551 24.5005 16.5312V19.5002C24.5005 19.7764 24.2766 20.0002 24.0005 20.0002H21.0315C20.7554 20.0002 20.5315 19.7764 20.5315 19.5002C20.5315 19.2241 20.7554 19.0002 21.0315 19.0002H23.5005V16.5312C23.5005 16.2551 23.7244 16.0312 24.0005 16.0312Z" fill="#333333"/>
716
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3.50031 15.0002V5.00024H4.50031V15.0002H3.50031Z" fill="#333333"/>
717
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M5.50031 12.0002V5.00024H6.50031V12.0002H5.50031Z" fill="#333333"/>
718
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.50031 12.0002V5.00024H8.50031V12.0002H7.50031Z" fill="#333333"/>
719
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10.5003 12.0002V5.00024H11.5003V12.0002H10.5003Z" fill="#333333"/>
720
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5003 12.0002V5.00024H13.5003V12.0002H12.5003Z" fill="#333333"/>
721
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M14.5003 12.0002V5.00024H15.5003V12.0002H14.5003Z" fill="#333333"/>
722
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16.5003 12.0002V5.00024H17.5003V12.0002H16.5003Z" fill="#333333"/>
723
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18.5003 12.0002V5.00024H19.5003V12.0002H18.5003Z" fill="#333333"/>
724
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M20.5003 15.0002V5.00024H21.5003V15.0002H20.5003Z" fill="#333333"/>
725
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M6.50031 13.0002H5.50031V14.0002H6.50031V13.0002Z" fill="#333333"/>
726
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.50031 13.0002H7.50031V14.0002H8.50031V13.0002Z" fill="#333333"/>
727
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11.5003 13.0002H10.5003V14.0002H11.5003V13.0002Z" fill="#333333"/>
728
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M13.5003 13.0002H12.5003V14.0002H13.5003V13.0002Z" fill="#333333"/>
729
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.5003 13.0002H14.5003V14.0002H15.5003V13.0002Z" fill="#333333"/>
730
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M17.5003 13.0002H16.5003V14.0002H17.5003V13.0002Z" fill="#333333"/>
731
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19.5003 13.0002H18.5003V14.0002H19.5003V13.0002Z" fill="#333333"/>
732
+ </symbol>
711
733
  </svg>
@@ -190,8 +190,18 @@ export const useDynamicEditState = (entityId, sectionName, extendedValidationRul
190
190
  };
191
191
 
192
192
  const resetEditState = (path = []) => {
193
- const fullPath = !path.length ? [...keys] : [...keys, "value", ...getValidPath(path)];
194
- dispatchWithModulesData(setEditModelField, [fullPath, initialValue, initialValue, entityId, sectionName]);
193
+ const pathToField = getValidPath(path);
194
+ const fullPath = !path.length ? [...keys] : [...keys, "value", ...pathToField];
195
+
196
+ const initialFieldValue = !path.length ? initialValue : get(initialValue, pathToField);
197
+
198
+ dispatchWithModulesData(setEditModelField, [
199
+ fullPath,
200
+ initialFieldValue,
201
+ initialFieldValue,
202
+ entityId,
203
+ sectionName,
204
+ ]);
195
205
  };
196
206
 
197
207
  const isEditStateValid = (value, path = [], errorTypes = [], dependencies = {}) => {
@@ -1171,7 +1171,7 @@ describe("useDynamicEditState", () => {
1171
1171
  expect(useDispatchWithModulesDataSpy, "to have a call satisfying", {
1172
1172
  args: [
1173
1173
  setEditModelField,
1174
- [["field", "value", "c", "d"], initialFieldValue, initialFieldValue, entityId, sectionName],
1174
+ [["field", "value", "c", "d"], initialFieldValue.c.d, initialFieldValue.c.d, entityId, sectionName],
1175
1175
  ],
1176
1176
  });
1177
1177
 
@@ -5,12 +5,14 @@ import Immutable from "immutable";
5
5
  import sinon from "sinon";
6
6
  import { messageContainsValues } from "./useLabelMessage";
7
7
  import useLabelMessage from "./useLabelMessage";
8
+ import { createMuiTheme, extractMessages, TestWrapper } from "../utils/testUtils";
8
9
 
9
10
  const TestComp = ({ message, buildMessage }) => {
10
11
  const [msgResult, missingValues = false] = useLabelMessage(message, buildMessage);
11
12
 
12
13
  return <div missing-values={missingValues ? 1 : 0}>{msgResult}</div>;
13
14
  };
15
+ const theme = createMuiTheme();
14
16
 
15
17
  describe("useLabelMessage", () => {
16
18
  let store, state;
@@ -45,12 +47,18 @@ describe("useLabelMessage", () => {
45
47
  values: { aValue: "testValue" },
46
48
  };
47
49
 
50
+ const messages = extractMessages({ "test.msg": message });
51
+
48
52
  return expect(
49
- <Provider store={store}>
50
- <IntlProvider locale="en">
51
- <TestComp message={message} />
52
- </IntlProvider>
53
- </Provider>,
53
+ <TestWrapper
54
+ provider={{ store }}
55
+ intlProvider={{ messages }}
56
+ memoryRouter
57
+ stylesProvider
58
+ muiThemeProvider={{ theme }}
59
+ >
60
+ <TestComp message={message} />
61
+ </TestWrapper>,
54
62
  "when mounted",
55
63
  "to satisfy",
56
64
  <div>Test message testValue</div>,
@@ -65,11 +73,9 @@ describe("useLabelMessage", () => {
65
73
  };
66
74
 
67
75
  return expect(
68
- <Provider store={store}>
69
- <IntlProvider locale="en">
70
- <TestComp message={message} />
71
- </IntlProvider>
72
- </Provider>,
76
+ <TestWrapper provider={{ store }} intlProvider memoryRouter stylesProvider muiThemeProvider={{ theme }}>
77
+ <TestComp message={message} />
78
+ </TestWrapper>,
73
79
  "when mounted",
74
80
  "to satisfy",
75
81
  <div missing-values={1}></div>,
@@ -6,6 +6,7 @@ import {
6
6
  SET_HREF_CONFIG,
7
7
  SET_CURRENT_PREPEND_PATH,
8
8
  SET_CLOSING_TAB_HANDLER_ACTIONS,
9
+ REMOVE_MODULE_TABS,
9
10
  } from "../actions/navigation";
10
11
  import { getAllAfterPrependHref } from "../utils/parseHelper";
11
12
  import { APPLICATION_SCOPE_HAS_CHANGED } from "../actions/scopes";
@@ -73,6 +74,29 @@ const navigationReducer = (state = initialState, action) => {
73
74
  s.deleteIn(["tabIndex", remainingSection]);
74
75
  }
75
76
  });
77
+ case REMOVE_MODULE_TABS:
78
+ return state.withMutations(s => {
79
+ const { module } = action.payload;
80
+
81
+ s.deleteIn(["moduleTabs", module]);
82
+ s.deleteIn(["closingTabsHandlerActions", module]);
83
+
84
+ s.get("tabIndex")
85
+ .keySeq()
86
+ .forEach(key => {
87
+ if (key.startsWith(module)) {
88
+ s.deleteIn(["tabIndex", key]);
89
+ }
90
+ });
91
+
92
+ s.get("mappedHrefs")
93
+ .keySeq()
94
+ .forEach(key => {
95
+ if (key.startsWith(module)) {
96
+ s.deleteIn(["mappedHrefs", key]);
97
+ }
98
+ });
99
+ });
76
100
  case SET_HREF_CONFIG:
77
101
  return state.set("config", Immutable.fromJS(action.payload));
78
102
  case SET_CURRENT_PREPEND_PATH:
@@ -6,6 +6,7 @@ import {
6
6
  setHrefConfig,
7
7
  setCurrentPrependPath,
8
8
  setClosingTabHandlerActions,
9
+ removeModuleTabs,
9
10
  } from "../actions/navigation";
10
11
  import reducer from "./navigation";
11
12
  import { applicationScopeHasChanged } from "../actions/scopes";
@@ -295,6 +296,43 @@ describe("Navigation reducer", () => {
295
296
  });
296
297
  });
297
298
 
299
+ describe("REMOVE_MODULE_TABS", () => {
300
+ it("can remove module tabs", () => {
301
+ const oldState = Immutable.fromJS({
302
+ moduleTabs: { test: ["test/new", "test/old"], another: [1, 2, 3] },
303
+ closingTabsHandlerActions: { test: [0, 1, 2], another: [] },
304
+ tabIndex: { "test/old": {}, "test/new": {}, test: {}, another: {} },
305
+ mappedHrefs: { "test/old": {}, "test/new": {}, test: {}, another2: {} },
306
+ config: { prependPath: "/:scope/" },
307
+ });
308
+ const action = removeModuleTabs("test");
309
+ const newState = reducer(oldState, action);
310
+ return expect(newState, "not to be", oldState).and(
311
+ "to equal",
312
+ Immutable.fromJS({
313
+ moduleTabs: { another: [1, 2, 3] },
314
+ closingTabsHandlerActions: { another: [] },
315
+ tabIndex: { another: {} },
316
+ mappedHrefs: { another2: {} },
317
+ config: { prependPath: "/:scope/" },
318
+ }),
319
+ );
320
+ });
321
+
322
+ it("does nothing if the module to remove is not found", () => {
323
+ const oldState = Immutable.fromJS({
324
+ moduleTabs: { test: ["test/new", "test/old"], another: [1, 2, 3] },
325
+ closingTabsHandlerActions: { test: [0, 1, 2], another: [] },
326
+ tabIndex: { "test/old": {}, "test/new": {}, test: {}, another: {} },
327
+ mappedHrefs: { "test/old": {}, "test/new": {}, test: {}, another2: {} },
328
+ config: { prependPath: "/:scope/" },
329
+ });
330
+ const action = removeModuleTabs("unknown");
331
+ const newState = reducer(oldState, action);
332
+ return expect(newState, "to be", oldState);
333
+ });
334
+ });
335
+
298
336
  describe("SET_HREF_CONFIG", () => {
299
337
  it("update href config in navigation state", () => {
300
338
  const oldState = Immutable.fromJS({
@@ -11,6 +11,10 @@ export const LOGOUT = "logout";
11
11
 
12
12
  const requestReducer = (state = initialState, action) => {
13
13
  if (action.type.endsWith("_REQUEST")) {
14
+ if (safeGet(action, "meta", "addToActiveRequests") === false) {
15
+ // this flag should only be used by requests triggered by a background process to avoid the spinner
16
+ return state;
17
+ }
14
18
  const requestName = action.type.replace(/_REQUEST$/, "");
15
19
  return state.setIn(["actives", requestName], true);
16
20
  }
@@ -28,6 +28,17 @@ describe("Request reducer", () => {
28
28
  );
29
29
  });
30
30
 
31
+ it("ignore activity flag when a request is started because addToActiveRequests is false", () => {
32
+ const oldState = Immutable.fromJS({
33
+ actives: {
34
+ SOME_FLAG: true,
35
+ },
36
+ });
37
+ const action = { type: "TEST_THIS_REQUEST", meta: { addToActiveRequests: false } };
38
+ const newState = reducer(oldState, action);
39
+ expect(newState, "to be", oldState);
40
+ });
41
+
31
42
  it("clears activity and logout flag when a request succeeds", () => {
32
43
  const oldState = Immutable.fromJS({
33
44
  actives: {
@@ -0,0 +1,56 @@
1
+ import Immutable from "immutable";
2
+ import { safeGet } from "../utils";
3
+ import {
4
+ GET_TASK_LIST_SUCCESS,
5
+ DELETE_TASK_REQUEST,
6
+ GET_TASK_LOG_SUCCESS,
7
+ CLEAR_TASK_LOG,
8
+ GET_TASKINFO_SUCCESS,
9
+ } from "../actions/tasks";
10
+ import { compareObjectProperty } from "../utils/propertyHelper";
11
+
12
+ const initialState = Immutable.fromJS({
13
+ tasks: [],
14
+ taskInfos: {},
15
+ logs: {},
16
+ });
17
+
18
+ const tasks = (state = initialState, action) => {
19
+ switch (action.type) {
20
+ case GET_TASKINFO_SUCCESS:
21
+ return state.setIn(["taskInfos", action.payload.taskId], Immutable.fromJS(action.payload));
22
+ case GET_TASK_LIST_SUCCESS:
23
+ return state.set(
24
+ "tasks",
25
+ Immutable.fromJS(action.payload.sort((a, b) => compareObjectProperty(a, b, "created"))),
26
+ );
27
+ case DELETE_TASK_REQUEST:
28
+ const deleteTaskId = safeGet(action, "meta", "taskId");
29
+
30
+ return state.withMutations(s => {
31
+ s.set(
32
+ "tasks",
33
+ s.get("tasks").filter(task => task.get("taskId") !== deleteTaskId),
34
+ );
35
+ s.deleteIn(["logs", deleteTaskId]);
36
+ s.deleteIn(["taskInfos", deleteTaskId]);
37
+ });
38
+ case GET_TASK_LOG_SUCCESS:
39
+ const logTaskId = safeGet(action, "meta", "taskId");
40
+ if (action.payload?.length > 0) {
41
+ return state.setIn(
42
+ ["logs", logTaskId],
43
+ Immutable.fromJS(action.payload.sort((a, b) => compareObjectProperty(a, b, "executionTime"))),
44
+ );
45
+ } else {
46
+ return state.deleteIn(["logs", logTaskId]);
47
+ }
48
+ case CLEAR_TASK_LOG:
49
+ const taskId = safeGet(action, "meta", "taskId");
50
+ return state.deleteIn(["logs", taskId]);
51
+ default:
52
+ return state;
53
+ }
54
+ };
55
+
56
+ export default tasks;