orc-shared 5.10.2-dev.2 → 5.99.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppFrame/MenuItem.js +3 -12
- package/dist/components/ApplicationModuleLoader.js +3 -2
- package/dist/components/Authenticate.js +29 -22
- package/dist/components/ErrorPlaceholder.js +8 -24
- package/dist/components/{IconButton.js → Form/Inputs/MultiSelector.js} +33 -31
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/LoadingIcon.js +38 -17
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
- package/dist/components/MaterialUI/Inputs/InputBase.js +20 -157
- 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/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
- package/dist/components/MaterialUI/muiThemes.js +2 -0
- package/dist/components/Provision.js +30 -13
- package/dist/components/Routing/SegmentPage.js +115 -56
- package/dist/components/Scope/ScopeNode.js +64 -57
- package/dist/components/Sidepanel.js +57 -23
- package/dist/components/Spritesheet.js +33 -17
- package/dist/components/Text.js +1 -60
- package/dist/components/ToastList.js +95 -64
- 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/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
- package/package.json +2 -2
- package/src/components/AppFrame/MenuItem.js +1 -9
- package/src/components/ApplicationModuleLoader.js +2 -2
- package/src/components/ApplicationModuleLoader.test.js +15 -28
- package/src/components/Authenticate.js +21 -23
- package/src/components/Authenticate.test.js +19 -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 +50 -59
- package/src/components/LoadingIcon.js +27 -14
- package/src/components/LoadingIcon.test.js +11 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +2 -2
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +0 -74
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +6 -18
- package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
- package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
- package/src/components/MaterialUI/Inputs/InputBase.js +31 -182
- package/src/components/MaterialUI/Inputs/InputBase.test.js +1 -392
- 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/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
- package/src/components/MaterialUI/muiThemes.js +3 -0
- 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 +45 -55
- package/src/components/Scope/ScopeNode.test.js +84 -163
- 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/ToastList.js +79 -90
- package/src/components/ToastList.test.js +29 -103
- 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/src/utils/toastHelper.js +8 -0
- package/src/utils/toastHelper.test.js +41 -0
- package/dist/components/Button.js +0 -70
- package/dist/components/CategoryList.js +0 -197
- package/dist/components/Checkbox.js +0 -103
- package/dist/components/Icon.js +0 -69
- package/dist/components/Input.js +0 -101
- package/dist/components/List/DataCell.js +0 -129
- package/dist/components/List/HeadCell.js +0 -125
- package/dist/components/List/HeadRow.js +0 -73
- package/dist/components/List/List.js +0 -274
- package/dist/components/List/Row.js +0 -109
- package/dist/components/List/enhanceColumnDefs.js +0 -111
- package/dist/components/List/index.js +0 -59
- 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 -158
- 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/CategoryList.js +0 -140
- package/src/components/CategoryList.test.js +0 -667
- 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/List/DataCell.js +0 -77
- package/src/components/List/DataCell.test.js +0 -357
- package/src/components/List/HeadCell.js +0 -105
- package/src/components/List/HeadCell.test.js +0 -331
- package/src/components/List/HeadRow.js +0 -21
- package/src/components/List/HeadRow.test.js +0 -27
- package/src/components/List/List.js +0 -162
- package/src/components/List/List.test.js +0 -705
- package/src/components/List/Row.js +0 -72
- package/src/components/List/Row.test.js +0 -194
- package/src/components/List/enhanceColumnDefs.js +0 -54
- package/src/components/List/enhanceColumnDefs.test.js +0 -179
- package/src/components/List/index.js +0 -6
- 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 -103
- 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,14 +1,13 @@
|
|
|
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
|
-
import { Loader } from "./Authenticate";
|
|
6
4
|
import ApplicationModuleLoader from "./ApplicationModuleLoader";
|
|
7
5
|
import { mount } from "enzyme";
|
|
8
6
|
import { getDefaultScope, getScopes } from "../actions/scopes";
|
|
9
7
|
import sinon from "sinon";
|
|
10
8
|
import { initializeFirstModuleScope } from "../actions/modules";
|
|
11
9
|
import { scopeTypes } from "../constants";
|
|
10
|
+
import LoadingIcon from "./LoadingIcon";
|
|
12
11
|
|
|
13
12
|
const TestComp = () => {
|
|
14
13
|
return <div className="test" />;
|
|
@@ -66,17 +65,13 @@ describe("ApplicationModuleLoader", () => {
|
|
|
66
65
|
state = state.setIn(["settings", "defaultScope"], null);
|
|
67
66
|
return expect(
|
|
68
67
|
<Provider store={store(state)}>
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
</ApplicationModuleLoader>
|
|
73
|
-
</ThemeProvider>
|
|
68
|
+
<ApplicationModuleLoader>
|
|
69
|
+
<TestComp />
|
|
70
|
+
</ApplicationModuleLoader>
|
|
74
71
|
</Provider>,
|
|
75
72
|
"when mounted",
|
|
76
73
|
"to exhaustively satisfy",
|
|
77
|
-
<
|
|
78
|
-
<Loader />
|
|
79
|
-
</ThemeProvider>,
|
|
74
|
+
<LoadingIcon />,
|
|
80
75
|
);
|
|
81
76
|
});
|
|
82
77
|
|
|
@@ -84,17 +79,13 @@ describe("ApplicationModuleLoader", () => {
|
|
|
84
79
|
state = state.setIn(["settings", "loadedModulesScope"], Immutable.fromJS(["moduleA"]));
|
|
85
80
|
return expect(
|
|
86
81
|
<Provider store={store(state)}>
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
</ApplicationModuleLoader>
|
|
91
|
-
</ThemeProvider>
|
|
82
|
+
<ApplicationModuleLoader>
|
|
83
|
+
<TestComp />
|
|
84
|
+
</ApplicationModuleLoader>
|
|
92
85
|
</Provider>,
|
|
93
86
|
"when mounted",
|
|
94
87
|
"to exhaustively satisfy",
|
|
95
|
-
<
|
|
96
|
-
<Loader />
|
|
97
|
-
</ThemeProvider>,
|
|
88
|
+
<LoadingIcon />,
|
|
98
89
|
);
|
|
99
90
|
});
|
|
100
91
|
|
|
@@ -103,11 +94,9 @@ describe("ApplicationModuleLoader", () => {
|
|
|
103
94
|
|
|
104
95
|
const component = (
|
|
105
96
|
<Provider store={theStore}>
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
</ApplicationModuleLoader>
|
|
110
|
-
</ThemeProvider>
|
|
97
|
+
<ApplicationModuleLoader>
|
|
98
|
+
<TestComp />
|
|
99
|
+
</ApplicationModuleLoader>
|
|
111
100
|
</Provider>
|
|
112
101
|
);
|
|
113
102
|
|
|
@@ -128,11 +117,9 @@ describe("ApplicationModuleLoader", () => {
|
|
|
128
117
|
|
|
129
118
|
const component = (
|
|
130
119
|
<Provider store={theStore}>
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
</ApplicationModuleLoader>
|
|
135
|
-
</ThemeProvider>
|
|
120
|
+
<ApplicationModuleLoader>
|
|
121
|
+
<TestComp />
|
|
122
|
+
</ApplicationModuleLoader>
|
|
136
123
|
</Provider>
|
|
137
124
|
);
|
|
138
125
|
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import Placeholder from "../components/Placeholder";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
3
|
+
import { safeGet } from "../utils";
|
|
5
4
|
import { useSelector } from "react-redux";
|
|
6
5
|
import { unwrapImmutable } from "../utils";
|
|
7
6
|
import { GET_AUTHENTICATION_PROFILE } from "../actions/authentication";
|
|
8
7
|
import { ERROR, LOGOUT } from "../reducers/request";
|
|
9
8
|
import ApplicationModuleLoader from "./ApplicationModuleLoader";
|
|
9
|
+
import LoadingIcon from "./LoadingIcon";
|
|
10
|
+
|
|
11
|
+
const useStyles = makeStyles({
|
|
12
|
+
wrapper: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
width: "60%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
padding: "0 20vw",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
10
21
|
|
|
11
22
|
export const useAuthenticationData = () => ({
|
|
12
23
|
loading: useSelector(state => state.getIn(["requests", "actives", GET_AUTHENTICATION_PROFILE])),
|
|
@@ -15,34 +26,21 @@ export const useAuthenticationData = () => ({
|
|
|
15
26
|
needLogin: useSelector(state => state.getIn(["requests", LOGOUT])),
|
|
16
27
|
});
|
|
17
28
|
|
|
18
|
-
export const Wrapper = styled.div`
|
|
19
|
-
display: flex;
|
|
20
|
-
width: 60%;
|
|
21
|
-
height: 100%;
|
|
22
|
-
padding: 0 20vw;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
export const Loader = withTheme(props => (
|
|
28
|
-
<Wrapper>
|
|
29
|
-
<Placeholder icon={getThemeProp(["icons", "loading"], "loading")(props)} animate />
|
|
30
|
-
</Wrapper>
|
|
31
|
-
));
|
|
32
|
-
|
|
33
29
|
export const Error = ({ requestError, needLogin }) => {
|
|
30
|
+
const classes = useStyles();
|
|
31
|
+
|
|
34
32
|
if (needLogin) {
|
|
35
33
|
return (
|
|
36
|
-
<
|
|
34
|
+
<div className={classes.wrapper}>
|
|
37
35
|
<h1>Not logged in</h1>
|
|
38
|
-
</
|
|
36
|
+
</div>
|
|
39
37
|
);
|
|
40
38
|
}
|
|
41
39
|
return (
|
|
42
|
-
<
|
|
40
|
+
<div className={classes.wrapper}>
|
|
43
41
|
<h1>{safeGet(requestError, "payload", "message") || "An error occurred"}</h1>
|
|
44
42
|
Last failing action: <pre>{JSON.stringify(requestError, null, 2)}</pre>
|
|
45
|
-
</
|
|
43
|
+
</div>
|
|
46
44
|
);
|
|
47
45
|
};
|
|
48
46
|
|
|
@@ -50,7 +48,7 @@ const Authenticate = ({ children }) => {
|
|
|
50
48
|
const { loading, authedUser, requestError, needLogin } = useAuthenticationData();
|
|
51
49
|
|
|
52
50
|
if (loading) {
|
|
53
|
-
return <
|
|
51
|
+
return <LoadingIcon />;
|
|
54
52
|
}
|
|
55
53
|
if (!authedUser) {
|
|
56
54
|
return <Error {...{ requestError, needLogin }} />;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Immutable from "immutable";
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
|
-
import
|
|
5
|
-
import Authenticate, { Loader, Wrapper } from "./Authenticate";
|
|
4
|
+
import Authenticate from "./Authenticate";
|
|
6
5
|
import { ERROR, LOGOUT } from "../reducers/request";
|
|
7
6
|
import { GET_AUTHENTICATION_PROFILE } from "../actions/authentication";
|
|
7
|
+
import LoadingIcon from "./LoadingIcon";
|
|
8
8
|
|
|
9
9
|
const TestComp = () => {
|
|
10
10
|
return <div className="test" />;
|
|
@@ -64,17 +64,13 @@ describe("Authenticate", () => {
|
|
|
64
64
|
state = state.setIn(["requests", "actives", GET_AUTHENTICATION_PROFILE], true);
|
|
65
65
|
return expect(
|
|
66
66
|
<Provider store={store(state)}>
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
</Authenticate>
|
|
71
|
-
</ThemeProvider>
|
|
67
|
+
<Authenticate>
|
|
68
|
+
<TestComp />
|
|
69
|
+
</Authenticate>
|
|
72
70
|
</Provider>,
|
|
73
71
|
"when mounted",
|
|
74
72
|
"to exhaustively satisfy",
|
|
75
|
-
<
|
|
76
|
-
<Loader />
|
|
77
|
-
</ThemeProvider>,
|
|
73
|
+
<LoadingIcon />,
|
|
78
74
|
);
|
|
79
75
|
});
|
|
80
76
|
|
|
@@ -82,17 +78,13 @@ describe("Authenticate", () => {
|
|
|
82
78
|
state = state.setIn(["settings", "defaultScope"], null);
|
|
83
79
|
return expect(
|
|
84
80
|
<Provider store={store(state)}>
|
|
85
|
-
<
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
</Authenticate>
|
|
89
|
-
</ThemeProvider>
|
|
81
|
+
<Authenticate applicationModuleReady={false}>
|
|
82
|
+
<TestComp />
|
|
83
|
+
</Authenticate>
|
|
90
84
|
</Provider>,
|
|
91
85
|
"when mounted",
|
|
92
86
|
"to exhaustively satisfy",
|
|
93
|
-
<
|
|
94
|
-
<Loader />
|
|
95
|
-
</ThemeProvider>,
|
|
87
|
+
<LoadingIcon />,
|
|
96
88
|
);
|
|
97
89
|
});
|
|
98
90
|
|
|
@@ -105,10 +97,10 @@ describe("Authenticate", () => {
|
|
|
105
97
|
</Authenticate>
|
|
106
98
|
</Provider>,
|
|
107
99
|
"when mounted",
|
|
108
|
-
"to
|
|
109
|
-
<
|
|
100
|
+
"to satisfy",
|
|
101
|
+
<div>
|
|
110
102
|
<h1>Not logged in</h1>
|
|
111
|
-
</
|
|
103
|
+
</div>,
|
|
112
104
|
);
|
|
113
105
|
});
|
|
114
106
|
|
|
@@ -127,8 +119,8 @@ describe("Authenticate", () => {
|
|
|
127
119
|
</Authenticate>
|
|
128
120
|
</Provider>,
|
|
129
121
|
"when mounted",
|
|
130
|
-
"to
|
|
131
|
-
<
|
|
122
|
+
"to satisfy",
|
|
123
|
+
<div>
|
|
132
124
|
<h1>404 - NotFound</h1>
|
|
133
125
|
{"Last failing action: "}
|
|
134
126
|
<pre>
|
|
@@ -140,7 +132,7 @@ describe("Authenticate", () => {
|
|
|
140
132
|
" }\n" +
|
|
141
133
|
"}"}
|
|
142
134
|
</pre>
|
|
143
|
-
</
|
|
135
|
+
</div>,
|
|
144
136
|
);
|
|
145
137
|
});
|
|
146
138
|
|
|
@@ -158,11 +150,11 @@ describe("Authenticate", () => {
|
|
|
158
150
|
</Authenticate>
|
|
159
151
|
</Provider>,
|
|
160
152
|
"when mounted",
|
|
161
|
-
"to
|
|
162
|
-
<
|
|
153
|
+
"to satisfy",
|
|
154
|
+
<div>
|
|
163
155
|
<h1>An error occurred</h1>
|
|
164
156
|
Last failing action: <pre>{'{\n "type": "TEST_ACTION"\n}'}</pre>
|
|
165
|
-
</
|
|
157
|
+
</div>,
|
|
166
158
|
);
|
|
167
159
|
});
|
|
168
160
|
});
|
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { getThemeProp } from "../utils";
|
|
4
|
-
import Placeholder from "./Placeholder";
|
|
2
|
+
import Placeholder from "./MaterialUI/DataDisplay/PredefinedElements/Placeholder";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
height: 100%;
|
|
10
|
-
padding: 0 20vw;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
const ErrorPlaceholder = withTheme(({ message, description, onClick, ...props }) => (
|
|
16
|
-
<Placeholder
|
|
17
|
-
icon={getThemeProp(["icons", "reportProblem"], "error")(props)}
|
|
18
|
-
warn
|
|
19
|
-
title={message}
|
|
20
|
-
subtitle={description}
|
|
21
|
-
onClick={onClick}
|
|
22
|
-
/>
|
|
23
|
-
));
|
|
4
|
+
const ErrorPlaceholder = ({ message, description }) => (
|
|
5
|
+
<Placeholder icon="report-problem-triangle" error title={message} subtitle={description} />
|
|
6
|
+
);
|
|
24
7
|
|
|
25
8
|
export default ErrorPlaceholder;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import
|
|
4
|
-
import Placeholder from "./Placeholder";
|
|
3
|
+
import Placeholder from "./MaterialUI/DataDisplay/PredefinedElements/Placeholder";
|
|
5
4
|
import ErrorPlaceholder from "./ErrorPlaceholder";
|
|
6
5
|
|
|
7
6
|
describe("ErrorPlaceholder", () => {
|
|
@@ -14,9 +13,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
14
13
|
getState: () => ({}),
|
|
15
14
|
}}
|
|
16
15
|
>
|
|
17
|
-
<
|
|
18
|
-
<ErrorPlaceholder message="Error" />
|
|
19
|
-
</ThemeProvider>
|
|
16
|
+
<ErrorPlaceholder message="Error" />
|
|
20
17
|
</Provider>,
|
|
21
18
|
"when mounted",
|
|
22
19
|
"to satisfy",
|
|
@@ -27,7 +24,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
27
24
|
getState: () => ({}),
|
|
28
25
|
}}
|
|
29
26
|
>
|
|
30
|
-
<Placeholder icon="
|
|
27
|
+
<Placeholder icon="report-problem-triangle" error title="Error" />
|
|
31
28
|
</Provider>,
|
|
32
29
|
));
|
|
33
30
|
|
|
@@ -40,9 +37,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
40
37
|
getState: () => ({}),
|
|
41
38
|
}}
|
|
42
39
|
>
|
|
43
|
-
<
|
|
44
|
-
<ErrorPlaceholder message="Error" description="This failed" />
|
|
45
|
-
</ThemeProvider>
|
|
40
|
+
<ErrorPlaceholder message="Error" description="This failed" />
|
|
46
41
|
</Provider>,
|
|
47
42
|
"when mounted",
|
|
48
43
|
"to satisfy",
|
|
@@ -53,7 +48,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
53
48
|
getState: () => ({}),
|
|
54
49
|
}}
|
|
55
50
|
>
|
|
56
|
-
<Placeholder icon="
|
|
51
|
+
<Placeholder icon="report-problem-triangle" error title="Error" subtitle="This failed" />
|
|
57
52
|
</Provider>,
|
|
58
53
|
));
|
|
59
54
|
|
|
@@ -67,9 +62,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
67
62
|
getState: () => ({}),
|
|
68
63
|
}}
|
|
69
64
|
>
|
|
70
|
-
<
|
|
71
|
-
<ErrorPlaceholder message="Error" onClick={handler} />
|
|
72
|
-
</ThemeProvider>
|
|
65
|
+
<ErrorPlaceholder message="Error" onClick={handler} />
|
|
73
66
|
</Provider>,
|
|
74
67
|
"when mounted",
|
|
75
68
|
"to satisfy",
|
|
@@ -80,7 +73,7 @@ describe("ErrorPlaceholder", () => {
|
|
|
80
73
|
getState: () => ({}),
|
|
81
74
|
}}
|
|
82
75
|
>
|
|
83
|
-
<Placeholder icon="
|
|
76
|
+
<Placeholder icon="report-problem-triangle" error title="Error" onClick={handler} />
|
|
84
77
|
</Provider>,
|
|
85
78
|
);
|
|
86
79
|
});
|
|
@@ -114,10 +114,11 @@ describe("InputField", () => {
|
|
|
114
114
|
if (type === "MultiSelector") {
|
|
115
115
|
val = ["thing"];
|
|
116
116
|
emptyVal = [];
|
|
117
|
+
target = "[role='button']";
|
|
117
118
|
} else {
|
|
118
119
|
val = "thing";
|
|
120
|
+
target = "select";
|
|
119
121
|
}
|
|
120
|
-
target = "select";
|
|
121
122
|
} else if (type === "SwitchInput") {
|
|
122
123
|
val = true;
|
|
123
124
|
} else if (type === "DateInput") {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Select from "../../MaterialUI/Inputs/Select";
|
|
3
|
+
import { memoize } from "../../../utils";
|
|
4
|
+
import SelectProps from "../../MaterialUI/Inputs/SelectProps";
|
|
5
|
+
|
|
6
|
+
export const selectEventUpdater = memoize(update => value => update(value));
|
|
7
|
+
|
|
8
|
+
const MultiSelector = ({ value, options, update, ...props }) => {
|
|
9
|
+
const selectProps = new SelectProps();
|
|
10
|
+
|
|
11
|
+
selectProps.set(SelectProps.propNames.value, value);
|
|
12
|
+
selectProps.set(SelectProps.propNames.onClose, props.onBlur);
|
|
13
|
+
selectProps.set(SelectProps.propNames.disabled, props.disabled);
|
|
14
|
+
selectProps.set(SelectProps.propNames.multiple, true);
|
|
15
|
+
selectProps.set(SelectProps.propNames.update, selectEventUpdater(update));
|
|
16
|
+
|
|
17
|
+
const hasError = props.required && (!Array.isArray(value) || value.length === 0);
|
|
18
|
+
selectProps.set(SelectProps.propNames.error, hasError);
|
|
19
|
+
|
|
20
|
+
return <Select options={options} selectProps={selectProps} />;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default MultiSelector;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import MultiSelector, { selectEventUpdater } from "./MultiSelector";
|
|
4
|
+
import { TestWrapper, createMuiTheme } from "../../../utils/testUtils";
|
|
5
|
+
import Immutable from "immutable";
|
|
6
|
+
import SelectMUI from "@material-ui/core/Select";
|
|
7
|
+
import MenuItem from "@material-ui/core/MenuItem";
|
|
8
|
+
import TooltippedTypography from "../../MaterialUI/DataDisplay/TooltippedElements/TooltippedTypography";
|
|
9
|
+
import Icon from "../../MaterialUI/DataDisplay/Icon";
|
|
10
|
+
|
|
11
|
+
describe("MultiSelector", () => {
|
|
12
|
+
let update, state, store, chevronDown;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
update = sinon.spy().named("update");
|
|
15
|
+
|
|
16
|
+
state = Immutable.fromJS({
|
|
17
|
+
locale: {
|
|
18
|
+
locale: "en-CA",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
store = {
|
|
23
|
+
subscribe: () => {},
|
|
24
|
+
dispatch: () => {},
|
|
25
|
+
getState: () => state,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
chevronDown = props => {
|
|
29
|
+
return <Icon id="dropdown-chevron-down" {...props} />;
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const theme = createMuiTheme();
|
|
34
|
+
|
|
35
|
+
it("renders a multi selector with multiple options", () =>
|
|
36
|
+
expect(
|
|
37
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
38
|
+
<MultiSelector
|
|
39
|
+
update={update}
|
|
40
|
+
value={["English"]}
|
|
41
|
+
options={[
|
|
42
|
+
{ value: "English", label: "English" },
|
|
43
|
+
{ value: "Francais", label: "Francais" },
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
</TestWrapper>,
|
|
47
|
+
"when mounted",
|
|
48
|
+
"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>
|
|
65
|
+
</TestWrapper>,
|
|
66
|
+
));
|
|
67
|
+
|
|
68
|
+
it("renders a multi selector with an error", () => {
|
|
69
|
+
expect(
|
|
70
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
71
|
+
<MultiSelector
|
|
72
|
+
update={update}
|
|
73
|
+
required={true}
|
|
74
|
+
value={[]}
|
|
75
|
+
options={[
|
|
76
|
+
{ value: "English", label: "English" },
|
|
77
|
+
{ value: "Francais", label: "Francais" },
|
|
78
|
+
]}
|
|
79
|
+
/>
|
|
80
|
+
</TestWrapper>,
|
|
81
|
+
"when mounted",
|
|
82
|
+
"to satisfy",
|
|
83
|
+
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
84
|
+
<div>
|
|
85
|
+
<SelectMUI value={[""]} disableUnderline={true} IconComponent={chevronDown} error={true} multiple={true}>
|
|
86
|
+
<MenuItem key="English" value="English">
|
|
87
|
+
<TooltippedTypography children="English" titleValue="English" />
|
|
88
|
+
</MenuItem>
|
|
89
|
+
<MenuItem key="Francais" value="Francais">
|
|
90
|
+
<TooltippedTypography noWrap children="Francais" titleValue="Francais" />
|
|
91
|
+
</MenuItem>
|
|
92
|
+
</SelectMUI>
|
|
93
|
+
<div></div>
|
|
94
|
+
</div>
|
|
95
|
+
</TestWrapper>,
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("selectEventUpdater", () => {
|
|
101
|
+
let update;
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
update = sinon.spy().named("update");
|
|
104
|
+
});
|
|
105
|
+
|
|
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
|
+
));
|
|
110
|
+
|
|
111
|
+
it("is memoized", () => expect(selectEventUpdater, "called with", [update], "to be", selectEventUpdater(update)));
|
|
112
|
+
});
|