orc-shared 5.10.2 → 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 (234) 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 +17 -26
  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/ApplicationModuleLoader.js +3 -2
  10. package/dist/components/Authenticate.js +29 -22
  11. package/dist/components/DropMenu/Menu.js +9 -9
  12. package/dist/components/ErrorPlaceholder.js +8 -24
  13. package/dist/components/Form/Field.js +4 -4
  14. package/dist/components/Form/Inputs/Button.js +2 -2
  15. package/dist/components/Form/Inputs/MultiSelector.js +137 -0
  16. package/dist/components/Form/Inputs/Selector.js +13 -10
  17. package/dist/components/Form/Inputs/index.js +1 -1
  18. package/dist/components/InternetExplorerWarningMessage.js +15 -15
  19. package/dist/components/LoadingIcon.js +38 -17
  20. package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
  21. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  22. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -1
  23. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  24. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  25. package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
  26. package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
  27. package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  28. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  29. package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
  30. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  31. package/dist/components/MaterialUI/Inputs/Select.js +175 -109
  32. package/dist/components/MaterialUI/Inputs/SelectProps.js +11 -1
  33. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  34. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  35. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
  36. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
  37. package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
  38. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
  39. package/dist/components/MaterialUI/muiThemes.js +3 -1
  40. package/dist/components/Provision.js +30 -13
  41. package/dist/components/Routing/SegmentPage.js +117 -56
  42. package/dist/components/Scope/ScopeNode.js +62 -57
  43. package/dist/components/Sidepanel.js +59 -23
  44. package/dist/components/Spritesheet.js +35 -17
  45. package/dist/components/Text.js +1 -60
  46. package/dist/components/ToastList.js +95 -64
  47. package/dist/components/Treeview/Branch.js +82 -20
  48. package/dist/components/Treeview/Label.js +108 -31
  49. package/dist/components/Treeview/Leaf.js +56 -12
  50. package/dist/components/Treeview/Node.js +22 -9
  51. package/dist/components/Treeview/index.js +7 -1
  52. package/dist/components/Treeview/settings.js +17 -6
  53. package/dist/{components/Modal/index.js → hooks/useWindowSize.js} +38 -36
  54. package/dist/sharedMessages.js +8 -0
  55. package/dist/utils/index.js +0 -4
  56. package/dist/utils/testUtils.js +1 -12
  57. package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
  58. package/package.json +2 -2
  59. package/src/components/AppFrame/About.js +13 -13
  60. package/src/components/AppFrame/Anchor.js +7 -7
  61. package/src/components/AppFrame/AppFrame.js +3 -3
  62. package/src/components/AppFrame/Help.js +4 -4
  63. package/src/components/AppFrame/MenuItem.js +15 -23
  64. package/src/components/AppFrame/Preferences.js +14 -14
  65. package/src/components/AppFrame/Sidebar.js +6 -6
  66. package/src/components/AppFrame/Topbar.js +6 -6
  67. package/src/components/ApplicationModuleLoader.js +2 -2
  68. package/src/components/ApplicationModuleLoader.test.js +15 -28
  69. package/src/components/Authenticate.js +21 -23
  70. package/src/components/Authenticate.test.js +19 -27
  71. package/src/components/DropMenu/Menu.js +9 -9
  72. package/src/components/ErrorPlaceholder.js +4 -21
  73. package/src/components/ErrorPlaceholder.test.js +7 -14
  74. package/src/components/Form/Field.js +4 -4
  75. package/src/components/Form/InputField.test.js +2 -1
  76. package/src/components/Form/Inputs/Button.js +2 -2
  77. package/src/components/Form/Inputs/MultiSelector.js +73 -0
  78. package/src/components/Form/Inputs/MultiSelector.test.js +332 -0
  79. package/src/components/Form/Inputs/Selector.js +12 -4
  80. package/src/components/Form/Inputs/Selector.test.js +27 -12
  81. package/src/components/Form/Inputs/index.js +1 -1
  82. package/src/components/InternetExplorerWarningMessage.js +15 -15
  83. package/src/components/Loader.test.js +50 -59
  84. package/src/components/LoadingIcon.js +27 -14
  85. package/src/components/LoadingIcon.test.js +11 -15
  86. package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
  87. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  88. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -1
  89. package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  90. package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  91. package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
  92. package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
  93. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  94. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
  95. package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  96. package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  97. package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
  98. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  99. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
  100. package/src/components/MaterialUI/Inputs/Select.js +143 -83
  101. package/src/components/MaterialUI/Inputs/Select.test.js +199 -14
  102. package/src/components/MaterialUI/Inputs/SelectProps.js +10 -0
  103. package/src/components/MaterialUI/Inputs/SelectProps.test.js +10 -0
  104. package/src/components/MaterialUI/Inputs/Switch.js +1 -1
  105. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  106. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  107. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
  108. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
  109. package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
  110. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
  111. package/src/components/MaterialUI/muiThemes.js +4 -1
  112. package/src/components/Navigation/Navigation.test.js +0 -5
  113. package/src/components/Navigation/useNavigationState.test.js +79 -222
  114. package/src/components/Provision.js +36 -42
  115. package/src/components/Provision.test.js +10 -26
  116. package/src/components/Routing/SegmentPage.js +68 -52
  117. package/src/components/Routing/SegmentPage.test.js +4 -12
  118. package/src/components/Scope/ScopeNode.js +44 -55
  119. package/src/components/Scope/ScopeNode.test.js +84 -163
  120. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  121. package/src/components/Sidepanel.js +38 -32
  122. package/src/components/Sidepanel.test.js +54 -27
  123. package/src/components/Spritesheet.js +23 -21
  124. package/src/components/Spritesheet.test.js +10 -10
  125. package/src/components/Text.js +0 -49
  126. package/src/components/ToastList.js +79 -90
  127. package/src/components/ToastList.test.js +29 -103
  128. package/src/components/Treeview/Branch.js +65 -47
  129. package/src/components/Treeview/Branch.test.js +2 -43
  130. package/src/components/Treeview/Label.js +68 -54
  131. package/src/components/Treeview/Label.test.js +55 -63
  132. package/src/components/Treeview/Leaf.js +41 -22
  133. package/src/components/Treeview/Leaf.test.js +1 -15
  134. package/src/components/Treeview/Node.js +16 -9
  135. package/src/components/Treeview/Node.test.js +269 -200
  136. package/src/components/Treeview/Treeview.test.js +248 -248
  137. package/src/components/Treeview/index.js +6 -0
  138. package/src/components/Treeview/settings.js +10 -6
  139. package/src/hooks/useMultipleFieldEditState.test.js +0 -1
  140. package/src/hooks/useWindowSize.js +39 -0
  141. package/src/hooks/useWindowSize.test.js +68 -0
  142. package/src/sharedMessages.js +8 -0
  143. package/src/translations/en-US.json +2 -0
  144. package/src/translations/fr-CA.json +2 -0
  145. package/src/utils/index.js +0 -4
  146. package/src/utils/testUtils.js +0 -10
  147. package/src/utils/testUtils.test.js +0 -68
  148. package/src/utils/toastHelper.js +8 -0
  149. package/src/utils/toastHelper.test.js +41 -0
  150. package/dist/components/Button.js +0 -70
  151. package/dist/components/CategoryList.js +0 -197
  152. package/dist/components/Checkbox.js +0 -103
  153. package/dist/components/Icon.js +0 -69
  154. package/dist/components/IconButton.js +0 -80
  155. package/dist/components/Input.js +0 -101
  156. package/dist/components/List/DataCell.js +0 -129
  157. package/dist/components/List/HeadCell.js +0 -125
  158. package/dist/components/List/HeadRow.js +0 -73
  159. package/dist/components/List/List.js +0 -274
  160. package/dist/components/List/Row.js +0 -109
  161. package/dist/components/List/enhanceColumnDefs.js +0 -111
  162. package/dist/components/List/index.js +0 -59
  163. package/dist/components/Modal/Dialog.js +0 -75
  164. package/dist/components/Modal/Wrapper.js +0 -69
  165. package/dist/components/MultiSelector.js +0 -187
  166. package/dist/components/Navigation/Bar.js +0 -293
  167. package/dist/components/Navigation/Tab.js +0 -182
  168. package/dist/components/Placeholder.js +0 -114
  169. package/dist/components/Scope/Selector.js +0 -123
  170. package/dist/components/Selector.js +0 -185
  171. package/dist/components/Switch.js +0 -128
  172. package/dist/components/Toolbar.js +0 -227
  173. package/dist/components/Tooltip.js +0 -66
  174. package/dist/getTheme.js +0 -158
  175. package/dist/getThemeOverrides.js +0 -93
  176. package/dist/hocs/withAuthentication.js +0 -72
  177. package/dist/utils/styledPropFuncs.js +0 -88
  178. package/src/components/Button.js +0 -90
  179. package/src/components/Button.test.js +0 -49
  180. package/src/components/CategoryList.js +0 -140
  181. package/src/components/CategoryList.test.js +0 -667
  182. package/src/components/Checkbox.js +0 -63
  183. package/src/components/Checkbox.test.js +0 -122
  184. package/src/components/Icon.js +0 -18
  185. package/src/components/IconButton.js +0 -30
  186. package/src/components/IconButton.test.js +0 -61
  187. package/src/components/Input.js +0 -35
  188. package/src/components/Input.test.js +0 -34
  189. package/src/components/List/DataCell.js +0 -77
  190. package/src/components/List/DataCell.test.js +0 -357
  191. package/src/components/List/HeadCell.js +0 -105
  192. package/src/components/List/HeadCell.test.js +0 -331
  193. package/src/components/List/HeadRow.js +0 -21
  194. package/src/components/List/HeadRow.test.js +0 -27
  195. package/src/components/List/List.js +0 -162
  196. package/src/components/List/List.test.js +0 -705
  197. package/src/components/List/Row.js +0 -72
  198. package/src/components/List/Row.test.js +0 -194
  199. package/src/components/List/enhanceColumnDefs.js +0 -54
  200. package/src/components/List/enhanceColumnDefs.test.js +0 -179
  201. package/src/components/List/index.js +0 -6
  202. package/src/components/Modal/Background.js +0 -10
  203. package/src/components/Modal/Dialog.js +0 -27
  204. package/src/components/Modal/Dialog.test.js +0 -20
  205. package/src/components/Modal/Modal.test.js +0 -52
  206. package/src/components/Modal/Wrapper.js +0 -32
  207. package/src/components/Modal/Wrapper.test.js +0 -55
  208. package/src/components/Modal/index.js +0 -22
  209. package/src/components/MultiSelector.js +0 -104
  210. package/src/components/MultiSelector.test.js +0 -348
  211. package/src/components/Navigation/Bar.js +0 -212
  212. package/src/components/Navigation/Bar.test.js +0 -552
  213. package/src/components/Navigation/Tab.js +0 -156
  214. package/src/components/Navigation/Tab.test.js +0 -404
  215. package/src/components/Placeholder.js +0 -61
  216. package/src/components/Placeholder.test.js +0 -106
  217. package/src/components/Scope/Selector.js +0 -70
  218. package/src/components/Scope/Selector.test.js +0 -138
  219. package/src/components/Selector.js +0 -191
  220. package/src/components/Selector.test.js +0 -157
  221. package/src/components/Switch.js +0 -112
  222. package/src/components/Switch.test.js +0 -130
  223. package/src/components/Text.test.js +0 -132
  224. package/src/components/Toolbar.js +0 -178
  225. package/src/components/Toolbar.test.js +0 -478
  226. package/src/components/Tooltip.js +0 -51
  227. package/src/components/Tooltip.test.js +0 -21
  228. package/src/getTheme.js +0 -103
  229. package/src/getTheme.test.js +0 -92
  230. package/src/getThemeOverrides.js +0 -27
  231. package/src/hocs/withAuthentication.js +0 -18
  232. package/src/hocs/withAuthentication.test.js +0 -120
  233. package/src/utils/styledPropFuncs.js +0 -20
  234. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,17 +1,18 @@
1
1
  import React from "react";
2
- import { Provider } from "react-redux";
3
- import { MemoryRouter } from "react-router-dom";
4
2
  import Immutable from "immutable";
5
3
  import { mount } from "enzyme";
4
+ import { ScopeIcon } from "../MaterialUI/ScopeSelector/TreeItem";
6
5
  import sinon from "sinon";
7
- import Icon from "../Icon";
8
- import { ScopeIcon, ContentLabel, ScopeNode, ScopeText } from "./ScopeNode";
6
+ import { ScopeNode } from "./ScopeNode";
9
7
  import { TestWrapper } from "../../utils/testUtils";
8
+ import { createMuiTheme } from "../../utils/testUtils";
9
+
10
+ const theme = createMuiTheme();
10
11
 
11
12
  describe("ScopeNode", () => {
12
- let closeSelector, store;
13
+ let onClick, store;
13
14
  beforeEach(() => {
14
- closeSelector = sinon.spy().named("close");
15
+ onClick = sinon.spy().named("onClick");
15
16
  store = {
16
17
  subscribe: () => {},
17
18
  dispatch: () => {},
@@ -24,208 +25,128 @@ describe("ScopeNode", () => {
24
25
 
25
26
  it("displays an icon and a label for a scope", () =>
26
27
  expect(
27
- <Provider store={store}>
28
- <MemoryRouter>
29
- <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
30
- </MemoryRouter>
31
- </Provider>,
28
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
29
+ <ScopeNode name="A scope" type="test" scopeId="ScopeId" isAuthorizedScope={true} />
30
+ </TestWrapper>,
32
31
  "when mounted",
33
32
  "to satisfy",
34
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
35
- <ScopeIcon type="test" />
36
- <ScopeText>A scope</ScopeText>
37
- </ContentLabel>,
33
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
34
+ <div id="selectorNodeScopeId">
35
+ <ScopeIcon type="test" />
36
+ <div>A scope</div>
37
+ </div>
38
+ </TestWrapper>,
38
39
  ));
39
40
 
40
41
  it("displays an icon and a label for the global scope", () =>
41
42
  expect(
42
- <Provider store={store}>
43
- <MemoryRouter>
44
- <ScopeNode name="A scope" type="Global" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
45
- </MemoryRouter>
46
- </Provider>,
43
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
44
+ <ScopeNode name="A scope" type="Global" scopeId="ScopeId" isAuthorizedScope={true} />
45
+ </TestWrapper>,
47
46
  "when mounted",
48
47
  "to satisfy",
49
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector} isGlobal={true}>
50
- <ScopeIcon type="Global" />
51
- <ScopeText>A scope</ScopeText>
52
- </ContentLabel>,
48
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
49
+ <div id="selectorNodeScopeId">
50
+ <ScopeIcon type="Global" />
51
+ <div>A scope</div>
52
+ </div>
53
+ </TestWrapper>,
53
54
  ));
54
55
 
55
56
  it("displays an icon and a label for an unauthorized scope", () =>
56
57
  expect(
57
- <Provider store={store}>
58
- <MemoryRouter>
59
- <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} />
60
- </MemoryRouter>
61
- </Provider>,
58
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
59
+ <ScopeNode name="A scope" type="test" scopeId="ScopeId" />
60
+ </TestWrapper>,
62
61
  "when mounted",
63
62
  "to satisfy",
64
- <ContentLabel id="selectorNodeScopeId">
65
- <ScopeIcon type="test" />
66
- <ScopeText>A scope</ScopeText>
67
- </ContentLabel>,
63
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
64
+ <div id="selectorNodeScopeId">
65
+ <ScopeIcon type="test" />
66
+ <div>A scope</div>
67
+ </div>
68
+ </TestWrapper>,
68
69
  ));
69
70
 
70
71
  it("displays an icon and a the fallback id for a scope when name is undefined", () =>
71
72
  expect(
72
- <Provider store={store}>
73
- <MemoryRouter>
74
- <ScopeNode type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
75
- </MemoryRouter>
76
- </Provider>,
73
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
74
+ <ScopeNode type="test" scopeId="ScopeId" isAuthorizedScope={true} />
75
+ </TestWrapper>,
77
76
  "when mounted",
78
77
  "to satisfy",
79
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
80
- <ScopeIcon type="test" />
81
- <ScopeText>ScopeId</ScopeText>
82
- </ContentLabel>,
78
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
79
+ <div id="selectorNodeScopeId">
80
+ <ScopeIcon type="test" />
81
+ <div>ScopeId</div>
82
+ </div>
83
+ </TestWrapper>,
83
84
  ));
84
85
 
85
86
  it("displays an icon and a the fallback id for a scope when name is null", () =>
86
87
  expect(
87
- <Provider store={store}>
88
- <MemoryRouter>
89
- <ScopeNode name={null} type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
90
- </MemoryRouter>
91
- </Provider>,
88
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
89
+ <ScopeNode name={null} type="test" scopeId="ScopeId" isAuthorizedScope={true} />
90
+ </TestWrapper>,
92
91
  "when mounted",
93
92
  "to satisfy",
94
- <ContentLabel id="selectorNodeScopeId" onClick={closeSelector}>
95
- <ScopeIcon type="test" />
96
- <ScopeText>ScopeId</ScopeText>
97
- </ContentLabel>,
93
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
94
+ <div id="selectorNodeScopeId">
95
+ <ScopeIcon type="test" />
96
+ <div>ScopeId</div>
97
+ </div>
98
+ </TestWrapper>,
98
99
  ));
99
100
 
100
101
  it("handles virtual scopes", () =>
101
102
  expect(
102
- <Provider store={store}>
103
- <MemoryRouter>
104
- <ScopeNode
105
- name="A scope"
106
- type="Virtual"
107
- id="ScopeId"
108
- isAuthorizedScope={true}
109
- closeSelector={closeSelector}
110
- />
111
- </MemoryRouter>
112
- </Provider>,
103
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
104
+ <ScopeNode name="A scope" type="Virtual" scopeId="ScopeId" isAuthorizedScope={true} />
105
+ </TestWrapper>,
106
+ "when mounted",
107
+ "to satisfy",
108
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
109
+ <div id="selectorNodeScopeId">
110
+ <ScopeIcon type="Virtual" />
111
+ <div>A scope</div>
112
+ </div>
113
+ </TestWrapper>,
114
+ ));
115
+
116
+ it("displays an icon without label for a scope with custom children", () =>
117
+ expect(
118
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
119
+ <ScopeNode type="test" isAuthorizedScope={true}>
120
+ <div>Another Display Test</div>
121
+ </ScopeNode>
122
+ </TestWrapper>,
113
123
  "when mounted",
114
124
  "to satisfy",
115
- <ContentLabel id="selectorNodeScopeId">
116
- <ScopeIcon type="Virtual" />
117
- <ScopeText>A scope</ScopeText>
118
- </ContentLabel>,
125
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
126
+ <div id="selectorNodescopeUnknown">
127
+ <ScopeIcon type="test" />
128
+ <div>Another Display Test</div>
129
+ </div>
130
+ </TestWrapper>,
119
131
  ));
120
132
 
121
- it("Call onScopeSelect on Node click if scope type is not virtual", () => {
133
+ it("Call onClick on Node click when defined", () => {
122
134
  const component = (
123
- <TestWrapper provider={{ store }} memoryRouter>
124
- <ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
135
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
136
+ <ScopeNode name="A scope" type="test" scopeId="ScopeId" onClick={onClick} isAuthorizedScope={true} />
125
137
  </TestWrapper>
126
138
  );
127
139
 
128
- const preventDefaultSpy = sinon.spy();
129
-
130
140
  const mountedComponent = mount(component);
131
141
 
132
142
  const event = {
133
- preventDefault: preventDefaultSpy,
143
+ preventDefault: () => {},
134
144
  };
135
145
 
136
- const node = mountedComponent.find(ContentLabel);
146
+ const node = mountedComponent.find("[data-qa='content-label']").first();
137
147
 
138
148
  node.invoke("onClick")(event);
139
149
 
140
- expect(preventDefaultSpy, "was called");
141
- expect(closeSelector, "to have a call satisfying", { args: [event] });
142
- });
143
- });
144
-
145
- describe("ContentLabel", () => {
146
- let onClick;
147
- beforeEach(() => {
148
- onClick = () => {};
149
- });
150
-
151
- it("sets css for authorized Global scope", () =>
152
- expect(
153
- <ContentLabel id="selectorNodeScopeId" isGlobal={true} onClick={onClick} />,
154
- "when mounted",
155
- "to have style rules satisfying",
156
- expect
157
- .it("to contain", "text-transform: uppercase;")
158
- .and("to contain", ":hover {background-color: #222;}")
159
- .and("not to contain", "color: #999999")
160
- .and("not to contain", "cursor: default;"),
161
- ));
162
-
163
- it("sets css for unauthorized Global scope", () =>
164
- expect(
165
- <ContentLabel id="selectorNodeScopeId" isGlobal={true} />,
166
- "when mounted",
167
- "to have style rules satisfying",
168
- expect
169
- .it("to contain", "text-transform: uppercase;")
170
- .and("not to contain", ":hover {background-color: #222;}")
171
- .and("to contain", "color: #999999")
172
- .and("to contain", "cursor: default;"),
173
- ));
174
-
175
- it("sets css for a not-clickable and a non-global scope", () =>
176
- expect(
177
- <ContentLabel isGlobal={false} />,
178
- "when mounted",
179
- "to have style rules satisfying",
180
- expect
181
- .it("not to contain", "text-transform: uppercase;")
182
- .and("not to contain", ":hover {background-color: #222;}")
183
- .and("to contain", "color: #999999")
184
- .and("to contain", "cursor: default;"),
185
- ));
186
-
187
- it("sets css for a clickable and a non-global scope", () =>
188
- expect(
189
- <ContentLabel isGlobal={false} onClick={onClick} />,
190
- "when mounted",
191
- "to have style rules satisfying",
192
- expect
193
- .it("not to contain", "text-transform: uppercase;")
194
- .and("to contain", ":hover {background-color: #222;}")
195
- .and("not to contain", "color: #999999")
196
- .and("not to contain", "cursor: default;"),
197
- ));
198
- });
199
-
200
- describe("ScopeIcon", () => {
201
- let theme;
202
- beforeEach(() => {
203
- theme = {
204
- icons: {
205
- scopeTypes: {
206
- Test: "test-icon",
207
- },
208
- },
209
- colors: {
210
- scopeTypes: {
211
- Test: "#00ff00",
212
- },
213
- },
214
- };
150
+ expect(onClick, "to have a call satisfying", { args: [event] });
215
151
  });
216
-
217
- it("renders an icon with id based on scope type", () =>
218
- expect(<ScopeIcon theme={theme} type="Test" />, "when mounted", "to satisfy", <Icon id="test-icon" />));
219
-
220
- it("renders in a color based on scope type", () =>
221
- expect(
222
- <ScopeIcon theme={theme} type="Test" />,
223
- "when mounted",
224
- "to have style rules satisfying",
225
- "to contain",
226
- "color: #00ff00;",
227
- ));
228
-
229
- it("by default renders a cross", () =>
230
- expect(<ScopeIcon theme={theme} type="N/A" />, "when mounted", "to satisfy", <Icon id="cross" />));
231
152
  });
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import Immutable from "immutable";
3
3
  import { Provider } from "react-redux";
4
- import { ThemeProvider } from "styled-components";
5
4
  import ScopeExtendedConfigurationLoader from "./ScopeExtendedConfigurationLoader";
6
5
  import { mount } from "enzyme";
7
6
  import { getScopeExtendedConfiguration } from "../actions/scopes";
@@ -58,9 +57,7 @@ describe("ScopeExtendedConfigurationLoader", () => {
58
57
 
59
58
  const component = (
60
59
  <Provider store={theStore}>
61
- <ThemeProvider theme={{}}>
62
- <ScopeExtendedConfigurationLoader />
63
- </ThemeProvider>
60
+ <ScopeExtendedConfigurationLoader />
64
61
  </Provider>
65
62
  );
66
63
 
@@ -1,40 +1,46 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
- import transition from "styled-transition-group";
4
-
5
- const getProp = propName => props => props[propName];
6
-
7
- const panelWidth = getProp("width");
3
+ import { CSSTransition } from "react-transition-group";
4
+ import { makeStyles } from "@material-ui/core/styles";
5
+ import classNames from "classnames";
8
6
 
9
7
  const getModalRoot = () => document.getElementById("modal");
10
8
 
11
- export const PanelDrawer = transition.div`
12
- position: absolute;
13
- top: 0;
14
- bottom: 0;
15
- right: 0;
16
- width: ${panelWidth};
17
-
18
- transition: transform ${getProp("timeout")}ms ease-out;
19
-
20
- &:enter {
21
- transform: translateX(${panelWidth});
22
- }
23
- &:enter-active {
24
- transform: translateX(0);
25
- }
26
- &:exit {
27
- transform: translateX(0);
28
- }
29
- &:exit-active {
30
- transform: translateX(${panelWidth});
31
- }
32
- `;
33
- PanelDrawer.defaultProps = {
34
- timeout: 1000,
35
- unmountOnExit: true,
9
+ const useStyles = makeStyles(theme => ({
10
+ panel: props => ({
11
+ position: "absolute",
12
+ top: 0,
13
+ bottom: 0,
14
+ right: 0,
15
+ width: theme.spacing(props.widthSpacing),
16
+
17
+ "&.enter": {
18
+ transform: `translateX(${theme.spacing(props.widthSpacing)})`,
19
+ },
20
+ "&.enter-active": {
21
+ transform: "translateX(0)",
22
+ transition: `transform ${props.timeout}ms ease-out`,
23
+ },
24
+ "&.exit": {
25
+ transform: "translateX(0)",
26
+ },
27
+ "&.exit-active": {
28
+ transform: `translateX(${theme.spacing(props.widthSpacing)})`,
29
+ transition: `transform ${props.timeout}ms ease-out`,
30
+ },
31
+ }),
32
+ }));
33
+
34
+ const Sidepanel = ({ in: inProp, widthSpacing = 30, timeout = 1000, children, className }) => {
35
+ const classes = useStyles({ widthSpacing, timeout });
36
+
37
+ const panel = (
38
+ <CSSTransition in={inProp} timeout={timeout} unmountOnExit>
39
+ <div className={classNames(classes.panel, className)}>{children}</div>
40
+ </CSSTransition>
41
+ );
42
+
43
+ return ReactDOM.createPortal(panel, getModalRoot());
36
44
  };
37
45
 
38
- const Sidepanel = props => ReactDOM.createPortal(<PanelDrawer {...props} />, getModalRoot());
39
-
40
46
  export default Sidepanel;
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
- import Sidepanel, { PanelDrawer } from "./Sidepanel";
3
+ import Sidepanel from "./Sidepanel";
4
+ import { createMuiTheme, TestWrapper } from "../utils/testUtils";
5
+
6
+ const theme = createMuiTheme();
4
7
 
5
8
  class RenderSidepanel extends React.Component {
6
9
  render() {
@@ -32,7 +35,7 @@ describe("Sidepanel", () => {
32
35
  document.body.removeChild(modalRoot);
33
36
  });
34
37
 
35
- it("renders a PanelDrawer in a portal", () => {
38
+ it("renders sidepanel in a portal", () => {
36
39
  ReactDOM.render(
37
40
  <RenderSidepanel in>
38
41
  <div id="inner">Foo</div>
@@ -42,32 +45,56 @@ describe("Sidepanel", () => {
42
45
  return expect(modalRoot, "queried for first", "div#inner", "to be a", "DOMElement");
43
46
  });
44
47
 
45
- describe("PanelDrawer", () => {
46
- it("sets the width it is given", () =>
47
- expect(
48
- <PanelDrawer in width="25vw" />,
49
- "when mounted",
50
- "to have style rules satisfying",
51
- "to contain",
52
- "width: 25vw;",
53
- ));
48
+ it("sets the width it is given", () => {
49
+ ReactDOM.render(
50
+ <TestWrapper muiThemeProvider={{ theme }}>
51
+ <Sidepanel in widthSpacing={25}>
52
+ <div id="inner">Foo</div>
53
+ </Sidepanel>
54
+ </TestWrapper>,
55
+ appRoot,
56
+ );
57
+ return expect(
58
+ modalRoot,
59
+ "queried for first",
60
+ "div#modal > div",
61
+ "to have style rules satisfying",
62
+ "to contain",
63
+ "width: 15.625rem",
64
+ );
65
+ });
54
66
 
55
- it("sets transition according to timeout", () =>
56
- expect(
57
- <PanelDrawer in timeout={300} />,
58
- "when mounted",
59
- "to have style rules satisfying",
60
- "to contain",
61
- "transition: transform 300ms",
62
- ));
67
+ it("sets transition according to timeout", () => {
68
+ ReactDOM.render(
69
+ <Sidepanel in timeout={300}>
70
+ <div id="inner">Foo</div>
71
+ </Sidepanel>,
72
+ appRoot,
73
+ );
74
+ return expect(
75
+ modalRoot,
76
+ "queried for first",
77
+ "div#modal > div",
78
+ "to have style rules satisfying",
79
+ "to contain",
80
+ "transition: transform 300ms",
81
+ );
82
+ });
63
83
 
64
- it("sets default transition", () =>
65
- expect(
66
- <PanelDrawer in />,
67
- "when mounted",
68
- "to have style rules satisfying",
69
- "to contain",
70
- "transition: transform 1000ms",
71
- ));
84
+ it("sets default transition", () => {
85
+ ReactDOM.render(
86
+ <Sidepanel in>
87
+ <div id="inner">Foo</div>
88
+ </Sidepanel>,
89
+ appRoot,
90
+ );
91
+ return expect(
92
+ modalRoot,
93
+ "queried for first",
94
+ "div#modal > div",
95
+ "to have style rules satisfying",
96
+ "to contain",
97
+ "transition: transform 1000ms",
98
+ );
72
99
  });
73
100
  });
@@ -1,35 +1,37 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import Icon from "./Icon";
2
+ import { makeStyles } from "@material-ui/core";
3
+ import Icon from "./MaterialUI/DataDisplay/Icon";
4
4
 
5
- export const Wrapper = styled.div`
6
- display: flex;
7
- flex-wrap: wrap;
8
- justify-content: space-around;
9
- overflow-y: auto;
10
- height: 100%;
11
- `;
12
-
13
- export const IconBlock = styled.div`
14
- flex: 0 0 30%;
15
- border: 1px solid #999;
16
- margin: 5px;
17
- padding: 5px 10px;
18
- font-size: 24px;
19
- `;
5
+ const useStyles = makeStyles(theme => ({
6
+ wrapper: {
7
+ display: "flex",
8
+ flexWrap: "wrap",
9
+ justifyContent: "space-around",
10
+ overflowY: "auto",
11
+ height: "100%",
12
+ },
13
+ iconBlock: {
14
+ flex: "0 0 30%",
15
+ border: "1px solid #999",
16
+ margin: theme.spacing(0.5),
17
+ padding: theme.spacing(0.5, 1),
18
+ fontSize: theme.spacing(2.4),
19
+ },
20
+ }));
20
21
 
21
22
  const arrify = thing => [].slice.call(thing);
22
23
 
23
24
  const SpriteSheet = () => {
25
+ const classes = useStyles();
24
26
  const iconIds = arrify(document.querySelectorAll('symbol[id^="icon-"]')).map(elm => elm.id.replace(/^icon-/, ""));
25
27
  return (
26
- <Wrapper>
28
+ <div className={classes.wrapper}>
27
29
  {iconIds.map(id => (
28
- <IconBlock key={id}>
30
+ <div className={classes.iconBlock} key={id}>
29
31
  <Icon id={id} /> {id}
30
- </IconBlock>
32
+ </div>
31
33
  ))}
32
- </Wrapper>
34
+ </div>
33
35
  );
34
36
  };
35
37
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import Spritesheet, { Wrapper, IconBlock } from "./Spritesheet";
3
- import Icon from "./Icon";
2
+ import Spritesheet from "./Spritesheet";
3
+ import Icon from "./MaterialUI/DataDisplay/Icon";
4
4
 
5
5
  describe("Spritesheet", () => {
6
6
  beforeEach(() => {
@@ -19,16 +19,16 @@ describe("Spritesheet", () => {
19
19
  <Spritesheet />,
20
20
  "when mounted",
21
21
  "to satisfy",
22
- <Wrapper>
23
- <IconBlock>
22
+ <div>
23
+ <div>
24
24
  <Icon id="test-1" /> {"test-1"}
25
- </IconBlock>
26
- <IconBlock>
25
+ </div>
26
+ <div>
27
27
  <Icon id="test-2" /> {"test-2"}
28
- </IconBlock>
29
- <IconBlock>
28
+ </div>
29
+ <div>
30
30
  <Icon id="test-3" /> {"test-3"}
31
- </IconBlock>
32
- </Wrapper>,
31
+ </div>
32
+ </div>,
33
33
  ));
34
34
  });
@@ -1,50 +1,4 @@
1
- import React from "react";
2
1
  import pt from "prop-types";
3
- import styled, { keyframes } from "styled-components";
4
- import { getThemeProp } from "../utils";
5
- import withErrorBoundary from "../hocs/withErrorBoundary";
6
- import useLabelMessage from "../hooks/useLabelMessage";
7
-
8
- const fadeCycle = keyframes`
9
- 0% {
10
- opacity: 0.3;
11
- }
12
- 100% {
13
- opacity: 0.7;
14
- }
15
- `;
16
-
17
- export const Placeholder = styled.span`
18
- display: inline-block;
19
- height: 1em;
20
- width: 6em;
21
- border-radius: 0.5em;
22
- background-color: ${getThemeProp(["colors", "textMedium"], "#999999")};
23
- animation: ${fadeCycle} 3s infinite alternate;
24
- `;
25
-
26
- const Text = ({ message: rawMessage, error }) => {
27
- const [labelMessage, missingValues] = useLabelMessage(rawMessage);
28
-
29
- if (error || (!rawMessage && rawMessage !== "")) {
30
- return (
31
- <span
32
- style={{
33
- color: "red",
34
- backgroundColor: "white",
35
- fontWeight: "bold",
36
- }}
37
- >
38
- Errored: {error && error.message ? error.message : "No message provided"}
39
- </span>
40
- );
41
- }
42
-
43
- if (missingValues) {
44
- return <Placeholder />;
45
- }
46
- return labelMessage;
47
- };
48
2
 
49
3
  export const ptLabel = pt.oneOfType([
50
4
  pt.string,
@@ -53,6 +7,3 @@ export const ptLabel = pt.oneOfType([
53
7
  defaultMessage: pt.string.isRequired,
54
8
  }),
55
9
  ]);
56
- Text.propTypes = { message: ptLabel };
57
-
58
- export default withErrorBoundary("Text")(Text);