@webiny/app-admin 5.20.0-beta.1 → 5.21.0
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/assets/icons/slack-logo.svg +1 -1
- package/base/Admin.d.ts +14 -0
- package/base/Admin.js +29 -0
- package/base/Base.d.ts +2 -0
- package/base/Base.js +65 -0
- package/base/plugins/AddGraphQLQuerySelection.d.ts +9 -0
- package/base/plugins/AddGraphQLQuerySelection.js +15 -0
- package/base/providers/ApolloProvider.d.ts +4 -0
- package/base/providers/ApolloProvider.js +14 -0
- package/base/providers/TelemetryProvider.d.ts +4 -0
- package/base/providers/TelemetryProvider.js +19 -0
- package/base/providers/UiStateProvider.d.ts +4 -0
- package/base/providers/UiStateProvider.js +10 -0
- package/base/providers/ViewCompositionProvider.d.ts +18 -0
- package/base/providers/ViewCompositionProvider.js +44 -0
- package/base/ui/Brand.d.ts +9 -0
- package/base/ui/Brand.js +6 -0
- package/base/ui/CenteredView.d.ts +8 -0
- package/base/ui/CenteredView.js +27 -0
- package/base/ui/Dashboard.d.ts +9 -0
- package/base/ui/Dashboard.js +6 -0
- package/base/ui/Layout.d.ts +13 -0
- package/base/ui/Layout.js +11 -0
- package/base/ui/LocaleSelector.d.ts +9 -0
- package/base/ui/LocaleSelector.js +6 -0
- package/base/ui/LoginScreen.d.ts +9 -0
- package/base/ui/LoginScreen.js +7 -0
- package/base/ui/Logo.d.ts +14 -0
- package/base/ui/Logo.js +20 -0
- package/base/ui/Menu.d.ts +35 -0
- package/base/ui/Menu.js +80 -0
- package/base/ui/Navigation.d.ts +35 -0
- package/base/ui/Navigation.js +147 -0
- package/base/ui/NotFound.d.ts +9 -0
- package/base/ui/NotFound.js +6 -0
- package/base/ui/Search.d.ts +28 -0
- package/base/ui/Search.js +48 -0
- package/base/ui/Tags.d.ts +8 -0
- package/base/ui/Tags.js +13 -0
- package/base/ui/UserMenu.d.ts +54 -0
- package/base/ui/UserMenu.js +86 -0
- package/components/AdminLayout.js +5 -31
- package/components/AppInstaller/AppInstaller.d.ts +4 -0
- package/components/AppInstaller/AppInstaller.js +136 -0
- package/components/AppInstaller/index.d.ts +1 -4
- package/components/AppInstaller/index.js +13 -133
- package/components/AppInstaller/styled.d.ts +4 -4
- package/components/FileManager/BottomInfoBar/SupportedFileTypes.js +2 -2
- package/components/Routes.d.ts +6 -0
- package/components/Routes.js +34 -0
- package/index.d.ts +28 -0
- package/index.js +26 -0
- package/package.json +15 -13
- package/plugins/MenuPlugin.d.ts +18 -1
- package/plugins/globalSearch/SearchBar.d.ts +6 -3
- package/plugins/globalSearch/SearchBar.js +2 -1
- package/plugins/globalSearch/index.d.ts +0 -3
- package/plugins/globalSearch/index.js +0 -18
- package/plugins/globalSearch/styled.d.ts +3 -3
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +2 -4
- package/styles/material-theme-assignments.scss +1 -0
- package/types.d.ts +1 -10
- package/ui/elements/form/FileManagerElement/styled.d.ts +9 -9
- package/ui/elements/form/FileManagerElement.d.ts +2 -3
- package/plugins/logo/Logo.d.ts +0 -22
- package/plugins/logo/Logo.js +0 -108
- package/plugins/logo/index.d.ts +0 -5
- package/plugins/logo/index.js +0 -32
- package/plugins/menu/documentation.d.ts +0 -4
- package/plugins/menu/documentation.js +0 -16
- package/plugins/menu/fileManager.d.ts +0 -4
- package/plugins/menu/fileManager.js +0 -64
- package/plugins/menu/index.d.ts +0 -6
- package/plugins/menu/index.js +0 -24
- package/plugins/menu/renderers/MenuGroupRenderer.d.ts +0 -7
- package/plugins/menu/renderers/MenuGroupRenderer.js +0 -126
- package/plugins/menu/renderers/MenuLinkRenderer.d.ts +0 -7
- package/plugins/menu/renderers/MenuLinkRenderer.js +0 -52
- package/plugins/menu/renderers/MenuSectionItemRenderer.d.ts +0 -7
- package/plugins/menu/renderers/MenuSectionItemRenderer.js +0 -77
- package/plugins/menu/renderers/MenuSectionRenderer.d.ts +0 -7
- package/plugins/menu/renderers/MenuSectionRenderer.js +0 -51
- package/plugins/menu/slack.d.ts +0 -4
- package/plugins/menu/slack.js +0 -16
- package/plugins/menu/source.d.ts +0 -4
- package/plugins/menu/source.js +0 -16
- package/plugins/userMenu/UserMenuElement.d.ts +0 -7
- package/plugins/userMenu/UserMenuElement.js +0 -43
- package/plugins/userMenu/UserMenuRenderer.d.ts +0 -6
- package/plugins/userMenu/UserMenuRenderer.js +0 -47
- package/plugins/userMenu/index.d.ts +0 -4
- package/plugins/userMenu/index.js +0 -16
- package/ui/views/AdminView.d.ts +0 -12
- package/ui/views/AdminView.js +0 -90
- package/ui/views/NavigationView/ContentElement.d.ts +0 -10
- package/ui/views/NavigationView/ContentElement.js +0 -86
- package/ui/views/NavigationView/FooterElement.d.ts +0 -13
- package/ui/views/NavigationView/FooterElement.js +0 -59
- package/ui/views/NavigationView/HeaderElement.d.ts +0 -16
- package/ui/views/NavigationView/HeaderElement.js +0 -66
- package/ui/views/NavigationView/NavigationViewRenderer.d.ts +0 -6
- package/ui/views/NavigationView/NavigationViewRenderer.js +0 -38
- package/ui/views/NavigationView/Styled.d.ts +0 -7
- package/ui/views/NavigationView/Styled.js +0 -47
- package/ui/views/NavigationView/legacyMenu.d.ts +0 -22
- package/ui/views/NavigationView/legacyMenu.js +0 -1
- package/ui/views/NavigationView/useNavigation.d.ts +0 -6
- package/ui/views/NavigationView/useNavigation.js +0 -22
- package/ui/views/NavigationView.d.ts +0 -26
- package/ui/views/NavigationView.js +0 -204
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import React, { Fragment, useEffect, createContext, useCallback, useMemo, useState, useContext } from "react";
|
|
5
|
+
import { nanoid } from "nanoid";
|
|
6
|
+
import { makeComposable, Plugins } from "@webiny/app-admin-core";
|
|
7
|
+
import { AddMenu as Menu, Tags } from "../..";
|
|
8
|
+
import { plugins } from "@webiny/plugins";
|
|
9
|
+
var NavigationContext = /*#__PURE__*/createContext(null);
|
|
10
|
+
NavigationContext.displayName = "NavigationContext";
|
|
11
|
+
export function useNavigation() {
|
|
12
|
+
return useContext(NavigationContext);
|
|
13
|
+
} // IMPORTANT! The following component is for BACKWARDS COMPATIBILITY purposes only!
|
|
14
|
+
// It is not a public component, and is not even exported from this file. We need it to take care of
|
|
15
|
+
// scaffolded plugins in users' projects, as well as our own applications (Page Builder and Form Builder).
|
|
16
|
+
|
|
17
|
+
var LegacyMenu = function LegacyMenu(props) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(Menu, Object.assign({}, props, {
|
|
19
|
+
name: props.name || nanoid(),
|
|
20
|
+
label: props.label
|
|
21
|
+
}), props.children);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var LegacyMenuPlugins = function LegacyMenuPlugins() {
|
|
25
|
+
// IMPORTANT! The following piece of code is for BACKWARDS COMPATIBILITY purposes only!
|
|
26
|
+
var _useState = useState(null),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
menus = _useState2[0],
|
|
29
|
+
setMenus = _useState2[1];
|
|
30
|
+
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var menuPlugins = plugins.byType("admin-menu");
|
|
33
|
+
|
|
34
|
+
if (!menuPlugins) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var menuElements = menuPlugins.map(function (plugin) {
|
|
39
|
+
return /*#__PURE__*/React.createElement(Plugins, {
|
|
40
|
+
key: plugin.name
|
|
41
|
+
}, plugin.render({
|
|
42
|
+
Menu: LegacyMenu,
|
|
43
|
+
Item: LegacyMenu,
|
|
44
|
+
Section: LegacyMenu
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
setMenus(menuElements);
|
|
48
|
+
}, []);
|
|
49
|
+
return menus;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export var NavigationProvider = function NavigationProvider(Component) {
|
|
53
|
+
return function NavigationProvider(_ref) {
|
|
54
|
+
var children = _ref.children;
|
|
55
|
+
|
|
56
|
+
var _useState3 = useState([]),
|
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
+
menuItems = _useState4[0],
|
|
59
|
+
setState = _useState4[1];
|
|
60
|
+
|
|
61
|
+
var mergeMenuItems = function mergeMenuItems(item1, item2) {
|
|
62
|
+
var _item2$label, _item2$icon;
|
|
63
|
+
|
|
64
|
+
return _objectSpread(_objectSpread({}, item1), {}, {
|
|
65
|
+
label: (_item2$label = item2.label) !== null && _item2$label !== void 0 ? _item2$label : item1.label,
|
|
66
|
+
icon: (_item2$icon = item2.icon) !== null && _item2$icon !== void 0 ? _item2$icon : item1.icon,
|
|
67
|
+
children: item2.children.reduce(function (acc, menu) {
|
|
68
|
+
var index = acc.findIndex(function (i) {
|
|
69
|
+
return i.name === menu.name;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if (index > -1) {
|
|
73
|
+
acc[index] = mergeMenuItems(acc[index], menu);
|
|
74
|
+
} else {
|
|
75
|
+
acc.push(menu);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return acc;
|
|
79
|
+
}, _toConsumableArray(item1.children))
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var setMenu = function setMenu(id, menuItem) {
|
|
84
|
+
setState(function (state) {
|
|
85
|
+
var index = state.findIndex(function (m) {
|
|
86
|
+
return m.name === id;
|
|
87
|
+
});
|
|
88
|
+
return index > -1 ? [].concat(_toConsumableArray(state.slice(0, index)), [mergeMenuItems(state[index], menuItem)], _toConsumableArray(state.slice(index + 1))) : [].concat(_toConsumableArray(state), [menuItem]);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var removeMenu = useCallback(function (id) {
|
|
93
|
+
setState(function (state) {
|
|
94
|
+
var index = state.findIndex(function (m) {
|
|
95
|
+
return m.name === id;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (index < 0) {
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return [].concat(_toConsumableArray(state.slice(0, index)), _toConsumableArray(state.slice(index + 1)));
|
|
103
|
+
});
|
|
104
|
+
}, [setState]);
|
|
105
|
+
var context = useMemo(function () {
|
|
106
|
+
return {
|
|
107
|
+
menuItems: menuItems,
|
|
108
|
+
setMenu: setMenu,
|
|
109
|
+
removeMenu: removeMenu
|
|
110
|
+
};
|
|
111
|
+
}, [menuItems, setMenu, removeMenu]);
|
|
112
|
+
return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
113
|
+
value: context
|
|
114
|
+
}, /*#__PURE__*/React.createElement(LegacyMenuPlugins, null), /*#__PURE__*/React.createElement(Component, null, children));
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export var Navigation = function Navigation() {
|
|
118
|
+
return /*#__PURE__*/React.createElement(Tags, {
|
|
119
|
+
tags: {
|
|
120
|
+
location: "navigation"
|
|
121
|
+
}
|
|
122
|
+
}, /*#__PURE__*/React.createElement(NavigationRenderer, null));
|
|
123
|
+
};
|
|
124
|
+
export var NavigationRenderer = makeComposable("NavigationRenderer");
|
|
125
|
+
var MenuItemContext = /*#__PURE__*/React.createContext(null);
|
|
126
|
+
MenuItemContext.displayName = "MenuItemContext";
|
|
127
|
+
export function useMenuItem() {
|
|
128
|
+
return React.useContext(MenuItemContext);
|
|
129
|
+
}
|
|
130
|
+
export var MenuItems = makeComposable("MenuItems", function (_ref2) {
|
|
131
|
+
var menuItems = _ref2.menuItems;
|
|
132
|
+
var menuItem = useMenuItem();
|
|
133
|
+
var depth = menuItem ? menuItem.depth : -1;
|
|
134
|
+
return /*#__PURE__*/React.createElement(Fragment, null, menuItems.map(function (menuItem) {
|
|
135
|
+
return /*#__PURE__*/React.createElement(MenuItemContext.Provider, {
|
|
136
|
+
key: menuItem.name,
|
|
137
|
+
value: {
|
|
138
|
+
menuItem: menuItem,
|
|
139
|
+
depth: depth + 1
|
|
140
|
+
}
|
|
141
|
+
}, /*#__PURE__*/React.createElement(MenuItem, null));
|
|
142
|
+
}));
|
|
143
|
+
});
|
|
144
|
+
export var MenuItem = function MenuItem() {
|
|
145
|
+
return /*#__PURE__*/React.createElement(MenuItemRenderer, null);
|
|
146
|
+
};
|
|
147
|
+
export var MenuItemRenderer = makeComposable("MenuItemRenderer");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const NotFound: React.FC<unknown> & {
|
|
3
|
+
original: React.ComponentType<unknown>;
|
|
4
|
+
originalName: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const NotFoundRenderer: React.FC<unknown> & {
|
|
7
|
+
original: React.ComponentType<unknown>;
|
|
8
|
+
originalName: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { makeComposable } from "@webiny/app-admin-core";
|
|
3
|
+
export var NotFound = makeComposable("NotFound", function () {
|
|
4
|
+
return /*#__PURE__*/React.createElement(NotFoundRenderer, null);
|
|
5
|
+
});
|
|
6
|
+
export var NotFoundRenderer = makeComposable("NotFoundRenderer");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface SearchOptionData {
|
|
3
|
+
route: string;
|
|
4
|
+
label: string;
|
|
5
|
+
search?: {
|
|
6
|
+
operator?: "and" | "or";
|
|
7
|
+
fields?: Array<string>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface SearchContext {
|
|
11
|
+
options: SearchOptionData[];
|
|
12
|
+
addOption(option: SearchOptionData): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useSearch(): SearchContext;
|
|
15
|
+
export declare const SearchProvider: (Component: any) => ({ children, ...props }: {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
children: any;
|
|
18
|
+
}) => JSX.Element;
|
|
19
|
+
export declare const Search: React.FC<unknown> & {
|
|
20
|
+
original: React.ComponentType<unknown>;
|
|
21
|
+
originalName: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const SearchRenderer: React.FC<unknown> & {
|
|
24
|
+
original: React.ComponentType<unknown>;
|
|
25
|
+
originalName: string;
|
|
26
|
+
};
|
|
27
|
+
export declare type SearchOptionProps = SearchOptionData;
|
|
28
|
+
export declare const SearchOption: (props: SearchOptionProps) => any;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["children"];
|
|
5
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
6
|
+
import { makeComposable } from "@webiny/app-admin-core";
|
|
7
|
+
var SearchContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
+
SearchContext.displayName = "SearchContext";
|
|
9
|
+
export function useSearch() {
|
|
10
|
+
return React.useContext(SearchContext);
|
|
11
|
+
}
|
|
12
|
+
export var SearchProvider = function SearchProvider(Component) {
|
|
13
|
+
return function SearchProvider(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
|
|
17
|
+
var _useState = useState([]),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
options = _useState2[0],
|
|
20
|
+
setOptions = _useState2[1];
|
|
21
|
+
|
|
22
|
+
var addOption = useCallback(function (option) {
|
|
23
|
+
return setOptions(function (options) {
|
|
24
|
+
return [].concat(_toConsumableArray(options), [option]);
|
|
25
|
+
});
|
|
26
|
+
}, [setOptions]);
|
|
27
|
+
var context = {
|
|
28
|
+
options: options,
|
|
29
|
+
addOption: addOption
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/React.createElement(SearchContext.Provider, {
|
|
32
|
+
value: context
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Component, props, children));
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export var Search = makeComposable("Search", function () {
|
|
37
|
+
return /*#__PURE__*/React.createElement(SearchRenderer, null);
|
|
38
|
+
});
|
|
39
|
+
export var SearchRenderer = makeComposable("SearchRenderer");
|
|
40
|
+
export var SearchOption = function SearchOption(props) {
|
|
41
|
+
var _useSearch = useSearch(),
|
|
42
|
+
addOption = _useSearch.addOption;
|
|
43
|
+
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
addOption(props);
|
|
46
|
+
}, []);
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TagsProps {
|
|
3
|
+
tags: Record<string, string | boolean>;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const Tags: ({ tags, children }: TagsProps) => JSX.Element;
|
|
7
|
+
export declare const useTags: () => Record<string, string | boolean>;
|
|
8
|
+
export {};
|
package/base/ui/Tags.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
var TagsContext = /*#__PURE__*/createContext({});
|
|
3
|
+
TagsContext.displayName = "TagsContext";
|
|
4
|
+
export var Tags = function Tags(_ref) {
|
|
5
|
+
var tags = _ref.tags,
|
|
6
|
+
children = _ref.children;
|
|
7
|
+
return /*#__PURE__*/React.createElement(TagsContext.Provider, {
|
|
8
|
+
value: tags
|
|
9
|
+
}, children);
|
|
10
|
+
};
|
|
11
|
+
export var useTags = function useTags() {
|
|
12
|
+
return useContext(TagsContext);
|
|
13
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface UserMenuItemData {
|
|
3
|
+
label?: string;
|
|
4
|
+
icon?: JSX.Element;
|
|
5
|
+
path?: string;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
element?: JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
export interface UserMenuContext {
|
|
10
|
+
menuItems: UserMenuItemData[];
|
|
11
|
+
addMenuItem(item: UserMenuItemData): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useUserMenu(): UserMenuContext;
|
|
14
|
+
export declare const UserMenuProvider: (Component: any) => ({ children, ...props }: {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
children: any;
|
|
17
|
+
}) => JSX.Element;
|
|
18
|
+
export declare const UserMenu: React.FC<unknown> & {
|
|
19
|
+
original: React.ComponentType<unknown>;
|
|
20
|
+
originalName: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const UserMenuRenderer: React.FC<unknown> & {
|
|
23
|
+
original: React.ComponentType<unknown>;
|
|
24
|
+
originalName: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const UserMenuHandle: React.FC<unknown> & {
|
|
27
|
+
original: React.ComponentType<unknown>;
|
|
28
|
+
originalName: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const UserMenuHandleRenderer: React.FC<unknown> & {
|
|
31
|
+
original: React.ComponentType<unknown>;
|
|
32
|
+
originalName: string;
|
|
33
|
+
};
|
|
34
|
+
export interface UserMenuItemProps {
|
|
35
|
+
menuItem: UserMenuItemData;
|
|
36
|
+
}
|
|
37
|
+
export declare const UserMenuItem: React.FC<UserMenuItemProps> & {
|
|
38
|
+
original: React.ComponentType<UserMenuItemProps>;
|
|
39
|
+
originalName: string;
|
|
40
|
+
};
|
|
41
|
+
export declare const UserMenuItemRenderer: React.FC<unknown> & {
|
|
42
|
+
original: React.ComponentType<unknown>;
|
|
43
|
+
originalName: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const AddUserMenuItem: (props: UserMenuItemProps["menuItem"]) => any;
|
|
46
|
+
export declare type UserMenuItemContext = UserMenuItemData;
|
|
47
|
+
export declare function useUserMenuItem(): UserMenuItemData;
|
|
48
|
+
export interface UserMenuItemsProps {
|
|
49
|
+
menuItems: UserMenuItemData[];
|
|
50
|
+
}
|
|
51
|
+
export declare const UserMenuItems: React.FC<UserMenuItemsProps> & {
|
|
52
|
+
original: React.ComponentType<UserMenuItemsProps>;
|
|
53
|
+
originalName: string;
|
|
54
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["children"];
|
|
5
|
+
import React, { Fragment, useCallback, useEffect, useState } from "react";
|
|
6
|
+
import { makeComposable } from "@webiny/app-admin-core";
|
|
7
|
+
var UserMenuContext = /*#__PURE__*/React.createContext(null);
|
|
8
|
+
UserMenuContext.displayName = "UserMenuContext";
|
|
9
|
+
export function useUserMenu() {
|
|
10
|
+
return React.useContext(UserMenuContext);
|
|
11
|
+
}
|
|
12
|
+
export var UserMenuProvider = function UserMenuProvider(Component) {
|
|
13
|
+
return function UserMenuProvider(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
|
|
17
|
+
var _useState = useState([]),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
menuItems = _useState2[0],
|
|
20
|
+
setItems = _useState2[1];
|
|
21
|
+
|
|
22
|
+
var addMenuItem = useCallback(function (item) {
|
|
23
|
+
setItems(function (items) {
|
|
24
|
+
return [].concat(_toConsumableArray(items), [item]);
|
|
25
|
+
});
|
|
26
|
+
return function () {
|
|
27
|
+
setItems(function (items) {
|
|
28
|
+
var index = items.findIndex(function (i) {
|
|
29
|
+
return i === item;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (index < 0) {
|
|
33
|
+
return items;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return [].concat(_toConsumableArray(items.slice(0, index)), _toConsumableArray(items.slice(index + 1)));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}, [setItems]);
|
|
40
|
+
var context = {
|
|
41
|
+
menuItems: menuItems,
|
|
42
|
+
addMenuItem: addMenuItem
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/React.createElement(UserMenuContext.Provider, {
|
|
45
|
+
value: context
|
|
46
|
+
}, /*#__PURE__*/React.createElement(Component, props, children));
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export var UserMenu = makeComposable("UserMenu", function () {
|
|
50
|
+
return /*#__PURE__*/React.createElement(UserMenuRenderer, null);
|
|
51
|
+
});
|
|
52
|
+
export var UserMenuRenderer = makeComposable("UserMenuRenderer");
|
|
53
|
+
export var UserMenuHandle = makeComposable("UserMenuHandle", function () {
|
|
54
|
+
return /*#__PURE__*/React.createElement(UserMenuHandleRenderer, null);
|
|
55
|
+
});
|
|
56
|
+
export var UserMenuHandleRenderer = makeComposable("UserMenuHandleRenderer");
|
|
57
|
+
export var UserMenuItem = makeComposable("UserMenuItem", function (_ref2) {
|
|
58
|
+
var menuItem = _ref2.menuItem;
|
|
59
|
+
return /*#__PURE__*/React.createElement(UserMenuItemContext.Provider, {
|
|
60
|
+
value: menuItem
|
|
61
|
+
}, /*#__PURE__*/React.createElement(UserMenuItemRenderer, null));
|
|
62
|
+
});
|
|
63
|
+
export var UserMenuItemRenderer = makeComposable("UserMenuItemRenderer");
|
|
64
|
+
export var AddUserMenuItem = function AddUserMenuItem(props) {
|
|
65
|
+
var _useUserMenu = useUserMenu(),
|
|
66
|
+
addMenuItem = _useUserMenu.addMenuItem;
|
|
67
|
+
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
return addMenuItem(props);
|
|
70
|
+
}, []);
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
var UserMenuItemContext = /*#__PURE__*/React.createContext(null);
|
|
74
|
+
UserMenuItemContext.displayName = "UserMenuItemContext";
|
|
75
|
+
export function useUserMenuItem() {
|
|
76
|
+
return React.useContext(UserMenuItemContext);
|
|
77
|
+
}
|
|
78
|
+
export var UserMenuItems = makeComposable("UserMenuItems", function (_ref3) {
|
|
79
|
+
var menuItems = _ref3.menuItems;
|
|
80
|
+
return /*#__PURE__*/React.createElement(Fragment, null, menuItems.map(function (item, index) {
|
|
81
|
+
return /*#__PURE__*/React.createElement(UserMenuItem, {
|
|
82
|
+
key: index,
|
|
83
|
+
menuItem: item
|
|
84
|
+
});
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { UIViewComponent } from "../ui/UIView";
|
|
4
|
-
import { GenericElement } from "../ui/elements/GenericElement";
|
|
5
|
-
import { AdminView } from "../ui/views/AdminView";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Layout } from "./..";
|
|
6
3
|
export var AdminLayout = function AdminLayout(_ref) {
|
|
7
4
|
var title = _ref.title,
|
|
8
5
|
children = _ref.children;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
view = _useState2[0],
|
|
13
|
-
setView = _useState2[1];
|
|
14
|
-
|
|
15
|
-
useEffect(function () {
|
|
16
|
-
var view = new AdminView();
|
|
17
|
-
|
|
18
|
-
if (title) {
|
|
19
|
-
view.setTitle(title);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
view.setContentElement(new GenericElement("admin-layout-content", function () {
|
|
23
|
-
return children;
|
|
24
|
-
}));
|
|
25
|
-
setView(view);
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
if (!view) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return /*#__PURE__*/React.createElement(UIViewComponent, {
|
|
33
|
-
view: view
|
|
34
|
-
});
|
|
6
|
+
return /*#__PURE__*/React.createElement(Layout, {
|
|
7
|
+
title: title
|
|
8
|
+
}, children);
|
|
35
9
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { default as localStorage } from "store";
|
|
4
|
+
import { LoginScreen } from "../..";
|
|
5
|
+
import { useSecurity } from "@webiny/app-security";
|
|
6
|
+
import { CircularProgress } from "@webiny/ui/Progress";
|
|
7
|
+
import { ButtonPrimary } from "@webiny/ui/Button";
|
|
8
|
+
import { SplitView, LeftPanel, RightPanel } from "../SplitView";
|
|
9
|
+
import { Grid, Cell } from "@webiny/ui/Grid";
|
|
10
|
+
import { Typography } from "@webiny/ui/Typography";
|
|
11
|
+
import { Elevation } from "@webiny/ui/Elevation";
|
|
12
|
+
import { useInstaller } from "./useInstaller";
|
|
13
|
+
import Sidebar from "./Sidebar";
|
|
14
|
+
import { Wrapper, alertClass, InnerContent, InstallContent, installerSplitView, SuccessDialog } from "./styled";
|
|
15
|
+
import { config as appConfig } from "@webiny/app/config";
|
|
16
|
+
export var AppInstaller = function AppInstaller(_ref) {
|
|
17
|
+
var children = _ref.children;
|
|
18
|
+
var tenantId = localStorage.get("webiny_tenant") || "root";
|
|
19
|
+
var lsKey = "webiny_installation_".concat(tenantId);
|
|
20
|
+
var wbyVersion = appConfig.getKey("WEBINY_VERSION", process.env.REACT_APP_WEBINY_VERSION);
|
|
21
|
+
|
|
22
|
+
var markInstallerAsCompleted = function markInstallerAsCompleted() {
|
|
23
|
+
localStorage.set(lsKey, wbyVersion);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var isInstallerCompleted = function isInstallerCompleted() {
|
|
27
|
+
return localStorage.get(lsKey) === wbyVersion;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
finished = _useState2[0],
|
|
33
|
+
setFinished = _useState2[1];
|
|
34
|
+
|
|
35
|
+
var _useSecurity = useSecurity(),
|
|
36
|
+
identity = _useSecurity.identity;
|
|
37
|
+
|
|
38
|
+
var _useInstaller = useInstaller({
|
|
39
|
+
isInstalled: isInstallerCompleted()
|
|
40
|
+
}),
|
|
41
|
+
loading = _useInstaller.loading,
|
|
42
|
+
installers = _useInstaller.installers,
|
|
43
|
+
installer = _useInstaller.installer,
|
|
44
|
+
showNextInstaller = _useInstaller.showNextInstaller,
|
|
45
|
+
showLogin = _useInstaller.showLogin,
|
|
46
|
+
onUser = _useInstaller.onUser,
|
|
47
|
+
skippingVersions = _useInstaller.skippingVersions;
|
|
48
|
+
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
if (identity) {
|
|
51
|
+
onUser();
|
|
52
|
+
}
|
|
53
|
+
}, [identity]);
|
|
54
|
+
|
|
55
|
+
if (isInstallerCompleted()) {
|
|
56
|
+
return /*#__PURE__*/React.createElement(LoginScreen, null, children);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var renderLayout = function renderLayout(content) {
|
|
60
|
+
var secure = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
61
|
+
return /*#__PURE__*/React.createElement(SplitView, {
|
|
62
|
+
className: installerSplitView
|
|
63
|
+
}, /*#__PURE__*/React.createElement(LeftPanel, {
|
|
64
|
+
span: 2
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Sidebar, {
|
|
66
|
+
allInstallers: installers,
|
|
67
|
+
installer: installer,
|
|
68
|
+
showLogin: showLogin
|
|
69
|
+
})), /*#__PURE__*/React.createElement(RightPanel, {
|
|
70
|
+
span: 10
|
|
71
|
+
}, !showLogin && !secure && content, (showLogin || secure) && /*#__PURE__*/React.createElement(LoginScreen, null, content)));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var renderBody = function renderBody(content) {
|
|
75
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(InstallContent, null, /*#__PURE__*/React.createElement(InnerContent, null, content)));
|
|
76
|
+
}; // Loading installers data
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if (loading) {
|
|
80
|
+
return /*#__PURE__*/React.createElement(CircularProgress, {
|
|
81
|
+
label: "Checking apps..."
|
|
82
|
+
});
|
|
83
|
+
} // This means there are no installers to run or installation was finished
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (!loading && (installers.length === 0 || finished)) {
|
|
87
|
+
markInstallerAsCompleted();
|
|
88
|
+
return /*#__PURE__*/React.createElement(LoginScreen, null, children);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (installer) {
|
|
92
|
+
return renderLayout(renderBody(installer.render({
|
|
93
|
+
onInstalled: showNextInstaller
|
|
94
|
+
})), installer.secure);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (skippingVersions) {
|
|
98
|
+
return renderBody( /*#__PURE__*/React.createElement(Elevation, {
|
|
99
|
+
z: 1,
|
|
100
|
+
className: alertClass
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
|
|
102
|
+
span: 12
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
104
|
+
use: "headline4"
|
|
105
|
+
}, "Important!")), /*#__PURE__*/React.createElement(Cell, {
|
|
106
|
+
span: 12
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
108
|
+
use: "body1",
|
|
109
|
+
tag: "div"
|
|
110
|
+
}, "We've detected that your current application is running Webiny", " ", /*#__PURE__*/React.createElement("strong", null, "v", skippingVersions.latest), ". However, your API is running ", /*#__PURE__*/React.createElement("strong", null, "v", skippingVersions.current), ". Unfortunately, we can't upgrade your system by skipping versions in between.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), "Here's a list of versions you skipped, that contain upgrades you need to install:", /*#__PURE__*/React.createElement("ul", null, skippingVersions.availableUpgrades.filter(function (v) {
|
|
111
|
+
return v !== skippingVersions.latest;
|
|
112
|
+
}).map(function (v) {
|
|
113
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
114
|
+
key: v
|
|
115
|
+
}, "v", v);
|
|
116
|
+
})), "For instructions on how to upgrade Webiny, please consult our", " ", /*#__PURE__*/React.createElement("a", {
|
|
117
|
+
href: "https://docs.webiny.com/docs/how-to-guides/upgrade-webiny",
|
|
118
|
+
target: "_blank",
|
|
119
|
+
rel: "noreferrer noopener"
|
|
120
|
+
}, "Upgrade Webiny"), " ", "guide. Note that some versions may have a dedicated article with upgrade instructions, so look out for those in the upgrade guide.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), "If you run into problems, find us on our", " ", /*#__PURE__*/React.createElement("a", {
|
|
121
|
+
href: "https://www.webiny.com/slack",
|
|
122
|
+
target: "_blank",
|
|
123
|
+
rel: "noreferrer noopener"
|
|
124
|
+
}, "Slack community."))))));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return renderLayout(renderBody( /*#__PURE__*/React.createElement(Elevation, {
|
|
128
|
+
z: 1
|
|
129
|
+
}, /*#__PURE__*/React.createElement(SuccessDialog, null, /*#__PURE__*/React.createElement("p", null, "You have successfully installed all new applications!"), /*#__PURE__*/React.createElement(ButtonPrimary, {
|
|
130
|
+
"data-testid": "open-webiny-cms-admin-button",
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
markInstallerAsCompleted();
|
|
133
|
+
setFinished(true);
|
|
134
|
+
}
|
|
135
|
+
}, "Open Admin Area")))), true);
|
|
136
|
+
};
|