orc-shared 1.1.0-dev.7 → 1.1.0
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 +71 -1
- package/dist/actions/metadata.js +295 -31
- package/dist/actions/navigation.js +1 -1
- package/dist/actions/requestState.js +78 -0
- package/dist/actions/requestsApi.js +58 -7
- package/dist/actions/scopes.js +1 -1
- 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 +5 -2
- package/dist/components/AppFrame/About.js +1 -1
- package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
- package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
- package/dist/components/AppFrame/MenuItem.js +1 -1
- package/dist/components/AppFrame/Preferences.js +1 -1
- package/dist/components/AppFrame/Sidebar.js +1 -1
- package/dist/components/AppFrame/Topbar.js +1 -1
- package/dist/components/Authenticate.js +1 -1
- 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/SelectionList.js +19 -6
- package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
- 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/DatePicker.js +11 -0
- package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
- 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 +19 -8
- 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/TabBar.js +38 -33
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +6 -4
- package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
- package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
- package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +19 -4
- package/dist/components/MaterialUI/textProps.js +1 -1
- package/dist/components/Modules.js +24 -2
- 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 +28 -2
- package/dist/components/Placeholder.js +1 -1
- package/dist/components/Routing/FullPage.js +2 -0
- package/dist/components/Routing/Segment.js +4 -3
- package/dist/components/Routing/SegmentPage.js +24 -11
- package/dist/components/Routing/withWaypointing.js +8 -2
- package/dist/components/Scope/ScopeNode.js +1 -1
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +9 -1
- package/dist/components/Scope/useScopeSelect.js +1 -1
- package/dist/components/Selector.js +1 -1
- package/dist/components/Sidepanel.js +1 -2
- 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 +26 -1
- package/dist/content/icons/html-templates.svg +3 -0
- package/dist/content/iconsSheet.svg +3 -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/useEntityLoader.js +182 -0
- package/dist/hooks/useFullEntityEditState.js +1 -1
- package/dist/hooks/useInfiniteScroll.js +104 -0
- package/dist/hooks/useLabelMessage.js +1 -1
- package/dist/hooks/useLoader.js +1 -0
- package/dist/hooks/useNavigationHandler.js +1 -1
- package/dist/hooks/useNotificationRequestState.js +159 -0
- package/dist/hooks/useRequestState.js +146 -0
- package/dist/hooks/useSelectorAndUnwrap.js +1 -1
- package/dist/reducers/metadata.js +52 -26
- package/dist/reducers/requestStates.js +181 -0
- 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 +1 -2
- package/dist/selectors/countries.js +1 -1
- package/dist/selectors/locale.js +1 -1
- package/dist/selectors/metadata.js +102 -12
- package/dist/selectors/navigation.js +1 -1
- package/dist/selectors/requestStates.js +82 -0
- package/dist/selectors/requests.js +1 -1
- package/dist/selectors/scope.js +1 -1
- package/dist/selectors/versionInfo.js +1 -1
- package/dist/selectors/view.js +1 -1
- package/dist/sharedMessages.js +44 -0
- 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 +2 -2
- 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 +3 -2
- package/dist/utils/testUtils.js +6 -2
- package/dist/utils/timezoneHelper.js +111 -0
- package/dist/utils/unwrapImmutable.js +1 -1
- package/dist/utils/urlHelper.js +11 -1
- package/package.json +3 -7
- package/src/actions/makeApiAction.js +24 -1
- package/src/actions/makeApiAction.test.js +76 -3
- package/src/actions/metadata.js +130 -0
- package/src/actions/metadata.test.js +337 -5
- package/src/actions/requestState.js +8 -0
- package/src/actions/requestState.test.js +14 -0
- package/src/actions/requestsApi.js +30 -0
- package/src/buildStore.js +2 -0
- package/src/components/AppFrame/AppFrame.test.js +6 -16
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
- package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
- package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
- package/src/components/AppFrame/Topbar.test.js +2 -4
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
- package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
- package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
- package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
- package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
- package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +4 -2
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
- package/src/components/MaterialUI/muiThemes.js +18 -3
- package/src/components/Modules.js +13 -1
- package/src/components/Modules.test.js +133 -1
- package/src/components/Navigation/Navigation.test.js +2 -0
- package/src/components/Navigation/useNavigationState.js +21 -1
- package/src/components/Navigation/useNavigationState.test.js +10 -0
- package/src/components/Routing/FullPage.js +2 -1
- package/src/components/Routing/FullPage.test.js +149 -79
- package/src/components/Routing/Segment.js +5 -2
- package/src/components/Routing/Segment.test.js +22 -1
- package/src/components/Routing/SegmentPage.js +19 -9
- package/src/components/Routing/SubPage.test.js +1 -1
- package/src/components/Routing/withWaypointing.js +19 -17
- package/src/components/Routing/withWaypointing.test.js +50 -0
- package/src/components/Scope/Scope.test.js +117 -0
- package/src/components/Scope/index.js +6 -10
- package/src/components/Sidepanel.js +0 -1
- package/src/components/Sidepanel.test.js +0 -3
- package/src/constants.js +18 -0
- package/src/content/icons/html-templates.svg +3 -0
- package/src/content/iconsSheet.svg +3 -0
- package/src/hooks/useEntityLoader.js +68 -0
- package/src/hooks/useEntityLoader.test.js +266 -0
- package/src/hooks/useInfiniteScroll.js +25 -0
- package/src/hooks/useInfiniteScroll.test.js +87 -0
- package/src/hooks/useLoader.js +1 -0
- package/src/hooks/useNotificationRequestState.js +78 -0
- package/src/hooks/useNotificationRequestState.test.js +264 -0
- package/src/hooks/useRequestState.js +57 -0
- package/src/hooks/useRequestState.test.js +217 -0
- package/src/reducers/metadata.js +76 -16
- package/src/reducers/metadata.test.js +458 -4
- package/src/reducers/requestStates.js +98 -0
- package/src/reducers/requestStates.test.js +399 -0
- package/src/selectors/authentication.js +0 -1
- package/src/selectors/locale.test.js +0 -2
- package/src/selectors/metadata.js +73 -13
- package/src/selectors/metadata.test.js +479 -8
- package/src/selectors/requestStates.js +12 -0
- package/src/selectors/requestStates.test.js +83 -0
- package/src/sharedMessages.js +44 -0
- package/src/translations/en-US.json +12 -1
- package/src/translations/fr-CA.json +13 -2
- package/src/utils/modelValidationHelper.js +1 -1
- package/src/utils/setTranslationWithFallback.js +1 -1
- package/src/utils/setTranslationWithFallback.test.js +4 -14
- package/src/utils/testUtils.js +3 -1
- package/src/utils/timezoneHelper.js +140 -0
- package/src/utils/timezoneHelper.test.js +33 -0
- package/src/utils/urlHelper.js +6 -0
- package/src/translations/it-IT.json +0 -54
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import Immutable from "immutable";
|
|
2
|
+
import reducer from "./requestStates";
|
|
3
|
+
import { requestStateOperationMap, requestStateOperations } from "../constants";
|
|
4
|
+
import { RESET_REQUEST_STATE } from "../actions/requestState";
|
|
5
|
+
|
|
6
|
+
const defaultState = {
|
|
7
|
+
creates: Immutable.Map(),
|
|
8
|
+
deletes: Immutable.Map(),
|
|
9
|
+
fetches: Immutable.Map(),
|
|
10
|
+
updates: Immutable.Map(),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("Request reducer", () => {
|
|
14
|
+
it("behaves as a reducer should", () => expect(reducer, "to be a reducer with initial state", defaultState));
|
|
15
|
+
|
|
16
|
+
it("should do nothing for an unknown action with requestState", () => {
|
|
17
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
18
|
+
const action = { type: "SOME_UNKNOWN_ACTION", meta: { requestState: {} } };
|
|
19
|
+
const newState = reducer(oldState, action);
|
|
20
|
+
expect(newState, "to be", oldState);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("state should not be modified if the action does not have the correct state", () =>
|
|
24
|
+
expect(reducer, "to be a reducer with initial state", defaultState));
|
|
25
|
+
|
|
26
|
+
it("state should not be modified if the action does not have the correct state", () => {
|
|
27
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
28
|
+
const action = { type: "TEST_THIS_REQUEST", meta: { requestState: null } };
|
|
29
|
+
const newState = reducer(oldState, action);
|
|
30
|
+
expect(newState, "to be", oldState);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it.each([
|
|
34
|
+
[requestStateOperations.delete, "REQUEST"],
|
|
35
|
+
[requestStateOperations.delete, "SUCCESS"],
|
|
36
|
+
[requestStateOperations.delete, "FAILURE"],
|
|
37
|
+
[requestStateOperations.update, "REQUEST"],
|
|
38
|
+
[requestStateOperations.update, "SUCCESS"],
|
|
39
|
+
[requestStateOperations.update, "FAILURE"],
|
|
40
|
+
])("%s %s should not modify the state if the operation is not supported", (operation, requestSuffix) => {
|
|
41
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
42
|
+
const action = {
|
|
43
|
+
type: "TEST_THIS_" + requestSuffix,
|
|
44
|
+
meta: {
|
|
45
|
+
requestState: {
|
|
46
|
+
keys: ["key1", "key2"],
|
|
47
|
+
operation: "unsupported",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const newState = reducer(oldState, action);
|
|
52
|
+
expect(newState, "to be", oldState);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
56
|
+
"%s operation REQUEST should initialize the state for the specified keys",
|
|
57
|
+
operation => {
|
|
58
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
59
|
+
const action = {
|
|
60
|
+
type: "TEST_THIS_REQUEST",
|
|
61
|
+
meta: {
|
|
62
|
+
requestState: {
|
|
63
|
+
keys: ["key1", "key2"],
|
|
64
|
+
operation: operation,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const expectedState = oldState.set(
|
|
70
|
+
requestStateOperationMap[operation],
|
|
71
|
+
Immutable.fromJS({
|
|
72
|
+
key1: {
|
|
73
|
+
key2: {
|
|
74
|
+
state: {
|
|
75
|
+
inProgress: true,
|
|
76
|
+
value: false,
|
|
77
|
+
error: false,
|
|
78
|
+
errorResponse: null,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const newState = reducer(oldState, action);
|
|
86
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
91
|
+
"%s operation SUCCESS should initialize the state for the specified keys",
|
|
92
|
+
operation => {
|
|
93
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
94
|
+
const action = {
|
|
95
|
+
type: "TEST_THIS_SUCCESS",
|
|
96
|
+
meta: {
|
|
97
|
+
requestState: {
|
|
98
|
+
keys: ["key1", "key2"],
|
|
99
|
+
operation: operation,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const expectedState = oldState.set(
|
|
105
|
+
requestStateOperationMap[operation],
|
|
106
|
+
Immutable.fromJS({
|
|
107
|
+
key1: {
|
|
108
|
+
key2: {
|
|
109
|
+
state: {
|
|
110
|
+
inProgress: false,
|
|
111
|
+
value: true,
|
|
112
|
+
error: false,
|
|
113
|
+
errorResponse: null,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const newState = reducer(oldState, action);
|
|
121
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
122
|
+
},
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
126
|
+
"%s operation FAILURE should initialize the state for the specified keys",
|
|
127
|
+
operation => {
|
|
128
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
129
|
+
const action = {
|
|
130
|
+
type: "TEST_THIS_FAILURE",
|
|
131
|
+
meta: {
|
|
132
|
+
requestState: {
|
|
133
|
+
keys: ["key1", "key2"],
|
|
134
|
+
operation: operation,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const expectedState = oldState.set(
|
|
140
|
+
requestStateOperationMap[operation],
|
|
141
|
+
Immutable.fromJS({
|
|
142
|
+
key1: {
|
|
143
|
+
key2: {
|
|
144
|
+
state: {
|
|
145
|
+
inProgress: false,
|
|
146
|
+
value: false,
|
|
147
|
+
error: true,
|
|
148
|
+
errorResponse: null,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const newState = reducer(oldState, action);
|
|
156
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
161
|
+
"%s operation FAILURE with a response should initialize the state for the specified keys",
|
|
162
|
+
operation => {
|
|
163
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
164
|
+
|
|
165
|
+
const action = {
|
|
166
|
+
type: "TEST_THIS_FAILURE",
|
|
167
|
+
payload: {
|
|
168
|
+
response: {
|
|
169
|
+
responseStatus: {
|
|
170
|
+
message: "a message",
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
meta: {
|
|
175
|
+
requestState: {
|
|
176
|
+
keys: ["key1", "key2"],
|
|
177
|
+
operation: operation,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const expectedState = oldState.set(
|
|
183
|
+
requestStateOperationMap[operation],
|
|
184
|
+
Immutable.fromJS({
|
|
185
|
+
key1: {
|
|
186
|
+
key2: {
|
|
187
|
+
state: {
|
|
188
|
+
inProgress: false,
|
|
189
|
+
value: false,
|
|
190
|
+
error: true,
|
|
191
|
+
errorResponse: action.payload,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const newState = reducer(oldState, action);
|
|
199
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
200
|
+
},
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
204
|
+
"%s operation should accept a string as key",
|
|
205
|
+
operation => {
|
|
206
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
207
|
+
const action = {
|
|
208
|
+
type: "TEST_THIS_REQUEST",
|
|
209
|
+
meta: {
|
|
210
|
+
requestState: {
|
|
211
|
+
keys: "key1",
|
|
212
|
+
operation: operation,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const expectedState = oldState.set(
|
|
218
|
+
requestStateOperationMap[operation],
|
|
219
|
+
Immutable.fromJS({
|
|
220
|
+
key1: {
|
|
221
|
+
state: {
|
|
222
|
+
inProgress: true,
|
|
223
|
+
value: false,
|
|
224
|
+
error: false,
|
|
225
|
+
errorResponse: null,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
}),
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const newState = reducer(oldState, action);
|
|
232
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe("RESET_REQUEST_STATE", () => {
|
|
238
|
+
it("state should not be modified if the operation is not supported", () => {
|
|
239
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
240
|
+
const action = {
|
|
241
|
+
type: RESET_REQUEST_STATE,
|
|
242
|
+
meta: {
|
|
243
|
+
requestState: {
|
|
244
|
+
keys: ["key1", "key2"],
|
|
245
|
+
operation: "unsupported",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
const newState = reducer(oldState, action);
|
|
250
|
+
expect(newState, "to be", oldState);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
254
|
+
"state is initialized when empty for %s operation",
|
|
255
|
+
operation => {
|
|
256
|
+
const oldState = Immutable.fromJS(defaultState);
|
|
257
|
+
const action = {
|
|
258
|
+
type: RESET_REQUEST_STATE,
|
|
259
|
+
meta: {
|
|
260
|
+
requestState: {
|
|
261
|
+
keys: ["key1", "key2"],
|
|
262
|
+
operation: operation,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const expectedState = oldState.set(
|
|
268
|
+
requestStateOperationMap[operation],
|
|
269
|
+
Immutable.fromJS({
|
|
270
|
+
key1: {
|
|
271
|
+
key2: {
|
|
272
|
+
state: {
|
|
273
|
+
inProgress: false,
|
|
274
|
+
value: false,
|
|
275
|
+
error: false,
|
|
276
|
+
errorResponse: null,
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
}),
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const newState = reducer(oldState, action);
|
|
284
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
285
|
+
},
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
289
|
+
"state is initialized when not empty for %s operation",
|
|
290
|
+
operation => {
|
|
291
|
+
let oldState = Immutable.fromJS(defaultState);
|
|
292
|
+
const action = {
|
|
293
|
+
type: RESET_REQUEST_STATE,
|
|
294
|
+
meta: {
|
|
295
|
+
requestState: {
|
|
296
|
+
keys: ["key1", "key2"],
|
|
297
|
+
operation: operation,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
oldState = oldState.set(
|
|
303
|
+
requestStateOperationMap[operation],
|
|
304
|
+
Immutable.fromJS({
|
|
305
|
+
key1: {
|
|
306
|
+
key2: {
|
|
307
|
+
state: {
|
|
308
|
+
inProgress: true,
|
|
309
|
+
value: true,
|
|
310
|
+
error: true,
|
|
311
|
+
errorResponse: null,
|
|
312
|
+
anotherProp: true,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
const expectedState = oldState.set(
|
|
320
|
+
requestStateOperationMap[operation],
|
|
321
|
+
Immutable.fromJS({
|
|
322
|
+
key1: {
|
|
323
|
+
key2: {
|
|
324
|
+
state: {
|
|
325
|
+
inProgress: false,
|
|
326
|
+
value: false,
|
|
327
|
+
error: false,
|
|
328
|
+
errorResponse: null,
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
}),
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const newState = reducer(oldState, action);
|
|
336
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
337
|
+
},
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
it.each([[requestStateOperations.delete], [requestStateOperations.update], [requestStateOperations.create]])(
|
|
341
|
+
"other keys are not touched when state is initialized for %s operation",
|
|
342
|
+
operation => {
|
|
343
|
+
let oldState = Immutable.fromJS({
|
|
344
|
+
deletes: Immutable.Map({
|
|
345
|
+
key3: {
|
|
346
|
+
key4: {
|
|
347
|
+
state: {
|
|
348
|
+
inProgress: false,
|
|
349
|
+
value: true,
|
|
350
|
+
error: false,
|
|
351
|
+
errorResponse: null,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
}),
|
|
356
|
+
updates: Immutable.Map({
|
|
357
|
+
key3: {
|
|
358
|
+
key4: {
|
|
359
|
+
state: {
|
|
360
|
+
inProgress: false,
|
|
361
|
+
value: true,
|
|
362
|
+
error: false,
|
|
363
|
+
errorResponse: null,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
}),
|
|
368
|
+
});
|
|
369
|
+
const action = {
|
|
370
|
+
type: RESET_REQUEST_STATE,
|
|
371
|
+
meta: {
|
|
372
|
+
requestState: {
|
|
373
|
+
keys: ["key1", "key2"],
|
|
374
|
+
operation: operation,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const expectedState = oldState.mergeIn(
|
|
380
|
+
[requestStateOperationMap[operation]],
|
|
381
|
+
Immutable.fromJS({
|
|
382
|
+
key1: {
|
|
383
|
+
key2: {
|
|
384
|
+
state: {
|
|
385
|
+
inProgress: false,
|
|
386
|
+
value: false,
|
|
387
|
+
error: false,
|
|
388
|
+
errorResponse: null,
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
}),
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
const newState = reducer(oldState, action);
|
|
396
|
+
expect(newState, "not to be", oldState).and("to equal", expectedState);
|
|
397
|
+
},
|
|
398
|
+
);
|
|
399
|
+
});
|
|
@@ -36,7 +36,6 @@ export const hasAdministratorPermissions = roleGroup =>
|
|
|
36
36
|
export const hasReaderPermissions = roleGroup =>
|
|
37
37
|
createSelector(selectGroupRolesClaims(roleGroup), getCurrentScope, (appRolesClaims, currentScope) => {
|
|
38
38
|
if (appRolesClaims != null) {
|
|
39
|
-
console.log("appRolesClaims", appRolesClaims);
|
|
40
39
|
return (
|
|
41
40
|
!!appRolesClaims.getIn(["*", platformRoles.Reader]) ||
|
|
42
41
|
!!appRolesClaims.getIn([currentScope, platformRoles.Reader])
|
|
@@ -217,7 +217,6 @@ describe("cultureOptionList", () => {
|
|
|
217
217
|
supportedLocales: [
|
|
218
218
|
{ language: "English", cultureIso: "en" },
|
|
219
219
|
{ language: "Français", cultureIso: "fr" },
|
|
220
|
-
{ language: "Italiano", cultureIso: "it" },
|
|
221
220
|
],
|
|
222
221
|
},
|
|
223
222
|
});
|
|
@@ -232,7 +231,6 @@ describe("cultureOptionList", () => {
|
|
|
232
231
|
Immutable.List([
|
|
233
232
|
{ value: "en", label: "English" },
|
|
234
233
|
{ value: "fr", label: "Français" },
|
|
235
|
-
{ value: "it", label: "Italiano" },
|
|
236
234
|
]),
|
|
237
235
|
));
|
|
238
236
|
|
|
@@ -5,8 +5,8 @@ import { setTranslationWithFallbackField } from "../utils/setTranslationWithFall
|
|
|
5
5
|
import { currentLocaleOrDefault } from "../selectors/locale";
|
|
6
6
|
import { getLocalization } from "../utils/localizationHelper";
|
|
7
7
|
import { getPropertyOrDefault } from "../utils/propertyHelper";
|
|
8
|
-
import {
|
|
9
|
-
import { attributeDataType } from "
|
|
8
|
+
import { ORDER_MODULE_NAME } from "../reducers/metadata";
|
|
9
|
+
import { attributeDataType, definitionType } from "../constants";
|
|
10
10
|
import { each, camelCase } from "lodash";
|
|
11
11
|
|
|
12
12
|
const metadata = state => state.get("metadata");
|
|
@@ -19,10 +19,24 @@ export const lookupSelector = memoize(moduleName =>
|
|
|
19
19
|
createSelector(lookupsModule(moduleName), module => module.get("index")),
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
+
export const mappedLookupsListSelector = memoize(moduleName =>
|
|
23
|
+
createSelector(lookupSelector(moduleName), currentLocaleOrDefault, (lookups, locale) =>
|
|
24
|
+
lookups.map(lookup =>
|
|
25
|
+
lookup
|
|
26
|
+
.set("displayName", getLocalization(lookup.get("displayName"), locale, lookup.get("lookupName")))
|
|
27
|
+
.delete("values"),
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
|
|
22
32
|
const lookupValuesSelector = memoize((moduleName, lookupName) =>
|
|
23
33
|
createSelector(lookups, lookups => lookups.getIn([moduleName, "index", lookupName]) || Immutable.Map()),
|
|
24
34
|
);
|
|
25
35
|
|
|
36
|
+
export const lookupByNameSelector = memoize((moduleName, lookupName) =>
|
|
37
|
+
createSelector(lookups, lookups => lookups.getIn([moduleName, "index", lookupName]) || null),
|
|
38
|
+
);
|
|
39
|
+
|
|
26
40
|
export const namedLookupSelector = memoize((moduleName, lookupName) =>
|
|
27
41
|
createSelector(
|
|
28
42
|
lookupSelector(moduleName),
|
|
@@ -37,7 +51,9 @@ export const namedLookupValuesSelector = memoize((moduleName, lookupName) =>
|
|
|
37
51
|
),
|
|
38
52
|
);
|
|
39
53
|
|
|
40
|
-
export const selectCurrentLookupDetails = memoize((moduleName,
|
|
54
|
+
export const selectCurrentLookupDetails = memoize((moduleName, lookupName) =>
|
|
55
|
+
namedLookupSelector(moduleName, lookupName),
|
|
56
|
+
);
|
|
41
57
|
|
|
42
58
|
export const namedLookupLocalizedSelector = memoize((moduleName, lookupName, key, defaultValue = key) =>
|
|
43
59
|
createSelector(lookupValuesSelector(moduleName, lookupName), currentLocaleOrDefault, (lookups, locale) => {
|
|
@@ -80,23 +96,55 @@ export const mappedLookupListSelector = memoize(moduleName =>
|
|
|
80
96
|
),
|
|
81
97
|
);
|
|
82
98
|
|
|
83
|
-
export const orderLookupsListCurrentInfo = lookupsListCurrentInfo(
|
|
99
|
+
export const orderLookupsListCurrentInfo = lookupsListCurrentInfo(ORDER_MODULE_NAME);
|
|
84
100
|
|
|
85
|
-
export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(
|
|
101
|
+
export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(ORDER_MODULE_NAME);
|
|
86
102
|
|
|
87
|
-
export const mappedOrderLookupsListSelector = mappedLookupListSelector(
|
|
103
|
+
export const mappedOrderLookupsListSelector = mappedLookupListSelector(ORDER_MODULE_NAME);
|
|
88
104
|
|
|
89
105
|
/*** DEFINITIONS ***/
|
|
90
106
|
const definitions = createSelector(metadata, meta => meta.get("definitions"));
|
|
91
107
|
const definitionsModule = memoize(moduleName =>
|
|
92
|
-
createSelector(definitions, definitions => definitions.get(moduleName)),
|
|
108
|
+
createSelector(definitions, definitions => definitions.get(moduleName) ?? Immutable.Map()),
|
|
93
109
|
);
|
|
94
110
|
|
|
95
|
-
const
|
|
111
|
+
export const mappedDefinitionsListSelector = memoize(moduleName =>
|
|
112
|
+
createSelector(definitionsModule(moduleName), currentLocaleOrDefault, (definitions, locale) =>
|
|
113
|
+
definitions.map(definition =>
|
|
114
|
+
definition
|
|
115
|
+
.set("type", definition.get("isSharedEntity") === true ? definitionType.shared : definitionType.embedded)
|
|
116
|
+
.set("displayName", getLocalization(definition.get("displayName"), locale, definition.get("entityTypeName")))
|
|
117
|
+
.delete("attributes"),
|
|
118
|
+
),
|
|
119
|
+
),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const mappedCustomDefinitionsListSelector = memoize(moduleName =>
|
|
123
|
+
createSelector(mappedDefinitionsListSelector(moduleName), definitions =>
|
|
124
|
+
definitions.filter(a => a.get("isBuiltIn") === false),
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export const mappedBaseDefinitionsListSelector = memoize(moduleName =>
|
|
129
|
+
createSelector(mappedDefinitionsListSelector(moduleName), definitions =>
|
|
130
|
+
definitions.filter(a => a.get("isBuiltIn") === true),
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
export const newProfileDefinitionInstanceSelector = createSelector(
|
|
135
|
+
definitions,
|
|
136
|
+
definitions => definitions.get("newInstance") || null,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
export const newProfileDefinitionNameSelector = createSelector(definitions, definitions =>
|
|
140
|
+
definitions.get("newInstanceId"),
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
export const definitionEntity = memoize((moduleName, entityName) =>
|
|
96
144
|
createSelector(definitionsModule(moduleName), definition => definition.getIn([entityName]) || Immutable.Map()),
|
|
97
145
|
);
|
|
98
146
|
|
|
99
|
-
const mappedDefinitionEntity = memoize((moduleName, entityName) =>
|
|
147
|
+
export const mappedDefinitionEntity = memoize((moduleName, entityName) =>
|
|
100
148
|
createSelector(definitionEntity(moduleName, entityName), currentLocaleOrDefault, (definition, locale) =>
|
|
101
149
|
setTranslationWithFallbackField(locale, definition, "entityTypeName", "displayName"),
|
|
102
150
|
),
|
|
@@ -109,16 +157,28 @@ const definitionEntityAttributes = memoize((moduleName, entityName) =>
|
|
|
109
157
|
),
|
|
110
158
|
);
|
|
111
159
|
|
|
112
|
-
const
|
|
160
|
+
const filterIsBuiltInAttributes = isBuiltIn => attributes => attributes.filter(a => a.get("isBuiltIn") === isBuiltIn);
|
|
161
|
+
|
|
162
|
+
export const definitionEntityCustomAttributesSelector = memoize((moduleName, entityName) =>
|
|
163
|
+
createSelector(definitionEntityAttributes(moduleName, entityName), filterIsBuiltInAttributes(false)),
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
export const definitionEntityBaseAttributesSelector = memoize((moduleName, entityName) =>
|
|
167
|
+
createSelector(definitionEntityAttributes(moduleName, entityName), filterIsBuiltInAttributes(true)),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
export const mappedDefinitionAttributesSelector = memoize((moduleName, entityName) =>
|
|
113
171
|
createSelector(definitionEntityAttributes(moduleName, entityName), currentLocaleOrDefault, (attributes, locale) =>
|
|
114
172
|
attributes.map(a => setTranslationWithFallbackField(locale, a, "name", "displayName")),
|
|
115
173
|
),
|
|
116
174
|
);
|
|
117
175
|
|
|
118
176
|
export const customAttributesSelector = memoize((moduleName, entityName) =>
|
|
119
|
-
createSelector(mappedDefinitionAttributesSelector(moduleName, entityName),
|
|
120
|
-
|
|
121
|
-
|
|
177
|
+
createSelector(mappedDefinitionAttributesSelector(moduleName, entityName), filterIsBuiltInAttributes(false)),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
export const baseAttributesSelector = memoize((moduleName, entityName) =>
|
|
181
|
+
createSelector(mappedDefinitionAttributesSelector(moduleName, entityName), filterIsBuiltInAttributes(true)),
|
|
122
182
|
);
|
|
123
183
|
|
|
124
184
|
export const profileAttributeGroupsSelector = createSelector(metadata, currentLocaleOrDefault, (meta, locale) => {
|