orc-shared 5.10.1-dev.7 → 5.10.1-dev.9
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.
- package/dist/components/Authenticate.js +41 -17
- package/dist/components/ErrorPlaceholder.js +8 -24
- package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/LoadingIcon.js +6 -16
- package/dist/components/MaterialUI/Inputs/Select.js +10 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
- package/dist/components/Provision.js +30 -13
- package/dist/components/Routing/SegmentPage.js +115 -56
- package/dist/components/Scope/ScopeNode.js +68 -45
- package/dist/components/Sidepanel.js +57 -23
- package/dist/components/Spritesheet.js +33 -17
- package/dist/components/Text.js +1 -60
- package/dist/components/Treeview/Branch.js +82 -20
- package/dist/components/Treeview/Label.js +108 -31
- package/dist/components/Treeview/Leaf.js +56 -12
- package/dist/components/Treeview/Node.js +22 -9
- package/dist/components/Treeview/index.js +7 -1
- package/dist/components/Treeview/settings.js +7 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/testUtils.js +1 -12
- package/package.json +1 -1
- package/src/components/ApplicationModuleLoader.test.js +14 -27
- package/src/components/Authenticate.js +29 -21
- package/src/components/Authenticate.test.js +18 -27
- package/src/components/ErrorPlaceholder.js +4 -21
- package/src/components/ErrorPlaceholder.test.js +7 -14
- package/src/components/Form/InputField.test.js +2 -1
- package/src/components/Form/Inputs/MultiSelector.js +23 -0
- package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
- package/src/components/Form/Inputs/index.js +1 -1
- package/src/components/Loader.test.js +21 -33
- package/src/components/LoadingIcon.js +2 -15
- package/src/components/LoadingIcon.test.js +2 -20
- package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +7 -0
- package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
- package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
- package/src/components/Navigation/Navigation.test.js +0 -5
- package/src/components/Navigation/useNavigationState.test.js +79 -222
- package/src/components/Provision.js +36 -42
- package/src/components/Provision.test.js +10 -26
- package/src/components/Routing/SegmentPage.js +68 -52
- package/src/components/Routing/SegmentPage.test.js +4 -12
- package/src/components/Scope/ScopeNode.js +61 -54
- package/src/components/Scope/ScopeNode.test.js +61 -154
- package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
- package/src/components/Sidepanel.js +38 -32
- package/src/components/Sidepanel.test.js +49 -27
- package/src/components/Spritesheet.js +23 -21
- package/src/components/Spritesheet.test.js +10 -10
- package/src/components/Text.js +0 -49
- package/src/components/Treeview/Branch.js +63 -45
- package/src/components/Treeview/Branch.test.js +21 -24
- package/src/components/Treeview/Label.js +66 -52
- package/src/components/Treeview/Label.test.js +42 -60
- package/src/components/Treeview/Leaf.js +41 -22
- package/src/components/Treeview/Leaf.test.js +15 -10
- package/src/components/Treeview/Node.js +16 -9
- package/src/components/Treeview/Node.test.js +269 -200
- package/src/components/Treeview/Treeview.test.js +248 -248
- package/src/components/Treeview/index.js +6 -0
- package/src/components/Treeview/settings.js +7 -6
- package/src/utils/index.js +0 -4
- package/src/utils/testUtils.js +0 -10
- package/src/utils/testUtils.test.js +0 -68
- package/dist/components/Button.js +0 -70
- package/dist/components/Checkbox.js +0 -103
- package/dist/components/IconButton.js +0 -80
- package/dist/components/Input.js +0 -101
- package/dist/components/Modal/Background.js +0 -55
- package/dist/components/Modal/Dialog.js +0 -75
- package/dist/components/Modal/Wrapper.js +0 -69
- package/dist/components/Modal/index.js +0 -86
- package/dist/components/MultiSelector.js +0 -187
- package/dist/components/Navigation/Bar.js +0 -293
- package/dist/components/Navigation/Tab.js +0 -182
- package/dist/components/Placeholder.js +0 -114
- package/dist/components/Scope/Selector.js +0 -123
- package/dist/components/Selector.js +0 -185
- package/dist/components/Switch.js +0 -128
- package/dist/components/Toolbar.js +0 -227
- package/dist/components/Tooltip.js +0 -66
- package/dist/getTheme.js +0 -153
- package/dist/getThemeOverrides.js +0 -93
- package/dist/hocs/withAuthentication.js +0 -72
- package/dist/utils/styledPropFuncs.js +0 -88
- package/src/components/Button.js +0 -90
- package/src/components/Button.test.js +0 -49
- package/src/components/Checkbox.js +0 -63
- package/src/components/Checkbox.test.js +0 -122
- package/src/components/Icon.js +0 -18
- package/src/components/IconButton.js +0 -30
- package/src/components/IconButton.test.js +0 -61
- package/src/components/Input.js +0 -35
- package/src/components/Input.test.js +0 -34
- package/src/components/Modal/Background.js +0 -10
- package/src/components/Modal/Dialog.js +0 -27
- package/src/components/Modal/Dialog.test.js +0 -20
- package/src/components/Modal/Modal.test.js +0 -52
- package/src/components/Modal/Wrapper.js +0 -32
- package/src/components/Modal/Wrapper.test.js +0 -55
- package/src/components/Modal/index.js +0 -22
- package/src/components/MultiSelector.js +0 -104
- package/src/components/MultiSelector.test.js +0 -348
- package/src/components/Navigation/Bar.js +0 -212
- package/src/components/Navigation/Bar.test.js +0 -552
- package/src/components/Navigation/Tab.js +0 -156
- package/src/components/Navigation/Tab.test.js +0 -404
- package/src/components/Placeholder.js +0 -61
- package/src/components/Placeholder.test.js +0 -106
- package/src/components/Scope/Selector.js +0 -70
- package/src/components/Scope/Selector.test.js +0 -138
- package/src/components/Selector.js +0 -191
- package/src/components/Selector.test.js +0 -157
- package/src/components/Switch.js +0 -112
- package/src/components/Switch.test.js +0 -130
- package/src/components/Text.test.js +0 -132
- package/src/components/Toolbar.js +0 -178
- package/src/components/Toolbar.test.js +0 -478
- package/src/components/Tooltip.js +0 -51
- package/src/components/Tooltip.test.js +0 -21
- package/src/getTheme.js +0 -98
- package/src/getTheme.test.js +0 -92
- package/src/getThemeOverrides.js +0 -27
- package/src/hocs/withAuthentication.js +0 -18
- package/src/hocs/withAuthentication.test.js +0 -120
- package/src/utils/styledPropFuncs.js +0 -20
- package/src/utils/styledPropFuncs.test.js +0 -166
|
@@ -1,12 +1,13 @@
|
|
|
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
|
|
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
13
|
let closeSelector, store;
|
|
@@ -24,103 +25,97 @@ describe("ScopeNode", () => {
|
|
|
24
25
|
|
|
25
26
|
it("displays an icon and a label for a scope", () =>
|
|
26
27
|
expect(
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
</MemoryRouter>
|
|
31
|
-
</Provider>,
|
|
28
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
29
|
+
<ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
|
|
30
|
+
</TestWrapper>,
|
|
32
31
|
"when mounted",
|
|
33
32
|
"to satisfy",
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
34
|
+
<div id="selectorNodeScopeId" onClick={closeSelector}>
|
|
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
|
-
<
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
</MemoryRouter>
|
|
46
|
-
</Provider>,
|
|
43
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
44
|
+
<ScopeNode name="A scope" type="Global" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
|
|
45
|
+
</TestWrapper>,
|
|
47
46
|
"when mounted",
|
|
48
47
|
"to satisfy",
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
49
|
+
<div id="selectorNodeScopeId" onClick={closeSelector}>
|
|
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
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
</MemoryRouter>
|
|
61
|
-
</Provider>,
|
|
58
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
59
|
+
<ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} />
|
|
60
|
+
</TestWrapper>,
|
|
62
61
|
"when mounted",
|
|
63
62
|
"to satisfy",
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
<
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
</MemoryRouter>
|
|
76
|
-
</Provider>,
|
|
73
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
74
|
+
<ScopeNode type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
|
|
75
|
+
</TestWrapper>,
|
|
77
76
|
"when mounted",
|
|
78
77
|
"to satisfy",
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
79
|
+
<div id="selectorNodeScopeId" onClick={closeSelector}>
|
|
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
|
-
<
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
</MemoryRouter>
|
|
91
|
-
</Provider>,
|
|
88
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
89
|
+
<ScopeNode name={null} type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
|
|
90
|
+
</TestWrapper>,
|
|
92
91
|
"when mounted",
|
|
93
92
|
"to satisfy",
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
94
|
+
<div id="selectorNodeScopeId" onClick={closeSelector}>
|
|
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
|
-
<
|
|
103
|
-
<
|
|
104
|
-
|
|
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" id="ScopeId" isAuthorizedScope={true} closeSelector={closeSelector} />
|
|
105
|
+
</TestWrapper>,
|
|
113
106
|
"when mounted",
|
|
114
107
|
"to satisfy",
|
|
115
|
-
<
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
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>,
|
|
119
114
|
));
|
|
120
115
|
|
|
121
116
|
it("Call onScopeSelect on Node click if scope type is not virtual", () => {
|
|
122
117
|
const component = (
|
|
123
|
-
<TestWrapper provider={{ store }} memoryRouter>
|
|
118
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} memoryRouter={{}}>
|
|
124
119
|
<ScopeNode name="A scope" type="test" id="ScopeId" closeSelector={closeSelector} isAuthorizedScope={true} />
|
|
125
120
|
</TestWrapper>
|
|
126
121
|
);
|
|
@@ -133,7 +128,7 @@ describe("ScopeNode", () => {
|
|
|
133
128
|
preventDefault: preventDefaultSpy,
|
|
134
129
|
};
|
|
135
130
|
|
|
136
|
-
const node = mountedComponent.find(
|
|
131
|
+
const node = mountedComponent.find("[data-qa='content-label']");
|
|
137
132
|
|
|
138
133
|
node.invoke("onClick")(event);
|
|
139
134
|
|
|
@@ -141,91 +136,3 @@ describe("ScopeNode", () => {
|
|
|
141
136
|
expect(closeSelector, "to have a call satisfying", { args: [event] });
|
|
142
137
|
});
|
|
143
138
|
});
|
|
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
|
-
};
|
|
215
|
-
});
|
|
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
|
-
});
|
|
@@ -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
|
-
<
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
const useStyles = makeStyles({
|
|
10
|
+
panel: props => ({
|
|
11
|
+
position: "absolute",
|
|
12
|
+
top: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
width: props.width,
|
|
16
|
+
|
|
17
|
+
"&.enter": {
|
|
18
|
+
transform: `translateX(${props.width})`,
|
|
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(${props.width})`,
|
|
29
|
+
transition: `transform ${props.timeout}ms ease-out`,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const Sidepanel = ({ in: inProp, width = "300px", timeout = 1000, children, className }) => {
|
|
35
|
+
const classes = useStyles({ width, 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,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
|
-
import Sidepanel
|
|
3
|
+
import Sidepanel from "./Sidepanel";
|
|
4
4
|
|
|
5
5
|
class RenderSidepanel extends React.Component {
|
|
6
6
|
render() {
|
|
@@ -32,7 +32,7 @@ describe("Sidepanel", () => {
|
|
|
32
32
|
document.body.removeChild(modalRoot);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it("renders
|
|
35
|
+
it("renders sidepanel in a portal", () => {
|
|
36
36
|
ReactDOM.render(
|
|
37
37
|
<RenderSidepanel in>
|
|
38
38
|
<div id="inner">Foo</div>
|
|
@@ -42,32 +42,54 @@ describe("Sidepanel", () => {
|
|
|
42
42
|
return expect(modalRoot, "queried for first", "div#inner", "to be a", "DOMElement");
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
it("sets the width it is given", () => {
|
|
46
|
+
ReactDOM.render(
|
|
47
|
+
<Sidepanel in width="25vw">
|
|
48
|
+
<div id="inner">Foo</div>
|
|
49
|
+
</Sidepanel>,
|
|
50
|
+
appRoot,
|
|
51
|
+
);
|
|
52
|
+
return expect(
|
|
53
|
+
modalRoot,
|
|
54
|
+
"queried for first",
|
|
55
|
+
"div#modal > div",
|
|
56
|
+
"to have style rules satisfying",
|
|
57
|
+
"to contain",
|
|
58
|
+
"width: 25vw",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
it("sets transition according to timeout", () => {
|
|
63
|
+
ReactDOM.render(
|
|
64
|
+
<Sidepanel in timeout={300}>
|
|
65
|
+
<div id="inner">Foo</div>
|
|
66
|
+
</Sidepanel>,
|
|
67
|
+
appRoot,
|
|
68
|
+
);
|
|
69
|
+
return expect(
|
|
70
|
+
modalRoot,
|
|
71
|
+
"queried for first",
|
|
72
|
+
"div#modal > div",
|
|
73
|
+
"to have style rules satisfying",
|
|
74
|
+
"to contain",
|
|
75
|
+
"transition: transform 300ms",
|
|
76
|
+
);
|
|
77
|
+
});
|
|
63
78
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
it("sets default transition", () => {
|
|
80
|
+
ReactDOM.render(
|
|
81
|
+
<Sidepanel in>
|
|
82
|
+
<div id="inner">Foo</div>
|
|
83
|
+
</Sidepanel>,
|
|
84
|
+
appRoot,
|
|
85
|
+
);
|
|
86
|
+
return expect(
|
|
87
|
+
modalRoot,
|
|
88
|
+
"queried for first",
|
|
89
|
+
"div#modal > div",
|
|
90
|
+
"to have style rules satisfying",
|
|
91
|
+
"to contain",
|
|
92
|
+
"transition: transform 1000ms",
|
|
93
|
+
);
|
|
72
94
|
});
|
|
73
95
|
});
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import Icon from "./Icon";
|
|
2
|
+
import { makeStyles } from "@material-ui/core";
|
|
3
|
+
import Icon from "./MaterialUI/DataDisplay/Icon";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
const useStyles = makeStyles({
|
|
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: "5px",
|
|
17
|
+
padding: "5px 10px",
|
|
18
|
+
fontSize: "24px",
|
|
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
|
-
<
|
|
28
|
+
<div className={classes.wrapper}>
|
|
27
29
|
{iconIds.map(id => (
|
|
28
|
-
<
|
|
30
|
+
<div className={classes.iconBlock} key={id}>
|
|
29
31
|
<Icon id={id} /> {id}
|
|
30
|
-
</
|
|
32
|
+
</div>
|
|
31
33
|
))}
|
|
32
|
-
</
|
|
34
|
+
</div>
|
|
33
35
|
);
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import 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
|
-
<
|
|
23
|
-
<
|
|
22
|
+
<div>
|
|
23
|
+
<div>
|
|
24
24
|
<Icon id="test-1" /> {"test-1"}
|
|
25
|
-
</
|
|
26
|
-
<
|
|
25
|
+
</div>
|
|
26
|
+
<div>
|
|
27
27
|
<Icon id="test-2" /> {"test-2"}
|
|
28
|
-
</
|
|
29
|
-
<
|
|
28
|
+
</div>
|
|
29
|
+
<div>
|
|
30
30
|
<Icon id="test-3" /> {"test-3"}
|
|
31
|
-
</
|
|
32
|
-
</
|
|
31
|
+
</div>
|
|
32
|
+
</div>,
|
|
33
33
|
));
|
|
34
34
|
});
|
package/src/components/Text.js
CHANGED
|
@@ -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);
|