orc-shared 1.1.0-dev.9 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/dist/actions/applications.js +1 -1
  2. package/dist/actions/authentication.js +1 -1
  3. package/dist/actions/countries.js +1 -1
  4. package/dist/actions/locale.js +1 -1
  5. package/dist/actions/makeApiAction.js +73 -3
  6. package/dist/actions/makeOrcApiAction.js +2 -2
  7. package/dist/actions/metadata.js +295 -31
  8. package/dist/actions/navigation.js +3 -3
  9. package/dist/actions/requestState.js +78 -0
  10. package/dist/actions/requestsApi.js +58 -7
  11. package/dist/actions/scopes.js +1 -1
  12. package/dist/actions/timezones.js +1 -1
  13. package/dist/actions/toasts.js +1 -1
  14. package/dist/actions/versionInfo.js +1 -1
  15. package/dist/actions/view.js +1 -1
  16. package/dist/buildStore.js +7 -4
  17. package/dist/components/AppFrame/About.js +3 -3
  18. package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
  19. package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
  20. package/dist/components/AppFrame/MenuItem.js +1 -1
  21. package/dist/components/AppFrame/Preferences.js +3 -3
  22. package/dist/components/AppFrame/Sidebar.js +1 -1
  23. package/dist/components/AppFrame/Topbar.js +1 -1
  24. package/dist/components/Authenticate.js +1 -1
  25. package/dist/components/CategoryList.js +1 -1
  26. package/dist/components/Checkbox.js +1 -1
  27. package/dist/components/DropMenu/Menu.js +1 -1
  28. package/dist/components/DropMenu/index.js +1 -1
  29. package/dist/components/Form/FieldList.js +3 -3
  30. package/dist/components/Form/Form.js +1 -1
  31. package/dist/components/Form/Inputs/Button.js +1 -1
  32. package/dist/components/Form/Inputs/FieldButtons.js +1 -1
  33. package/dist/components/Form/Inputs/Number.js +1 -1
  34. package/dist/components/Form/Inputs/ReadOnly.js +1 -1
  35. package/dist/components/Form/Inputs/SmallButton.js +1 -1
  36. package/dist/components/Form/Inputs/Text.js +1 -1
  37. package/dist/components/Form/Inputs/Time.js +1 -1
  38. package/dist/components/Form/Inputs/Toggles.js +1 -1
  39. package/dist/components/Form/Inputs/Translation.js +3 -3
  40. package/dist/components/List/HeadCell.js +1 -1
  41. package/dist/components/List/List.js +1 -1
  42. package/dist/components/List/Row.js +1 -1
  43. package/dist/components/List/enhanceColumnDefs.js +2 -2
  44. package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
  45. package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
  46. package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
  47. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +3 -3
  48. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +19 -6
  49. package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
  50. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
  51. package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
  52. package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
  53. package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
  54. package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
  55. package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
  56. package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
  57. package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +3 -3
  58. package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
  59. package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
  60. package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
  61. package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
  62. package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
  63. package/dist/components/MaterialUI/Inputs/DatePicker.js +11 -0
  64. package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
  65. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
  66. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  67. package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
  68. package/dist/components/MaterialUI/Inputs/Select.js +2 -2
  69. package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
  70. package/dist/components/MaterialUI/Inputs/Switch.js +3 -3
  71. package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
  72. package/dist/components/MaterialUI/Inputs/TimePicker.js +19 -8
  73. package/dist/components/MaterialUI/Inputs/createInput.js +3 -3
  74. package/dist/components/MaterialUI/Inputs/index.js +1 -1
  75. package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
  76. package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
  77. package/dist/components/MaterialUI/Navigation/TabBar.js +38 -33
  78. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +13 -5
  79. package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
  80. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  81. package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
  82. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
  83. package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
  84. package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
  85. package/dist/components/MaterialUI/muiThemes.js +21 -6
  86. package/dist/components/MaterialUI/textProps.js +1 -1
  87. package/dist/components/Modules.js +24 -2
  88. package/dist/components/MultiSelector.js +1 -1
  89. package/dist/components/Navigation/Bar.js +3 -3
  90. package/dist/components/Navigation/Tab.js +1 -1
  91. package/dist/components/Navigation/useNavigationState.js +30 -4
  92. package/dist/components/Placeholder.js +1 -1
  93. package/dist/components/Routing/FullPage.js +2 -0
  94. package/dist/components/Routing/Segment.js +4 -3
  95. package/dist/components/Routing/SegmentPage.js +8 -6
  96. package/dist/components/Routing/withWaypointing.js +10 -4
  97. package/dist/components/Scope/ScopeNode.js +1 -1
  98. package/dist/components/Scope/Selector.js +1 -1
  99. package/dist/components/Scope/index.js +11 -3
  100. package/dist/components/Scope/useScopeSelect.js +1 -1
  101. package/dist/components/Selector.js +1 -1
  102. package/dist/components/Sidepanel.js +1 -2
  103. package/dist/components/Spritesheet.js +1 -1
  104. package/dist/components/Switch.js +1 -1
  105. package/dist/components/Text.js +1 -1
  106. package/dist/components/ToastList.js +1 -1
  107. package/dist/components/Toolbar.js +1 -1
  108. package/dist/components/Treeview/Label.js +1 -1
  109. package/dist/components/Treeview/Leaf.js +1 -1
  110. package/dist/components/Treeview/Node.js +3 -3
  111. package/dist/components/Treeview/index.js +2 -2
  112. package/dist/components/Treeview/settings.js +1 -1
  113. package/dist/constants.js +26 -1
  114. package/dist/content/icons/html-templates.svg +3 -0
  115. package/dist/content/iconsSheet.svg +3 -0
  116. package/dist/getThemeOverrides.js +2 -2
  117. package/dist/hocs/withInfiniteScroll.js +1 -1
  118. package/dist/hocs/withUpdateHandler.js +2 -2
  119. package/dist/hooks/useDispatchWithModulesData.js +1 -1
  120. package/dist/hooks/useEditState.js +3 -3
  121. package/dist/hooks/useEntityLoader.js +182 -0
  122. package/dist/hooks/useFullEntityEditState.js +3 -3
  123. package/dist/hooks/useInfiniteScroll.js +104 -0
  124. package/dist/hooks/useLabelMessage.js +3 -3
  125. package/dist/hooks/useLoader.js +1 -0
  126. package/dist/hooks/useMultipleFieldEditState.js +2 -2
  127. package/dist/hooks/useNavigationHandler.js +1 -1
  128. package/dist/hooks/useNotificationRequestState.js +159 -0
  129. package/dist/hooks/useRequestState.js +146 -0
  130. package/dist/hooks/useSelectorAndUnwrap.js +1 -1
  131. package/dist/reducers/metadata.js +52 -26
  132. package/dist/reducers/requestStates.js +181 -0
  133. package/dist/schemas/countries.js +1 -1
  134. package/dist/schemas/definitions.js +1 -1
  135. package/dist/schemas/metadata.js +1 -1
  136. package/dist/schemas/productDefinitions.js +1 -1
  137. package/dist/schemas/timezones.js +1 -1
  138. package/dist/selectors/applications.js +1 -1
  139. package/dist/selectors/authentication.js +1 -2
  140. package/dist/selectors/countries.js +1 -1
  141. package/dist/selectors/locale.js +1 -1
  142. package/dist/selectors/metadata.js +117 -17
  143. package/dist/selectors/navigation.js +1 -1
  144. package/dist/selectors/requestStates.js +82 -0
  145. package/dist/selectors/requests.js +1 -1
  146. package/dist/selectors/scope.js +2 -1
  147. package/dist/selectors/versionInfo.js +1 -1
  148. package/dist/selectors/view.js +1 -1
  149. package/dist/sharedMessages.js +44 -0
  150. package/dist/spawnerMiddleware.js +1 -1
  151. package/dist/utils/displayModeHelper.js +1 -1
  152. package/dist/utils/flatten.js +2 -2
  153. package/dist/utils/localizationHelper.js +1 -1
  154. package/dist/utils/mapHelper.js +1 -1
  155. package/dist/utils/modelValidationHelper.js +2 -2
  156. package/dist/utils/parseHelper.js +1 -1
  157. package/dist/utils/propertyHelper.js +2 -2
  158. package/dist/utils/propertyValidator.js +1 -1
  159. package/dist/utils/setTranslation.js +27 -1
  160. package/dist/utils/setTranslationWithFallback.js +33 -3
  161. package/dist/utils/testUtils.js +6 -2
  162. package/dist/utils/timezoneHelper.js +111 -0
  163. package/dist/utils/unwrapImmutable.js +1 -1
  164. package/dist/utils/urlHelper.js +11 -1
  165. package/package.json +3 -7
  166. package/src/actions/makeApiAction.js +24 -1
  167. package/src/actions/makeApiAction.test.js +76 -3
  168. package/src/actions/metadata.js +130 -0
  169. package/src/actions/metadata.test.js +337 -5
  170. package/src/actions/requestState.js +8 -0
  171. package/src/actions/requestState.test.js +14 -0
  172. package/src/actions/requestsApi.js +30 -0
  173. package/src/buildStore.js +2 -0
  174. package/src/components/AppFrame/AppFrame.test.js +6 -16
  175. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
  176. package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
  177. package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
  178. package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
  179. package/src/components/AppFrame/Topbar.test.js +2 -4
  180. package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
  181. package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
  182. package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
  183. package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
  184. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  185. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  186. package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
  187. package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
  188. package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
  189. package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
  190. package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
  191. package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
  192. package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
  193. package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
  194. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +9 -3
  195. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
  196. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
  197. package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
  198. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
  199. package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
  200. package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
  201. package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
  202. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
  203. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
  204. package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
  205. package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
  206. package/src/components/MaterialUI/muiThemes.js +18 -3
  207. package/src/components/Modules.js +13 -1
  208. package/src/components/Modules.test.js +133 -1
  209. package/src/components/Navigation/Navigation.test.js +2 -0
  210. package/src/components/Navigation/useNavigationState.js +21 -1
  211. package/src/components/Navigation/useNavigationState.test.js +10 -0
  212. package/src/components/Routing/FullPage.js +2 -1
  213. package/src/components/Routing/FullPage.test.js +52 -0
  214. package/src/components/Routing/Segment.js +5 -2
  215. package/src/components/Routing/Segment.test.js +22 -1
  216. package/src/components/Routing/SegmentPage.js +12 -4
  217. package/src/components/Routing/SubPage.test.js +1 -1
  218. package/src/components/Routing/withWaypointing.js +19 -17
  219. package/src/components/Routing/withWaypointing.test.js +50 -0
  220. package/src/components/Scope/Scope.test.js +117 -0
  221. package/src/components/Scope/index.js +6 -10
  222. package/src/components/Sidepanel.js +0 -1
  223. package/src/components/Sidepanel.test.js +0 -3
  224. package/src/constants.js +18 -0
  225. package/src/content/icons/html-templates.svg +3 -0
  226. package/src/content/iconsSheet.svg +3 -0
  227. package/src/hooks/useEntityLoader.js +68 -0
  228. package/src/hooks/useEntityLoader.test.js +266 -0
  229. package/src/hooks/useInfiniteScroll.js +25 -0
  230. package/src/hooks/useInfiniteScroll.test.js +87 -0
  231. package/src/hooks/useLoader.js +1 -0
  232. package/src/hooks/useNotificationRequestState.js +78 -0
  233. package/src/hooks/useNotificationRequestState.test.js +264 -0
  234. package/src/hooks/useRequestState.js +57 -0
  235. package/src/hooks/useRequestState.test.js +217 -0
  236. package/src/reducers/metadata.js +76 -16
  237. package/src/reducers/metadata.test.js +458 -4
  238. package/src/reducers/requestStates.js +98 -0
  239. package/src/reducers/requestStates.test.js +399 -0
  240. package/src/selectors/authentication.js +0 -1
  241. package/src/selectors/locale.test.js +0 -2
  242. package/src/selectors/metadata.js +90 -19
  243. package/src/selectors/metadata.test.js +532 -123
  244. package/src/selectors/requestStates.js +12 -0
  245. package/src/selectors/requestStates.test.js +83 -0
  246. package/src/selectors/scope.js +1 -1
  247. package/src/sharedMessages.js +44 -0
  248. package/src/translations/en-US.json +12 -1
  249. package/src/translations/fr-CA.json +13 -2
  250. package/src/utils/modelValidationHelper.js +1 -1
  251. package/src/utils/setTranslation.js +16 -1
  252. package/src/utils/setTranslation.test.js +24 -0
  253. package/src/utils/setTranslationWithFallback.js +19 -2
  254. package/src/utils/setTranslationWithFallback.test.js +104 -6
  255. package/src/utils/testUtils.js +3 -1
  256. package/src/utils/timezoneHelper.js +140 -0
  257. package/src/utils/timezoneHelper.test.js +33 -0
  258. package/src/utils/urlHelper.js +6 -0
  259. package/src/translations/it-IT.json +0 -54
@@ -1,88 +1,111 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
2
+ import { FormattedMessage } from "react-intl";
3
+ import sharedMessages from "../../../sharedMessages";
4
+ import Link from "@material-ui/core/Link";
5
+ import Typography from "@material-ui/core/Typography";
6
+ import Grid from "@material-ui/core/Grid";
7
+ import { makeStyles } from "@material-ui/core/styles";
8
+ import classNames from "classnames";
3
9
 
4
- export const List = styled.div`
5
- display: flex;
6
- min-height: 10vh;
7
- max-height: 90vh;
8
- overflow-x: hidden;
9
- overflow-y: auto;
10
- width: 60vw;
11
- padding: 45px 60px 10px;
12
- justify-content: center;
13
- flex-wrap: wrap;
14
- `;
10
+ const useStyles = makeStyles(theme => ({
11
+ popperContainer: {
12
+ cursor: "pointer",
13
+ position: "relative",
14
+ },
15
+ header: {
16
+ borderBottom: `1px solid ${theme.palette.grey.light}`,
17
+ margin: theme.spacing(0),
18
+ padding: `${theme.spacing(1, 2)} !important`,
19
+ width: `calc(100% + ${theme.spacing(2)})`,
20
+ maxWidth: "none",
21
+ flexGrow: 1,
22
+ backgroundColor: theme.palette.grey.lighter,
23
+ textAlign: "center",
24
+ borderRadius: theme.spacing(1, 1, 0, 0),
25
+ },
26
+ content: {
27
+ borderRadius: theme.shape.borderRadius,
28
+ },
29
+ wrapper: {
30
+ backgroundColor: theme.palette.background.paper,
31
+ width: theme.spacing(82),
32
+ borderRadius: theme.spacing(1),
33
+ border: `1px solid ${theme.palette.grey.borders}`,
34
+ boxShadow: `${theme.spacing(0, 0, 2)} rgba(0,0,0,0.5)`,
35
+ position: "relative",
36
+ },
37
+ container: {
38
+ borderRadius: theme.shape.borderRadius,
39
+ textAlign: "center",
40
+ "&:hover": {
41
+ backgroundColor: theme.palette.grey.lighter,
42
+ },
43
+ overflow: "hidden",
44
+ },
45
+ containerSelected: {
46
+ boxShadow: `${theme.spacing(0, 0, 0.8)} ${theme.palette.grey.borders}`,
47
+ },
48
+ appLink: {
49
+ padding: theme.spacing(2),
50
+ display: "block",
51
+ },
52
+ headerTitle: {
53
+ fontSize: theme.typography.h3Size,
54
+ textTransform: theme.typography.button.textTransform,
55
+ fontFamily: theme.typography.button.fontFamily,
56
+ fontWeight: theme.typography.button.fontWeight,
57
+ },
58
+ label: {
59
+ fontSize: theme.typography.h4Size,
60
+ color: theme.palette.text.primary,
61
+ },
62
+ }));
15
63
 
16
- export const Block = styled.div`
17
- flex: 0 0 140px;
18
- text-align: center;
19
- height: 120px;
20
- display: flex;
21
- flex-flow: column nowrap;
22
- align-items: center;
23
- `;
24
- export const Link = styled.a``;
64
+ export const ApplicationDialog = ({ toggle, applications, applicationId, applicationOrder }) => {
65
+ const classes = useStyles();
25
66
 
26
- export const Logo = styled.img`
27
- height: 60px;
28
- width: 60px;
29
- border-radius: 50%;
30
-
31
- ${Link}:hover > & {
32
- background-color: rgba(255, 255, 255, 0.65);
33
- box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.65);
34
- }
35
- `;
36
-
37
- export const Label = styled.span`
38
- ${Link}:hover ~ & {
39
- visibility: visible;
40
- }
41
- visibility: hidden;
42
- display: block;
43
- margin: 22px -60px 0;
44
- font-family: Roboto, sans-serif;
45
- font-size: 14px;
46
- text-transform: uppercase;
47
- color: rgba(255, 255, 255, 0.65);
48
- `;
49
-
50
- export const Indicator = styled.div`
51
- background-color: white;
52
- border-radius: 50%;
53
- height: 8px;
54
- width: 8px;
55
- margin-top: -17px;
56
- ${Link}:hover ~ & {
57
- visibility: hidden;
58
- }
59
- `;
60
-
61
- const ApplicationDialog = ({ toggle, applications, applicationId, applicationOrder }) => (
62
- <List>
63
- {applications.map(app => (
64
- <Block key={app.name}>
65
- <Link
66
- id={app.name}
67
- href={app.url}
68
- target="_blank"
69
- onClick={
70
- app.name === applicationId
71
- ? event => {
72
- event.preventDefault();
73
- toggle();
74
- }
75
- : /* istanbul ignore next */
76
- () => {}
77
- }
78
- >
79
- <Logo src={app.iconUri} alt={app.displayName} />
80
- </Link>
81
- <Label>{app.displayName}</Label>
82
- {app.name === applicationId ? <Indicator /> : null}
83
- </Block>
84
- ))}
85
- </List>
86
- );
67
+ return (
68
+ <Grid container spacing={2} className={classes.wrapper}>
69
+ <Grid item xs={12} className={classes.header}>
70
+ <Typography
71
+ children={<FormattedMessage {...sharedMessages.appSelectorTitle} />}
72
+ className={classes.headerTitle}
73
+ />
74
+ </Grid>
75
+ <Grid item container xs={12} className={classes.content}>
76
+ {applications.map(app => (
77
+ <Grid
78
+ className={classNames(classes.container, app.name === applicationId ? classes.containerSelected : "")}
79
+ item
80
+ key={app.name}
81
+ xs={6}
82
+ md={3}
83
+ >
84
+ <Link
85
+ className={classes.appLink}
86
+ id={app.name}
87
+ href={app.url}
88
+ target="_blank"
89
+ underline="none"
90
+ onClick={
91
+ app.name === applicationId
92
+ ? event => {
93
+ event.preventDefault();
94
+ toggle();
95
+ }
96
+ : /* istanbul ignore next */
97
+ () => {}
98
+ }
99
+ >
100
+ <img height="60" src={app.iconUri} alt={app.displayName} />
101
+ <br />
102
+ <Typography children={app.displayName} className={classes.label} />
103
+ </Link>
104
+ </Grid>
105
+ ))}
106
+ </Grid>
107
+ </Grid>
108
+ );
109
+ };
87
110
 
88
111
  export default ApplicationDialog;
@@ -1,9 +1,16 @@
1
1
  import React from "react";
2
2
  import sinon from "sinon";
3
- import { getStyledClassSelector } from "../../../utils/testUtils";
4
- import ApplicationDialog, { List, Block, Link, Logo, Label, Indicator } from "./ApplicationDialog";
3
+ import { extractMessages, TestWrapper, createMuiTheme } from "../../../utils/testUtils";
4
+ import ApplicationDialog from "./ApplicationDialog";
5
+ import Link from "@material-ui/core/Link";
6
+ import Grid from "@material-ui/core/Grid";
7
+ import sharedMessages from "~/sharedMessages";
8
+ import { mount } from "enzyme";
5
9
 
10
+ const messages = extractMessages(sharedMessages);
6
11
  describe("ApplicationDialog", () => {
12
+ const theme = createMuiTheme();
13
+
7
14
  let toggle, applications;
8
15
  beforeEach(() => {
9
16
  toggle = sinon.spy().named("toggle");
@@ -23,30 +30,60 @@ describe("ApplicationDialog", () => {
23
30
  ];
24
31
  });
25
32
 
26
- it("renders a dialog structure listing applications", () =>
33
+ it("renders a dialog structure listing applications", () => {
34
+ const component = (
35
+ <TestWrapper intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
36
+ <ApplicationDialog toggle={toggle} applications={applications} applicationId="ChosenId" />
37
+ </TestWrapper>
38
+ );
39
+
40
+ const expected = (
41
+ <TestWrapper intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
42
+ <Grid>
43
+ <Grid>
44
+ <p>Orckestra Commerce Cloud Applications List</p>
45
+ </Grid>
46
+ <Grid>
47
+ <Grid key="ChosenId">
48
+ <Link href="/test/url" underline="none">
49
+ <img src="/url/to/img1.png" alt="Current App" />
50
+ <br />
51
+ <p>Current App</p>
52
+ </Link>
53
+ </Grid>
54
+ <Grid key="OtherId">
55
+ <Link href="/test/some/other/url" underline="none">
56
+ <img src="/url/to/img2.png" alt="Other App" />
57
+ <br />
58
+ <p>Other App</p>
59
+ </Link>
60
+ </Grid>
61
+ </Grid>
62
+ </Grid>
63
+ </TestWrapper>
64
+ );
65
+ expect(component, "when mounted", "to satisfy", expected);
66
+ });
67
+
68
+ it("triggers toggle when the current app link is clicked", () => {
69
+ const component = (
70
+ <TestWrapper intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
71
+ <ApplicationDialog toggle={toggle} applications={applications} applicationId="ChosenId" />
72
+ </TestWrapper>
73
+ );
74
+
75
+ const mountedComponent = mount(component);
76
+
77
+ const currAppLink = mountedComponent.find(Link).at(0);
78
+ currAppLink.simulate("click");
79
+ expect(toggle, "was called once");
80
+ });
81
+ /*
27
82
  expect(
28
83
  <ApplicationDialog toggle={toggle} applications={applications} applicationId="ChosenId" />,
29
84
  "when mounted",
30
- "with event",
31
- {
32
- type: "click",
33
- target: getStyledClassSelector(Link) + '[href="/test/url"]',
34
- },
35
85
  "to satisfy",
36
- <List>
37
- <Block key="ChosenId">
38
- <Link id="ChosenId" href="/test/url">
39
- <Logo src="/url/to/img1.png" />
40
- </Link>
41
- <Label>Current App</Label>
42
- <Indicator />
43
- </Block>
44
- <Block key="OtherId">
45
- <Link id="OtherId" href="/test/some/other/url">
46
- <Logo src="/url/to/img2.png" />
47
- </Link>
48
- <Label>Other App</Label>
49
- </Block>
50
- </List>,
86
+ ,
51
87
  ).then(() => expect(toggle, "was called once")));
88
+ */
52
89
  });
@@ -1,10 +1,16 @@
1
1
  import React from "react";
2
- import ApplicationSelector, { getAnchor, getDialog } from "./index";
3
- import Header, { MenuIcon, Wrapper } from "./Header";
4
- import ApplicationDialog, { List, Block, Link, Logo, Label, Indicator } from "./ApplicationDialog";
2
+ import { extractMessages, TestWrapper, createMuiTheme } from "../../../utils/testUtils";
3
+ import ApplicationSelector from "./index";
4
+ import PopperedIcon from "../../MaterialUI/DataDisplay/PopperedElements/PopperedIcon";
5
+ import ApplicationDialog from "./ApplicationDialog";
6
+ import sharedMessages from "~/sharedMessages";
7
+
8
+ const messages = extractMessages(sharedMessages);
5
9
 
6
10
  describe("ApplicationSelector", () => {
7
- let props, applications, thisApp, modalRoot;
11
+ const theme = createMuiTheme();
12
+
13
+ let props, applications, thisApp;
8
14
  beforeEach(() => {
9
15
  thisApp = {
10
16
  name: "current",
@@ -26,92 +32,19 @@ describe("ApplicationSelector", () => {
26
32
  applications,
27
33
  applicationId: "current",
28
34
  };
29
- modalRoot = document.createElement("div");
30
- modalRoot.id = "modal";
31
- document.body.appendChild(modalRoot);
32
- });
33
- afterEach(() => {
34
- document.body.removeChild(modalRoot);
35
35
  });
36
36
 
37
- it("renders a modal application selector dialog", () =>
38
- expect(
39
- <ApplicationSelector {...props} />,
40
- "when mounted",
41
- "with event",
42
- "click",
43
- "to satisfy",
44
- <Wrapper>
45
- <MenuIcon />
46
- </Wrapper>,
47
- ).then(() =>
48
- expect(
49
- modalRoot,
50
- "to contain",
51
- <List>
52
- <Block key="current">
53
- <Link href="/test/url">
54
- <Logo src="/url/to/img1.png" />
55
- </Link>
56
- <Label>Test label</Label>
57
- <Indicator />
58
- </Block>
59
- <Block key="other">
60
- <Link href="/test/elsewhere">
61
- <Logo src="/url/to/img2.png" />
62
- </Link>
63
- <Label>Test again</Label>
64
- </Block>
65
- </List>,
66
- ),
67
- ));
68
-
69
- describe("getAnchor", () => {
70
- let toggle;
71
- beforeEach(() => {
72
- toggle = () => {};
73
- });
74
-
75
- it("takes props and returns a header render function", () =>
76
- expect(
77
- getAnchor,
78
- "when called with",
79
- ["foo", props],
80
- "when called with",
81
- [toggle],
82
- "to equal",
83
- <Header className="foo" open application={thisApp} toggle={toggle} />,
84
- ));
85
-
86
- it("handles a missing app list", () => {
87
- delete props.applications;
88
- return expect(
89
- getAnchor,
90
- "when called with",
91
- ["foo", props],
92
- "when called with",
93
- [toggle],
94
- "to equal",
95
- <Header className="foo" open toggle={toggle} />,
96
- );
97
- });
98
- });
99
-
100
- describe("getDialog", () => {
101
- let toggle;
102
- beforeEach(() => {
103
- toggle = () => {};
104
- });
105
-
106
- it("takes props and returns a header render function", () =>
107
- expect(
108
- getDialog,
109
- "when called with",
110
- [props],
111
- "when called with",
112
- [toggle],
113
- "to equal",
114
- <ApplicationDialog open applications={applications} applicationId={props.applicationId} toggle={toggle} />,
115
- ));
37
+ it("renders a poppered application selector dialog", () => {
38
+ const component = (
39
+ <TestWrapper intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
40
+ <ApplicationSelector {...props} />
41
+ </TestWrapper>
42
+ );
43
+ const expected = (
44
+ <TestWrapper intlProvider={{ messages }} stylesProvider muiThemeProvider={{ theme }}>
45
+ <PopperedIcon popperValue={<ApplicationDialog {...props} />} id="app-list" placement="bottom-start" />
46
+ </TestWrapper>
47
+ );
48
+ expect(component, "when mounted", "to satisfy", expected);
116
49
  });
117
50
  });
@@ -1,24 +1,43 @@
1
1
  import React from "react";
2
- import Header from "./Header";
3
2
  import ApplicationDialog from "./ApplicationDialog";
4
- import Modal from "../../Modal";
3
+ import PopperedIcon from "../../MaterialUI/DataDisplay/PopperedElements/PopperedIcon";
4
+ import { makeStyles } from "@material-ui/core/styles";
5
5
 
6
- const getApp = (apps = [], id) => apps.filter(app => app.name === id)[0];
6
+ const useStyles = makeStyles(theme => ({
7
+ popperContainer: {
8
+ cursor: "pointer",
9
+ position: "relative",
10
+ fontSize: theme.spacing(2.4),
11
+ padding: theme.spacing(0.5, 1.3),
12
+ "& svg": {
13
+ color: theme.palette.grey.icon,
14
+ },
15
+ },
16
+ arrow: {
17
+ top: 0,
18
+ left: theme.spacing(1),
19
+ width: theme.spacing(1),
20
+ height: theme.spacing(1),
21
+ transform: "translateX(-50%) rotate(45deg)",
22
+ marginTop: theme.spacing(-1.5),
23
+ backgroundColor: theme.palette.grey.lighter,
24
+ border: "1px solid",
25
+ borderColor: `${theme.palette.grey.borders} transparent transparent ${theme.palette.grey.borders}`,
26
+ zIndex: 2000,
27
+ position: "absolute",
28
+ },
29
+ }));
7
30
 
8
- export const getAnchor = (className, props) => toggle =>
9
- (
10
- <Header
11
- className={className}
12
- open={props.open}
13
- application={getApp(props.applications, props.applicationId)}
14
- toggle={toggle}
31
+ const ApplicationSelector = ({ className, ...props }) => {
32
+ const classes = useStyles();
33
+ return (
34
+ <PopperedIcon
35
+ popperValue={<ApplicationDialog {...props} />}
36
+ id="app-list"
37
+ classprop={classes}
38
+ placement="bottom-start"
15
39
  />
16
40
  );
17
-
18
- export const getDialog = props => toggle => <ApplicationDialog {...props} toggle={toggle} />;
19
-
20
- const ApplicationSelector = ({ className, ...props }) => {
21
- return <Modal anchor={getAnchor(className, props)} content={getDialog(props)} look="dark" />;
22
41
  };
23
42
 
24
43
  export default ApplicationSelector;
@@ -9,7 +9,7 @@ import { VIEW_STATE_SET_FIELD } from "../../actions/view";
9
9
  import { SIGN_OUT_REQUEST, SIGN_OUT_SUCCESS, SIGN_OUT_FAILURE } from "../../actions/authentication";
10
10
  import { PREFS_NAME } from "./Preferences";
11
11
  import { ABOUT_NAME } from "./About";
12
- import { Wrapper as AppSelWrapper, MenuIcon } from "./ApplicationSelector/Header";
12
+ import ApplicationSelector from "./ApplicationSelector";
13
13
  import { Wrapper as MenuWrapper } from "../DropMenu";
14
14
  import Topbar, { Wrapper, AppBox, CurrentApp, AppLabel, AppLogo, useMenuProps } from "./Topbar";
15
15
  import { HelpLink } from "./Help";
@@ -79,9 +79,7 @@ describe("Topbar", () => {
79
79
  "to satisfy",
80
80
  <Wrapper onClick={clicker}>
81
81
  <AppBox>
82
- <AppSelWrapper>
83
- <MenuIcon />
84
- </AppSelWrapper>
82
+ <ApplicationSelector {...props} />
85
83
  <AppLabel>
86
84
  <AppLogo src="/test/url" />
87
85
  Test label
@@ -11,10 +11,13 @@ const useStyles = makeStyles(theme => ({
11
11
  fontSize: theme.spacing(1.2),
12
12
  marginBottom: theme.spacing(0.6),
13
13
  },
14
-
14
+ listHeight: {
15
+ height: props => props.height && theme.spacing(props.height),
16
+ },
15
17
  paper: {
18
+ flexGrow: 1,
19
+ height: "1px", // forces the container to takes 100%
16
20
  overflow: "auto",
17
- height: props => theme.spacing(props.height),
18
21
  border: `1px solid ${theme.palette.primary.light}`,
19
22
  borderRadius: theme.shape.borderRadius,
20
23
  boxShadow: "none",
@@ -38,6 +41,11 @@ const useStyles = makeStyles(theme => ({
38
41
  actionPanel: {
39
42
  paddingTop: theme.spacing(2),
40
43
  },
44
+ listContainer: {
45
+ display: "flex",
46
+ flexDirection: "column",
47
+ height: "100%",
48
+ },
41
49
  }));
42
50
 
43
51
  const defaultInfoPanelXs = 6;
@@ -74,7 +82,7 @@ const SelectionList = ({
74
82
  useEffect(() => {
75
83
  const listDataIds = listData.data.map(d => d.id);
76
84
  const checkedFromList = listDataIds.filter(l => checked.includes(l));
77
- if (defaultSelection && checkedFromList.length === 0) {
85
+ if (defaultSelection && checkedFromList.length === 0 && checked[0] !== defaultSelection) {
78
86
  setChecked([defaultSelection]);
79
87
  }
80
88
  }, [defaultSelection, checked, listData.data]);
@@ -101,7 +109,7 @@ const SelectionList = ({
101
109
  const dividerDiff = showDivider ? 1 : 0;
102
110
 
103
111
  const listComponent = (
104
- <>
112
+ <div className={classes.listContainer}>
105
113
  <div className={classes.title}>{listData.title}</div>
106
114
  <ScrollableCustomList
107
115
  ref={refScrollableList}
@@ -118,7 +126,7 @@ const SelectionList = ({
118
126
  onChange={onChangeEvent}
119
127
  />
120
128
  {actionPanel ? <div className={classes.actionPanel}>{actionPanel}</div> : null}
121
- </>
129
+ </div>
122
130
  );
123
131
 
124
132
  const dividerComponent = showDivider && (
@@ -129,7 +137,7 @@ const SelectionList = ({
129
137
 
130
138
  return (
131
139
  <Grid container spacing={2}>
132
- <Grid item xs={12 - infoPanelXs - dividerDiff}>
140
+ <Grid item xs={12 - infoPanelXs - dividerDiff} className={classes.listHeight}>
133
141
  {listComponent}
134
142
  </Grid>
135
143
  {dividerComponent}
@@ -33,8 +33,10 @@ describe("SelectionList", () => {
33
33
  <TestWrapper intlProvider={{ messages }}>
34
34
  <Grid>
35
35
  <Grid>
36
- <div>{listTitle}</div>
37
- <ScrollableCustomList checked={[]} items={list} classes={{}} />
36
+ <div>
37
+ <div>{listTitle}</div>
38
+ <ScrollableCustomList checked={[]} items={list} classes={{}} />
39
+ </div>
38
40
  </Grid>
39
41
  <Grid>
40
42
  <div></div>
@@ -60,8 +62,10 @@ describe("SelectionList", () => {
60
62
  <TestWrapper intlProvider={{ messages }}>
61
63
  <Grid>
62
64
  <Grid>
63
- <div>{listTitle}</div>
64
- <ScrollableCustomList checked={[]} items={list} classes={{}} />
65
+ <div>
66
+ <div>{listTitle}</div>
67
+ <ScrollableCustomList checked={[]} items={list} classes={{}} />
68
+ </div>
65
69
  </Grid>
66
70
  <Grid>
67
71
  <div></div>
@@ -86,8 +90,10 @@ describe("SelectionList", () => {
86
90
  const expected = (
87
91
  <Grid>
88
92
  <Grid>
89
- <div>{listTitle}</div>
90
- <ScrollableCustomList checked={[]} items={list} classes={{}} />
93
+ <div>
94
+ <div>{listTitle}</div>
95
+ <ScrollableCustomList checked={[]} items={list} classes={{}} />
96
+ </div>
91
97
  </Grid>
92
98
  <Grid>
93
99
  <hr />
@@ -117,9 +123,11 @@ describe("SelectionList", () => {
117
123
  const expected = (
118
124
  <Grid>
119
125
  <Grid>
120
- <div>{listTitle}</div>
121
- <ScrollableCustomList checked={[]} items={list} classes={{}} />
122
- <div>{actionPanel}</div>
126
+ <div>
127
+ <div>{listTitle}</div>
128
+ <ScrollableCustomList checked={[]} items={list} classes={{}} />
129
+ <div>{actionPanel}</div>
130
+ </div>
123
131
  </Grid>
124
132
  <Grid>
125
133
  <hr />
@@ -145,8 +153,10 @@ describe("SelectionList", () => {
145
153
  const expected = (
146
154
  <Grid>
147
155
  <Grid>
148
- <div>{listTitle}</div>
149
- <ScrollableCustomList checked={[]} items={list} classes={{}} />
156
+ <div>
157
+ <div>{listTitle}</div>
158
+ <ScrollableCustomList checked={[]} items={list} classes={{}} />
159
+ </div>
150
160
  </Grid>
151
161
  <Grid>
152
162
  <div>Test</div>