orc-shared 5.99.0-dev.1 → 5.99.0-dev.10

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 (102) hide show
  1. package/dist/components/AppFrame/About.js +13 -13
  2. package/dist/components/AppFrame/Anchor.js +7 -7
  3. package/dist/components/AppFrame/AppFrame.js +3 -3
  4. package/dist/components/AppFrame/Help.js +4 -4
  5. package/dist/components/AppFrame/MenuItem.js +14 -14
  6. package/dist/components/AppFrame/Preferences.js +14 -14
  7. package/dist/components/AppFrame/Sidebar.js +6 -6
  8. package/dist/components/AppFrame/Topbar.js +6 -6
  9. package/dist/components/DropMenu/Menu.js +9 -9
  10. package/dist/components/Form/Field.js +4 -4
  11. package/dist/components/Form/Inputs/Button.js +2 -2
  12. package/dist/components/Form/Inputs/MultiSelector.js +67 -12
  13. package/dist/components/Form/Inputs/Selector.js +13 -10
  14. package/dist/components/InternetExplorerWarningMessage.js +15 -15
  15. package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
  16. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  17. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +4 -4
  18. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  19. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  20. package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  21. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  22. package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
  23. package/dist/components/MaterialUI/Inputs/InputBase.js +209 -24
  24. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  25. package/dist/components/MaterialUI/Inputs/Select.js +170 -114
  26. package/dist/components/MaterialUI/Inputs/SelectProps.js +10 -2
  27. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  28. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
  29. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
  30. package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
  31. package/dist/components/MaterialUI/muiThemes.js +1 -1
  32. package/dist/components/Routing/SegmentPage.js +9 -7
  33. package/dist/components/Scope/ScopeNode.js +7 -9
  34. package/dist/components/Sidepanel.js +29 -27
  35. package/dist/components/Spritesheet.js +17 -15
  36. package/dist/components/ToastList.js +11 -11
  37. package/dist/components/Treeview/Branch.js +9 -9
  38. package/dist/components/Treeview/Label.js +8 -8
  39. package/dist/components/Treeview/Leaf.js +2 -2
  40. package/dist/components/Treeview/settings.js +10 -1
  41. package/dist/hocs/withScrollBox.js +3 -8
  42. package/dist/hooks/useWindowSize.js +88 -0
  43. package/dist/sharedMessages.js +8 -0
  44. package/package.json +1 -1
  45. package/src/components/AppFrame/About.js +13 -13
  46. package/src/components/AppFrame/Anchor.js +7 -7
  47. package/src/components/AppFrame/AppFrame.js +3 -3
  48. package/src/components/AppFrame/Help.js +4 -4
  49. package/src/components/AppFrame/MenuItem.js +14 -14
  50. package/src/components/AppFrame/Preferences.js +14 -14
  51. package/src/components/AppFrame/Sidebar.js +6 -6
  52. package/src/components/AppFrame/Topbar.js +6 -6
  53. package/src/components/DropMenu/Menu.js +9 -9
  54. package/src/components/Form/Field.js +4 -4
  55. package/src/components/Form/Inputs/Button.js +2 -2
  56. package/src/components/Form/Inputs/MultiSelector.js +55 -5
  57. package/src/components/Form/Inputs/MultiSelector.test.js +259 -39
  58. package/src/components/Form/Inputs/Selector.js +12 -4
  59. package/src/components/Form/Inputs/Selector.test.js +27 -12
  60. package/src/components/InternetExplorerWarningMessage.js +15 -15
  61. package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
  62. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  63. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
  64. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +74 -0
  65. package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  66. package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  67. package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  68. package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  69. package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
  70. package/src/components/MaterialUI/Inputs/InputBase.js +209 -8
  71. package/src/components/MaterialUI/Inputs/InputBase.test.js +481 -3
  72. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  73. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
  74. package/src/components/MaterialUI/Inputs/Select.js +140 -87
  75. package/src/components/MaterialUI/Inputs/Select.test.js +170 -30
  76. package/src/components/MaterialUI/Inputs/SelectProps.js +9 -1
  77. package/src/components/MaterialUI/Inputs/SelectProps.test.js +8 -0
  78. package/src/components/MaterialUI/Inputs/Switch.js +1 -1
  79. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
  80. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
  81. package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
  82. package/src/components/MaterialUI/muiThemes.js +1 -1
  83. package/src/components/Routing/SegmentPage.js +7 -7
  84. package/src/components/Scope/ScopeNode.js +7 -8
  85. package/src/components/Sidepanel.js +7 -7
  86. package/src/components/Sidepanel.test.js +9 -4
  87. package/src/components/Spritesheet.js +5 -5
  88. package/src/components/ToastList.js +11 -11
  89. package/src/components/Treeview/Branch.js +10 -10
  90. package/src/components/Treeview/Branch.test.js +2 -40
  91. package/src/components/Treeview/Label.js +9 -9
  92. package/src/components/Treeview/Label.test.js +13 -3
  93. package/src/components/Treeview/Leaf.js +3 -3
  94. package/src/components/Treeview/Leaf.test.js +1 -20
  95. package/src/components/Treeview/settings.js +3 -0
  96. package/src/hocs/withScrollBox.js +2 -8
  97. package/src/hooks/useMultipleFieldEditState.test.js +0 -1
  98. package/src/hooks/useWindowSize.js +39 -0
  99. package/src/hooks/useWindowSize.test.js +68 -0
  100. package/src/sharedMessages.js +8 -0
  101. package/src/translations/en-US.json +2 -0
  102. package/src/translations/fr-CA.json +2 -0
@@ -1,17 +1,23 @@
1
1
  import React from "react";
2
2
  import sinon from "sinon";
3
- import MultiSelector, { selectEventUpdater } from "./MultiSelector";
4
- import { TestWrapper, createMuiTheme } from "../../../utils/testUtils";
3
+ import MultiSelector from "./MultiSelector";
4
+ import { TestWrapper, createMuiTheme, extractMessages } from "../../../utils/testUtils";
5
5
  import Immutable from "immutable";
6
6
  import SelectMUI from "@material-ui/core/Select";
7
7
  import MenuItem from "@material-ui/core/MenuItem";
8
8
  import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
9
9
  import Icon from "../../MaterialUI/DataDisplay/Icon";
10
+ import FormControl from "@material-ui/core/FormControl";
11
+ import { render, screen, fireEvent } from "@testing-library/react";
12
+ import sharedMessages from "../../../sharedMessages";
13
+
14
+ const messages = extractMessages(sharedMessages);
10
15
 
11
16
  describe("MultiSelector", () => {
12
- let update, state, store, chevronDown;
17
+ let update, state, store, chevronDown, multipleRenderValue;
13
18
  beforeEach(() => {
14
19
  update = sinon.spy().named("update");
20
+ multipleRenderValue = sinon.fake.returns("En, It");
15
21
 
16
22
  state = Immutable.fromJS({
17
23
  locale: {
@@ -34,7 +40,7 @@ describe("MultiSelector", () => {
34
40
 
35
41
  it("renders a multi selector with multiple options", () =>
36
42
  expect(
37
- <TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
43
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
38
44
  <MultiSelector
39
45
  update={update}
40
46
  value={["English"]}
@@ -46,32 +52,34 @@ describe("MultiSelector", () => {
46
52
  </TestWrapper>,
47
53
  "when mounted",
48
54
  "to satisfy",
49
- <TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
50
- <SelectMUI
51
- value={["English"]}
52
- disableUnderline={true}
53
- IconComponent={chevronDown}
54
- error={false}
55
- multiple={true}
56
- renderValue={selected => selected.join(", ")}
57
- >
58
- <MenuItem key="English" value="English">
59
- <TooltippedTypography children="English" titleValue="English" />
60
- </MenuItem>
61
- <MenuItem key="Francais" value="Francais">
62
- <TooltippedTypography noWrap children="Francais" titleValue="Francais" />
63
- </MenuItem>
64
- </SelectMUI>
55
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
56
+ <FormControl>
57
+ <SelectMUI
58
+ value={["English"]}
59
+ disableUnderline={true}
60
+ IconComponent={chevronDown}
61
+ error={false}
62
+ multiple={true}
63
+ renderValue={selected => selected.join(", ")}
64
+ >
65
+ <MenuItem key="English" value="English">
66
+ <TooltippedTypography children="English" titleValue="English" />
67
+ </MenuItem>
68
+ <MenuItem key="Francais" value="Francais">
69
+ <TooltippedTypography noWrap children="Francais" titleValue="Francais" />
70
+ </MenuItem>
71
+ </SelectMUI>
72
+ </FormControl>
65
73
  </TestWrapper>,
66
74
  ));
67
75
 
68
- it("renders a multi selector with an error", () => {
76
+ it("renders a multi selector with select all and clear options without errors", () =>
69
77
  expect(
70
- <TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
78
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
71
79
  <MultiSelector
72
80
  update={update}
73
- required={true}
74
- value={[]}
81
+ addClearSelectAll={true}
82
+ value={["English"]}
75
83
  options={[
76
84
  { value: "English", label: "English" },
77
85
  { value: "Francais", label: "Francais" },
@@ -80,9 +88,16 @@ describe("MultiSelector", () => {
80
88
  </TestWrapper>,
81
89
  "when mounted",
82
90
  "to satisfy",
83
- <TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
84
- <div>
85
- <SelectMUI value={[""]} disableUnderline={true} IconComponent={chevronDown} error={true} multiple={true}>
91
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
92
+ <FormControl>
93
+ <SelectMUI
94
+ value={["English"]}
95
+ disableUnderline={true}
96
+ IconComponent={chevronDown}
97
+ error={false}
98
+ multiple={false}
99
+ renderValue={selected => selected.join(", ")}
100
+ >
86
101
  <MenuItem key="English" value="English">
87
102
  <TooltippedTypography children="English" titleValue="English" />
88
103
  </MenuItem>
@@ -90,23 +105,228 @@ describe("MultiSelector", () => {
90
105
  <TooltippedTypography noWrap children="Francais" titleValue="Francais" />
91
106
  </MenuItem>
92
107
  </SelectMUI>
93
- <div></div>
94
- </div>
108
+ </FormControl>
95
109
  </TestWrapper>,
110
+ ));
111
+
112
+ it("Expect multipleRenderValue to be called and selection to be rendered correctly", () => {
113
+ const allOptions = [
114
+ { value: "English", label: "English" },
115
+ { value: "Francais", label: "Francais" },
116
+ { value: "Italiano", label: "Italiano" },
117
+ ];
118
+
119
+ const multiSelector = (
120
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
121
+ <MultiSelector
122
+ update={update}
123
+ multipleRenderValue={multipleRenderValue}
124
+ value={["English", "Italiano"]}
125
+ options={allOptions}
126
+ />
127
+ </TestWrapper>
96
128
  );
129
+
130
+ render(multiSelector);
131
+
132
+ const selectionText = screen.queryByText("En, It");
133
+
134
+ expect(selectionText, "not to be null");
135
+ expect(multipleRenderValue, "to have a call satisfying", { args: [["English", "Italiano"], allOptions] });
97
136
  });
98
- });
99
137
 
100
- describe("selectEventUpdater", () => {
101
- let update;
102
- beforeEach(() => {
103
- update = sinon.spy().named("update");
138
+ it("Expect to have both 'Select All' and 'Clear' options to be available with partial selection", () => {
139
+ const multiSelector = (
140
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
141
+ <MultiSelector
142
+ update={update}
143
+ addClearSelectAll={true}
144
+ value={["English"]}
145
+ options={[
146
+ { value: "English", label: "English" },
147
+ { value: "Francais", label: "Francais" },
148
+ ]}
149
+ />
150
+ </TestWrapper>
151
+ );
152
+
153
+ render(multiSelector);
154
+
155
+ const selectButton = screen.getByRole("button");
156
+ fireEvent.mouseDown(selectButton);
157
+
158
+ const selectAllOption = screen.queryByText("Select All");
159
+ const clearOption = screen.queryByText("Clear");
160
+
161
+ expect(selectAllOption, "not to be null");
162
+ expect(clearOption, "not to be null");
104
163
  });
105
164
 
106
- it("creates a handler for an event and calls update with the value of the target", () =>
107
- expect(selectEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
108
- expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
109
- ));
165
+ it("Expect to have only 'Clear' option to be available with all options being selected", () => {
166
+ const multiSelector = (
167
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
168
+ <MultiSelector
169
+ update={update}
170
+ addClearSelectAll={true}
171
+ value={["English", "Francais"]}
172
+ options={[
173
+ { value: "English", label: "English" },
174
+ { value: "Francais", label: "Francais" },
175
+ ]}
176
+ />
177
+ </TestWrapper>
178
+ );
179
+
180
+ render(multiSelector);
181
+
182
+ const selectButton = screen.getByRole("button");
183
+ fireEvent.mouseDown(selectButton);
184
+
185
+ const selectAllOption = screen.queryByText("Select All");
186
+ const clearOption = screen.queryByText("Clear");
187
+
188
+ expect(selectAllOption, "to be null");
189
+ expect(clearOption, "not to be null");
190
+ });
191
+
192
+ it("Expect to have only 'Select All' option to be available with an empty selection", () => {
193
+ const multiSelector = (
194
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
195
+ <MultiSelector
196
+ update={update}
197
+ addClearSelectAll={true}
198
+ value={[]}
199
+ options={[
200
+ { value: "English", label: "English" },
201
+ { value: "Francais", label: "Francais" },
202
+ ]}
203
+ />
204
+ </TestWrapper>
205
+ );
206
+
207
+ render(multiSelector);
208
+
209
+ const selectButton = screen.getByRole("button");
210
+ fireEvent.mouseDown(selectButton);
211
+
212
+ const selectAllOption = screen.queryByText("Select All");
213
+ const clearOption = screen.queryByText("Clear");
110
214
 
111
- it("is memoized", () => expect(selectEventUpdater, "called with", [update], "to be", selectEventUpdater(update)));
215
+ expect(selectAllOption, "not to be null");
216
+ expect(clearOption, "to be null");
217
+ });
218
+
219
+ it("Picking one selection should update with it along with existing ones", () => {
220
+ const multiSelector = (
221
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
222
+ <MultiSelector
223
+ update={update}
224
+ addClearSelectAll={true}
225
+ value={["English"]}
226
+ options={[
227
+ { value: "English", label: "English" },
228
+ { value: "Francais", label: "Francais" },
229
+ { value: "Italiano", label: "Italiano" },
230
+ ]}
231
+ />
232
+ </TestWrapper>
233
+ );
234
+
235
+ render(multiSelector);
236
+
237
+ const selectButton = screen.getByRole("button");
238
+ fireEvent.mouseDown(selectButton);
239
+
240
+ const optionToSelect = screen.getByText("Italiano");
241
+ fireEvent.click(optionToSelect);
242
+
243
+ expect(update, "to have calls satisfying", [{ args: [["English", "Italiano"]] }]);
244
+ });
245
+
246
+ it("The 'Select All' option should update with all values", () => {
247
+ const multiSelector = (
248
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
249
+ <MultiSelector
250
+ update={update}
251
+ addClearSelectAll={true}
252
+ value={["English"]}
253
+ options={[
254
+ { value: "English", label: "English" },
255
+ { value: "Francais", label: "Francais" },
256
+ { value: "Italiano", label: "Italiano" },
257
+ ]}
258
+ />
259
+ </TestWrapper>
260
+ );
261
+
262
+ render(multiSelector);
263
+
264
+ const selectButton = screen.getByRole("button");
265
+ fireEvent.mouseDown(selectButton);
266
+
267
+ const optionToSelect = screen.getByText("Select All");
268
+ fireEvent.click(optionToSelect);
269
+
270
+ expect(update, "to have calls satisfying", [{ args: [["English", "Francais", "Italiano"]] }]);
271
+ });
272
+
273
+ it("The 'Clear' option should update with an empty list", () => {
274
+ const multiSelector = (
275
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
276
+ <MultiSelector
277
+ update={update}
278
+ addClearSelectAll={true}
279
+ value={["English"]}
280
+ options={[
281
+ { value: "English", label: "English" },
282
+ { value: "Francais", label: "Francais" },
283
+ { value: "Italiano", label: "Italiano" },
284
+ ]}
285
+ />
286
+ </TestWrapper>
287
+ );
288
+
289
+ render(multiSelector);
290
+
291
+ const selectButton = screen.getByRole("button");
292
+ fireEvent.mouseDown(selectButton);
293
+
294
+ const optionToSelect = screen.getByText("Clear");
295
+ fireEvent.click(optionToSelect);
296
+
297
+ expect(update, "to have calls satisfying", [{ args: [[]] }]);
298
+ });
299
+
300
+ it("renders a multi selector with an error", () => {
301
+ expect(
302
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
303
+ <MultiSelector
304
+ update={update}
305
+ required={true}
306
+ value={[]}
307
+ options={[
308
+ { value: "English", label: "English" },
309
+ { value: "Francais", label: "Francais" },
310
+ ]}
311
+ />
312
+ </TestWrapper>,
313
+ "when mounted",
314
+ "to satisfy",
315
+ <TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
316
+ <FormControl>
317
+ <div>
318
+ <SelectMUI value={[""]} disableUnderline={true} IconComponent={chevronDown} error={true} multiple={true}>
319
+ <MenuItem key="English" value="English">
320
+ <TooltippedTypography children="English" titleValue="English" />
321
+ </MenuItem>
322
+ <MenuItem key="Francais" value="Francais">
323
+ <TooltippedTypography noWrap children="Francais" titleValue="Francais" />
324
+ </MenuItem>
325
+ </SelectMUI>
326
+ <div></div>
327
+ </div>
328
+ </FormControl>
329
+ </TestWrapper>,
330
+ );
331
+ });
112
332
  });
@@ -1,17 +1,25 @@
1
1
  import React from "react";
2
2
  import Select from "../../MaterialUI/Inputs/Select";
3
- import { memoize } from "../../../utils";
4
3
  import SelectProps from "../../MaterialUI/Inputs/SelectProps";
5
4
 
6
- export const selectEventUpdater = memoize(update => value => update(value));
7
-
8
5
  const Selector = ({ value, options, update, ...props }) => {
9
6
  const selectProps = new SelectProps();
10
7
 
11
8
  selectProps.set(SelectProps.propNames.value, value);
12
9
  selectProps.set(SelectProps.propNames.onClose, props.onBlur);
13
10
  selectProps.set(SelectProps.propNames.disabled, props.disabled);
14
- selectProps.set(SelectProps.propNames.update, selectEventUpdater(update));
11
+ selectProps.set(SelectProps.propNames.update, update);
12
+ selectProps.set(SelectProps.propNames.autoWidth, false);
13
+ selectProps.set(SelectProps.propNames.positionOverride, {
14
+ anchorOrigin: {
15
+ vertical: "bottom",
16
+ horizontal: "left",
17
+ },
18
+ transformOrigin: {
19
+ vertical: "top",
20
+ horizontal: "left",
21
+ },
22
+ });
15
23
 
16
24
  const hasError = props.required && !value ? true : false;
17
25
  selectProps.set(SelectProps.propNames.error, hasError);
@@ -1,12 +1,13 @@
1
1
  import React from "react";
2
2
  import sinon from "sinon";
3
- import Selector, { selectEventUpdater } from "./Selector";
3
+ import Selector from "./Selector";
4
4
  import { TestWrapper, createMuiTheme } from "./../../../utils/testUtils";
5
5
  import Immutable from "immutable";
6
6
  import SelectMUI from "@material-ui/core/Select";
7
7
  import MenuItem from "@material-ui/core/MenuItem";
8
8
  import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
9
9
  import Icon from "../../MaterialUI/DataDisplay/Icon";
10
+ import { mount } from "enzyme";
10
11
 
11
12
  describe("Selector", () => {
12
13
  let update, state, store, chevronDown;
@@ -88,18 +89,32 @@ describe("Selector", () => {
88
89
  </TestWrapper>,
89
90
  );
90
91
  });
91
- });
92
92
 
93
- describe("selectEventUpdater", () => {
94
- let update;
95
- beforeEach(() => {
96
- update = sinon.spy().named("update");
97
- });
93
+ it("Update is invoked when selection has changed", () => {
94
+ const mountedComponent = mount(
95
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider intlProvider>
96
+ <Selector
97
+ update={update}
98
+ required={true}
99
+ value={null}
100
+ options={[
101
+ { value: "English", label: "English" },
102
+ { value: "Francais", label: "Francais" },
103
+ ]}
104
+ />
105
+ </TestWrapper>,
106
+ );
98
107
 
99
- it("creates a handler for an event and calls update with the value of the target", () =>
100
- expect(selectEventUpdater, "called with", [update], "called with", ["foo"]).then(() =>
101
- expect(update, "to have calls satisfying", [{ args: ["foo"] }]),
102
- ));
108
+ const selectMui = mountedComponent.find(SelectMUI);
103
109
 
104
- it("is memoized", () => expect(selectEventUpdater, "called with", [update], "to be", selectEventUpdater(update)));
110
+ const event = {
111
+ target: {
112
+ value: "Francais",
113
+ },
114
+ };
115
+
116
+ selectMui.invoke("onChange")(event);
117
+
118
+ expect(update, "to have calls satisfying", [{ args: ["Francais"] }]);
119
+ });
105
120
  });
@@ -8,29 +8,29 @@ import sharedMessages from "../sharedMessages";
8
8
  const useStyles = makeStyles(theme => ({
9
9
  container: {
10
10
  fontFamily: "'Open Sans', sans-serif",
11
- fontSize: "14px",
11
+ fontSize: theme.spacing(1.4),
12
12
  background: "rgba(255,255,255,0.85)",
13
- maxWidth: "700px",
14
- width: "calc(100% - 40px)",
13
+ maxWidth: theme.spacing(70),
14
+ width: `calc(100% - ${theme.spacing(4)})`,
15
15
  display: "block",
16
16
  top: "50%",
17
17
  left: "50%",
18
18
  position: "absolute",
19
- boxShadow: "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)",
19
+ boxShadow: `${theme.spacing(0, 0.4, 0.8, 0)} rgba(0, 0, 0, 0.2), ${theme.spacing(0, 0.6, 2, 0)} rgba(0, 0, 0, 0.19)`,
20
20
  transform: "translateY(-50%) translateX(-50%)",
21
- padding: "80px",
22
- borderRadius: "3px",
21
+ padding: theme.spacing(8),
22
+ borderRadius: theme.spacing(0.3),
23
23
  "& header": {
24
- paddingBottom: "20px",
25
- marginBottom: "20px",
24
+ paddingBottom: theme.spacing(2),
25
+ marginBottom: theme.spacing(2),
26
26
  borderBottom: "1px solid #999",
27
27
  "& h1": {
28
28
  fontWeight: 400,
29
- fontWize: "30px",
29
+ fontWize: theme.spacing(3),
30
30
  marginTop: 0,
31
- marginBottom: "5px",
31
+ marginBottom: theme.spacing(0.5),
32
32
  "& p": {
33
- fontSize: "16px",
33
+ fontSize: theme.spacing(1.6),
34
34
  margin: 0,
35
35
  color: "#999",
36
36
  fontWeight: 400,
@@ -43,7 +43,7 @@ const useStyles = makeStyles(theme => ({
43
43
  flexWrap: "wrap",
44
44
  width: "100%",
45
45
  boxSizing: "border-box",
46
- marginTop: "40px",
46
+ marginTop: theme.spacing(4),
47
47
  },
48
48
  gridItem: {
49
49
  display: "flex",
@@ -52,16 +52,16 @@ const useStyles = makeStyles(theme => ({
52
52
  flexDirection: "column",
53
53
  },
54
54
  browserIconContainer: {
55
- width: "48px",
55
+ width: theme.spacing(4.8),
56
56
  textAlign: "center",
57
57
  },
58
58
  browserIconCaption: {
59
- fontSize: "11px",
59
+ fontSize: theme.spacing(1.1),
60
60
  color: "#999",
61
61
  },
62
62
  browserIcon: {
63
63
  stroke: "none",
64
- fontSize: "48px",
64
+ fontSize: theme.spacing(4.8),
65
65
  },
66
66
  }));
67
67
 
@@ -24,12 +24,12 @@ const useStyles = makeStyles(theme => ({
24
24
  },
25
25
  containerWide: {
26
26
  width: theme.spacing(106.4),
27
- height: `calc(100% - 80px)`,
27
+ height: `calc(100% - ${theme.spacing(8)})`,
28
28
  maxHeight: theme.spacing(73),
29
29
  },
30
30
  containerFullwidth: {
31
- width: `calc(100% - 80px)`,
32
- height: `calc(100% - 80px)`,
31
+ width: `calc(100% - ${theme.spacing(8)})`,
32
+ height: `calc(100% - ${theme.spacing(8)})`,
33
33
  },
34
34
  title: {
35
35
  height: theme.spacing(4),
@@ -44,18 +44,18 @@ const useStyles = makeStyles(theme => ({
44
44
  },
45
45
  textSkeleton: {
46
46
  width: "100%",
47
- height: 6,
47
+ height: theme.spacing(0.6),
48
48
  animation: false,
49
49
  },
50
50
  chipSkeleton: {
51
- width: 60,
52
- height: 25,
51
+ width: theme.spacing(6),
52
+ height: theme.spacing(2.5),
53
53
  animation: false,
54
- borderRadius: "15px",
54
+ borderRadius: theme.spacing(1.5),
55
55
  },
56
56
  radioSkeleton: {
57
- width: 17,
58
- height: 17,
57
+ width: theme.spacing(1.7),
58
+ height: theme.spacing(1.7),
59
59
  animation: false,
60
60
  },
61
61
  root: {
@@ -73,7 +73,7 @@ const useStyles = makeStyles(theme => ({
73
73
  },
74
74
  active: {
75
75
  backgroundColor: `${theme.palette.primary.dark} !important`,
76
- boxShadow: "inset 10px 0 10px 1px rgba(0,0,0,0.18)",
76
+ boxShadow: `inset ${theme.spacing(1, 0, 1, 0.1)} rgba(0,0,0,0.18)`,
77
77
 
78
78
  "&:after": {
79
79
  borderLeftColor: `${theme.palette.primary.dark} !important`,
@@ -165,7 +165,7 @@ const StepperModal = ({
165
165
  <FormattedMessage {...sharedMessages.cancel} />
166
166
  </Button>
167
167
 
168
- {currentStep < steps.length - 1 &&
168
+ {(currentStep < steps.length - 1 || steps[currentStep]?.isIntermediate) &&
169
169
  (steps[currentStep]?.actions?.length > 0 ? (
170
170
  steps[currentStep].actions.map(action => (
171
171
  <Button
@@ -191,7 +191,7 @@ const StepperModal = ({
191
191
  </Button>
192
192
  ))}
193
193
 
194
- {currentStep === steps.length - 1 && (
194
+ {currentStep === steps.length - 1 && !steps[currentStep]?.isIntermediate && (
195
195
  <Button
196
196
  variant="contained"
197
197
  color="primary"
@@ -335,6 +335,80 @@ describe("StepperModal", () => {
335
335
  expect(okCallback, "was called");
336
336
  });
337
337
 
338
+ it("Renders StepperModal correctly without confirm button for an intermediate step", () => {
339
+ const open = true;
340
+ const title = "title";
341
+ const backdropClickCallback = jest.fn();
342
+ const okCallback = jest.fn();
343
+ const cancelCallback = jest.fn();
344
+ const modalProps = new ModalProps();
345
+ const actions = [
346
+ {
347
+ value: "first value",
348
+ label: "first action",
349
+ Handler: () => {},
350
+ },
351
+ {
352
+ value: "second value",
353
+ label: "second action",
354
+ Handler: () => {},
355
+ },
356
+ ];
357
+ const steps = [{ title: "step1", content: <div>content</div>, actions, isIntermediate: true }];
358
+
359
+ const titleComponent = (
360
+ <div>
361
+ <div>{title}</div>
362
+ <div>step1</div>
363
+ </div>
364
+ );
365
+ const messageComponent = <div>{steps[0].content}</div>;
366
+
367
+ modalProps.set(ModalProps.propNames.title, titleComponent);
368
+ modalProps.set(ModalProps.propNames.open, open);
369
+ modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
370
+ modalProps.set(ModalProps.propNames.type, "wide");
371
+
372
+ const actionPanel = (
373
+ <div>
374
+ <div></div>
375
+ <div>
376
+ <Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
377
+ {sharedMessages.cancel.defaultMessage}
378
+ </Button>
379
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
380
+ first action
381
+ </Button>
382
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
383
+ second action
384
+ </Button>
385
+ </div>
386
+ </div>
387
+ );
388
+
389
+ modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
390
+
391
+ const component = (
392
+ <IntlProvider locale="en-US" messages={messages}>
393
+ <StepperModal
394
+ steps={steps}
395
+ title={title}
396
+ open={open}
397
+ confirmCallback={okCallback}
398
+ closeCallback={cancelCallback}
399
+ />
400
+ </IntlProvider>
401
+ );
402
+
403
+ const expected = (
404
+ <IntlProvider locale="en-US" messages={messages}>
405
+ <Modal message={messageComponent} modalProps={modalProps} />
406
+ </IntlProvider>
407
+ );
408
+
409
+ expect(component, "when mounted", "to satisfy", expected);
410
+ });
411
+
338
412
  it("Render closed modal", () => {
339
413
  const open = false;
340
414
 
@@ -17,7 +17,7 @@ const useStyles = makeStyles(theme => ({
17
17
  label: {
18
18
  fontSize: theme.typography.h2Size,
19
19
  fontFamily: theme.typography.fontFamily,
20
- fontWeight: theme.typography.fontWeightMedium,
20
+ fontWeight: theme.typography.fontWeightRegular,
21
21
  },
22
22
  }));
23
23
 
@@ -29,7 +29,7 @@ const useStyles = makeStyles(theme => ({
29
29
  },
30
30
  "&::-webkit-scrollbar-thumb": {
31
31
  background: theme.palette.grey.borders,
32
- border: `5px white solid`,
32
+ border: `${theme.spacing(0.5)} white solid`,
33
33
  backgroundClip: "padding-box",
34
34
  borderRadius: theme.spacing(1.5),
35
35
  },