orc-shared 5.10.1-dev.8 → 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
|
@@ -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
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import { ThemeProvider } from "styled-components";
|
|
4
3
|
import { mount, act } from "unexpected-reaction";
|
|
5
4
|
import sinon from "sinon";
|
|
6
5
|
import { spyOnConsole } from "../utils/testUtils";
|
|
7
6
|
import ErrorPlaceholder from "./ErrorPlaceholder";
|
|
8
7
|
import Loader, { Loading } from "./Loader";
|
|
8
|
+
import ColumnWrapper from "./ColumnWrapper";
|
|
9
9
|
|
|
10
10
|
describe("Loader placeholder", () => {
|
|
11
11
|
let clock;
|
|
@@ -18,11 +18,9 @@ describe("Loader placeholder", () => {
|
|
|
18
18
|
|
|
19
19
|
it("renders null, then load spinner if no props set", () => {
|
|
20
20
|
const loader = mount(
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
</div>
|
|
25
|
-
</ThemeProvider>,
|
|
21
|
+
<div>
|
|
22
|
+
<Loading />
|
|
23
|
+
</div>,
|
|
26
24
|
);
|
|
27
25
|
expect(loader, "to satisfy", <div />);
|
|
28
26
|
act(() => {
|
|
@@ -34,7 +32,7 @@ describe("Loader placeholder", () => {
|
|
|
34
32
|
"svg",
|
|
35
33
|
"to satisfy",
|
|
36
34
|
<svg>
|
|
37
|
-
<use href="#icon-
|
|
35
|
+
<use href="#icon-orckestra-loader" />
|
|
38
36
|
</svg>,
|
|
39
37
|
);
|
|
40
38
|
});
|
|
@@ -50,9 +48,7 @@ describe("Loader placeholder", () => {
|
|
|
50
48
|
getState: () => ({}),
|
|
51
49
|
}}
|
|
52
50
|
>
|
|
53
|
-
<
|
|
54
|
-
<Loading {...{ error }} />
|
|
55
|
-
</ThemeProvider>
|
|
51
|
+
<Loading {...{ error }} />
|
|
56
52
|
</Provider>,
|
|
57
53
|
"when mounted",
|
|
58
54
|
"to satisfy",
|
|
@@ -63,9 +59,7 @@ describe("Loader placeholder", () => {
|
|
|
63
59
|
getState: () => ({}),
|
|
64
60
|
}}
|
|
65
61
|
>
|
|
66
|
-
<
|
|
67
|
-
<ErrorPlaceholder message="This is a test" />
|
|
68
|
-
</ThemeProvider>
|
|
62
|
+
<ErrorPlaceholder message="This is a test" />
|
|
69
63
|
</Provider>,
|
|
70
64
|
);
|
|
71
65
|
});
|
|
@@ -73,9 +67,9 @@ describe("Loader placeholder", () => {
|
|
|
73
67
|
});
|
|
74
68
|
|
|
75
69
|
describe("Loader", () => {
|
|
76
|
-
let clock,
|
|
70
|
+
let clock, componentLoader, errorLoader;
|
|
77
71
|
beforeEach(() => {
|
|
78
|
-
|
|
72
|
+
componentLoader = () => import("./ColumnWrapper");
|
|
79
73
|
errorLoader = () => Promise.reject(new Error("This is not right"));
|
|
80
74
|
clock = sinon.useFakeTimers();
|
|
81
75
|
});
|
|
@@ -85,13 +79,11 @@ describe("Loader", () => {
|
|
|
85
79
|
spyOnConsole(["error"]);
|
|
86
80
|
|
|
87
81
|
it("loads the component", () => {
|
|
88
|
-
const Comp = Loader(
|
|
82
|
+
const Comp = Loader(componentLoader);
|
|
89
83
|
const loader = mount(
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
</div>
|
|
94
|
-
</ThemeProvider>,
|
|
84
|
+
<div>
|
|
85
|
+
<Comp />
|
|
86
|
+
</div>,
|
|
95
87
|
);
|
|
96
88
|
expect(loader, "to satisfy", <div />);
|
|
97
89
|
act(() => {
|
|
@@ -115,7 +107,7 @@ describe("Loader", () => {
|
|
|
115
107
|
loader,
|
|
116
108
|
"to satisfy",
|
|
117
109
|
<div>
|
|
118
|
-
<
|
|
110
|
+
<ColumnWrapper />
|
|
119
111
|
</div>,
|
|
120
112
|
).then(() => expect(console.error, "was not called")),
|
|
121
113
|
);
|
|
@@ -131,11 +123,9 @@ describe("Loader", () => {
|
|
|
131
123
|
getState: () => ({}),
|
|
132
124
|
}}
|
|
133
125
|
>
|
|
134
|
-
<
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
</div>
|
|
138
|
-
</ThemeProvider>
|
|
126
|
+
<div>
|
|
127
|
+
<Comp />
|
|
128
|
+
</div>
|
|
139
129
|
</Provider>,
|
|
140
130
|
);
|
|
141
131
|
expect(loader, "to satisfy", <div />);
|
|
@@ -148,7 +138,7 @@ describe("Loader", () => {
|
|
|
148
138
|
"svg",
|
|
149
139
|
"to satisfy",
|
|
150
140
|
<svg>
|
|
151
|
-
<use href="#icon-
|
|
141
|
+
<use href="#icon-orckestra-loader" />
|
|
152
142
|
</svg>,
|
|
153
143
|
);
|
|
154
144
|
let load;
|
|
@@ -166,11 +156,9 @@ describe("Loader", () => {
|
|
|
166
156
|
getState: () => ({}),
|
|
167
157
|
}}
|
|
168
158
|
>
|
|
169
|
-
<
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
</div>
|
|
173
|
-
</ThemeProvider>
|
|
159
|
+
<div>
|
|
160
|
+
<ErrorPlaceholder message="This is not right" />
|
|
161
|
+
</div>
|
|
174
162
|
</Provider>,
|
|
175
163
|
).then(() => expect(console.error, "was called")),
|
|
176
164
|
);
|
|
@@ -1,19 +1,6 @@
|
|
|
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
|
-
display: flex;
|
|
8
|
-
width: 60%;
|
|
9
|
-
height: 100%;
|
|
10
|
-
padding: 0 20vw;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
const LoadingIcon = withTheme(props => (
|
|
16
|
-
<Placeholder icon={getThemeProp(["icons", "loading"], "loading")(props)} animate />
|
|
17
|
-
));
|
|
4
|
+
const LoadingIcon = () => <Placeholder icon="orckestra-loader" animateIcon />;
|
|
18
5
|
|
|
19
6
|
export default LoadingIcon;
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import Placeholder from "./Placeholder";
|
|
2
|
+
import Placeholder from "./MaterialUI/DataDisplay/PredefinedElements/Placeholder";
|
|
4
3
|
import LoadingIcon from "./LoadingIcon";
|
|
5
4
|
|
|
6
5
|
describe("LoadingIcon", () => {
|
|
7
6
|
it("shows a spinning load icon", () =>
|
|
8
|
-
expect(
|
|
9
|
-
<ThemeProvider theme={{}}>
|
|
10
|
-
<LoadingIcon />
|
|
11
|
-
</ThemeProvider>,
|
|
12
|
-
"when mounted",
|
|
13
|
-
"to satisfy",
|
|
14
|
-
<Placeholder icon="loading" animate />,
|
|
15
|
-
));
|
|
16
|
-
|
|
17
|
-
it("gets icon from theme", () =>
|
|
18
|
-
expect(
|
|
19
|
-
<ThemeProvider theme={{ icons: { loading: "spinner" } }}>
|
|
20
|
-
<LoadingIcon />
|
|
21
|
-
</ThemeProvider>,
|
|
22
|
-
"when mounted",
|
|
23
|
-
"to satisfy",
|
|
24
|
-
<Placeholder icon="spinner" animate />,
|
|
25
|
-
));
|
|
7
|
+
expect(<LoadingIcon />, "when mounted", "to satisfy", <Placeholder icon="orckestra-loader" animateIcon />));
|
|
26
8
|
});
|
|
@@ -8,7 +8,7 @@ import TableMui from "@material-ui/core/Table";
|
|
|
8
8
|
import TableHead from "@material-ui/core/TableHead";
|
|
9
9
|
import TableRow from "@material-ui/core/TableRow";
|
|
10
10
|
import { buildHeaderAndRowFromConfig } from "./tableHelpers";
|
|
11
|
-
import Placeholder from "
|
|
11
|
+
import Placeholder from "./PredefinedElements/Placeholder";
|
|
12
12
|
import TableInfoBar from "./PredefinedElements/TableInfoBar";
|
|
13
13
|
import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
14
14
|
import TableProps from "./TableProps";
|
|
@@ -145,6 +145,8 @@ export const SelectIconButton = props => {
|
|
|
145
145
|
);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
const renderMultipleValues = selected => selected?.join(", ");
|
|
149
|
+
|
|
148
150
|
const selectEmptyValue = "~~#~~";
|
|
149
151
|
|
|
150
152
|
const Select = ({ options, selectProps, children }) => {
|
|
@@ -169,6 +171,7 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
169
171
|
const native = selectProps?.get(SelectProps.propNames.native);
|
|
170
172
|
const onClose = selectProps?.get(SelectProps.propNames.onClose);
|
|
171
173
|
const inputProps = selectProps?.get(SelectProps.propNames.inputProps);
|
|
174
|
+
const multiple = selectProps?.get(SelectProps.propNames.multiple);
|
|
172
175
|
const hasError = !!error;
|
|
173
176
|
|
|
174
177
|
if (sortType === sortTypeEnum.numeric) {
|
|
@@ -252,6 +255,8 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
252
255
|
error={hasError}
|
|
253
256
|
native={native}
|
|
254
257
|
inputProps={inputProps}
|
|
258
|
+
multiple={multiple}
|
|
259
|
+
renderValue={multiple ? renderMultipleValues : undefined}
|
|
255
260
|
classes={{
|
|
256
261
|
icon: classes.icon,
|
|
257
262
|
root: selectProps?.getStyle(SelectProps.ruleNames.root),
|
|
@@ -275,6 +280,8 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
275
280
|
error={hasError}
|
|
276
281
|
native={native}
|
|
277
282
|
inputProps={inputProps}
|
|
283
|
+
multiple={multiple}
|
|
284
|
+
renderValue={multiple ? renderMultipleValues : undefined}
|
|
278
285
|
classes={{
|
|
279
286
|
icon: classes.icon,
|
|
280
287
|
root: selectProps?.getStyle(SelectProps.ruleNames.root),
|
|
@@ -669,4 +669,49 @@ describe("Select Component", () => {
|
|
|
669
669
|
|
|
670
670
|
expect(muiSelect.prop("open"), "to be true");
|
|
671
671
|
});
|
|
672
|
+
|
|
673
|
+
it("Renders Select component with multiple values", () => {
|
|
674
|
+
const options = [
|
|
675
|
+
{ value: "aValue", label: "aLabel" },
|
|
676
|
+
{ value: "anotherValue", label: "anotherLabel" },
|
|
677
|
+
];
|
|
678
|
+
|
|
679
|
+
const selectProps = new SelectProps();
|
|
680
|
+
|
|
681
|
+
selectProps.set(SelectProps.propNames.update, update);
|
|
682
|
+
selectProps.set(SelectProps.propNames.multiple, true);
|
|
683
|
+
selectProps.set(SelectProps.propNames.value, ["aValue"]);
|
|
684
|
+
|
|
685
|
+
const component = (
|
|
686
|
+
<TestWrapper stylesProvider muiThemeProvider={{ theme }}>
|
|
687
|
+
<Select options={options} selectProps={selectProps} />
|
|
688
|
+
</TestWrapper>
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
const ChevronDown = props => {
|
|
692
|
+
return <Icon id="dropdown-chevron-down" {...props} />;
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
const expected = (
|
|
696
|
+
<TestWrapper stylesProvider muiThemeProvider={{ theme }}>
|
|
697
|
+
<SelectMUI
|
|
698
|
+
value={["aValue"]}
|
|
699
|
+
disableUnderline={true}
|
|
700
|
+
IconComponent={ChevronDown}
|
|
701
|
+
error={false}
|
|
702
|
+
multiple={true}
|
|
703
|
+
renderValue={selected => selected.join(", ")}
|
|
704
|
+
>
|
|
705
|
+
<MenuItem key="aValue" value="aValue">
|
|
706
|
+
<TooltippedTypography children="aLabel" titleValue="aLabel" />
|
|
707
|
+
</MenuItem>
|
|
708
|
+
<MenuItem key="anotherValue" value="anotherValue">
|
|
709
|
+
<TooltippedTypography noWrap children="anotherLabel" titleValue="anotherLabel" />
|
|
710
|
+
</MenuItem>
|
|
711
|
+
</SelectMUI>
|
|
712
|
+
</TestWrapper>
|
|
713
|
+
);
|
|
714
|
+
|
|
715
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
716
|
+
});
|
|
672
717
|
});
|
|
@@ -21,6 +21,7 @@ class SelectProps extends ComponentProps {
|
|
|
21
21
|
onClose: "onClose",
|
|
22
22
|
native: "native",
|
|
23
23
|
inputProps: "inputProps",
|
|
24
|
+
multiple: "multiple",
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
static ruleNames = {
|
|
@@ -42,6 +43,7 @@ class SelectProps extends ComponentProps {
|
|
|
42
43
|
this.componentProps.set(this.constructor.propNames.onClose, null);
|
|
43
44
|
this.componentProps.set(this.constructor.propNames.native, null);
|
|
44
45
|
this.componentProps.set(this.constructor.propNames.inputProps, null);
|
|
46
|
+
this.componentProps.set(this.constructor.propNames.multiple, null);
|
|
45
47
|
|
|
46
48
|
this.componentClasses.set(this.constructor.ruleNames.root, null);
|
|
47
49
|
this.componentClasses.set(this.constructor.ruleNames.paper, null);
|
|
@@ -15,6 +15,7 @@ describe("Select Props", () => {
|
|
|
15
15
|
"onClose",
|
|
16
16
|
"native",
|
|
17
17
|
"inputProps",
|
|
18
|
+
"multiple",
|
|
18
19
|
];
|
|
19
20
|
|
|
20
21
|
expect(SelectProps.propNames, "to have keys", propNames);
|
|
@@ -34,6 +35,7 @@ describe("Select Props", () => {
|
|
|
34
35
|
"onClose",
|
|
35
36
|
"native",
|
|
36
37
|
"inputProps",
|
|
38
|
+
"multiple",
|
|
37
39
|
];
|
|
38
40
|
|
|
39
41
|
const selectProps = new SelectProps();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState, isValidElement, cloneElement } from "react";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
2
3
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
4
|
import Button from "@material-ui/core/Button";
|
|
4
5
|
import Menu from "@material-ui/core/Menu";
|
|
5
6
|
import MenuItem from "@material-ui/core/MenuItem";
|
|
6
|
-
import Text from "../../Text";
|
|
7
7
|
import DropDownMenuProps, { isDropDownMenuProps } from "./DropDownMenuProps";
|
|
8
8
|
|
|
9
9
|
const useStyles = makeStyles(theme => ({
|
|
@@ -95,7 +95,7 @@ const DropDownMenu = ({ payload, menuItems, children, dropDownMenuProps = new Dr
|
|
|
95
95
|
onClick={onMenuItemClick(action, itemContext)}
|
|
96
96
|
disabled={disabled}
|
|
97
97
|
>
|
|
98
|
-
<
|
|
98
|
+
{typeof title === "string" ? title : <FormattedMessage {...title} />}
|
|
99
99
|
</MenuItem>
|
|
100
100
|
))}
|
|
101
101
|
</Menu>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
2
|
import ReactDOM from "react-dom";
|
|
4
3
|
import sinon from "sinon";
|
|
5
4
|
import { mount } from "enzyme";
|
|
@@ -14,7 +13,7 @@ describe("DropDownMenu", () => {
|
|
|
14
13
|
let store, menuItems, container;
|
|
15
14
|
beforeEach(() => {
|
|
16
15
|
menuItems = [
|
|
17
|
-
{ title: "asd", action: sinon.spy().named("action"), itemContext: "aContext" },
|
|
16
|
+
{ title: { id: "asd", defaultMessage: "asd" }, action: sinon.spy().named("action"), itemContext: "aContext" },
|
|
18
17
|
{ title: "asd2", action: sinon.spy().named("action"), itemContext: "myContext" },
|
|
19
18
|
];
|
|
20
19
|
store = {
|
|
@@ -73,9 +72,9 @@ describe("DropDownMenu", () => {
|
|
|
73
72
|
const payload = "payload";
|
|
74
73
|
|
|
75
74
|
ReactDOM.render(
|
|
76
|
-
<
|
|
75
|
+
<TestWrapper provider={{ store }} intlProvider>
|
|
77
76
|
<DropDownMenu payload={payload} menuItems={menuItems} />
|
|
78
|
-
</
|
|
77
|
+
</TestWrapper>,
|
|
79
78
|
container,
|
|
80
79
|
);
|
|
81
80
|
|
|
@@ -98,9 +97,9 @@ describe("DropDownMenu", () => {
|
|
|
98
97
|
const payload = "payload";
|
|
99
98
|
|
|
100
99
|
const component = (
|
|
101
|
-
<
|
|
100
|
+
<TestWrapper provider={{ store }} intlProvider>
|
|
102
101
|
<DropDownMenu payload={payload} menuItems={menuItems} />
|
|
103
|
-
</
|
|
102
|
+
</TestWrapper>
|
|
104
103
|
);
|
|
105
104
|
|
|
106
105
|
const mountedComponent = mount(component);
|
|
@@ -5,11 +5,6 @@ import Navigation from "./index";
|
|
|
5
5
|
import TabBar from "../MaterialUI/Navigation/TabBar";
|
|
6
6
|
import { TestWrapper, createMuiTheme } from "./../../utils/testUtils";
|
|
7
7
|
|
|
8
|
-
jest.mock("./Tab", () => ({
|
|
9
|
-
__esModule: true,
|
|
10
|
-
default: require("../../utils/testUtils").PropStruct,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
8
|
const TestComp = () => <div />;
|
|
14
9
|
const TestComp1 = () => <div />;
|
|
15
10
|
const TestComp2 = () => <div />;
|