orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
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/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { getThemeProp } from "../../utils";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
5
4
|
import sharedMessages from "./../../sharedMessages";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
const useStyles = makeStyles(theme => ({
|
|
7
|
+
helpLink: {
|
|
8
|
+
fontFamily: theme.typography.button.fontFamily,
|
|
9
|
+
fontSize: "12px",
|
|
10
|
+
textTransform: "uppercase",
|
|
11
|
+
color: theme.palette.grey.borders,
|
|
12
|
+
width: "40px",
|
|
13
|
+
cursor: "pointer",
|
|
14
|
+
paddingTop: "14px",
|
|
15
|
+
paddingRight: "10px",
|
|
16
|
+
textDecoration: "none",
|
|
17
|
+
"&:hover": {
|
|
18
|
+
color: theme.palette.primary.light,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
21
22
|
|
|
22
23
|
const Help = ({ helpUrl }) => {
|
|
24
|
+
const classes = useStyles();
|
|
25
|
+
|
|
23
26
|
return (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
</
|
|
27
|
+
<a href={helpUrl} target="_blank" rel="noreferrer" className={classes.helpLink}>
|
|
28
|
+
<FormattedMessage {...sharedMessages.help} />
|
|
29
|
+
</a>
|
|
27
30
|
);
|
|
28
31
|
};
|
|
29
32
|
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import Immutable from "immutable";
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { IntlProvider } from "react-intl";
|
|
5
|
-
import Help
|
|
5
|
+
import Help from "./Help";
|
|
6
6
|
import { extractMessages } from "./../../utils/testUtils";
|
|
7
7
|
import sharedMessages from "./../../sharedMessages";
|
|
8
8
|
import { stringifyWithoutQuotes } from "./../../utils/parseHelper";
|
|
@@ -50,7 +50,7 @@ describe("Help", () => {
|
|
|
50
50
|
</Provider>,
|
|
51
51
|
"when mounted",
|
|
52
52
|
"to satisfy",
|
|
53
|
-
<
|
|
53
|
+
<a href="any_help_url.com">{stringifyWithoutQuotes(messages["orc-shared.help"])}</a>,
|
|
54
54
|
));
|
|
55
55
|
|
|
56
56
|
it("sets css for help button ", () =>
|
|
@@ -62,6 +62,6 @@ describe("Help", () => {
|
|
|
62
62
|
</Provider>,
|
|
63
63
|
"when mounted",
|
|
64
64
|
"to have style rules satisfying",
|
|
65
|
-
expect.it("to contain", "cursor: pointer;").and("to contain", ":hover {color: #
|
|
65
|
+
expect.it("to contain", "cursor: pointer;").and("to contain", ":hover {color: #7986cb;}"),
|
|
66
66
|
));
|
|
67
67
|
});
|
|
@@ -1,147 +1,127 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
import
|
|
3
|
-
import transition from "styled-transition-group";
|
|
2
|
+
import { makeStyles } from "@material-ui/core/styles";
|
|
4
3
|
import { Link } from "react-router-dom";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import Icon from "../Icon";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
8
6
|
|
|
9
|
-
const
|
|
7
|
+
const getToastColor = (theme, alertType) => {
|
|
8
|
+
const toastBorderColors = {
|
|
9
|
+
error: theme.palette.error.main,
|
|
10
|
+
warn: theme.palette.warning.main,
|
|
11
|
+
confirm: theme.palette.success.main,
|
|
12
|
+
};
|
|
13
|
+
return toastBorderColors[alertType] || "red";
|
|
14
|
+
};
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)};
|
|
21
|
-
text-decoration: none;
|
|
22
|
-
cursor: pointer;
|
|
16
|
+
const useStyles = makeStyles(theme => ({
|
|
17
|
+
block: props => ({
|
|
18
|
+
display: "block",
|
|
19
|
+
position: "relative",
|
|
20
|
+
padding: "0 10px",
|
|
21
|
+
marginBottom: "35px",
|
|
22
|
+
textDecoration: "none",
|
|
23
|
+
cursor: "pointer",
|
|
24
|
+
color: props.active ? theme.palette.primary.light : theme.palette.text.hint,
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
`,
|
|
32
|
-
)};
|
|
33
|
-
`;
|
|
26
|
+
"&:hover": {
|
|
27
|
+
color: props.menuToggle ? undefined : theme.palette.primary.light,
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
alert: props => {
|
|
31
|
+
const toastColor = getToastColor(theme, props.alertType);
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
return {
|
|
34
|
+
borderRadius: "50%",
|
|
35
|
+
border: `4px solid ${toastColor}`,
|
|
36
|
+
position: "absolute",
|
|
37
|
+
top: 0,
|
|
38
|
+
left: "27px",
|
|
39
|
+
visibility: "hidden",
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
"&.show": {
|
|
42
|
+
visibility: "visible",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
alertMessage: props => {
|
|
47
|
+
const toastColor = getToastColor(theme, props.alertType);
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
font-size: 11px;
|
|
63
|
-
font-weight: bold;
|
|
64
|
-
line-height: 1.2;
|
|
49
|
+
return {
|
|
50
|
+
position: "absolute",
|
|
51
|
+
zIndex: 10000,
|
|
52
|
+
top: "calc(-10px - 0.7em)",
|
|
53
|
+
left: "22px",
|
|
54
|
+
width: "max-content",
|
|
55
|
+
borderRadius: "5px",
|
|
56
|
+
padding: "10px 15px",
|
|
57
|
+
boxShadow: "0 2px 4px 0 rgba(0, 0, 0, 0.5)",
|
|
58
|
+
color: theme.palette.grey.light,
|
|
59
|
+
backgroundColor: toastColor,
|
|
60
|
+
fontSize: "11px",
|
|
61
|
+
fontWeight: "bold",
|
|
62
|
+
lineHeight: 1.2,
|
|
63
|
+
transition: `transform 200ms cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 100ms 50ms ease-out`,
|
|
64
|
+
opacity: 0.01,
|
|
65
|
+
transform: "translateX(-50%) scaleX(0)",
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
`;
|
|
76
|
-
const transitionStatement = css`
|
|
77
|
-
transition: transform ${transformTime}ms cubic-bezier(0.68, -0.55, 0.27, 1.55),
|
|
78
|
-
opacity ${opacityTime}ms ${opacityDelay}ms ease-out;
|
|
79
|
-
`;
|
|
80
|
-
export const AlertMessage = transition.div`
|
|
81
|
-
${alertStyling}
|
|
82
|
-
${transitionStatement}
|
|
67
|
+
"&::before": {
|
|
68
|
+
content: "",
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: "calc(10px + 0.2em)",
|
|
71
|
+
left: "-0.9em",
|
|
72
|
+
border: "solid transparent",
|
|
73
|
+
borderWidth: "0.4em 0.9em 0.4em 0",
|
|
74
|
+
borderRightColor: toastColor,
|
|
75
|
+
},
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
77
|
+
"&.show": {
|
|
78
|
+
opacity: 1,
|
|
79
|
+
transform: "translateX(0) scaleX(1)",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
menuIcon: props => ({
|
|
84
|
+
fontSize: "24px",
|
|
85
|
+
verticalAlign: "middle",
|
|
86
|
+
color: props.active ? theme.palette.primary.light : theme.palette.text.hint,
|
|
87
|
+
}),
|
|
88
|
+
label: props => ({
|
|
89
|
+
fontFamily: theme.typography.button.fontFamily,
|
|
90
|
+
fontSize: "13px",
|
|
91
|
+
verticalAlign: "middle",
|
|
92
|
+
textTransform: "uppercase",
|
|
93
|
+
paddingLeft: "10px",
|
|
94
|
+
transition: "opacity 0.3s ease-out",
|
|
95
|
+
opacity: props.showLabel ? 1 : 0,
|
|
96
|
+
}),
|
|
97
|
+
}));
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
font-size: 24px;
|
|
105
|
-
vertical-align: middle;
|
|
106
|
-
`;
|
|
99
|
+
const FilteredLink = ({ staticContext, dispatch, component, ...props }) => <Link {...props} />;
|
|
107
100
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
font-size: 13px;
|
|
111
|
-
vertical-align: middle;
|
|
112
|
-
text-transform: uppercase;
|
|
113
|
-
padding-left: 10px;
|
|
101
|
+
const MenuItem = ({ open = false, label = "", icon, alert, isHidden = false, href, menuToggle, active, ...props }) => {
|
|
102
|
+
const classes = useStyles({ active: active, menuToggle: menuToggle, alertType: alert?.type, showLabel: open });
|
|
114
103
|
|
|
115
|
-
transition: opacity 0.3s ease-out;
|
|
116
|
-
opacity: ${ifFlag("show", 1, 0)};
|
|
117
|
-
`;
|
|
118
|
-
|
|
119
|
-
const MenuItem = ({ open = false, label = "", icon, alert, isHidden = false, href, ...props }) => {
|
|
120
|
-
let ItemWrapper = Block;
|
|
121
|
-
if (props.menuToggle) {
|
|
122
|
-
ItemWrapper = BlockWithA;
|
|
123
|
-
}
|
|
124
104
|
const alertMessage = useRef("");
|
|
125
|
-
|
|
105
|
+
const showAlert = !!alert;
|
|
106
|
+
const showAlertMessage = !!alert?.message;
|
|
107
|
+
if (showAlert && showAlertMessage) {
|
|
126
108
|
alertMessage.current = alert.message;
|
|
127
109
|
}
|
|
128
110
|
|
|
111
|
+
if (isHidden) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ItemWrapper = menuToggle ? "a" : FilteredLink;
|
|
116
|
+
|
|
129
117
|
return (
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
</AlertMessage>
|
|
138
|
-
</Alert>
|
|
139
|
-
) : null}
|
|
140
|
-
<Label show={open}>
|
|
141
|
-
<Text message={label} />
|
|
142
|
-
</Label>
|
|
143
|
-
</ItemWrapper>
|
|
144
|
-
)
|
|
118
|
+
<ItemWrapper to={href} className={classes.block} {...props}>
|
|
119
|
+
<Icon id={icon} className={classes.menuIcon} />
|
|
120
|
+
<div className={`${classes.alert} ${showAlert ? "show" : undefined}`}>
|
|
121
|
+
<div className={`${classes.alertMessage} ${showAlertMessage ? "show" : undefined}`}>{alertMessage.current}</div>
|
|
122
|
+
</div>
|
|
123
|
+
<span className={classes.label}>{typeof label === "string" ? label : <FormattedMessage {...label} />}</span>
|
|
124
|
+
</ItemWrapper>
|
|
145
125
|
);
|
|
146
126
|
};
|
|
147
127
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Provider } from "react-redux";
|
|
3
|
-
import { ThemeProvider } from "styled-components";
|
|
4
3
|
import { MemoryRouter } from "react-router-dom";
|
|
5
4
|
import { Ignore } from "unexpected-reaction";
|
|
6
|
-
import MenuItem
|
|
5
|
+
import MenuItem from "./MenuItem";
|
|
6
|
+
import { Link } from "react-router-dom";
|
|
7
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
8
|
+
import sharedMessages from "./../../sharedMessages";
|
|
9
|
+
import { extractMessages, TestWrapper } from "./../../utils/testUtils";
|
|
7
10
|
|
|
8
|
-
const
|
|
11
|
+
const messages = extractMessages(sharedMessages);
|
|
9
12
|
|
|
10
13
|
describe("MenuItem", () => {
|
|
11
14
|
let store = {
|
|
@@ -24,10 +27,11 @@ describe("MenuItem", () => {
|
|
|
24
27
|
"when mounted",
|
|
25
28
|
"to satisfy",
|
|
26
29
|
<MemoryRouter>
|
|
27
|
-
<
|
|
28
|
-
<
|
|
30
|
+
<Link id="test" data-test-id="test" to="/foo/test">
|
|
31
|
+
<Icon id="cake" />
|
|
29
32
|
<Ignore />
|
|
30
|
-
|
|
33
|
+
<Ignore />
|
|
34
|
+
</Link>
|
|
31
35
|
</MemoryRouter>,
|
|
32
36
|
));
|
|
33
37
|
|
|
@@ -41,10 +45,11 @@ describe("MenuItem", () => {
|
|
|
41
45
|
"when mounted",
|
|
42
46
|
"to satisfy",
|
|
43
47
|
<MemoryRouter>
|
|
44
|
-
<
|
|
45
|
-
<
|
|
48
|
+
<a id="test">
|
|
49
|
+
<Icon id="cake" />
|
|
50
|
+
<Ignore />
|
|
46
51
|
<Ignore />
|
|
47
|
-
</
|
|
52
|
+
</a>
|
|
48
53
|
</MemoryRouter>,
|
|
49
54
|
));
|
|
50
55
|
|
|
@@ -58,10 +63,11 @@ describe("MenuItem", () => {
|
|
|
58
63
|
"when mounted",
|
|
59
64
|
"to satisfy",
|
|
60
65
|
<MemoryRouter>
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
|
|
66
|
+
<Link id="test" to="/foo/test">
|
|
67
|
+
<Icon id="cake" />
|
|
68
|
+
<Ignore />
|
|
69
|
+
<span>Test</span>
|
|
70
|
+
</Link>
|
|
65
71
|
</MemoryRouter>,
|
|
66
72
|
));
|
|
67
73
|
|
|
@@ -75,12 +81,11 @@ describe("MenuItem", () => {
|
|
|
75
81
|
"when mounted",
|
|
76
82
|
"to satisfy",
|
|
77
83
|
<MemoryRouter>
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
</Block>
|
|
84
|
+
<Link id="test" to="/foo/test">
|
|
85
|
+
<Icon id="cake" />
|
|
86
|
+
<Ignore />
|
|
87
|
+
<span></span>
|
|
88
|
+
</Link>
|
|
84
89
|
</MemoryRouter>,
|
|
85
90
|
));
|
|
86
91
|
|
|
@@ -94,11 +99,13 @@ describe("MenuItem", () => {
|
|
|
94
99
|
"when mounted",
|
|
95
100
|
"to satisfy",
|
|
96
101
|
<MemoryRouter>
|
|
97
|
-
<
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
<Link id="test" to="/foo/test">
|
|
103
|
+
<Icon id="cake" />
|
|
104
|
+
<div className="show">
|
|
105
|
+
<div></div>
|
|
106
|
+
</div>
|
|
107
|
+
<span>Test</span>
|
|
108
|
+
</Link>
|
|
102
109
|
</MemoryRouter>,
|
|
103
110
|
));
|
|
104
111
|
|
|
@@ -112,11 +119,13 @@ describe("MenuItem", () => {
|
|
|
112
119
|
"when mounted",
|
|
113
120
|
"to satisfy",
|
|
114
121
|
<MemoryRouter>
|
|
115
|
-
<
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
<Link id="test" to="/foo/test">
|
|
123
|
+
<Icon id="cake" />
|
|
124
|
+
<div className="show">
|
|
125
|
+
<div></div>
|
|
126
|
+
</div>
|
|
127
|
+
<span>Test</span>
|
|
128
|
+
</Link>
|
|
120
129
|
</MemoryRouter>,
|
|
121
130
|
));
|
|
122
131
|
|
|
@@ -130,13 +139,13 @@ describe("MenuItem", () => {
|
|
|
130
139
|
"when mounted",
|
|
131
140
|
"to satisfy",
|
|
132
141
|
<MemoryRouter>
|
|
133
|
-
<
|
|
134
|
-
<
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
</
|
|
138
|
-
<
|
|
139
|
-
</
|
|
142
|
+
<Link id="test" to="/foo/test">
|
|
143
|
+
<Icon id="cake" />
|
|
144
|
+
<div>
|
|
145
|
+
<div className="show">Test message</div>
|
|
146
|
+
</div>
|
|
147
|
+
<span>Test</span>
|
|
148
|
+
</Link>
|
|
140
149
|
</MemoryRouter>,
|
|
141
150
|
));
|
|
142
151
|
|
|
@@ -156,15 +165,13 @@ describe("MenuItem", () => {
|
|
|
156
165
|
"when mounted",
|
|
157
166
|
"to satisfy",
|
|
158
167
|
<MemoryRouter>
|
|
159
|
-
<
|
|
160
|
-
<
|
|
161
|
-
<
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<Label>Test</Label>
|
|
167
|
-
</Block>
|
|
168
|
+
<Link id="test" to="/foo/test">
|
|
169
|
+
<Icon id="cake" />
|
|
170
|
+
<div>
|
|
171
|
+
<div className="show">Test message</div>
|
|
172
|
+
</div>
|
|
173
|
+
<span>Test</span>
|
|
174
|
+
</Link>
|
|
168
175
|
</MemoryRouter>,
|
|
169
176
|
));
|
|
170
177
|
|
|
@@ -192,31 +199,27 @@ describe("MenuItem", () => {
|
|
|
192
199
|
const hide = state => false;
|
|
193
200
|
|
|
194
201
|
expect(
|
|
195
|
-
<
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
</MemoryRouter>
|
|
206
|
-
</Provider>,
|
|
202
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} memoryRouter>
|
|
203
|
+
<MenuItem
|
|
204
|
+
id="test"
|
|
205
|
+
href="/foo/test"
|
|
206
|
+
icon="cake"
|
|
207
|
+
label={{ id: "Test", defaultMessage: "Test" }}
|
|
208
|
+
alert={{ message: "Test message", type: "warn" }}
|
|
209
|
+
hide={hide}
|
|
210
|
+
/>
|
|
211
|
+
</TestWrapper>,
|
|
207
212
|
"when mounted",
|
|
208
213
|
"to satisfy",
|
|
209
|
-
<
|
|
210
|
-
<
|
|
211
|
-
<
|
|
212
|
-
<
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
</Block>
|
|
219
|
-
</MemoryRouter>,
|
|
214
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} memoryRouter>
|
|
215
|
+
<Link id="test" to="/foo/test">
|
|
216
|
+
<Icon id="cake" />
|
|
217
|
+
<div>
|
|
218
|
+
<div className="show">Test message</div>
|
|
219
|
+
</div>
|
|
220
|
+
<span>Test</span>
|
|
221
|
+
</Link>
|
|
222
|
+
</TestWrapper>,
|
|
220
223
|
);
|
|
221
224
|
});
|
|
222
225
|
|
|
@@ -237,108 +240,14 @@ describe("MenuItem", () => {
|
|
|
237
240
|
"when mounted",
|
|
238
241
|
"to satisfy",
|
|
239
242
|
<MemoryRouter>
|
|
240
|
-
<
|
|
241
|
-
<
|
|
242
|
-
<
|
|
243
|
-
<
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<Label>Test</Label>
|
|
248
|
-
</Block>
|
|
243
|
+
<Link id="test" to="/foo/test">
|
|
244
|
+
<Icon id="cake" />
|
|
245
|
+
<div>
|
|
246
|
+
<div className="show">Test message</div>
|
|
247
|
+
</div>
|
|
248
|
+
<span>Test</span>
|
|
249
|
+
</Link>
|
|
249
250
|
</MemoryRouter>,
|
|
250
251
|
);
|
|
251
252
|
});
|
|
252
|
-
|
|
253
|
-
describe("Block", () => {
|
|
254
|
-
it("sets text color to highlight if active", () =>
|
|
255
|
-
expect(
|
|
256
|
-
<MemoryRouter>
|
|
257
|
-
<Block to="" active />
|
|
258
|
-
</MemoryRouter>,
|
|
259
|
-
"when mounted",
|
|
260
|
-
"to have style rules satisfying",
|
|
261
|
-
"to contain",
|
|
262
|
-
"color: #ffffff;",
|
|
263
|
-
));
|
|
264
|
-
|
|
265
|
-
it("sets text color to grey if not active", () =>
|
|
266
|
-
expect(
|
|
267
|
-
<MemoryRouter>
|
|
268
|
-
<Block to="" />
|
|
269
|
-
</MemoryRouter>,
|
|
270
|
-
"when mounted",
|
|
271
|
-
"to have style rules satisfying",
|
|
272
|
-
"to contain",
|
|
273
|
-
"color: #999999;",
|
|
274
|
-
));
|
|
275
|
-
|
|
276
|
-
it("adds a hover rule if menu flag is unset", () =>
|
|
277
|
-
expect(
|
|
278
|
-
<MemoryRouter>
|
|
279
|
-
<Block to="" />
|
|
280
|
-
</MemoryRouter>,
|
|
281
|
-
"when mounted",
|
|
282
|
-
"to have style rules satisfying",
|
|
283
|
-
"to match",
|
|
284
|
-
/:hover\s*\{[^}]*\bcolor: #ffffff;[^}]*\}/,
|
|
285
|
-
));
|
|
286
|
-
|
|
287
|
-
it("does not add a hover rule if menuToggle flag is set", () =>
|
|
288
|
-
expect(
|
|
289
|
-
<MemoryRouter>
|
|
290
|
-
<Block to="" menuToggle />
|
|
291
|
-
</MemoryRouter>,
|
|
292
|
-
"when mounted",
|
|
293
|
-
"to have style rules satisfying",
|
|
294
|
-
"not to match",
|
|
295
|
-
/:hover\s*\{[^}]*\bcolor: #ffffff;[^}]*\}/,
|
|
296
|
-
));
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
describe("Label", () => {
|
|
300
|
-
it("sets full opacity if open", () =>
|
|
301
|
-
expect(<Label show />, "when mounted", "to have style rules satisfying", "to contain", "opacity: 1;"));
|
|
302
|
-
|
|
303
|
-
it("sets zero opacity if not open", () =>
|
|
304
|
-
expect(<Label />, "when mounted", "to have style rules satisfying", "to contain", "opacity: 0;"));
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe("Alert", () => {
|
|
308
|
-
it("has a default color (red)", () =>
|
|
309
|
-
expect(<Alert />, "when mounted", "to have style rules satisfying", "to match", /border: \d+px solid red/));
|
|
310
|
-
|
|
311
|
-
it("has a default color", () =>
|
|
312
|
-
expect(
|
|
313
|
-
<ThemeProvider theme={{ colors: { toasts: { test: "blue" } } }}>
|
|
314
|
-
<Alert type="test" />
|
|
315
|
-
</ThemeProvider>,
|
|
316
|
-
"when mounted",
|
|
317
|
-
"to have style rules satisfying",
|
|
318
|
-
"to match",
|
|
319
|
-
/border: \d+px solid blue/,
|
|
320
|
-
));
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
describe("AlertMessage", () => {
|
|
324
|
-
it("has a default color (red)", () =>
|
|
325
|
-
expect(
|
|
326
|
-
<AlertMessage in message="Test" />,
|
|
327
|
-
"when mounted",
|
|
328
|
-
"to have style rules satisfying",
|
|
329
|
-
"to contain",
|
|
330
|
-
"background-color: red",
|
|
331
|
-
));
|
|
332
|
-
|
|
333
|
-
it("has a default color", () =>
|
|
334
|
-
expect(
|
|
335
|
-
<ThemeProvider theme={{ colors: { toasts: { test: "blue" } } }}>
|
|
336
|
-
<AlertMessage in message="Test" type="test" />
|
|
337
|
-
</ThemeProvider>,
|
|
338
|
-
"when mounted",
|
|
339
|
-
"to have style rules satisfying",
|
|
340
|
-
"to contain",
|
|
341
|
-
"background-color: blue",
|
|
342
|
-
));
|
|
343
|
-
});
|
|
344
253
|
});
|