orc-shared 1.2.0-dev.13 → 1.2.0-dev.14
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/AppFrame.js +14 -4
- package/dist/components/AppFrame/MenuItem.js +1 -4
- package/dist/components/Routing/FullPage.js +6 -3
- package/package.json +1 -1
- package/src/components/AppFrame/AppFrame.js +13 -2
- package/src/components/AppFrame/AppFrame.test.js +53 -0
- package/src/components/AppFrame/MenuItem.js +1 -12
- package/src/components/Routing/FullPage.js +12 -4
- package/src/components/Routing/FullPage.test.js +24 -0
|
@@ -165,7 +165,17 @@ var AppFrame = function AppFrame(_ref) {
|
|
|
165
165
|
}, [needLogin]);
|
|
166
166
|
(0, _react.useEffect)(function () {
|
|
167
167
|
document.title = (currentApplication == null ? void 0 : currentApplication.displayName) || applicationId;
|
|
168
|
-
}, [currentApplication, applicationId]);
|
|
168
|
+
}, [currentApplication, applicationId]); // Extract only what's needed for the SideBar and its menuItems
|
|
169
|
+
|
|
170
|
+
var menuItemFromModules = (0, _react.useMemo)(function () {
|
|
171
|
+
return (modules != null ? modules : []).map(function (item) {
|
|
172
|
+
return {
|
|
173
|
+
id: item.id,
|
|
174
|
+
label: item.label,
|
|
175
|
+
icon: item.icon
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
}, [modules]);
|
|
169
179
|
|
|
170
180
|
var _useViewState = (0, _useViewState3.default)(_Preferences.PREFS_NAME),
|
|
171
181
|
_useViewState2 = _slicedToArray(_useViewState, 1),
|
|
@@ -191,7 +201,7 @@ var AppFrame = function AppFrame(_ref) {
|
|
|
191
201
|
}), /*#__PURE__*/_react.default.createElement(_Sidebar.default, {
|
|
192
202
|
open: open,
|
|
193
203
|
toggle: toggle,
|
|
194
|
-
modules:
|
|
204
|
+
modules: menuItemFromModules,
|
|
195
205
|
activeModules: activeModules
|
|
196
206
|
}), /*#__PURE__*/_react.default.createElement(ViewPort, {
|
|
197
207
|
open: open,
|
|
@@ -201,11 +211,11 @@ var AppFrame = function AppFrame(_ref) {
|
|
|
201
211
|
}), /*#__PURE__*/_react.default.createElement(_loadingScreen.default, null), /*#__PURE__*/_react.default.createElement(_Preferences.default, null));
|
|
202
212
|
};
|
|
203
213
|
|
|
204
|
-
__signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseViewState{[prefViewState]}", function () {
|
|
214
|
+
__signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseMemo{menuItemFromModules}\nuseViewState{[prefViewState]}", function () {
|
|
205
215
|
return [_reactIntl.useIntl, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _useApplicationHelpUrl.default, _useLoader.default, _useToggle3.default, _useLoader.default, _useViewState3.default];
|
|
206
216
|
});
|
|
207
217
|
|
|
208
|
-
__signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseViewState{[prefViewState]}", function () {
|
|
218
|
+
__signature__(AppFrame, "useIntl{{ formatMessage }}\nuseSelector{locale}\nuseSelector{needLogin}\nuseSelector{}\nuseSelector{moduleName}\nuseApplicationHelpUrl{[helpUrl]}\nuseLoader{}\nuseToggle{[open, toggle, reset]}\nuseLoader{}\nuseState{[doesApplicationNeedRefresh, setDoesApplicationNeedRefresh](false)}\nuseEffect{}\nuseEffect{}\nuseMemo{menuItemFromModules}\nuseViewState{[prefViewState]}", function () {
|
|
209
219
|
return [_reactIntl.useIntl, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _reactRedux.useSelector, _useApplicationHelpUrl.default, _useLoader.default, _useToggle3.default, _useLoader.default, _useViewState3.default];
|
|
210
220
|
});
|
|
211
221
|
|
|
@@ -20,7 +20,7 @@ var _Icon = _interopRequireDefault(require("../Icon"));
|
|
|
20
20
|
var _templateObject;
|
|
21
21
|
|
|
22
22
|
var _excluded = ["menuToggle", "staticContext", "dispatch", "active", "component"],
|
|
23
|
-
_excluded2 = ["open", "label", "icon", "alert", "
|
|
23
|
+
_excluded2 = ["open", "label", "icon", "alert", "isHidden", "href"];
|
|
24
24
|
|
|
25
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
26
|
|
|
@@ -134,9 +134,6 @@ var MenuItem = function MenuItem(_ref5) {
|
|
|
134
134
|
label = _ref5$label === void 0 ? "" : _ref5$label,
|
|
135
135
|
icon = _ref5.icon,
|
|
136
136
|
alert = _ref5.alert,
|
|
137
|
-
pageScopeSelector = _ref5.pageScopeSelector,
|
|
138
|
-
closingTabHandler = _ref5.closingTabHandler,
|
|
139
|
-
hide = _ref5.hide,
|
|
140
137
|
_ref5$isHidden = _ref5.isHidden,
|
|
141
138
|
isHidden = _ref5$isHidden === void 0 ? false : _ref5$isHidden,
|
|
142
139
|
href = _ref5.href,
|
|
@@ -35,8 +35,11 @@ var FullPage = function FullPage(_ref) {
|
|
|
35
35
|
location = _ref.location,
|
|
36
36
|
match = _ref.match,
|
|
37
37
|
modulePrependPath = _ref.modulePrependPath,
|
|
38
|
-
isVisible = _ref.isVisible
|
|
38
|
+
_ref$isVisible = _ref.isVisible,
|
|
39
|
+
isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible;
|
|
39
40
|
var component = config.component,
|
|
41
|
+
_config$routerCompone = config.routerComponent,
|
|
42
|
+
routerComponent = _config$routerCompone === void 0 ? null : _config$routerCompone,
|
|
40
43
|
componentProps = config.componentProps,
|
|
41
44
|
_config$pages = config.pages,
|
|
42
45
|
pages = _config$pages === void 0 ? {} : _config$pages,
|
|
@@ -59,12 +62,12 @@ var FullPage = function FullPage(_ref) {
|
|
|
59
62
|
|
|
60
63
|
return /*#__PURE__*/_react.default.createElement(_Page.default, {
|
|
61
64
|
path: path,
|
|
62
|
-
component: component,
|
|
65
|
+
component: component != null ? component : routerComponent,
|
|
63
66
|
pages: pages,
|
|
64
67
|
subpages: subpages,
|
|
65
68
|
location: location,
|
|
66
69
|
match: match,
|
|
67
|
-
isVisible: isVisible,
|
|
70
|
+
isVisible: isVisible === true || routerComponent != null,
|
|
68
71
|
modulePrependPath: modulePrependPath
|
|
69
72
|
});
|
|
70
73
|
};
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
|
2
2
|
import { useIntl } from "react-intl";
|
|
3
3
|
import pt from "prop-types";
|
|
4
4
|
import styled, { css } from "styled-components";
|
|
@@ -89,6 +89,17 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
|
|
|
89
89
|
document.title = currentApplication?.displayName || applicationId;
|
|
90
90
|
}, [currentApplication, applicationId]);
|
|
91
91
|
|
|
92
|
+
// Extract only what's needed for the SideBar and its menuItems
|
|
93
|
+
const menuItemFromModules = useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
(modules ?? []).map(item => ({
|
|
96
|
+
id: item.id,
|
|
97
|
+
label: item.label,
|
|
98
|
+
icon: item.icon,
|
|
99
|
+
})),
|
|
100
|
+
[modules],
|
|
101
|
+
);
|
|
102
|
+
|
|
92
103
|
const [prefViewState] = useViewState(PREFS_NAME);
|
|
93
104
|
|
|
94
105
|
return (
|
|
@@ -109,7 +120,7 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
|
|
|
109
120
|
}}
|
|
110
121
|
onClick={reset}
|
|
111
122
|
/>
|
|
112
|
-
<Sidebar {...{ open, toggle, modules, activeModules }} />
|
|
123
|
+
<Sidebar {...{ open, toggle, modules: menuItemFromModules, activeModules }} />
|
|
113
124
|
<ViewPort open={open} onClick={reset}>
|
|
114
125
|
{noScope && !forceShowScope.includes(moduleName) ? (
|
|
115
126
|
<React.Fragment>
|
|
@@ -294,6 +294,59 @@ describe("AppFrame", () => {
|
|
|
294
294
|
expect(document.title, "to equal", "Marketing Legacy");
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
+
it("renders a viewport with scope selector, top bar and sidebar with undefined modules", () => {
|
|
298
|
+
props.modules = undefined;
|
|
299
|
+
props.children = [<TestComp1 key="1" />, <TestComp2 key="2" />, <TestComp3 key="3" />];
|
|
300
|
+
expect(
|
|
301
|
+
<Provider store={store}>
|
|
302
|
+
<MemoryRouter initialEntries={["/Foo/bar"]}>
|
|
303
|
+
<ThemeProvider theme={{}}>
|
|
304
|
+
<I18n>
|
|
305
|
+
<AppFrame {...props} />
|
|
306
|
+
</I18n>
|
|
307
|
+
</ThemeProvider>
|
|
308
|
+
</MemoryRouter>
|
|
309
|
+
</Provider>,
|
|
310
|
+
"when mounted",
|
|
311
|
+
"to satisfy",
|
|
312
|
+
<Provider store={store}>
|
|
313
|
+
<ThemeProvider theme={{}}>
|
|
314
|
+
<MemoryRouter initialEntries={["/Foo/bar"]}>
|
|
315
|
+
<Base>
|
|
316
|
+
<Wrapper>
|
|
317
|
+
<AppBox>
|
|
318
|
+
<ApplicationSelector {...props} />
|
|
319
|
+
<AppLabel>
|
|
320
|
+
<AppLogo />
|
|
321
|
+
Marketing Legacy
|
|
322
|
+
</AppLabel>
|
|
323
|
+
</AppBox>
|
|
324
|
+
<MenuWrapper>
|
|
325
|
+
<Ignore />
|
|
326
|
+
</MenuWrapper>
|
|
327
|
+
<HelpLink>Help</HelpLink>
|
|
328
|
+
</Wrapper>
|
|
329
|
+
<SideBar>
|
|
330
|
+
<MenuToggle />
|
|
331
|
+
<Logo />
|
|
332
|
+
</SideBar>
|
|
333
|
+
<ViewPort>
|
|
334
|
+
<ScopeBar name="Test 1" />
|
|
335
|
+
<TestComp1 key="1" />
|
|
336
|
+
<TestComp2 key="2" />
|
|
337
|
+
<TestComp3 key="3" />
|
|
338
|
+
</ViewPort>
|
|
339
|
+
<About messages={props.aboutMessages} />
|
|
340
|
+
<LoadingScreen />
|
|
341
|
+
</Base>
|
|
342
|
+
</MemoryRouter>
|
|
343
|
+
</ThemeProvider>
|
|
344
|
+
</Provider>,
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
expect(document.title, "to equal", "Marketing Legacy");
|
|
348
|
+
});
|
|
349
|
+
|
|
297
350
|
it("renders a viewport with scope selector, top bar and sidebar when no current application", () => {
|
|
298
351
|
props.modules = [
|
|
299
352
|
{ id: "test1", component: TestComp1, route: "/test1" },
|
|
@@ -116,18 +116,7 @@ export const Label = styled.span`
|
|
|
116
116
|
opacity: ${ifFlag("show", 1, 0)};
|
|
117
117
|
`;
|
|
118
118
|
|
|
119
|
-
const MenuItem = ({
|
|
120
|
-
open = false,
|
|
121
|
-
label = "",
|
|
122
|
-
icon,
|
|
123
|
-
alert,
|
|
124
|
-
pageScopeSelector,
|
|
125
|
-
closingTabHandler,
|
|
126
|
-
hide, // This props is not used in the component, but we need to destructure it so props can be used in ItemWrapper
|
|
127
|
-
isHidden = false,
|
|
128
|
-
href,
|
|
129
|
-
...props
|
|
130
|
-
}) => {
|
|
119
|
+
const MenuItem = ({ open = false, label = "", icon, alert, isHidden = false, href, ...props }) => {
|
|
131
120
|
let ItemWrapper = Block;
|
|
132
121
|
if (props.menuToggle) {
|
|
133
122
|
ItemWrapper = BlockWithA;
|
|
@@ -2,8 +2,16 @@ import React from "react";
|
|
|
2
2
|
import Page from "./Page";
|
|
3
3
|
import SegmentPage from "./SegmentPage";
|
|
4
4
|
|
|
5
|
-
const FullPage = ({ path, config, location, match, modulePrependPath, isVisible }) => {
|
|
6
|
-
const {
|
|
5
|
+
const FullPage = ({ path, config, location, match, modulePrependPath, isVisible = true }) => {
|
|
6
|
+
const {
|
|
7
|
+
component,
|
|
8
|
+
routerComponent = null,
|
|
9
|
+
componentProps,
|
|
10
|
+
pages = {},
|
|
11
|
+
segments,
|
|
12
|
+
subpages,
|
|
13
|
+
entityIdResolver,
|
|
14
|
+
} = config;
|
|
7
15
|
if (segments) {
|
|
8
16
|
return (
|
|
9
17
|
<SegmentPage
|
|
@@ -21,12 +29,12 @@ const FullPage = ({ path, config, location, match, modulePrependPath, isVisible
|
|
|
21
29
|
return (
|
|
22
30
|
<Page
|
|
23
31
|
path={path}
|
|
24
|
-
component={component}
|
|
32
|
+
component={component ?? routerComponent}
|
|
25
33
|
pages={pages}
|
|
26
34
|
subpages={subpages}
|
|
27
35
|
location={location}
|
|
28
36
|
match={match}
|
|
29
|
-
isVisible={isVisible}
|
|
37
|
+
isVisible={isVisible === true || routerComponent != null}
|
|
30
38
|
modulePrependPath={modulePrependPath}
|
|
31
39
|
/>
|
|
32
40
|
);
|
|
@@ -86,6 +86,30 @@ describe("Fullpage", () => {
|
|
|
86
86
|
<View2 />,
|
|
87
87
|
));
|
|
88
88
|
|
|
89
|
+
it("shows a page when there is a router component no matter how visible is set", () =>
|
|
90
|
+
expect(
|
|
91
|
+
<TestWrapper
|
|
92
|
+
provider={{ store }}
|
|
93
|
+
memoryRouter={{ initialEntries: ["/meep/snap/stuff"] }}
|
|
94
|
+
stylesProvider
|
|
95
|
+
muiThemeProvider={{ theme }}
|
|
96
|
+
>
|
|
97
|
+
<FullPage
|
|
98
|
+
path="/meep/snap"
|
|
99
|
+
config={{
|
|
100
|
+
routerComponent: View1,
|
|
101
|
+
pages: { "/stuff": { component: View2 } },
|
|
102
|
+
}}
|
|
103
|
+
location={{ location: true }}
|
|
104
|
+
match={{ match: true }}
|
|
105
|
+
isVisible={false}
|
|
106
|
+
/>
|
|
107
|
+
</TestWrapper>,
|
|
108
|
+
"when mounted",
|
|
109
|
+
"to satisfy",
|
|
110
|
+
<View2 />,
|
|
111
|
+
));
|
|
112
|
+
|
|
89
113
|
it("does not show a page when not visible", () =>
|
|
90
114
|
expect(
|
|
91
115
|
<TestWrapper
|