orc-shared 1.1.0-dev.8 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) 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 +73 -3
  6. package/dist/actions/makeOrcApiAction.js +2 -2
  7. package/dist/actions/metadata.js +295 -31
  8. package/dist/actions/navigation.js +3 -3
  9. package/dist/actions/requestState.js +78 -0
  10. package/dist/actions/requestsApi.js +58 -7
  11. package/dist/actions/scopes.js +1 -1
  12. package/dist/actions/timezones.js +1 -1
  13. package/dist/actions/toasts.js +1 -1
  14. package/dist/actions/versionInfo.js +1 -1
  15. package/dist/actions/view.js +1 -1
  16. package/dist/buildStore.js +7 -4
  17. package/dist/components/AppFrame/About.js +3 -3
  18. package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
  19. package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
  20. package/dist/components/AppFrame/MenuItem.js +1 -1
  21. package/dist/components/AppFrame/Preferences.js +3 -3
  22. package/dist/components/AppFrame/Sidebar.js +1 -1
  23. package/dist/components/AppFrame/Topbar.js +1 -1
  24. package/dist/components/Authenticate.js +1 -1
  25. package/dist/components/CategoryList.js +1 -1
  26. package/dist/components/Checkbox.js +1 -1
  27. package/dist/components/DropMenu/Menu.js +1 -1
  28. package/dist/components/DropMenu/index.js +1 -1
  29. package/dist/components/Form/FieldList.js +3 -3
  30. package/dist/components/Form/Form.js +1 -1
  31. package/dist/components/Form/Inputs/Button.js +1 -1
  32. package/dist/components/Form/Inputs/FieldButtons.js +1 -1
  33. package/dist/components/Form/Inputs/Number.js +1 -1
  34. package/dist/components/Form/Inputs/ReadOnly.js +1 -1
  35. package/dist/components/Form/Inputs/SmallButton.js +1 -1
  36. package/dist/components/Form/Inputs/Text.js +1 -1
  37. package/dist/components/Form/Inputs/Time.js +1 -1
  38. package/dist/components/Form/Inputs/Toggles.js +1 -1
  39. package/dist/components/Form/Inputs/Translation.js +3 -3
  40. package/dist/components/List/HeadCell.js +1 -1
  41. package/dist/components/List/List.js +1 -1
  42. package/dist/components/List/Row.js +1 -1
  43. package/dist/components/List/enhanceColumnDefs.js +2 -2
  44. package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
  45. package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
  46. package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
  47. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +3 -3
  48. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +19 -6
  49. package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
  50. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
  51. package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
  52. package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
  53. package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
  54. package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
  55. package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
  56. package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
  57. package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +3 -3
  58. package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
  59. package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
  60. package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
  61. package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
  62. package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
  63. package/dist/components/MaterialUI/Inputs/DatePicker.js +11 -0
  64. package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
  65. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
  66. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  67. package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
  68. package/dist/components/MaterialUI/Inputs/Select.js +2 -2
  69. package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
  70. package/dist/components/MaterialUI/Inputs/Switch.js +3 -3
  71. package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
  72. package/dist/components/MaterialUI/Inputs/TimePicker.js +19 -8
  73. package/dist/components/MaterialUI/Inputs/createInput.js +3 -3
  74. package/dist/components/MaterialUI/Inputs/index.js +1 -1
  75. package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
  76. package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
  77. package/dist/components/MaterialUI/Navigation/TabBar.js +38 -33
  78. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +6 -4
  79. package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
  80. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  81. package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
  82. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
  83. package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
  84. package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
  85. package/dist/components/MaterialUI/muiThemes.js +21 -6
  86. package/dist/components/MaterialUI/textProps.js +1 -1
  87. package/dist/components/Modules.js +24 -2
  88. package/dist/components/MultiSelector.js +1 -1
  89. package/dist/components/Navigation/Bar.js +3 -3
  90. package/dist/components/Navigation/Tab.js +1 -1
  91. package/dist/components/Navigation/useNavigationState.js +30 -4
  92. package/dist/components/Placeholder.js +1 -1
  93. package/dist/components/Routing/FullPage.js +2 -0
  94. package/dist/components/Routing/Segment.js +4 -3
  95. package/dist/components/Routing/SegmentPage.js +24 -11
  96. package/dist/components/Routing/withWaypointing.js +10 -4
  97. package/dist/components/Scope/ScopeNode.js +1 -1
  98. package/dist/components/Scope/Selector.js +1 -1
  99. package/dist/components/Scope/index.js +11 -3
  100. package/dist/components/Scope/useScopeSelect.js +1 -1
  101. package/dist/components/Selector.js +1 -1
  102. package/dist/components/Sidepanel.js +1 -2
  103. package/dist/components/Spritesheet.js +1 -1
  104. package/dist/components/Switch.js +1 -1
  105. package/dist/components/Text.js +1 -1
  106. package/dist/components/ToastList.js +1 -1
  107. package/dist/components/Toolbar.js +1 -1
  108. package/dist/components/Treeview/Label.js +1 -1
  109. package/dist/components/Treeview/Leaf.js +1 -1
  110. package/dist/components/Treeview/Node.js +3 -3
  111. package/dist/components/Treeview/index.js +2 -2
  112. package/dist/components/Treeview/settings.js +1 -1
  113. package/dist/constants.js +26 -1
  114. package/dist/content/icons/html-templates.svg +3 -0
  115. package/dist/content/iconsSheet.svg +3 -0
  116. package/dist/getThemeOverrides.js +2 -2
  117. package/dist/hocs/withInfiniteScroll.js +1 -1
  118. package/dist/hocs/withUpdateHandler.js +2 -2
  119. package/dist/hooks/useDispatchWithModulesData.js +1 -1
  120. package/dist/hooks/useEditState.js +3 -3
  121. package/dist/hooks/useEntityLoader.js +182 -0
  122. package/dist/hooks/useFullEntityEditState.js +3 -3
  123. package/dist/hooks/useInfiniteScroll.js +104 -0
  124. package/dist/hooks/useLabelMessage.js +3 -3
  125. package/dist/hooks/useLoader.js +1 -0
  126. package/dist/hooks/useMultipleFieldEditState.js +2 -2
  127. package/dist/hooks/useNavigationHandler.js +1 -1
  128. package/dist/hooks/useNotificationRequestState.js +159 -0
  129. package/dist/hooks/useRequestState.js +146 -0
  130. package/dist/hooks/useSelectorAndUnwrap.js +1 -1
  131. package/dist/reducers/metadata.js +52 -26
  132. package/dist/reducers/requestStates.js +181 -0
  133. package/dist/schemas/countries.js +1 -1
  134. package/dist/schemas/definitions.js +1 -1
  135. package/dist/schemas/metadata.js +1 -1
  136. package/dist/schemas/productDefinitions.js +1 -1
  137. package/dist/schemas/timezones.js +1 -1
  138. package/dist/selectors/applications.js +1 -1
  139. package/dist/selectors/authentication.js +1 -2
  140. package/dist/selectors/countries.js +1 -1
  141. package/dist/selectors/locale.js +1 -1
  142. package/dist/selectors/metadata.js +117 -17
  143. package/dist/selectors/navigation.js +1 -1
  144. package/dist/selectors/requestStates.js +82 -0
  145. package/dist/selectors/requests.js +1 -1
  146. package/dist/selectors/scope.js +2 -1
  147. package/dist/selectors/versionInfo.js +1 -1
  148. package/dist/selectors/view.js +1 -1
  149. package/dist/sharedMessages.js +44 -0
  150. package/dist/spawnerMiddleware.js +1 -1
  151. package/dist/utils/displayModeHelper.js +1 -1
  152. package/dist/utils/flatten.js +2 -2
  153. package/dist/utils/localizationHelper.js +1 -1
  154. package/dist/utils/mapHelper.js +1 -1
  155. package/dist/utils/modelValidationHelper.js +2 -2
  156. package/dist/utils/parseHelper.js +1 -1
  157. package/dist/utils/propertyHelper.js +2 -2
  158. package/dist/utils/propertyValidator.js +1 -1
  159. package/dist/utils/setTranslation.js +27 -1
  160. package/dist/utils/setTranslationWithFallback.js +33 -3
  161. package/dist/utils/testUtils.js +6 -2
  162. package/dist/utils/timezoneHelper.js +111 -0
  163. package/dist/utils/unwrapImmutable.js +1 -1
  164. package/dist/utils/urlHelper.js +11 -1
  165. package/package.json +3 -7
  166. package/src/actions/makeApiAction.js +24 -1
  167. package/src/actions/makeApiAction.test.js +76 -3
  168. package/src/actions/metadata.js +130 -0
  169. package/src/actions/metadata.test.js +337 -5
  170. package/src/actions/requestState.js +8 -0
  171. package/src/actions/requestState.test.js +14 -0
  172. package/src/actions/requestsApi.js +30 -0
  173. package/src/buildStore.js +2 -0
  174. package/src/components/AppFrame/AppFrame.test.js +6 -16
  175. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
  176. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
  177. package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
  178. package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
  179. package/src/components/AppFrame/Topbar.test.js +2 -4
  180. package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
  181. package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
  182. package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
  183. package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
  184. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  185. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  186. package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
  187. package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
  188. package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
  189. package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
  190. package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
  191. package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
  192. package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
  193. package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
  194. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +4 -2
  195. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
  196. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
  197. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
  198. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  199. package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
  200. package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
  201. package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
  202. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
  203. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
  204. package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
  205. package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
  206. package/src/components/MaterialUI/muiThemes.js +18 -3
  207. package/src/components/Modules.js +13 -1
  208. package/src/components/Modules.test.js +133 -1
  209. package/src/components/Navigation/Navigation.test.js +2 -0
  210. package/src/components/Navigation/useNavigationState.js +21 -1
  211. package/src/components/Navigation/useNavigationState.test.js +10 -0
  212. package/src/components/Routing/FullPage.js +2 -1
  213. package/src/components/Routing/FullPage.test.js +149 -79
  214. package/src/components/Routing/Segment.js +5 -2
  215. package/src/components/Routing/Segment.test.js +22 -1
  216. package/src/components/Routing/SegmentPage.js +19 -9
  217. package/src/components/Routing/SubPage.test.js +1 -1
  218. package/src/components/Routing/withWaypointing.js +19 -17
  219. package/src/components/Routing/withWaypointing.test.js +50 -0
  220. package/src/components/Scope/Scope.test.js +117 -0
  221. package/src/components/Scope/index.js +6 -10
  222. package/src/components/Sidepanel.js +0 -1
  223. package/src/components/Sidepanel.test.js +0 -3
  224. package/src/constants.js +18 -0
  225. package/src/content/icons/html-templates.svg +3 -0
  226. package/src/content/iconsSheet.svg +3 -0
  227. package/src/hooks/useEntityLoader.js +68 -0
  228. package/src/hooks/useEntityLoader.test.js +266 -0
  229. package/src/hooks/useInfiniteScroll.js +25 -0
  230. package/src/hooks/useInfiniteScroll.test.js +87 -0
  231. package/src/hooks/useLoader.js +1 -0
  232. package/src/hooks/useNotificationRequestState.js +78 -0
  233. package/src/hooks/useNotificationRequestState.test.js +264 -0
  234. package/src/hooks/useRequestState.js +57 -0
  235. package/src/hooks/useRequestState.test.js +217 -0
  236. package/src/reducers/metadata.js +76 -16
  237. package/src/reducers/metadata.test.js +458 -4
  238. package/src/reducers/requestStates.js +98 -0
  239. package/src/reducers/requestStates.test.js +399 -0
  240. package/src/selectors/authentication.js +0 -1
  241. package/src/selectors/locale.test.js +0 -2
  242. package/src/selectors/metadata.js +90 -19
  243. package/src/selectors/metadata.test.js +532 -123
  244. package/src/selectors/requestStates.js +12 -0
  245. package/src/selectors/requestStates.test.js +83 -0
  246. package/src/selectors/scope.js +1 -1
  247. package/src/sharedMessages.js +44 -0
  248. package/src/translations/en-US.json +12 -1
  249. package/src/translations/fr-CA.json +13 -2
  250. package/src/utils/modelValidationHelper.js +1 -1
  251. package/src/utils/setTranslation.js +16 -1
  252. package/src/utils/setTranslation.test.js +24 -0
  253. package/src/utils/setTranslationWithFallback.js +19 -2
  254. package/src/utils/setTranslationWithFallback.test.js +104 -6
  255. package/src/utils/testUtils.js +3 -1
  256. package/src/utils/timezoneHelper.js +140 -0
  257. package/src/utils/timezoneHelper.test.js +33 -0
  258. package/src/utils/urlHelper.js +6 -0
  259. 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),
@@ -32,12 +46,16 @@ export const namedLookupSelector = memoize((moduleName, lookupName) =>
32
46
  );
33
47
 
34
48
  export const namedLookupValuesSelector = memoize((moduleName, lookupName) =>
35
- createSelector(namedLookupSelector(moduleName, lookupName), currentLocaleOrDefault, (statuses, locale) =>
36
- (statuses.get("values") || Immutable.Map()).map(status => setTranslation(locale, status, "displayName")),
49
+ createSelector(namedLookupSelector(moduleName, lookupName), currentLocaleOrDefault, (lookup, locale) =>
50
+ (lookup.get("values") || Immutable.Map()).map(lookupValue =>
51
+ setTranslationWithFallbackField(locale, lookupValue, "name", "displayName"),
52
+ ),
37
53
  ),
38
54
  );
39
55
 
40
- export const selectCurrentLookupDetails = memoize((moduleName, id) => namedLookupSelector(moduleName, id));
56
+ export const selectCurrentLookupDetails = memoize((moduleName, lookupName) =>
57
+ namedLookupSelector(moduleName, lookupName),
58
+ );
41
59
 
42
60
  export const namedLookupLocalizedSelector = memoize((moduleName, lookupName, key, defaultValue = key) =>
43
61
  createSelector(lookupValuesSelector(moduleName, lookupName), currentLocaleOrDefault, (lookups, locale) => {
@@ -80,23 +98,55 @@ export const mappedLookupListSelector = memoize(moduleName =>
80
98
  ),
81
99
  );
82
100
 
83
- export const orderLookupsListCurrentInfo = lookupsListCurrentInfo(ORDER_LOOKUP_MODULE_NAME);
101
+ export const orderLookupsListCurrentInfo = lookupsListCurrentInfo(ORDER_MODULE_NAME);
84
102
 
85
- export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(ORDER_LOOKUP_MODULE_NAME);
103
+ export const orderLookupsNextPageToLoad = lookupsNextPageToLoad(ORDER_MODULE_NAME);
86
104
 
87
- export const mappedOrderLookupsListSelector = mappedLookupListSelector(ORDER_LOOKUP_MODULE_NAME);
105
+ export const mappedOrderLookupsListSelector = mappedLookupListSelector(ORDER_MODULE_NAME);
88
106
 
89
107
  /*** DEFINITIONS ***/
90
108
  const definitions = createSelector(metadata, meta => meta.get("definitions"));
91
109
  const definitionsModule = memoize(moduleName =>
92
- createSelector(definitions, definitions => definitions.get(moduleName)),
110
+ createSelector(definitions, definitions => definitions.get(moduleName) ?? Immutable.Map()),
111
+ );
112
+
113
+ export const mappedDefinitionsListSelector = memoize(moduleName =>
114
+ createSelector(definitionsModule(moduleName), currentLocaleOrDefault, (definitions, locale) =>
115
+ definitions.map(definition =>
116
+ definition
117
+ .set("type", definition.get("isSharedEntity") === true ? definitionType.shared : definitionType.embedded)
118
+ .set("displayName", getLocalization(definition.get("displayName"), locale, definition.get("entityTypeName")))
119
+ .delete("attributes"),
120
+ ),
121
+ ),
122
+ );
123
+
124
+ export const mappedCustomDefinitionsListSelector = memoize(moduleName =>
125
+ createSelector(mappedDefinitionsListSelector(moduleName), definitions =>
126
+ definitions.filter(a => a.get("isBuiltIn") === false),
127
+ ),
93
128
  );
94
129
 
95
- const definitionEntity = memoize((moduleName, entityName) =>
130
+ export const mappedBaseDefinitionsListSelector = memoize(moduleName =>
131
+ createSelector(mappedDefinitionsListSelector(moduleName), definitions =>
132
+ definitions.filter(a => a.get("isBuiltIn") === true),
133
+ ),
134
+ );
135
+
136
+ export const newProfileDefinitionInstanceSelector = createSelector(
137
+ definitions,
138
+ definitions => definitions.get("newInstance") || null,
139
+ );
140
+
141
+ export const newProfileDefinitionNameSelector = createSelector(definitions, definitions =>
142
+ definitions.get("newInstanceId"),
143
+ );
144
+
145
+ export const definitionEntity = memoize((moduleName, entityName) =>
96
146
  createSelector(definitionsModule(moduleName), definition => definition.getIn([entityName]) || Immutable.Map()),
97
147
  );
98
148
 
99
- const mappedDefinitionEntity = memoize((moduleName, entityName) =>
149
+ export const mappedDefinitionEntity = memoize((moduleName, entityName) =>
100
150
  createSelector(definitionEntity(moduleName, entityName), currentLocaleOrDefault, (definition, locale) =>
101
151
  setTranslationWithFallbackField(locale, definition, "entityTypeName", "displayName"),
102
152
  ),
@@ -109,16 +159,29 @@ const definitionEntityAttributes = memoize((moduleName, entityName) =>
109
159
  ),
110
160
  );
111
161
 
112
- const mappedDefinitionAttributesSelector = memoize((moduleName, entityName) =>
162
+ const filterIsBuiltInAttributes = isBuiltIn => attributes =>
163
+ attributes.filter(a => a.get("isBuiltIn") === isBuiltIn).sortBy(x => x.get("displayOrder"));
164
+
165
+ export const definitionEntityCustomAttributesSelector = memoize((moduleName, entityName) =>
166
+ createSelector(definitionEntityAttributes(moduleName, entityName), filterIsBuiltInAttributes(false)),
167
+ );
168
+
169
+ export const definitionEntityBaseAttributesSelector = memoize((moduleName, entityName) =>
170
+ createSelector(definitionEntityAttributes(moduleName, entityName), filterIsBuiltInAttributes(true)),
171
+ );
172
+
173
+ export const mappedDefinitionAttributesSelector = memoize((moduleName, entityName) =>
113
174
  createSelector(definitionEntityAttributes(moduleName, entityName), currentLocaleOrDefault, (attributes, locale) =>
114
175
  attributes.map(a => setTranslationWithFallbackField(locale, a, "name", "displayName")),
115
176
  ),
116
177
  );
117
178
 
118
179
  export const customAttributesSelector = memoize((moduleName, entityName) =>
119
- createSelector(mappedDefinitionAttributesSelector(moduleName, entityName), attributes =>
120
- attributes.filter(a => a.get("isBuiltIn") === false),
121
- ),
180
+ createSelector(mappedDefinitionAttributesSelector(moduleName, entityName), filterIsBuiltInAttributes(false)),
181
+ );
182
+
183
+ export const baseAttributesSelector = memoize((moduleName, entityName) =>
184
+ createSelector(mappedDefinitionAttributesSelector(moduleName, entityName), filterIsBuiltInAttributes(true)),
122
185
  );
123
186
 
124
187
  export const profileAttributeGroupsSelector = createSelector(metadata, currentLocaleOrDefault, (meta, locale) => {
@@ -144,11 +207,15 @@ export const groupedCustomAttributesDefinitionSelector = memoize((moduleName, en
144
207
  })
145
208
  .set(
146
209
  "baseAttributes",
147
- group.filter(i => i.get("dataType") !== attributeDataType.entityReference),
210
+ group
211
+ .filter(i => i.get("dataType") !== attributeDataType.entityReference)
212
+ .sortBy(x => x.get("displayOrder")),
148
213
  )
149
214
  .set(
150
215
  "profileAttributes",
151
- group.filter(i => i.get("dataType") === attributeDataType.entityReference),
216
+ group
217
+ .filter(i => i.get("dataType") === attributeDataType.entityReference)
218
+ .sortBy(x => x.get("displayOrder")),
152
219
  );
153
220
  })
154
221
  .sortBy(x => x.get("displayOrder")),
@@ -160,8 +227,12 @@ export const customAttributesDefinitionSelector = memoize((moduleName, profileEn
160
227
  mappedDefinitionEntity(moduleName, profileEntityName),
161
228
  customAttributesSelector(moduleName, profileEntityName),
162
229
  (definition, attributes) => {
163
- const profileAttributes = attributes?.filter(a => a.get("dataType") === attributeDataType.entityReference);
164
- const baseAttributes = attributes?.filter(a => a.get("dataType") !== attributeDataType.entityReference);
230
+ const profileAttributes = attributes
231
+ ?.filter(a => a.get("dataType") === attributeDataType.entityReference)
232
+ .sortBy(x => x.get("displayOrder"));
233
+ const baseAttributes = attributes
234
+ ?.filter(a => a.get("dataType") !== attributeDataType.entityReference)
235
+ .sortBy(x => x.get("displayOrder"));
165
236
  return definition.set("baseAttributes", baseAttributes).set("profileAttributes", profileAttributes);
166
237
  },
167
238
  ),