orc-shared 1.7.0-dev.8 → 5.2.0-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.
- package/dist/actions/modules.js +15 -1
- package/dist/actions/navigation.js +1 -14
- package/dist/actions/scopes.js +2 -3
- package/dist/buildStore.js +1 -7
- package/dist/components/AppFrame/Sidebar.js +8 -4
- package/dist/components/MaterialUI/DataDisplay/Notification.js +0 -6
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +6 -18
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -2
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +2 -4
- package/dist/components/MaterialUI/DataDisplay/tableHelpers.js +7 -7
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +0 -5
- package/dist/components/MaterialUI/Inputs/DatePicker.js +8 -15
- package/dist/components/MaterialUI/Inputs/InputBase.js +16 -102
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -7
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +46 -43
- package/dist/components/MaterialUI/Inputs/TimePicker.js +2 -5
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +1 -6
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +0 -1
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +1 -3
- package/dist/components/Routing/Page.js +1 -4
- package/dist/components/Routing/SegmentPage.js +1 -4
- package/dist/components/Routing/SubPage.js +8 -38
- package/dist/components/Scope/useScopeConfirmationModalState.js +3 -1
- package/dist/constants.js +2 -18
- package/dist/content/icons/hide.svg +1 -10
- package/dist/content/icons/open-in-new-tab.svg +1 -3
- package/dist/content/iconsSheet.svg +650 -117
- package/dist/content/orckestra-logo-white.png +0 -0
- package/dist/hooks/useEditState.js +2 -4
- package/dist/reducers/modules.js +3 -4
- package/dist/reducers/navigation.js +0 -16
- package/dist/reducers/request.js +1 -6
- package/dist/reducers/scopes.js +0 -3
- package/dist/reducers/view.js +1 -1
- package/dist/selectors/authentication.js +1 -15
- package/dist/selectors/metadata.js +1 -1
- package/dist/sharedMessages.js +1 -17
- package/dist/utils/propertyHelper.js +0 -33
- package/dist/utils/timezoneHelper.js +1 -23
- package/package.json +7 -10
- package/src/actions/modules.js +10 -0
- package/src/actions/modules.test.js +14 -0
- package/src/actions/navigation.js +0 -7
- package/src/actions/navigation.test.js +0 -12
- package/src/actions/scopes.js +1 -2
- package/src/actions/scopes.test.js +1 -2
- package/src/buildStore.js +0 -6
- package/src/components/AppFrame/About.test.js +3 -3
- package/src/components/AppFrame/Sidebar.js +3 -4
- package/src/components/Form/InputField.test.js +0 -18
- package/src/components/Form/Inputs/Date.test.js +0 -18
- package/src/components/MaterialUI/DataDisplay/Notification.js +0 -6
- package/src/components/MaterialUI/DataDisplay/Notification.test.js +0 -37
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +5 -23
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +0 -121
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -2
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +0 -20
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +1 -2
- package/src/components/MaterialUI/DataDisplay/tableHelpers.js +8 -8
- package/src/components/MaterialUI/DataDisplay/tableHelpers.test.js +0 -93
- package/src/components/MaterialUI/Inputs/Autocomplete.js +0 -5
- package/src/components/MaterialUI/Inputs/Autocomplete.test.js +0 -15
- package/src/components/MaterialUI/Inputs/DatePicker.js +3 -17
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +1 -143
- package/src/components/MaterialUI/Inputs/InputBase.js +15 -103
- package/src/components/MaterialUI/Inputs/InputBase.test.js +1 -376
- package/src/components/MaterialUI/Inputs/InputBaseProps.js +0 -6
- package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +0 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +27 -39
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +34 -39
- package/src/components/MaterialUI/Inputs/TimePicker.js +1 -5
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +1 -6
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +0 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +1 -2
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +0 -52
- package/src/components/Routing/Page.js +1 -12
- package/src/components/Routing/SegmentPage.js +1 -12
- package/src/components/Routing/SubPage.js +9 -41
- package/src/components/Routing/SubPage.test.js +1 -295
- package/src/components/Scope/useScopeConfirmationModalState.js +3 -1
- package/src/components/Scope/useScopeConfirmationModalState.test.js +35 -4
- package/src/components/Text.test.js +59 -44
- package/src/constants.js +0 -15
- package/src/content/icons/hide.svg +1 -10
- package/src/content/icons/open-in-new-tab.svg +1 -3
- package/src/content/iconsSheet.svg +650 -117
- package/src/content/orckestra-logo-white.png +0 -0
- package/src/hooks/useEditState.js +2 -12
- package/src/hooks/useEditState.test.js +1 -1
- package/src/hooks/useLabelMessage.test.js +10 -16
- package/src/reducers/modules.js +4 -4
- package/src/reducers/modules.test.js +5 -5
- package/src/reducers/navigation.js +0 -24
- package/src/reducers/navigation.test.js +0 -38
- package/src/reducers/request.js +1 -6
- package/src/reducers/request.test.js +0 -34
- package/src/reducers/scopes.js +0 -3
- package/src/reducers/scopes.test.js +0 -47
- package/src/reducers/view.js +1 -1
- package/src/reducers/view.test.js +8 -1
- package/src/selectors/authentication.js +0 -13
- package/src/selectors/authentication.test.js +0 -322
- package/src/selectors/metadata.js +1 -1
- package/src/selectors/metadata.test.js +0 -12
- package/src/sharedMessages.js +1 -17
- package/src/translations/en-US.json +12 -16
- package/src/translations/fr-CA.json +12 -16
- package/src/utils/propertyHelper.js +0 -38
- package/src/utils/propertyHelper.test.js +0 -160
- package/src/utils/timezoneHelper.js +0 -18
- package/src/utils/timezoneHelper.test.js +1 -23
- package/dist/actions/globalErrorMessages.js +0 -63
- package/dist/actions/tasks.js +0 -170
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.js +0 -160
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.js +0 -88
- package/dist/components/TaskDetailsModal.js +0 -191
- package/dist/content/icons/anonymize.svg +0 -3
- package/dist/content/icons/archives.svg +0 -3
- package/dist/content/icons/clean-index.svg +0 -3
- package/dist/content/icons/date-index.svg +0 -3
- package/dist/content/icons/inventory.svg +0 -4
- package/dist/content/icons/query-tester.svg +0 -10
- package/dist/content/icons/reciprocity.svg +0 -10
- package/dist/content/icons/schema.svg +0 -11
- package/dist/content/icons/synonyms.svg +0 -3
- package/dist/content/icons/tenant.svg +0 -3
- package/dist/content/icons/time-index.svg +0 -3
- package/dist/hooks/useDispatchWithErrorHandling.js +0 -103
- package/dist/hooks/useScopeGuardLoader.js +0 -77
- package/dist/reducers/globalErrorMessages.js +0 -78
- package/dist/reducers/scopeRouteState.js +0 -83
- package/dist/reducers/tasks.js +0 -98
- package/dist/selectors/globalErrorMessages.js +0 -57
- package/dist/selectors/scopeRouteState.js +0 -53
- package/dist/selectors/tasks.js +0 -64
- package/dist/utils/responseProcessingHelper.js +0 -86
- package/src/actions/globalErrorMessages.js +0 -12
- package/src/actions/globalErrorMessages.test.js +0 -21
- package/src/actions/tasks.js +0 -77
- package/src/actions/tasks.test.js +0 -169
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.js +0 -108
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/GlobalErrorMessages.test.js +0 -468
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.js +0 -29
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/LookupDisplayValue.test.js +0 -147
- package/src/components/TaskDetailsModal.js +0 -132
- package/src/components/TaskDetailsModal.test.js +0 -317
- package/src/content/icons/anonymize.svg +0 -3
- package/src/content/icons/archives.svg +0 -3
- package/src/content/icons/clean-index.svg +0 -3
- package/src/content/icons/date-index.svg +0 -3
- package/src/content/icons/inventory.svg +0 -4
- package/src/content/icons/query-tester.svg +0 -10
- package/src/content/icons/reciprocity.svg +0 -10
- package/src/content/icons/schema.svg +0 -11
- package/src/content/icons/synonyms.svg +0 -3
- package/src/content/icons/tenant.svg +0 -3
- package/src/content/icons/time-index.svg +0 -3
- package/src/hooks/useDispatchWithErrorHandling.js +0 -57
- package/src/hooks/useDispatchWithErrorHandling.test.js +0 -230
- package/src/hooks/useScopeGuardLoader.js +0 -25
- package/src/hooks/useScopeGuardLoader.test.js +0 -187
- package/src/reducers/globalErrorMessages.js +0 -25
- package/src/reducers/globalErrorMessages.test.js +0 -66
- package/src/reducers/scopeRouteState.js +0 -29
- package/src/reducers/scopeRouteState.test.js +0 -49
- package/src/reducers/tasks.js +0 -56
- package/src/reducers/tasks.test.js +0 -404
- package/src/selectors/globalErrorMessages.js +0 -11
- package/src/selectors/globalErrorMessages.test.js +0 -25
- package/src/selectors/scopeRouteState.js +0 -5
- package/src/selectors/scopeRouteState.test.js +0 -13
- package/src/selectors/tasks.js +0 -16
- package/src/selectors/tasks.test.js +0 -60
- package/src/utils/responseProcessingHelper.js +0 -42
- package/src/utils/responseProcessingHelper.test.js +0 -218
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useDispatchWithErrorHandling } from "./useDispatchWithErrorHandling";
|
|
3
|
-
import sinon from "sinon";
|
|
4
|
-
import { mount } from "enzyme";
|
|
5
|
-
import { Provider } from "react-redux";
|
|
6
|
-
import Immutable from "immutable";
|
|
7
|
-
import { pushGlobalErrorMessage } from "../actions/globalErrorMessages";
|
|
8
|
-
|
|
9
|
-
const delay = () => new Promise(resolve => setTimeout(resolve, 10));
|
|
10
|
-
|
|
11
|
-
describe("useDispatchWithErrorHandling", () => {
|
|
12
|
-
let store, state, dispatchSpy;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
state = Immutable.fromJS({});
|
|
16
|
-
dispatchSpy = sinon.stub().named("dispatch");
|
|
17
|
-
|
|
18
|
-
store = {
|
|
19
|
-
subscribe: () => {},
|
|
20
|
-
dispatch: dispatchSpy,
|
|
21
|
-
getState: () => state,
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("Dispatches action just with specified parameters", () => {
|
|
26
|
-
dispatchSpy.resolves({});
|
|
27
|
-
|
|
28
|
-
const TestComp = () => {
|
|
29
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
30
|
-
dispatch({
|
|
31
|
-
action: { type: "testing" },
|
|
32
|
-
errorTitle: "title",
|
|
33
|
-
errorDescription: "desc",
|
|
34
|
-
validationLookupModule: "order",
|
|
35
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
36
|
-
});
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const component = (
|
|
41
|
-
<Provider store={store}>
|
|
42
|
-
<TestComp />
|
|
43
|
-
</Provider>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
mount(component);
|
|
47
|
-
|
|
48
|
-
expect(dispatchSpy.callCount, "to be", 1);
|
|
49
|
-
expect(dispatchSpy, "to have a call satisfying", { args: [{ type: "testing" }] });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("does not push messages because data is null", () => {
|
|
53
|
-
dispatchSpy.resolves(null);
|
|
54
|
-
|
|
55
|
-
const TestComp = () => {
|
|
56
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
57
|
-
dispatch({
|
|
58
|
-
action: { type: "testing" },
|
|
59
|
-
errorTitle: "title",
|
|
60
|
-
errorDescription: "desc",
|
|
61
|
-
validationLookupModule: "order",
|
|
62
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
63
|
-
});
|
|
64
|
-
return null;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const component = (
|
|
68
|
-
<Provider store={store}>
|
|
69
|
-
<TestComp />
|
|
70
|
-
</Provider>
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
mount(component);
|
|
74
|
-
|
|
75
|
-
expect(dispatchSpy.callCount, "to be", 1);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("does not push messages because data is an empty object", () => {
|
|
79
|
-
dispatchSpy.resolves({});
|
|
80
|
-
|
|
81
|
-
const TestComp = () => {
|
|
82
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
83
|
-
dispatch({
|
|
84
|
-
action: { type: "testing" },
|
|
85
|
-
errorTitle: "title",
|
|
86
|
-
errorDescription: "desc",
|
|
87
|
-
validationLookupModule: "order",
|
|
88
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
89
|
-
});
|
|
90
|
-
return null;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const component = (
|
|
94
|
-
<Provider store={store}>
|
|
95
|
-
<TestComp />
|
|
96
|
-
</Provider>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
mount(component);
|
|
100
|
-
|
|
101
|
-
expect(dispatchSpy.callCount, "to be", 1);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("does not push messages because data is a response with error=false", () => {
|
|
105
|
-
dispatchSpy.resolves({ error: false });
|
|
106
|
-
|
|
107
|
-
const TestComp = () => {
|
|
108
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
109
|
-
dispatch({
|
|
110
|
-
action: { type: "testing" },
|
|
111
|
-
errorTitle: "title",
|
|
112
|
-
errorDescription: "desc",
|
|
113
|
-
validationLookupModule: "order",
|
|
114
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
115
|
-
});
|
|
116
|
-
return null;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const component = (
|
|
120
|
-
<Provider store={store}>
|
|
121
|
-
<TestComp />
|
|
122
|
-
</Provider>
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
mount(component);
|
|
126
|
-
|
|
127
|
-
expect(dispatchSpy.callCount, "to be", 1);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("dispatch new message with title and description because of empty msg list", () => {
|
|
131
|
-
dispatchSpy.resolves({
|
|
132
|
-
error: true,
|
|
133
|
-
payload: {
|
|
134
|
-
status: 500,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const TestComp = () => {
|
|
139
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
140
|
-
dispatch({
|
|
141
|
-
action: { type: "testing" },
|
|
142
|
-
errorTitle: "title",
|
|
143
|
-
errorDescription: "desc",
|
|
144
|
-
validationLookupModule: "order",
|
|
145
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
146
|
-
});
|
|
147
|
-
return null;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const component = (
|
|
151
|
-
<Provider store={store}>
|
|
152
|
-
<TestComp />
|
|
153
|
-
</Provider>
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
mount(component);
|
|
157
|
-
|
|
158
|
-
delay().then(() => {
|
|
159
|
-
expect(dispatchSpy.callCount, "to be", 2);
|
|
160
|
-
expect(dispatchSpy, "to have a call satisfying", {
|
|
161
|
-
args: [
|
|
162
|
-
pushGlobalErrorMessage({
|
|
163
|
-
title: "title",
|
|
164
|
-
description: "desc",
|
|
165
|
-
messages: [],
|
|
166
|
-
}),
|
|
167
|
-
],
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("dispatch new message with only title because msg list is filled", () => {
|
|
173
|
-
dispatchSpy.resolves({
|
|
174
|
-
error: true,
|
|
175
|
-
payload: {
|
|
176
|
-
status: 500,
|
|
177
|
-
response: {
|
|
178
|
-
errors: [
|
|
179
|
-
{
|
|
180
|
-
message: "msg",
|
|
181
|
-
lookupModule: "mod",
|
|
182
|
-
lookupName: "name",
|
|
183
|
-
lookupKey: "key",
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const TestComp = () => {
|
|
191
|
-
const dispatch = useDispatchWithErrorHandling();
|
|
192
|
-
dispatch({
|
|
193
|
-
action: { type: "testing" },
|
|
194
|
-
errorTitle: "title",
|
|
195
|
-
errorDescription: "desc",
|
|
196
|
-
validationLookupModule: "order",
|
|
197
|
-
validationLookupName: "ValidationsOrderReturns",
|
|
198
|
-
});
|
|
199
|
-
return null;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const component = (
|
|
203
|
-
<Provider store={store}>
|
|
204
|
-
<TestComp />
|
|
205
|
-
</Provider>
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
mount(component);
|
|
209
|
-
|
|
210
|
-
delay().then(() => {
|
|
211
|
-
expect(dispatchSpy.callCount, "to be", 2);
|
|
212
|
-
expect(dispatchSpy, "to have a call satisfying", {
|
|
213
|
-
args: [
|
|
214
|
-
pushGlobalErrorMessage({
|
|
215
|
-
title: "title",
|
|
216
|
-
description: null,
|
|
217
|
-
messages: [
|
|
218
|
-
{
|
|
219
|
-
message: "msg",
|
|
220
|
-
lookupModule: "mod",
|
|
221
|
-
lookupName: "name",
|
|
222
|
-
lookupKey: "key",
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
}),
|
|
226
|
-
],
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useSelector } from "react-redux";
|
|
2
|
-
import { getScopeChangeInProgress } from "../selectors/scopeRouteState";
|
|
3
|
-
import useLoader from "./useLoader";
|
|
4
|
-
|
|
5
|
-
// look at scopeRouteState.js for documentation
|
|
6
|
-
|
|
7
|
-
const useScopeGuardLoader = (actions, cutoutSelector) => {
|
|
8
|
-
const changeInProgress = useSelector(getScopeChangeInProgress);
|
|
9
|
-
|
|
10
|
-
const cutoutSelectorGuard = (...selArgs) => {
|
|
11
|
-
if (changeInProgress) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (cutoutSelector) {
|
|
16
|
-
return cutoutSelector.apply(null, selArgs);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return true;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
useLoader(actions, cutoutSelectorGuard);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default useScopeGuardLoader;
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { mount, act } from "unexpected-reaction";
|
|
3
|
-
import { Provider, useSelector } from "react-redux";
|
|
4
|
-
import Immutable from "immutable";
|
|
5
|
-
import sinon from "sinon";
|
|
6
|
-
import { spyOnConsole } from "../utils/testUtils";
|
|
7
|
-
import useScopeGuardLoader from "./useScopeGuardLoader";
|
|
8
|
-
|
|
9
|
-
const TestComp = ({ loader, cutout }) => {
|
|
10
|
-
useScopeGuardLoader(loader, cutout);
|
|
11
|
-
const [tick, setTick] = useState(0);
|
|
12
|
-
const live = useSelector(state => state.get("live"));
|
|
13
|
-
return (
|
|
14
|
-
<div id="test" onClick={() => setTick(tick + 1)} data-live={live}>
|
|
15
|
-
{tick}
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
describe("useScopeGuardLoader", () => {
|
|
21
|
-
spyOnConsole(["warn"]);
|
|
22
|
-
|
|
23
|
-
let loader, state, store, appNode;
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
state = Immutable.fromJS({
|
|
26
|
-
cutout: "yes",
|
|
27
|
-
live: 0,
|
|
28
|
-
requests: {
|
|
29
|
-
logout: false,
|
|
30
|
-
},
|
|
31
|
-
scopeRouteState: {
|
|
32
|
-
scopeChangeInProgress: false,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
const subs = [];
|
|
36
|
-
store = {
|
|
37
|
-
updateState: () => {
|
|
38
|
-
subs.forEach((sub, i) => {
|
|
39
|
-
sub();
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
subscribe: sub => {
|
|
43
|
-
subs.push(sub);
|
|
44
|
-
return () => {};
|
|
45
|
-
},
|
|
46
|
-
getState: () => state,
|
|
47
|
-
dispatch: sinon.spy().named("dispatch"),
|
|
48
|
-
};
|
|
49
|
-
loader = { type: "TEST_ACTION" };
|
|
50
|
-
appNode = document.createElement("div");
|
|
51
|
-
document.body.appendChild(appNode);
|
|
52
|
-
});
|
|
53
|
-
afterEach(() => {
|
|
54
|
-
document.body.removeChild(appNode);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("dispatches the loader action on mount if cutout returns falsy", () =>
|
|
58
|
-
expect(
|
|
59
|
-
<Provider store={store}>
|
|
60
|
-
<TestComp loader={loader} cutout={state => state.get("live")} />
|
|
61
|
-
</Provider>,
|
|
62
|
-
"when mounted",
|
|
63
|
-
"to satisfy",
|
|
64
|
-
<div>0</div>,
|
|
65
|
-
).then(() => expect(store.dispatch, "to have calls satisfying", [{ args: [loader] }])));
|
|
66
|
-
|
|
67
|
-
it("does not dispatch the loader action on mount because scope change is in progress", () => {
|
|
68
|
-
state = state.setIn(["scopeRouteState", "scopeChangeInProgress"], true);
|
|
69
|
-
|
|
70
|
-
return expect(
|
|
71
|
-
<Provider store={store}>
|
|
72
|
-
<TestComp loader={loader} cutout={state => state.get("live")} />
|
|
73
|
-
</Provider>,
|
|
74
|
-
"when mounted",
|
|
75
|
-
"to satisfy",
|
|
76
|
-
<div>0</div>,
|
|
77
|
-
).then(() => expect(store.dispatch, "not to have calls satisfying", [{ args: [loader] }]));
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("does not dispatch loader if cutout returns truthy", () =>
|
|
81
|
-
expect(
|
|
82
|
-
<Provider store={store}>
|
|
83
|
-
<TestComp loader={loader} cutout={state => state.get("cutout")} />
|
|
84
|
-
</Provider>,
|
|
85
|
-
"when mounted",
|
|
86
|
-
"to satisfy",
|
|
87
|
-
<div>0</div>,
|
|
88
|
-
).then(() => expect(store.dispatch, "was not called")));
|
|
89
|
-
|
|
90
|
-
it("does not dispatch loader if logged out", () => {
|
|
91
|
-
state = state.setIn(["requests", "logout"], true);
|
|
92
|
-
|
|
93
|
-
expect(
|
|
94
|
-
<Provider store={store}>
|
|
95
|
-
<TestComp loader={loader} cutout={state => state.get("cutout")} />
|
|
96
|
-
</Provider>,
|
|
97
|
-
"when mounted",
|
|
98
|
-
"to satisfy",
|
|
99
|
-
<div>0</div>,
|
|
100
|
-
).then(() => expect(store.dispatch, "was not called"));
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("does not dispatch loader if no cutout selector given, warns", () =>
|
|
104
|
-
expect(
|
|
105
|
-
<Provider store={store}>
|
|
106
|
-
<TestComp loader={loader} />
|
|
107
|
-
</Provider>,
|
|
108
|
-
"when mounted",
|
|
109
|
-
"to satisfy",
|
|
110
|
-
<div>0</div>,
|
|
111
|
-
)
|
|
112
|
-
.then(() => expect(store.dispatch, "was not called"))
|
|
113
|
-
.then(() =>
|
|
114
|
-
expect(console.warn, "not to have calls satisfying", [
|
|
115
|
-
{
|
|
116
|
-
args: ["useLoader hook called without cutout selector, loader will never be dispatched."],
|
|
117
|
-
},
|
|
118
|
-
]),
|
|
119
|
-
));
|
|
120
|
-
|
|
121
|
-
it("dispatches multiple loader actions", () => {
|
|
122
|
-
const loaderSeries = [{ type: "TEST_ACTION1" }, { type: "TEST_ACTION2" }, { type: "TEST_ACTION3" }];
|
|
123
|
-
return expect(
|
|
124
|
-
<Provider store={store}>
|
|
125
|
-
<TestComp loader={loaderSeries} cutout={state => state.get("live")} />
|
|
126
|
-
</Provider>,
|
|
127
|
-
"when mounted",
|
|
128
|
-
"to satisfy",
|
|
129
|
-
<div>0</div>,
|
|
130
|
-
).then(() =>
|
|
131
|
-
expect(store.dispatch, "to have calls satisfying", [
|
|
132
|
-
{ args: [loaderSeries[0]] },
|
|
133
|
-
{ args: [loaderSeries[1]] },
|
|
134
|
-
{ args: [loaderSeries[2]] },
|
|
135
|
-
]),
|
|
136
|
-
);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("only dispatches once if cutout does not change", () =>
|
|
140
|
-
expect(
|
|
141
|
-
<Provider store={store}>
|
|
142
|
-
<TestComp loader={loader} cutout={state => state.get("live")} />
|
|
143
|
-
</Provider>,
|
|
144
|
-
"when mounted",
|
|
145
|
-
"with event",
|
|
146
|
-
"click",
|
|
147
|
-
"with event",
|
|
148
|
-
"click",
|
|
149
|
-
"with event",
|
|
150
|
-
"click",
|
|
151
|
-
"with event",
|
|
152
|
-
"click",
|
|
153
|
-
"to satisfy",
|
|
154
|
-
<div>4</div>,
|
|
155
|
-
).then(() => expect(store.dispatch, "to have calls satisfying", [{ args: [loader] }])));
|
|
156
|
-
|
|
157
|
-
it("fires loader if cutout is falsy, but not again if it becomes truthy", () => {
|
|
158
|
-
const selector = state => state.get("live");
|
|
159
|
-
mount(
|
|
160
|
-
<Provider store={store}>
|
|
161
|
-
<TestComp loader={loader} cutout={selector} />
|
|
162
|
-
</Provider>,
|
|
163
|
-
);
|
|
164
|
-
expect(store.dispatch, "to have calls satisfying", [{}]);
|
|
165
|
-
act(() => {
|
|
166
|
-
state = state.set("live", 1);
|
|
167
|
-
store.updateState();
|
|
168
|
-
});
|
|
169
|
-
expect(store.dispatch, "was called once");
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("fires loader if cutout was truthy, becomes falsy", () => {
|
|
173
|
-
const selector = state => state.get("live");
|
|
174
|
-
state = state.set("live", 1);
|
|
175
|
-
mount(
|
|
176
|
-
<Provider store={store}>
|
|
177
|
-
<TestComp loader={loader} cutout={selector} />
|
|
178
|
-
</Provider>,
|
|
179
|
-
);
|
|
180
|
-
expect(store.dispatch, "was not called");
|
|
181
|
-
act(() => {
|
|
182
|
-
state = state.set("live", 0);
|
|
183
|
-
store.updateState();
|
|
184
|
-
});
|
|
185
|
-
expect(store.dispatch, "was called");
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
import { POP_GLOBAL_ERROR_MESSAGE, PUSH_GLOBAL_ERROR_MESSAGE } from "../actions/globalErrorMessages";
|
|
3
|
-
|
|
4
|
-
const initialState = Immutable.fromJS({
|
|
5
|
-
dialog: {
|
|
6
|
-
errorMessages: [],
|
|
7
|
-
},
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const globalErrorMessages = (state = initialState, action) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case PUSH_GLOBAL_ERROR_MESSAGE: {
|
|
13
|
-
const newMsgs = state.getIn(["dialog", "errorMessages"]).push(Immutable.fromJS(action.payload));
|
|
14
|
-
return state.setIn(["dialog", "errorMessages"], newMsgs);
|
|
15
|
-
}
|
|
16
|
-
case POP_GLOBAL_ERROR_MESSAGE: {
|
|
17
|
-
const newMsgs = state.getIn(["dialog", "errorMessages"]).shift();
|
|
18
|
-
return state.setIn(["dialog", "errorMessages"], newMsgs);
|
|
19
|
-
}
|
|
20
|
-
default:
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default globalErrorMessages;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
import reducer from "./globalErrorMessages";
|
|
3
|
-
import { popGlobalErrorMessage, pushGlobalErrorMessage } from "../actions/globalErrorMessages";
|
|
4
|
-
|
|
5
|
-
describe("Global error messages reducer", () => {
|
|
6
|
-
it("behaves as a reducer should", () =>
|
|
7
|
-
expect(reducer, "to be a reducer with initial state", {
|
|
8
|
-
dialog: {
|
|
9
|
-
errorMessages: [],
|
|
10
|
-
},
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
it("save new message to end of the list", () => {
|
|
14
|
-
const oldState = Immutable.fromJS({
|
|
15
|
-
dialog: {
|
|
16
|
-
errorMessages: [{ msg: "123" }],
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
const action = pushGlobalErrorMessage({ msg: "456" });
|
|
20
|
-
const newState = reducer(oldState, action);
|
|
21
|
-
expect(newState, "not to be", oldState).and(
|
|
22
|
-
"to equal",
|
|
23
|
-
Immutable.fromJS({
|
|
24
|
-
dialog: {
|
|
25
|
-
errorMessages: [{ msg: "123" }, { msg: "456" }],
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("remove oldest message", () => {
|
|
32
|
-
const oldState = Immutable.fromJS({
|
|
33
|
-
dialog: {
|
|
34
|
-
errorMessages: [{ msg: "123" }, { msg: "456" }],
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
const action = popGlobalErrorMessage();
|
|
38
|
-
const newState = reducer(oldState, action);
|
|
39
|
-
expect(newState, "not to be", oldState).and(
|
|
40
|
-
"to equal",
|
|
41
|
-
Immutable.fromJS({
|
|
42
|
-
dialog: {
|
|
43
|
-
errorMessages: [{ msg: "456" }],
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("remove oldest message on an empty list", () => {
|
|
50
|
-
const oldState = Immutable.fromJS({
|
|
51
|
-
dialog: {
|
|
52
|
-
errorMessages: [],
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
const action = popGlobalErrorMessage();
|
|
56
|
-
const newState = reducer(oldState, action);
|
|
57
|
-
expect(newState, "to be", oldState).and(
|
|
58
|
-
"to equal",
|
|
59
|
-
Immutable.fromJS({
|
|
60
|
-
dialog: {
|
|
61
|
-
errorMessages: [],
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
import { SET_ROUTE } from "../actions/navigation";
|
|
3
|
-
import { APPLICATION_SCOPE_HAS_CHANGED } from "../actions/scopes";
|
|
4
|
-
|
|
5
|
-
const initialState = Immutable.fromJS({
|
|
6
|
-
scopeChangeInProgress: false,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
This reducer and its associated hook is used to prevent a request from being sent out while the application's scope is changing.
|
|
11
|
-
Basically the reducer responds to an action, set a flag to true and then set it to false once another action is triggered (route change).
|
|
12
|
-
|
|
13
|
-
This is a pretty hackish way to ensure that the correct requests are being executed (references #74924, #74764) however we know of no other way to achieve the desired result.
|
|
14
|
-
* */
|
|
15
|
-
|
|
16
|
-
const viewStateReducer = (state = initialState, action) => {
|
|
17
|
-
switch (action.type) {
|
|
18
|
-
case APPLICATION_SCOPE_HAS_CHANGED: {
|
|
19
|
-
return state.set("scopeChangeInProgress", action.payload.newScope !== action.payload.previousScope);
|
|
20
|
-
}
|
|
21
|
-
case SET_ROUTE: {
|
|
22
|
-
return state.set("scopeChangeInProgress", false);
|
|
23
|
-
}
|
|
24
|
-
default:
|
|
25
|
-
return state;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default viewStateReducer;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
import { applicationScopeHasChanged } from "../actions/scopes";
|
|
3
|
-
import reducer from "./scopeRouteState";
|
|
4
|
-
import { setRoute } from "../actions/navigation";
|
|
5
|
-
|
|
6
|
-
describe("scopeRouteState", () => {
|
|
7
|
-
it("behaves as a reducer should", () =>
|
|
8
|
-
expect(reducer, "to be a reducer with initial state", { scopeChangeInProgress: false }));
|
|
9
|
-
|
|
10
|
-
it("set scopeChangeInProgress to true if scope is different", () => {
|
|
11
|
-
const oldState = Immutable.Map({
|
|
12
|
-
scopeChangeInProgress: false,
|
|
13
|
-
});
|
|
14
|
-
const action = applicationScopeHasChanged("prevScope", "newScope", "module");
|
|
15
|
-
|
|
16
|
-
const newState = reducer(oldState, action);
|
|
17
|
-
return expect(newState, "not to be", oldState).and(
|
|
18
|
-
"to satisfy",
|
|
19
|
-
Immutable.fromJS({
|
|
20
|
-
scopeChangeInProgress: true,
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("scopeChangeInProgress stays false if prev and new scope are identical", () => {
|
|
26
|
-
const oldState = Immutable.Map({
|
|
27
|
-
scopeChangeInProgress: false,
|
|
28
|
-
});
|
|
29
|
-
const action = applicationScopeHasChanged("sameScope", "sameScope", "module");
|
|
30
|
-
|
|
31
|
-
const newState = reducer(oldState, action);
|
|
32
|
-
return expect(newState, "to be", oldState);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("set scopeChangeInProgress to false when route changes", () => {
|
|
36
|
-
const oldState = Immutable.Map({
|
|
37
|
-
scopeChangeInProgress: true,
|
|
38
|
-
});
|
|
39
|
-
const action = setRoute("loc", {});
|
|
40
|
-
|
|
41
|
-
const newState = reducer(oldState, action);
|
|
42
|
-
return expect(newState, "not to be", oldState).and(
|
|
43
|
-
"to satisfy",
|
|
44
|
-
Immutable.fromJS({
|
|
45
|
-
scopeChangeInProgress: false,
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
});
|
package/src/reducers/tasks.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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;
|