orc-shared 5.10.0-dev.2 → 5.10.0-dev.21

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 (186) hide show
  1. package/dist/actions/metadata.js +30 -11
  2. package/dist/actions/requestsApi.js +10 -1
  3. package/dist/components/AppFrame/About.js +136 -100
  4. package/dist/components/AppFrame/Anchor.js +45 -21
  5. package/dist/components/AppFrame/AppFrame.js +53 -31
  6. package/dist/components/AppFrame/Help.js +35 -15
  7. package/dist/components/AppFrame/MenuItem.js +148 -114
  8. package/dist/components/AppFrame/Preferences.js +136 -97
  9. package/dist/components/AppFrame/Sidebar.js +51 -28
  10. package/dist/components/AppFrame/Topbar.js +61 -36
  11. package/dist/components/ColumnWrapper.js +28 -5
  12. package/dist/components/Culture.js +33 -14
  13. package/dist/components/DropMenu/Menu.js +79 -45
  14. package/dist/components/DropMenu/index.js +34 -29
  15. package/dist/components/Form/Combination.js +45 -16
  16. package/dist/components/Form/Field.js +57 -38
  17. package/dist/components/Form/FieldElements.js +0 -11
  18. package/dist/components/Form/Fieldset.js +47 -19
  19. package/dist/components/Form/Form.js +22 -9
  20. package/dist/components/Form/FormElement.js +40 -7
  21. package/dist/components/Form/Inputs/Button.js +63 -18
  22. package/dist/components/Form/Inputs/ReadOnly.js +50 -27
  23. package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
  24. package/dist/components/Form/Inputs/Text.js +20 -37
  25. package/dist/components/Form/Inputs/Toggles.js +39 -40
  26. package/dist/components/Form/Inputs/index.js +2 -13
  27. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
  28. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
  29. package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
  30. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
  31. package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
  32. package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
  33. package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
  34. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  35. package/dist/components/MaterialUI/Inputs/Select.js +2 -0
  36. package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
  37. package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
  38. package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  39. package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
  40. package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
  41. package/dist/components/MaterialUI/muiThemes.js +2 -1
  42. package/dist/components/Provision.js +1 -1
  43. package/dist/constants.js +2 -1
  44. package/dist/content/iconsSheet.svg +740 -116
  45. package/dist/hocs/withScrollBox.js +27 -12
  46. package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
  47. package/dist/hooks/useInMemoryPaging.js +135 -0
  48. package/dist/hooks/useMultipleFieldEditState.js +12 -3
  49. package/dist/reducers/metadata.js +6 -0
  50. package/dist/schemas/metadata.js +9 -1
  51. package/dist/selectors/locale.js +1 -0
  52. package/dist/selectors/metadata.js +14 -11
  53. package/dist/sharedMessages.js +184 -0
  54. package/dist/utils/ListHelper.js +271 -0
  55. package/dist/utils/comparisonHelper.js +185 -0
  56. package/dist/utils/propertyBagHelper.js +3 -1
  57. package/dist/utils/timezoneHelper.js +18 -31
  58. package/package.json +4 -3
  59. package/src/actions/metadata.js +11 -0
  60. package/src/actions/metadata.test.js +27 -0
  61. package/src/actions/requestsApi.js +6 -0
  62. package/src/components/AppFrame/About.js +97 -117
  63. package/src/components/AppFrame/About.test.js +128 -90
  64. package/src/components/AppFrame/Anchor.js +34 -36
  65. package/src/components/AppFrame/Anchor.test.js +5 -68
  66. package/src/components/AppFrame/AppFrame.js +31 -40
  67. package/src/components/AppFrame/AppFrame.test.js +424 -445
  68. package/src/components/AppFrame/Help.js +23 -20
  69. package/src/components/AppFrame/Help.test.js +3 -3
  70. package/src/components/AppFrame/MenuItem.js +106 -126
  71. package/src/components/AppFrame/MenuItem.test.js +78 -169
  72. package/src/components/AppFrame/Preferences.js +110 -98
  73. package/src/components/AppFrame/Preferences.test.js +115 -219
  74. package/src/components/AppFrame/Sidebar.js +39 -41
  75. package/src/components/AppFrame/Sidebar.test.js +88 -168
  76. package/src/components/AppFrame/Topbar.js +59 -52
  77. package/src/components/AppFrame/Topbar.test.js +31 -39
  78. package/src/components/ColumnWrapper.js +18 -9
  79. package/src/components/Culture.js +20 -10
  80. package/src/components/Culture.test.js +27 -16
  81. package/src/components/DropMenu/DropMenu.test.js +185 -224
  82. package/src/components/DropMenu/Menu.js +73 -80
  83. package/src/components/DropMenu/Menu.test.js +35 -86
  84. package/src/components/DropMenu/index.js +19 -15
  85. package/src/components/Form/Combination.js +35 -28
  86. package/src/components/Form/Combination.test.js +6 -19
  87. package/src/components/Form/Field.js +53 -66
  88. package/src/components/Form/Field.test.js +29 -51
  89. package/src/components/Form/FieldElements.js +0 -14
  90. package/src/components/Form/FieldElements.test.js +104 -111
  91. package/src/components/Form/Fieldset.js +42 -37
  92. package/src/components/Form/Fieldset.test.js +14 -7
  93. package/src/components/Form/Form.js +11 -7
  94. package/src/components/Form/Form.test.js +75 -56
  95. package/src/components/Form/FormElement.js +24 -16
  96. package/src/components/Form/InputField.test.js +24 -30
  97. package/src/components/Form/Inputs/Button.js +58 -14
  98. package/src/components/Form/Inputs/Button.test.js +32 -7
  99. package/src/components/Form/Inputs/Inputs.test.js +0 -7
  100. package/src/components/Form/Inputs/ReadOnly.js +34 -28
  101. package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
  102. package/src/components/Form/Inputs/Selector.js +22 -0
  103. package/src/components/Form/Inputs/Selector.test.js +105 -0
  104. package/src/components/Form/Inputs/Text.js +15 -44
  105. package/src/components/Form/Inputs/Text.test.js +20 -29
  106. package/src/components/Form/Inputs/Toggles.js +27 -26
  107. package/src/components/Form/Inputs/Toggles.test.js +22 -28
  108. package/src/components/Form/Inputs/index.js +4 -15
  109. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
  110. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
  111. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
  112. package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
  113. package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
  114. package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
  115. package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
  116. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  117. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
  118. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
  119. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
  120. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
  121. package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
  122. package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
  123. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  124. package/src/components/MaterialUI/Inputs/Select.js +2 -0
  125. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  126. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  127. package/src/components/MaterialUI/Inputs/Switch.js +22 -1
  128. package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
  129. package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  130. package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
  131. package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
  132. package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
  133. package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
  134. package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
  135. package/src/components/MaterialUI/muiThemes.js +1 -0
  136. package/src/components/Navigation/Bar.test.js +92 -87
  137. package/src/components/Provision.js +1 -1
  138. package/src/components/TaskDetailsModal.test.js +1 -3
  139. package/src/constants.js +1 -0
  140. package/src/content/iconsSheet.svg +740 -116
  141. package/src/hocs/withScrollBox.js +32 -19
  142. package/src/hocs/withScrollBox.test.js +15 -3
  143. package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
  144. package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
  145. package/src/hooks/useInMemoryPaging.js +78 -0
  146. package/src/hooks/useInMemoryPaging.test.js +515 -0
  147. package/src/hooks/useMultipleFieldEditState.js +11 -4
  148. package/src/hooks/useMultipleFieldEditState.test.js +49 -1
  149. package/src/reducers/metadata.js +6 -1
  150. package/src/reducers/metadata.test.js +31 -0
  151. package/src/requests +1 -0
  152. package/src/schemas/metadata.js +3 -0
  153. package/src/selectors/locale.js +1 -1
  154. package/src/selectors/metadata.js +12 -9
  155. package/src/selectors/metadata.test.js +92 -11
  156. package/src/sharedMessages.js +184 -0
  157. package/src/timezones.json +883 -0
  158. package/src/translations/en-US.json +46 -0
  159. package/src/translations/fr-CA.json +46 -0
  160. package/src/utils/ListHelper.js +203 -0
  161. package/src/utils/ListHelper.test.js +710 -0
  162. package/src/utils/comparisonHelper.js +135 -0
  163. package/src/utils/comparisonHelper.test.js +334 -0
  164. package/src/utils/propertyBagHelper.js +2 -0
  165. package/src/utils/propertyBagHelper.test.js +6 -0
  166. package/src/utils/timezoneHelper.js +10 -135
  167. package/src/utils/timezoneHelper.test.js +7 -7
  168. package/dist/components/Form/FieldList.js +0 -270
  169. package/dist/components/Form/Inputs/FieldButtons.js +0 -66
  170. package/dist/components/Form/Inputs/Number.js +0 -117
  171. package/dist/components/Form/Inputs/SmallButton.js +0 -91
  172. package/dist/components/Form/Inputs/Time.js +0 -86
  173. package/dist/components/Form/Inputs/Translation.js +0 -169
  174. package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
  175. package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
  176. package/src/components/Form/FieldList.js +0 -210
  177. package/src/components/Form/FieldList.test.js +0 -558
  178. package/src/components/Form/Inputs/FieldButtons.js +0 -90
  179. package/src/components/Form/Inputs/Number.js +0 -60
  180. package/src/components/Form/Inputs/Number.test.js +0 -435
  181. package/src/components/Form/Inputs/SmallButton.js +0 -37
  182. package/src/components/Form/Inputs/SmallButton.test.js +0 -65
  183. package/src/components/Form/Inputs/Time.js +0 -32
  184. package/src/components/Form/Inputs/Time.test.js +0 -41
  185. package/src/components/Form/Inputs/Translation.js +0 -93
  186. package/src/components/Form/Inputs/Translation.test.js +0 -204
@@ -1,11 +1,8 @@
1
1
  import React from "react";
2
2
  import Immutable from "immutable";
3
- import { Provider } from "react-redux";
4
- import { IntlProvider } from "react-intl";
5
3
  import { RSAA } from "redux-api-middleware";
6
4
  import sinon from "sinon";
7
5
  import { Ignore } from "unexpected-reaction";
8
- import { getStyledClassSelector } from "../../utils/testUtils";
9
6
  import { CHANGE_LOCALE } from "../../actions/locale";
10
7
  import {
11
8
  SET_DEFAULT_LANGUAGE_REQUEST,
@@ -18,22 +15,13 @@ import {
18
15
  SET_MY_APPLICATION_FAILURE,
19
16
  } from "../../actions/applications";
20
17
  import { setValue } from "../../actions/view";
21
- import { FieldBox, Label } from "../Form/Field";
22
- import { Wrapper as SelectorWrapper } from "../Selector";
23
- import Preferences, {
24
- Header,
25
- PrefForm,
26
- Footer,
27
- PrefButton,
28
- createGetUpdater,
29
- Wrapper,
30
- PREFS_NAME,
31
- clickOutsideHandler,
32
- } from "./Preferences";
18
+ import Preferences, { PREFS_NAME, clickOutsideHandler, stateEventUpdater } from "./Preferences";
33
19
  import { RESET_VERSION_INFO } from "../../actions/versionInfo";
34
- import { extractMessages } from "./../../utils/testUtils";
20
+ import { extractMessages, TestWrapper } from "./../../utils/testUtils";
35
21
  import sharedMessages from "./../../sharedMessages";
36
22
  import { stringifyWithoutQuotes } from "./../../utils/parseHelper";
23
+ import InformationItem from "../MaterialUI/DataDisplay/PredefinedElements/InformationItem";
24
+ import Button from "@material-ui/core/Button";
37
25
 
38
26
  const messages = extractMessages(sharedMessages);
39
27
 
@@ -151,11 +139,9 @@ describe("Preferences", () => {
151
139
 
152
140
  it("renders a form dialog", () => {
153
141
  return expect(
154
- <Provider store={store}>
155
- <IntlProvider locale="en-US" messages={messages}>
156
- <Preferences />
157
- </IntlProvider>
158
- </Provider>,
142
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
143
+ <Preferences />
144
+ </TestWrapper>,
159
145
  "when mounted",
160
146
  "to satisfy",
161
147
  null,
@@ -166,48 +152,34 @@ describe("Preferences", () => {
166
152
  "with event",
167
153
  {
168
154
  type: "click",
169
- target: getStyledClassSelector(PrefButton) + ":last-child",
155
+ target: "#savePrefs",
170
156
  },
171
157
  "to satisfy",
172
- <div>
158
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
173
159
  <div>
174
- <Wrapper>
175
- <Header>{stringifyWithoutQuotes(messages["orc-shared.preferences"])}</Header>
176
- <PrefForm>
177
- <FieldBox>
178
- <Label id="language_label">{stringifyWithoutQuotes(messages["orc-shared.displayLanguage"])}</Label>
179
- <SelectorWrapper>
180
- <select id="language" value="en-US" onChange={() => {}}>
181
- <option>English</option>
182
- <option>EnglishCa</option>
183
- <option>Francais</option>
184
- <option>Francais-Qc</option>
185
- </select>
186
- <Ignore />
160
+ <div>
161
+ <div>
162
+ <div>{stringifyWithoutQuotes(messages["orc-shared.preferences"])}</div>
163
+ <div>
164
+ <InformationItem label={sharedMessages.displayLanguage}>
187
165
  <Ignore />
188
- </SelectorWrapper>
189
- </FieldBox>
190
- <FieldBox>
191
- <Label id="application_label">{stringifyWithoutQuotes(messages["orc-shared.defaultApp"])}</Label>
192
- <SelectorWrapper>
193
- <select id="application" value={4} onChange={() => {}}>
194
- <option>Marketing Legacy</option>
195
- <option>Product Information</option>
196
- </select>
166
+ </InformationItem>
167
+ <InformationItem label={sharedMessages.defaultApp}>
197
168
  <Ignore />
198
- <Ignore />
199
- </SelectorWrapper>
200
- </FieldBox>
201
- </PrefForm>
202
- <Footer>
203
- <PrefButton id="cancelPrefs">{stringifyWithoutQuotes(messages["orc-shared.cancel"])}</PrefButton>
204
- <PrefButton id="savePrefs" primary>
205
- {stringifyWithoutQuotes(messages["orc-shared.save"])}
206
- </PrefButton>
207
- </Footer>
208
- </Wrapper>
169
+ </InformationItem>
170
+ </div>
171
+ <div>
172
+ <Button id="cancelPrefs" variant="outlined">
173
+ {stringifyWithoutQuotes(messages["orc-shared.cancel"])}
174
+ </Button>
175
+ <Button id="savePrefs" variant="outlined" color="primary">
176
+ {stringifyWithoutQuotes(messages["orc-shared.save"])}
177
+ </Button>
178
+ </div>
179
+ </div>
180
+ </div>
209
181
  </div>
210
- </div>,
182
+ </TestWrapper>,
211
183
  ),
212
184
  )
213
185
  .then(() =>
@@ -222,11 +194,9 @@ describe("Preferences", () => {
222
194
  it("shows view state fields, saves language change", () => {
223
195
  state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, language: "fr-CA" }));
224
196
  return expect(
225
- <Provider store={store}>
226
- <IntlProvider locale="en-US" messages={messages}>
227
- <Preferences />
228
- </IntlProvider>
229
- </Provider>,
197
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
198
+ <Preferences />
199
+ </TestWrapper>,
230
200
  "when mounted",
231
201
  "to satisfy",
232
202
  null,
@@ -237,43 +207,27 @@ describe("Preferences", () => {
237
207
  "with event",
238
208
  {
239
209
  type: "click",
240
- target: getStyledClassSelector(PrefButton) + ":last-child",
210
+ target: "#savePrefs",
241
211
  },
242
212
  "to satisfy",
243
- <div>
213
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
244
214
  <div>
245
- <Wrapper>
246
- <Ignore />
247
- <PrefForm>
248
- <FieldBox>
249
- <Label id="language_label">{stringifyWithoutQuotes(messages["orc-shared.displayLanguage"])}</Label>
250
- <SelectorWrapper>
251
- <select id="language" value="fr-CA" onChange={() => {}}>
252
- <option>English</option>
253
- <option>EnglishCa</option>
254
- <option>Francais</option>
255
- <option>Francais-Qc</option>
256
- </select>
257
- <Ignore />
215
+ <div>
216
+ <div>
217
+ <Ignore />
218
+ <div>
219
+ <InformationItem label={sharedMessages.displayLanguage}>
258
220
  <Ignore />
259
- </SelectorWrapper>
260
- </FieldBox>
261
- <FieldBox>
262
- <Label id="application_label">{stringifyWithoutQuotes(messages["orc-shared.defaultApp"])}</Label>
263
- <SelectorWrapper>
264
- <select id="application" value={4} onChange={() => {}}>
265
- <option>Marketing Legacy</option>
266
- <option>Product Information</option>
267
- </select>
221
+ </InformationItem>
222
+ <InformationItem label={sharedMessages.defaultApp}>
268
223
  <Ignore />
269
- <Ignore />
270
- </SelectorWrapper>
271
- </FieldBox>
272
- </PrefForm>
273
- <Ignore />
274
- </Wrapper>
224
+ </InformationItem>
225
+ </div>
226
+ <Ignore />
227
+ </div>
228
+ </div>
275
229
  </div>
276
- </div>,
230
+ </TestWrapper>,
277
231
  ),
278
232
  )
279
233
  .then(() =>
@@ -351,11 +305,9 @@ describe("Preferences", () => {
351
305
  it("shows view state fields, saves application change", () => {
352
306
  state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, application: 3 }));
353
307
  return expect(
354
- <Provider store={store}>
355
- <IntlProvider locale="en-US" messages={messages}>
356
- <Preferences />
357
- </IntlProvider>
358
- </Provider>,
308
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
309
+ <Preferences />
310
+ </TestWrapper>,
359
311
  "when mounted",
360
312
  "to satisfy",
361
313
  null,
@@ -366,43 +318,27 @@ describe("Preferences", () => {
366
318
  "with event",
367
319
  {
368
320
  type: "click",
369
- target: getStyledClassSelector(PrefButton) + ":last-child",
321
+ target: "#savePrefs",
370
322
  },
371
323
  "to satisfy",
372
- <div>
324
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
373
325
  <div>
374
- <Wrapper>
375
- <Ignore />
376
- <PrefForm>
377
- <FieldBox>
378
- <Label id="language_label">{stringifyWithoutQuotes(messages["orc-shared.displayLanguage"])}</Label>
379
- <SelectorWrapper>
380
- <select id="language" value="en-US" onChange={() => {}}>
381
- <option>English</option>
382
- <option>EnglishCa</option>
383
- <option>Francais</option>
384
- <option>Francais-Qc</option>
385
- </select>
386
- <Ignore />
387
- <Ignore />
388
- </SelectorWrapper>
389
- </FieldBox>
390
- <FieldBox>
391
- <Label id="application_label">{stringifyWithoutQuotes(messages["orc-shared.defaultApp"])}</Label>
392
- <SelectorWrapper>
393
- <select id="application" value={3} onChange={() => {}}>
394
- <option>Marketing Legacy</option>
395
- <option>Product Information</option>
396
- </select>
326
+ <div>
327
+ <div>
328
+ <Ignore />
329
+ <div>
330
+ <InformationItem label={sharedMessages.displayLanguage}>
397
331
  <Ignore />
332
+ </InformationItem>
333
+ <InformationItem label={sharedMessages.defaultApp}>
398
334
  <Ignore />
399
- </SelectorWrapper>
400
- </FieldBox>
401
- </PrefForm>
402
- <Ignore />
403
- </Wrapper>
335
+ </InformationItem>
336
+ </div>
337
+ <Ignore />
338
+ </div>
339
+ </div>
404
340
  </div>
405
- </div>,
341
+ </TestWrapper>,
406
342
  ),
407
343
  )
408
344
  .then(() =>
@@ -444,11 +380,9 @@ describe("Preferences", () => {
444
380
  it("clears and closes", () => {
445
381
  state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, language: "fr-CA", application: 3 }));
446
382
  return expect(
447
- <Provider store={store}>
448
- <IntlProvider locale="en-US" messages={messages}>
449
- <Preferences />
450
- </IntlProvider>
451
- </Provider>,
383
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
384
+ <Preferences />
385
+ </TestWrapper>,
452
386
  "when mounted",
453
387
  "to satisfy",
454
388
  null,
@@ -459,43 +393,27 @@ describe("Preferences", () => {
459
393
  "with event",
460
394
  {
461
395
  type: "click",
462
- target: getStyledClassSelector(PrefButton) + ":first-child",
396
+ target: "#cancelPrefs",
463
397
  },
464
398
  "to satisfy",
465
- <div>
399
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
466
400
  <div>
467
- <Wrapper>
468
- <Ignore />
469
- <PrefForm>
470
- <FieldBox>
471
- <Label id="language_label">{stringifyWithoutQuotes(messages["orc-shared.displayLanguage"])}</Label>
472
- <SelectorWrapper>
473
- <select id="language" value="fr-CA" onChange={() => {}}>
474
- <option>English</option>
475
- <option>EnglishCa</option>
476
- <option>Francais</option>
477
- <option>Francais-Qc</option>
478
- </select>
401
+ <div>
402
+ <div>
403
+ <Ignore />
404
+ <div>
405
+ <InformationItem label={sharedMessages.displayLanguage}>
479
406
  <Ignore />
407
+ </InformationItem>
408
+ <InformationItem label={sharedMessages.defaultApp}>
480
409
  <Ignore />
481
- </SelectorWrapper>
482
- </FieldBox>
483
- <FieldBox>
484
- <Label id="application_label">{stringifyWithoutQuotes(messages["orc-shared.defaultApp"])}</Label>
485
- <SelectorWrapper>
486
- <select id="application" value={3} onChange={() => {}}>
487
- <option>Marketing Legacy</option>
488
- <option>Product Information</option>
489
- </select>
490
- <Ignore />
491
- <Ignore />
492
- </SelectorWrapper>
493
- </FieldBox>
494
- </PrefForm>
495
- <Ignore />
496
- </Wrapper>
410
+ </InformationItem>
411
+ </div>
412
+ <Ignore />
413
+ </div>
414
+ </div>
497
415
  </div>
498
- </div>,
416
+ </TestWrapper>,
499
417
  ),
500
418
  )
501
419
  .then(() =>
@@ -518,11 +436,9 @@ describe("Preferences", () => {
518
436
  .deleteIn(["locale", "defaultCulture"])
519
437
  .deleteIn(["settings", "defaultApp"]);
520
438
  expect(
521
- <Provider store={store}>
522
- <IntlProvider locale="en-US" messages={messages}>
523
- <Preferences />
524
- </IntlProvider>
525
- </Provider>,
439
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
440
+ <Preferences />
441
+ </TestWrapper>,
526
442
  "when mounted",
527
443
  "to satisfy",
528
444
  null,
@@ -530,66 +446,46 @@ describe("Preferences", () => {
530
446
  expect(
531
447
  modalRoot,
532
448
  "to satisfy",
533
- <div>
449
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
534
450
  <div>
535
- <Wrapper>
536
- <Ignore />
537
- <PrefForm>
538
- <FieldBox>
539
- <Label id="language_label">{stringifyWithoutQuotes(messages["orc-shared.displayLanguage"])}</Label>
540
- <SelectorWrapper>
541
- <select id="language" value="" onChange={() => {}}>
542
- <option>English</option>
543
- <option>EnglishCa</option>
544
- <option>Francais</option>
545
- <option>Francais-Qc</option>
546
- </select>
547
- <Ignore />
548
- <Ignore />
549
- </SelectorWrapper>
550
- </FieldBox>
551
- <FieldBox>
552
- <Label id="application_label">{stringifyWithoutQuotes(messages["orc-shared.defaultApp"])}</Label>
553
- <SelectorWrapper>
554
- <select id="application" value="" onChange={() => {}}>
555
- <option>Marketing Legacy</option>
556
- <option>Product Information</option>
557
- </select>
451
+ <div>
452
+ <div>
453
+ <Ignore />
454
+ <div>
455
+ <InformationItem label={sharedMessages.displayLanguage}>
558
456
  <Ignore />
457
+ </InformationItem>
458
+ <InformationItem label={sharedMessages.defaultApp}>
559
459
  <Ignore />
560
- </SelectorWrapper>
561
- </FieldBox>
562
- </PrefForm>
563
- <Ignore />
564
- </Wrapper>
460
+ </InformationItem>
461
+ </div>
462
+ <Ignore />
463
+ </div>
464
+ </div>
565
465
  </div>
566
- </div>,
466
+ </TestWrapper>,
567
467
  ),
568
468
  );
569
469
  });
570
470
 
571
- describe("createGetUpdater", () => {
572
- let update, update2;
471
+ describe("stateEventUpdater", () => {
472
+ let update;
573
473
  beforeEach(() => {
574
474
  update = sinon.spy().named("update");
575
- update2 = () => {};
576
475
  });
577
- it("returns an update function", () =>
578
- expect(createGetUpdater, "when called with", [update], "called with", ["testField"], "called with", [
579
- "testValue",
580
- ]).then(() => expect(update, "to have calls satisfying", [{ args: ["testField", "testValue"] }])));
581
476
 
582
- it("memoizes on update function and field name", () => {
583
- const update1_1 = createGetUpdater(update)("111");
584
- const update1_2 = createGetUpdater(update)("222");
585
- const update2_1 = createGetUpdater(update2)("111");
586
- const update2_2 = createGetUpdater(update2)("222");
587
- expect(createGetUpdater, "called with", [update]).then(f =>
588
- expect(f, "called with", ["111"], "to be", update1_1).and("called with", ["222"], "to be", update1_2),
589
- );
590
- expect(createGetUpdater, "called with", [update2]).then(f =>
591
- expect(f, "called with", ["111"], "to be", update2_1).and("called with", ["222"], "to be", update2_2),
592
- );
593
- });
477
+ it("creates a handler for an event and calls update with the value of the target", () =>
478
+ expect(stateEventUpdater, "called with", [update, "application"], "called with", ["foo"]).then(() =>
479
+ expect(update, "to have calls satisfying", [{ args: ["application", "foo"] }]),
480
+ ));
481
+
482
+ it("is memoized", () =>
483
+ expect(
484
+ stateEventUpdater,
485
+ "called with",
486
+ [update, "application"],
487
+ "to be",
488
+ stateEventUpdater(update, "application"),
489
+ ));
594
490
  });
595
491
  });
@@ -1,34 +1,36 @@
1
1
  import React from "react";
2
2
  import { useSelector } from "react-redux";
3
- import styled, { withTheme } from "styled-components";
3
+ import { makeStyles } from "@material-ui/core/styles";
4
4
  import { useLocation } from "react-router-dom";
5
- import { getThemeProp } from "../../utils";
6
5
  import { selectPrependHrefConfig } from "../../selectors/navigation";
7
6
  import MenuItem from "./MenuItem";
8
7
  import { getScopeModuleInformationSelector } from "../../selectors/modules";
9
8
 
10
- export const Bar = styled.div`
11
- box-sizing: border-box;
12
- padding-top: 60px;
13
- height: calc(100% - 40px);
14
- width: 200px;
15
- display: flex;
16
- flex-direction: column;
17
- justify-content: flex-start;
18
- color: ${getThemeProp(["colors", "textMedium"], "#999999")};
19
- `;
9
+ const useStyles = makeStyles(theme => ({
10
+ bar: {
11
+ boxSizing: "border-box",
12
+ paddingTop: "60px",
13
+ height: "calc(100% - 40px)",
14
+ width: "200px",
15
+ display: "flex",
16
+ flexDirection: "column",
17
+ justifyContent: "flex-start",
18
+ color: theme.palette.text.hint,
19
+ },
20
+ logoSvg: {
21
+ flex: "0 0 auto",
22
+ margin: "auto 12.5px 7px",
23
+ height: "25px",
24
+ width: "25px",
25
+ fillRule: "evenodd",
26
+ clipRule: "evenodd",
27
+ fill: "#666666",
28
+ },
29
+ }));
20
30
 
21
- export const MenuToggle = withTheme(({ open, toggle, theme }) => (
22
- <MenuItem
23
- id="sidebarMenuToggle"
24
- menuToggle
25
- open={open}
26
- icon={(open ? getThemeProp(["icons", "sidebarOpen"], "layers") : getThemeProp(["icons", "sidebarClosed"], "menu"))({
27
- theme,
28
- })}
29
- onClick={toggle}
30
- />
31
- ));
31
+ export const MenuToggle = ({ open, toggle }) => (
32
+ <MenuItem id="sidebarMenuToggle" menuToggle open={open} icon={open ? "collapse" : "expand"} onClick={toggle} />
33
+ );
32
34
 
33
35
  const useEnhancement = id => {
34
36
  const location = useLocation();
@@ -49,27 +51,23 @@ export const EnhancedMenuItem = ({ id, ...props }) => {
49
51
  return <MenuItem {...props} {...useEnhancement(id)} isHidden={isHidden} />;
50
52
  };
51
53
 
52
- const LogoSvg = styled.svg`
53
- flex: 0 0 auto;
54
- margin: auto 12.5px 7px;
55
- height: 25px;
56
- width: 25px;
57
- fill-rule: evenodd;
58
- clip-rule: evenodd;
59
- fill: #666666;
60
- `;
54
+ export const Logo = () => {
55
+ const classes = useStyles();
61
56
 
62
- export const Logo = () => (
63
- <LogoSvg viewBox="0 0 354 354">
64
- <g>
65
- <path d="M0 241.41c0-65.49 50.53-111.98 119.66-111.98s119.25 46.49 119.25 111.98c0 65.49-50.13 111.97-119.25 111.97S0 306.9 0 241.41Zm175.04 0c0-37.6-23.85-60.23-55.38-60.23s-55.79 22.64-55.79 60.23c0 37.59 24.26 60.23 55.79 60.23 31.53 0 55.38-22.64 55.38-60.23Zm178.1-76.35h-77.48c0-48.29-39.29-87.58-87.58-87.58V0c91.02 0 165.07 74.05 165.07 165.06h-.01Z" />
66
- </g>
67
- </LogoSvg>
68
- );
57
+ return (
58
+ <svg viewBox="0 0 354 354" className={classes.logoSvg}>
59
+ <g>
60
+ <path d="M0 241.41c0-65.49 50.53-111.98 119.66-111.98s119.25 46.49 119.25 111.98c0 65.49-50.13 111.97-119.25 111.97S0 306.9 0 241.41Zm175.04 0c0-37.6-23.85-60.23-55.38-60.23s-55.79 22.64-55.79 60.23c0 37.59 24.26 60.23 55.79 60.23 31.53 0 55.38-22.64 55.38-60.23Zm178.1-76.35h-77.48c0-48.29-39.29-87.58-87.58-87.58V0c91.02 0 165.07 74.05 165.07 165.06h-.01Z" />
61
+ </g>
62
+ </svg>
63
+ );
64
+ };
69
65
 
70
66
  const Sidebar = ({ open, toggle, modules = [], activeModules = [] }) => {
67
+ const classes = useStyles();
68
+
71
69
  return (
72
- <Bar open={open}>
70
+ <div open={open} className={classes.bar}>
73
71
  <MenuToggle open={open} toggle={toggle} />
74
72
  {modules.map(item => (
75
73
  <EnhancedMenuItem
@@ -81,7 +79,7 @@ const Sidebar = ({ open, toggle, modules = [], activeModules = [] }) => {
81
79
  />
82
80
  ))}
83
81
  <Logo />
84
- </Bar>
82
+ </div>
85
83
  );
86
84
  };
87
85