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.
Files changed (245) hide show
  1. package/dist/actions/applications.js +1 -1
  2. package/dist/actions/authentication.js +1 -1
  3. package/dist/actions/countries.js +1 -1
  4. package/dist/actions/locale.js +1 -1
  5. package/dist/actions/makeApiAction.js +71 -1
  6. package/dist/actions/metadata.js +295 -31
  7. package/dist/actions/navigation.js +1 -1
  8. package/dist/actions/requestState.js +78 -0
  9. package/dist/actions/requestsApi.js +58 -7
  10. package/dist/actions/scopes.js +1 -1
  11. package/dist/actions/timezones.js +1 -1
  12. package/dist/actions/toasts.js +1 -1
  13. package/dist/actions/versionInfo.js +1 -1
  14. package/dist/actions/view.js +1 -1
  15. package/dist/buildStore.js +5 -2
  16. package/dist/components/AppFrame/About.js +1 -1
  17. package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
  18. package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
  19. package/dist/components/AppFrame/MenuItem.js +1 -1
  20. package/dist/components/AppFrame/Preferences.js +1 -1
  21. package/dist/components/AppFrame/Sidebar.js +1 -1
  22. package/dist/components/AppFrame/Topbar.js +1 -1
  23. package/dist/components/Authenticate.js +1 -1
  24. package/dist/components/CategoryList.js +1 -1
  25. package/dist/components/Checkbox.js +1 -1
  26. package/dist/components/DropMenu/Menu.js +1 -1
  27. package/dist/components/DropMenu/index.js +1 -1
  28. package/dist/components/Form/FieldList.js +1 -1
  29. package/dist/components/Form/Form.js +1 -1
  30. package/dist/components/Form/Inputs/Button.js +1 -1
  31. package/dist/components/Form/Inputs/FieldButtons.js +1 -1
  32. package/dist/components/Form/Inputs/Number.js +1 -1
  33. package/dist/components/Form/Inputs/ReadOnly.js +1 -1
  34. package/dist/components/Form/Inputs/SmallButton.js +1 -1
  35. package/dist/components/Form/Inputs/Text.js +1 -1
  36. package/dist/components/Form/Inputs/Time.js +1 -1
  37. package/dist/components/Form/Inputs/Toggles.js +1 -1
  38. package/dist/components/Form/Inputs/Translation.js +1 -1
  39. package/dist/components/List/HeadCell.js +1 -1
  40. package/dist/components/List/List.js +1 -1
  41. package/dist/components/List/Row.js +1 -1
  42. package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
  43. package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
  44. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +1 -1
  45. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +19 -6
  46. package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
  47. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
  48. package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
  49. package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
  50. package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
  51. package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
  52. package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
  53. package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
  54. package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +1 -1
  55. package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
  56. package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
  57. package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
  58. package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
  59. package/dist/components/MaterialUI/Inputs/DatePicker.js +11 -0
  60. package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
  61. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
  62. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  63. package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
  64. package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
  65. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  66. package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
  67. package/dist/components/MaterialUI/Inputs/TimePicker.js +19 -8
  68. package/dist/components/MaterialUI/Inputs/createInput.js +1 -1
  69. package/dist/components/MaterialUI/Inputs/index.js +1 -1
  70. package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
  71. package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
  72. package/dist/components/MaterialUI/Navigation/TabBar.js +38 -33
  73. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +6 -4
  74. package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
  75. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  76. package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
  77. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
  78. package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
  79. package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
  80. package/dist/components/MaterialUI/muiThemes.js +19 -4
  81. package/dist/components/MaterialUI/textProps.js +1 -1
  82. package/dist/components/Modules.js +24 -2
  83. package/dist/components/MultiSelector.js +1 -1
  84. package/dist/components/Navigation/Bar.js +1 -1
  85. package/dist/components/Navigation/Tab.js +1 -1
  86. package/dist/components/Navigation/useNavigationState.js +28 -2
  87. package/dist/components/Placeholder.js +1 -1
  88. package/dist/components/Routing/FullPage.js +2 -0
  89. package/dist/components/Routing/Segment.js +4 -3
  90. package/dist/components/Routing/SegmentPage.js +24 -11
  91. package/dist/components/Routing/withWaypointing.js +8 -2
  92. package/dist/components/Scope/ScopeNode.js +1 -1
  93. package/dist/components/Scope/Selector.js +1 -1
  94. package/dist/components/Scope/index.js +9 -1
  95. package/dist/components/Scope/useScopeSelect.js +1 -1
  96. package/dist/components/Selector.js +1 -1
  97. package/dist/components/Sidepanel.js +1 -2
  98. package/dist/components/Spritesheet.js +1 -1
  99. package/dist/components/Switch.js +1 -1
  100. package/dist/components/Text.js +1 -1
  101. package/dist/components/ToastList.js +1 -1
  102. package/dist/components/Toolbar.js +1 -1
  103. package/dist/components/Treeview/Label.js +1 -1
  104. package/dist/components/Treeview/Leaf.js +1 -1
  105. package/dist/components/Treeview/Node.js +1 -1
  106. package/dist/components/Treeview/settings.js +1 -1
  107. package/dist/constants.js +26 -1
  108. package/dist/content/icons/html-templates.svg +3 -0
  109. package/dist/content/iconsSheet.svg +3 -0
  110. package/dist/hocs/withInfiniteScroll.js +1 -1
  111. package/dist/hooks/useDispatchWithModulesData.js +1 -1
  112. package/dist/hooks/useEditState.js +1 -1
  113. package/dist/hooks/useEntityLoader.js +182 -0
  114. package/dist/hooks/useFullEntityEditState.js +1 -1
  115. package/dist/hooks/useInfiniteScroll.js +104 -0
  116. package/dist/hooks/useLabelMessage.js +1 -1
  117. package/dist/hooks/useLoader.js +1 -0
  118. package/dist/hooks/useNavigationHandler.js +1 -1
  119. package/dist/hooks/useNotificationRequestState.js +159 -0
  120. package/dist/hooks/useRequestState.js +146 -0
  121. package/dist/hooks/useSelectorAndUnwrap.js +1 -1
  122. package/dist/reducers/metadata.js +52 -26
  123. package/dist/reducers/requestStates.js +181 -0
  124. package/dist/schemas/countries.js +1 -1
  125. package/dist/schemas/definitions.js +1 -1
  126. package/dist/schemas/metadata.js +1 -1
  127. package/dist/schemas/productDefinitions.js +1 -1
  128. package/dist/schemas/timezones.js +1 -1
  129. package/dist/selectors/applications.js +1 -1
  130. package/dist/selectors/authentication.js +1 -2
  131. package/dist/selectors/countries.js +1 -1
  132. package/dist/selectors/locale.js +1 -1
  133. package/dist/selectors/metadata.js +102 -12
  134. package/dist/selectors/navigation.js +1 -1
  135. package/dist/selectors/requestStates.js +82 -0
  136. package/dist/selectors/requests.js +1 -1
  137. package/dist/selectors/scope.js +1 -1
  138. package/dist/selectors/versionInfo.js +1 -1
  139. package/dist/selectors/view.js +1 -1
  140. package/dist/sharedMessages.js +44 -0
  141. package/dist/spawnerMiddleware.js +1 -1
  142. package/dist/utils/displayModeHelper.js +1 -1
  143. package/dist/utils/localizationHelper.js +1 -1
  144. package/dist/utils/mapHelper.js +1 -1
  145. package/dist/utils/modelValidationHelper.js +2 -2
  146. package/dist/utils/parseHelper.js +1 -1
  147. package/dist/utils/propertyHelper.js +2 -2
  148. package/dist/utils/propertyValidator.js +1 -1
  149. package/dist/utils/setTranslationWithFallback.js +3 -2
  150. package/dist/utils/testUtils.js +6 -2
  151. package/dist/utils/timezoneHelper.js +111 -0
  152. package/dist/utils/unwrapImmutable.js +1 -1
  153. package/dist/utils/urlHelper.js +11 -1
  154. package/package.json +3 -7
  155. package/src/actions/makeApiAction.js +24 -1
  156. package/src/actions/makeApiAction.test.js +76 -3
  157. package/src/actions/metadata.js +130 -0
  158. package/src/actions/metadata.test.js +337 -5
  159. package/src/actions/requestState.js +8 -0
  160. package/src/actions/requestState.test.js +14 -0
  161. package/src/actions/requestsApi.js +30 -0
  162. package/src/buildStore.js +2 -0
  163. package/src/components/AppFrame/AppFrame.test.js +6 -16
  164. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
  165. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
  166. package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
  167. package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
  168. package/src/components/AppFrame/Topbar.test.js +2 -4
  169. package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
  170. package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
  171. package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
  172. package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
  173. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  174. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  175. package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
  176. package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
  177. package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
  178. package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
  179. package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
  180. package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
  181. package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
  182. package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
  183. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +4 -2
  184. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
  185. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
  186. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
  187. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  188. package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
  189. package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
  190. package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
  191. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
  192. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
  193. package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
  194. package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
  195. package/src/components/MaterialUI/muiThemes.js +18 -3
  196. package/src/components/Modules.js +13 -1
  197. package/src/components/Modules.test.js +133 -1
  198. package/src/components/Navigation/Navigation.test.js +2 -0
  199. package/src/components/Navigation/useNavigationState.js +21 -1
  200. package/src/components/Navigation/useNavigationState.test.js +10 -0
  201. package/src/components/Routing/FullPage.js +2 -1
  202. package/src/components/Routing/FullPage.test.js +149 -79
  203. package/src/components/Routing/Segment.js +5 -2
  204. package/src/components/Routing/Segment.test.js +22 -1
  205. package/src/components/Routing/SegmentPage.js +19 -9
  206. package/src/components/Routing/SubPage.test.js +1 -1
  207. package/src/components/Routing/withWaypointing.js +19 -17
  208. package/src/components/Routing/withWaypointing.test.js +50 -0
  209. package/src/components/Scope/Scope.test.js +117 -0
  210. package/src/components/Scope/index.js +6 -10
  211. package/src/components/Sidepanel.js +0 -1
  212. package/src/components/Sidepanel.test.js +0 -3
  213. package/src/constants.js +18 -0
  214. package/src/content/icons/html-templates.svg +3 -0
  215. package/src/content/iconsSheet.svg +3 -0
  216. package/src/hooks/useEntityLoader.js +68 -0
  217. package/src/hooks/useEntityLoader.test.js +266 -0
  218. package/src/hooks/useInfiniteScroll.js +25 -0
  219. package/src/hooks/useInfiniteScroll.test.js +87 -0
  220. package/src/hooks/useLoader.js +1 -0
  221. package/src/hooks/useNotificationRequestState.js +78 -0
  222. package/src/hooks/useNotificationRequestState.test.js +264 -0
  223. package/src/hooks/useRequestState.js +57 -0
  224. package/src/hooks/useRequestState.test.js +217 -0
  225. package/src/reducers/metadata.js +76 -16
  226. package/src/reducers/metadata.test.js +458 -4
  227. package/src/reducers/requestStates.js +98 -0
  228. package/src/reducers/requestStates.test.js +399 -0
  229. package/src/selectors/authentication.js +0 -1
  230. package/src/selectors/locale.test.js +0 -2
  231. package/src/selectors/metadata.js +73 -13
  232. package/src/selectors/metadata.test.js +479 -8
  233. package/src/selectors/requestStates.js +12 -0
  234. package/src/selectors/requestStates.test.js +83 -0
  235. package/src/sharedMessages.js +44 -0
  236. package/src/translations/en-US.json +12 -1
  237. package/src/translations/fr-CA.json +13 -2
  238. package/src/utils/modelValidationHelper.js +1 -1
  239. package/src/utils/setTranslationWithFallback.js +1 -1
  240. package/src/utils/setTranslationWithFallback.test.js +4 -14
  241. package/src/utils/testUtils.js +3 -1
  242. package/src/utils/timezoneHelper.js +140 -0
  243. package/src/utils/timezoneHelper.test.js +33 -0
  244. package/src/utils/urlHelper.js +6 -0
  245. 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 { ORDER_LOOKUP_MODULE_NAME } from "~/reducers/metadata";
9
- import { attributeDataType } from "~/constants";
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, id) => namedLookupSelector(moduleName, id));
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(ORDER_LOOKUP_MODULE_NAME);
99
+ export const orderLookupsListCurrentInfo = lookupsListCurrentInfo(ORDER_MODULE_NAME);
84
100
 
85
- export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(ORDER_LOOKUP_MODULE_NAME);
101
+ export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(ORDER_MODULE_NAME);
86
102
 
87
- export const mappedOrderLookupsListSelector = mappedLookupListSelector(ORDER_LOOKUP_MODULE_NAME);
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 definitionEntity = memoize((moduleName, entityName) =>
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 mappedDefinitionAttributesSelector = memoize((moduleName, entityName) =>
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), attributes =>
120
- attributes.filter(a => a.get("isBuiltIn") === false),
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) => {