@blaze-cms/plugin-admin-core-ui 0.131.0-admin-updates.0 → 0.131.0-project-admin-customisations.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/CHANGELOG.md +15 -1
- package/README.md +97 -0
- package/lib/components/Layout/Layout.js +6 -3
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/Layout/components/Grid/Grid.js +10 -88
- package/lib/components/Layout/components/Grid/Grid.js.map +1 -1
- package/lib/components/Menu/Icons/ChevronDown.js +27 -0
- package/lib/components/Menu/Icons/ChevronDown.js.map +1 -0
- package/lib/components/Menu/Icons/ChevronUp.js +27 -0
- package/lib/components/Menu/Icons/ChevronUp.js.map +1 -0
- package/lib/components/Menu/Items/MenuActionItem.js +37 -0
- package/lib/components/Menu/Items/MenuActionItem.js.map +1 -0
- package/lib/components/Menu/Items/MenuItem.js +73 -0
- package/lib/components/Menu/Items/MenuItem.js.map +1 -0
- package/lib/components/Menu/Items/MenuLinkItem.js +36 -0
- package/lib/components/Menu/Items/MenuLinkItem.js.map +1 -0
- package/lib/components/Menu/Menu.js +86 -0
- package/lib/components/Menu/Menu.js.map +1 -0
- package/lib/components/Menu/Section/MenuSection.js +28 -0
- package/lib/components/Menu/Section/MenuSection.js.map +1 -0
- package/lib/components/Menu/Section/MenuSectionCollapsible.js +91 -0
- package/lib/components/Menu/Section/MenuSectionCollapsible.js.map +1 -0
- package/lib/components/Menu/Section/MenuSectionItem.js +40 -0
- package/lib/components/Menu/Section/MenuSectionItem.js.map +1 -0
- package/lib/components/Menu/Section/MenuSectionItems.js +33 -0
- package/lib/components/Menu/Section/MenuSectionItems.js.map +1 -0
- package/lib/components/Menu/index.js +12 -0
- package/lib/components/Menu/index.js.map +1 -0
- package/lib/components/SideBar/SideBar.js +3 -14
- package/lib/components/SideBar/SideBar.js.map +1 -1
- package/lib/constants.js +1 -1
- package/lib/constants.js.map +1 -1
- package/lib/index.js +13 -9
- package/lib/index.js.map +1 -1
- package/lib/utils/menu-handler-singleton.js +114 -0
- package/lib/utils/menu-handler-singleton.js.map +1 -0
- package/lib-es/components/Layout/Layout.js +6 -3
- package/lib-es/components/Layout/Layout.js.map +1 -1
- package/lib-es/components/Layout/components/Grid/Grid.js +14 -54
- package/lib-es/components/Layout/components/Grid/Grid.js.map +1 -1
- package/lib-es/components/Menu/Icons/ChevronDown.js +16 -0
- package/lib-es/components/Menu/Icons/ChevronDown.js.map +1 -0
- package/lib-es/components/Menu/Icons/ChevronUp.js +16 -0
- package/lib-es/components/Menu/Icons/ChevronUp.js.map +1 -0
- package/lib-es/components/Menu/Items/MenuActionItem.js +31 -0
- package/lib-es/components/Menu/Items/MenuActionItem.js.map +1 -0
- package/lib-es/components/Menu/Items/MenuItem.js +64 -0
- package/lib-es/components/Menu/Items/MenuItem.js.map +1 -0
- package/lib-es/components/Menu/Items/MenuLinkItem.js +28 -0
- package/lib-es/components/Menu/Items/MenuLinkItem.js.map +1 -0
- package/lib-es/components/Menu/Menu.js +40 -0
- package/lib-es/components/Menu/Menu.js.map +1 -0
- package/lib-es/components/Menu/Section/MenuSection.js +18 -0
- package/lib-es/components/Menu/Section/MenuSection.js.map +1 -0
- package/lib-es/components/Menu/Section/MenuSectionCollapsible.js +67 -0
- package/lib-es/components/Menu/Section/MenuSectionCollapsible.js.map +1 -0
- package/lib-es/components/Menu/Section/MenuSectionItem.js +30 -0
- package/lib-es/components/Menu/Section/MenuSectionItem.js.map +1 -0
- package/lib-es/components/Menu/Section/MenuSectionItems.js +20 -0
- package/lib-es/components/Menu/Section/MenuSectionItems.js.map +1 -0
- package/lib-es/components/Menu/index.js +3 -0
- package/lib-es/components/Menu/index.js.map +1 -0
- package/lib-es/components/SideBar/SideBar.js +2 -7
- package/lib-es/components/SideBar/SideBar.js.map +1 -1
- package/lib-es/constants.js +1 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/index.js +9 -9
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/menu-handler-singleton.js +55 -0
- package/lib-es/utils/menu-handler-singleton.js.map +1 -0
- package/package.json +9 -8
- package/src/components/Layout/Layout.js +14 -3
- package/src/components/Layout/components/Grid/Grid.js +13 -52
- package/src/components/Menu/Icons/ChevronDown.js +16 -0
- package/src/components/Menu/Icons/ChevronUp.js +16 -0
- package/src/components/Menu/Items/MenuActionItem.js +30 -0
- package/src/components/Menu/Items/MenuItem.js +49 -0
- package/src/components/Menu/Items/MenuLinkItem.js +25 -0
- package/src/components/Menu/Menu.js +48 -0
- package/src/components/Menu/Section/MenuSection.js +16 -0
- package/src/components/Menu/Section/MenuSectionCollapsible.js +59 -0
- package/src/components/Menu/Section/MenuSectionItem.js +28 -0
- package/src/components/Menu/Section/MenuSectionItems.js +17 -0
- package/src/components/Menu/index.js +3 -0
- package/src/components/SideBar/SideBar.js +3 -6
- package/src/constants.js +3 -1
- package/src/index.js +7 -6
- package/src/utils/menu-handler-singleton.js +64 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuSectionCollapsible.js","names":["React","useState","ChevronDown","ChevronUp","capitalise","s","charAt","toUpperCase","slice","MenuSectionCollapsible","name","item","children","label","loadOpen","icon","MenuSectionIcon","items","collapsed","setCollapsed","CollapseIcon","createElement","handleClick","modifier","buttonModifier","className","type","onClick","role","Object","keys","length"],"sources":["../../../../src/components/Menu/Section/MenuSectionCollapsible.js"],"sourcesContent":["import React, { useState } from 'react';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\n\nconst capitalise = s => {\n if (typeof s !== 'string') return '';\n return s.charAt(0).toUpperCase() + s.slice(1);\n};\n\nconst MenuSectionCollapsible = ({ name, item, children }) => {\n const { label, loadOpen, icon: MenuSectionIcon, items } = item;\n const [collapsed, setCollapsed] = useState(!loadOpen);\n\n const CollapseIcon = () => (collapsed ? <ChevronDown /> : <ChevronUp />);\n\n const handleClick = () => {\n setCollapsed(!collapsed);\n };\n\n const modifier = collapsed ? 'side-nav__list--item' : 'side-nav__list--item__selected';\n\n const buttonModifier = collapsed ? 'side-nav__list-link' : 'side-nav__list-link--selected';\n\n if (name) {\n return (\n <li className={modifier}>\n <button type=\"button\" className={buttonModifier} onClick={handleClick}>\n <div className=\"side-nav__list-link--icon\">{MenuSectionIcon && <MenuSectionIcon />}</div>\n <div className=\"side-nav__list-link--wrapper\">\n <div className=\"side-nav__list-link--label\">{capitalise(name)}</div>\n <div className=\"side-nav__list-link--toggleCollapseIcon\" role=\"button\">\n <CollapseIcon />\n </div>\n </div>\n </button>\n <div className=\"side-nav__list-link--children\">{collapsed ? null : children}</div>\n </li>\n );\n }\n\n if (label && items && Object.keys(items).length > 0) {\n return <li className={modifier}>{children}</li>;\n }\n\n if (label && items && Object.keys(items).length === 0) {\n return (\n <li className={modifier}>\n <button type=\"button\" className=\"side-nav__list-link\" onClick={handleClick}>\n <div className=\"side-nav__list-link--icon\">{MenuSectionIcon && <MenuSectionIcon />}</div>\n <div className=\"side-nav__list-label\">{label}</div>\n </button>\n </li>\n );\n }\n\n return null;\n};\n\nexport default MenuSectionCollapsible;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,SAAS,MAAM,oBAAoB;AAE1C,MAAMC,UAAU,GAAGC,CAAC,IAAI;EACtB,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE,OAAO,EAAE;EACpC,OAAOA,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC,IAAI;EAAEC,IAAI;EAAEC;AAAS,CAAC,KAAK;EAC3D,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,IAAI,EAAEC,eAAe;IAAEC;EAAM,CAAC,GAAGN,IAAI;EAC9D,MA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CAACb,KAAK,CAAC,CAACc,MAAM,GAAG,CAAC,EAAE;IACnD,oBAAO/B,KAAA,CAAAqB,aAAA;MAAII,SAAS,EAAEF;IAAS,GAAEX,QAAa,CAAC;EACjD;EAEA,IAAIC,KAAK,IAAII,KAAK,IAAIY,MAAM,CAACC,IAAI,CAACb,KAAK,CAAC,CAACc,MAAM,KAAK,CAAC,EAAE;IACrD,oBACE/B,KAAA,CAAAqB,aAAA;MAAII,SAAS,EAAEF;IAAS,gBACtBvB,KAAA,CAAAqB,aAAA;MAAQK,IAAI,EAAC,QAAQ;MAACD,SAAS,EAAC,qBAAqB;MAACE,OAAO,EAAEL;IAAY,gBACzEtB,KAAA,CAAAqB,aAAA;MAAKI,SAAS,EAAC;IAA2B,GAAET,eAAe,iBAAIhB,KAAA,CAAAqB,aAAA,CAACL,eAAe,MAAE,CAAO,CAAC,eACzFhB,KAAA,CAAAqB,aAAA;MAAKI,SAAS,EAAC;IAAsB,GAAEZ,KAAW,CAC5C,CACN,CAAC;EAET;EAEA,OAAO,IAAI;AACb,CAAC;AAED,eAAeJ,sBAAsB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import MenuItem from '../Items/MenuItem';
|
|
4
|
+
import MenuSectionCollapsible from './MenuSectionCollapsible';
|
|
5
|
+
const MenuSectionItem = ({
|
|
6
|
+
name,
|
|
7
|
+
item
|
|
8
|
+
}) => {
|
|
9
|
+
if (!item) return null;
|
|
10
|
+
if (item.uri) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
12
|
+
item: item,
|
|
13
|
+
RenderItems: MenuSectionCollapsible
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (Object.values(item.items).length === 0) return null;
|
|
17
|
+
return /*#__PURE__*/React.createElement(MenuSectionCollapsible, {
|
|
18
|
+
name: name,
|
|
19
|
+
item: item
|
|
20
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
21
|
+
item: item,
|
|
22
|
+
RenderItems: MenuSectionCollapsible
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
export default MenuSectionItem;
|
|
26
|
+
MenuSectionItem.propTypes = {
|
|
27
|
+
name: PropTypes.string.isRequired,
|
|
28
|
+
item: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node, PropTypes.object]).isRequired
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=MenuSectionItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuSectionItem.js","names":["React","PropTypes","MenuItem","MenuSectionCollapsible","MenuSectionItem","name","item","uri","createElement","RenderItems","Object","values","items","length","propTypes","string","isRequired","oneOfType","arrayOf","node","object"],"sources":["../../../../src/components/Menu/Section/MenuSectionItem.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport MenuItem from '../Items/MenuItem';\nimport MenuSectionCollapsible from './MenuSectionCollapsible';\n\nconst MenuSectionItem = ({ name, item }) => {\n if (!item) return null;\n\n if (item.uri) {\n return <MenuItem item={item} RenderItems={MenuSectionCollapsible} />;\n }\n\n if (Object.values(item.items).length === 0) return null;\n\n return (\n <MenuSectionCollapsible name={name} item={item}>\n <MenuItem item={item} RenderItems={MenuSectionCollapsible} />\n </MenuSectionCollapsible>\n );\n};\n\nexport default MenuSectionItem;\n\nMenuSectionItem.propTypes = {\n name: PropTypes.string.isRequired,\n item: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node, PropTypes.object])\n .isRequired\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,QAAQ,MAAM,mBAAmB;AACxC,OAAOC,sBAAsB,MAAM,0BAA0B;AAE7D,MAAMC,eAAe,GAAGA,CAAC;EAAEC,IAAI;EAAEC;AAAK,CAAC,KAAK;EAC1C,IAAI,CAACA,IAAI,EAAE,OAAO,IAAI;EAEtB,IAAIA,IAAI,CAACC,GAAG,EAAE;IACZ,oBAAOP,KAAA,CAAAQ,aAAA,CAACN,QAAQ;MAACI,IAAI,EAAEA,IAAK;MAACG,WAAW,EAAEN;IAAuB,CAAE,CAAC;EACtE;EAEA,IAAIO,MAAM,CAACC,MAAM,CAACL,IAAI,CAACM,KAAK,CAAC,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAEvD,oBACEb,KAAA,CAAAQ,aAAA,CAACL,sBAAsB;IAACE,IAAI,EAAEA,IAAK;IAACC,IAAI,EAAEA;EAAK,gBAC7CN,KAAA,CAAAQ,aAAA,CAACN,QAAQ;IAACI,IAAI,EAAEA,IAAK;IAACG,WAAW,EAAEN;EAAuB,CAAE,CACtC,CAAC;AAE7B,CAAC;AAED,eAAeC,eAAe;AAE9BA,eAAe,CAACU,SAAS,GAAG;EAC1BT,IAAI,EAAEJ,SAAS,CAACc,MAAM,CAACC,UAAU;EACjCV,IAAI,EAAEL,SAAS,CAACgB,SAAS,CAAC,CAAChB,SAAS,CAACiB,OAAO,CAACjB,SAAS,CAACkB,IAAI,CAAC,EAAElB,SAAS,CAACkB,IAAI,EAAElB,SAAS,CAACmB,MAAM,CAAC,CAAC,CAC7FJ;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import MenuSectionItem from './MenuSectionItem';
|
|
4
|
+
const MenuSectionItems = ({
|
|
5
|
+
sectionItems
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
items
|
|
9
|
+
} = sectionItems;
|
|
10
|
+
const menuSections = Object.entries(items).sort((a, b) => a[1].order - b[1].order);
|
|
11
|
+
return menuSections.map(menuItem => /*#__PURE__*/React.createElement(MenuSectionItem, {
|
|
12
|
+
name: menuItem[0],
|
|
13
|
+
item: menuItem[1]
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
export default MenuSectionItems;
|
|
17
|
+
MenuSectionItems.propTypes = {
|
|
18
|
+
sectionItems: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=MenuSectionItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuSectionItems.js","names":["React","PropTypes","MenuSectionItem","MenuSectionItems","sectionItems","items","menuSections","Object","entries","sort","a","b","order","map","menuItem","createElement","name","item","propTypes","oneOfType","arrayOf","node","isRequired"],"sources":["../../../../src/components/Menu/Section/MenuSectionItems.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport MenuSectionItem from './MenuSectionItem';\n\nconst MenuSectionItems = ({ sectionItems }) => {\n const { items } = sectionItems;\n\n const menuSections = Object.entries(items).sort((a, b) => a[1].order - b[1].order);\n\n return menuSections.map(menuItem => <MenuSectionItem name={menuItem[0]} item={menuItem[1]} />);\n};\n\nexport default MenuSectionItems;\n\nMenuSectionItems.propTypes = {\n sectionItems: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC;AAAa,CAAC,KAAK;EAC7C,MAAM;IAAEC;EAAM,CAAC,GAAGD,YAAY;EAE9B,MAAME,YAAY,GAAGC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACE,KAAK,GAAGD,CAAC,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC;EAElF,OAAON,YAAY,CAACO,GAAG,CAACC,QAAQ,iBAAId,KAAA,CAAAe,aAAA,CAACb,eAAe;IAACc,IAAI,EAAEF,QAAQ,CAAC,CAAC,CAAE;IAACG,IAAI,EAAEH,QAAQ,CAAC,CAAC;EAAE,CAAE,CAAC,CAAC;AAChG,CAAC;AAED,eAAeX,gBAAgB;AAE/BA,gBAAgB,CAACe,SAAS,GAAG;EAC3Bd,YAAY,EAAEH,SAAS,CAACkB,SAAS,CAAC,CAAClB,SAAS,CAACmB,OAAO,CAACnB,SAAS,CAACoB,IAAI,CAAC,EAAEpB,SAAS,CAACoB,IAAI,CAAC,CAAC,CAACC;AACzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Menu"],"sources":["../../../src/components/Menu/index.js"],"sourcesContent":["import Menu from './Menu';\n\nexport default Menu;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,QAAQ;AAEzB,eAAeA,IAAI"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import classnames from 'classnames';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import { useApolloClient } from '@apollo/client';
|
|
6
5
|
import Avatar from '@blaze-react/avatar';
|
|
7
6
|
import { handleLogout } from '@blaze-cms/core-auth-ui';
|
|
8
|
-
import
|
|
7
|
+
import Menu from '../Menu';
|
|
9
8
|
const SideBar = ({
|
|
10
|
-
menuItems,
|
|
11
9
|
isOpenMenu,
|
|
12
10
|
onMenuClick,
|
|
13
11
|
userData
|
|
@@ -39,9 +37,7 @@ const SideBar = ({
|
|
|
39
37
|
className: sideNavWrapperClassname,
|
|
40
38
|
"data-testid": "sidenav",
|
|
41
39
|
id: "side-nav__wrapper"
|
|
42
|
-
},
|
|
43
|
-
key: data.header
|
|
44
|
-
}, data))) : 'Not available content types'), /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Menu, null)), /*#__PURE__*/React.createElement("div", {
|
|
45
41
|
className: "side-nav__user"
|
|
46
42
|
}, /*#__PURE__*/React.createElement("div", {
|
|
47
43
|
className: "side-nav__user--info"
|
|
@@ -64,7 +60,6 @@ const SideBar = ({
|
|
|
64
60
|
}, "Log off")));
|
|
65
61
|
};
|
|
66
62
|
SideBar.propTypes = {
|
|
67
|
-
menuItems: PropTypes.array.isRequired,
|
|
68
63
|
isOpenMenu: PropTypes.bool.isRequired,
|
|
69
64
|
onMenuClick: PropTypes.func.isRequired,
|
|
70
65
|
userData: PropTypes.object.isRequired
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideBar.js","names":["React","classnames","PropTypes","useApolloClient","Avatar","handleLogout","
|
|
1
|
+
{"version":3,"file":"SideBar.js","names":["React","classnames","PropTypes","useApolloClient","Avatar","handleLogout","Menu","SideBar","isOpenMenu","onMenuClick","userData","client","firstname","lastname","username","sideNavClassname","sideNavWrapperClassname","createElement","className","role","id","onClick","window","location","href","propTypes","bool","isRequired","func","object"],"sources":["../../../src/components/SideBar/SideBar.js"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\nimport Avatar from '@blaze-react/avatar';\nimport { handleLogout } from '@blaze-cms/core-auth-ui';\nimport Menu from '../Menu';\n\nconst SideBar = ({ isOpenMenu, onMenuClick, userData }) => {\n const client = useApolloClient();\n\n const { firstname, lastname } = userData;\n const username = `${firstname} ${lastname}`;\n\n const sideNavClassname = classnames('side-nav', {\n 'side-nav--open': isOpenMenu,\n 'side-nav--close': !isOpenMenu\n });\n\n const sideNavWrapperClassname = classnames('side-nav__wrapper', {\n 'side-nav__wrapper--close': !isOpenMenu\n });\n\n return (\n <div data-testid=\"sidebar\" className={sideNavClassname}>\n <div\n role=\"button\"\n className=\"side-nav__button open\"\n id=\"side-nav-button\"\n onClick={onMenuClick}>\n <i className=\"material-icons\">keyboard_arrow_left</i>\n </div>\n {/* <Link to=\"/\" className=\"side-nav__block-home\">\n Dashboard\n </Link> */}\n <div className={sideNavWrapperClassname} data-testid=\"sidenav\" id=\"side-nav__wrapper\">\n <Menu />\n </div>\n <div className=\"side-nav__user\">\n <div className=\"side-nav__user--info\">\n <Avatar username={username} />\n <span className=\"user-name\">{username}</span>\n </div>\n <div className=\"side-nav__user--button\">\n <span\n id=\"logout-button\"\n role=\"button\"\n onClick={async () => {\n await handleLogout(client);\n window.location.href = '/';\n }}\n className=\"material-icons\">\n power_settings_new\n </span>\n </div>\n <span className=\"side-nav__user--toggle\">Log off</span>\n </div>\n </div>\n );\n};\n\nSideBar.propTypes = {\n isOpenMenu: PropTypes.bool.isRequired,\n onMenuClick: PropTypes.func.isRequired,\n userData: PropTypes.object.isRequired\n};\n\nexport default SideBar;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,MAAM,MAAM,qBAAqB;AACxC,SAASC,YAAY,QAAQ,yBAAyB;AACtD,OAAOC,IAAI,MAAM,SAAS;AAE1B,MAAMC,OAAO,GAAGA,CAAC;EAAEC,UAAU;EAAEC,WAAW;EAAEC;AAAS,CAAC,KAAK;EACzD,MAAMC,MAAM,GAAGR,eAAe,CAAC,CAAC;EAEhC,MAAM;IAAES,SAAS;IAAEC;EAAS,CAAC,GAAGH,QAAQ;EACxC,MAAMI,QAAQ,GAAI,GAAEF,SAAU,IAAGC,QAAS,EAAC;EAE3C,MAAME,gBAAgB,GAAGd,UAAU,CAAC,UAAU,EAAE;IAC9C,gBAAgB,EAAEO,UAAU;IAC5B,iBAAiB,EAAE,CAACA;EACtB,CAAC,CAAC;EAEF,MAAMQ,uBAAuB,GAAGf,UAAU,CAAC,mBAAmB,EAAE;IAC9D,0BAA0B,EAAE,CAACO;EAC/B,CAAC,CAAC;EAEF,oBACER,KAAA,CAAAiB,aAAA;IAAK,eAAY,SAAS;IAACC,SAAS,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AQ,EAAER,SAAS,CAAC2B,MAAM,CAACF;AAC7B,CAAC;AAED,eAAepB,OAAO"}
|
package/lib-es/constants.js
CHANGED
package/lib-es/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["PLUGIN_NAME","LOGO_PROPS","src","DEFAULT_LABEL","text","icon","ACTIVE_LABEL","DOWN_ICON"],"sources":["../src/constants.js"],"sourcesContent":["const PLUGIN_NAME = 'admin-core-ui';\nconst LOGO_PROPS = {
|
|
1
|
+
{"version":3,"file":"constants.js","names":["PLUGIN_NAME","LOGO_PROPS","src","process","env","BLAZE_ADMIN_HEAD_LOGO_URL","DEFAULT_LABEL","text","icon","ACTIVE_LABEL","DOWN_ICON"],"sources":["../src/constants.js"],"sourcesContent":["const PLUGIN_NAME = 'admin-core-ui';\nconst LOGO_PROPS = {\n src: process.env.BLAZE_ADMIN_HEAD_LOGO_URL || 'https://images.thisisblaze.com/logo-98-148.png'\n};\n\nconst DEFAULT_LABEL = {\n text: 'See more',\n icon: 'down'\n};\n\nconst ACTIVE_LABEL = {\n text: 'See less',\n icon: 'up'\n};\n\nconst DOWN_ICON = 'down';\n\nexport { PLUGIN_NAME, LOGO_PROPS, ACTIVE_LABEL, DEFAULT_LABEL, DOWN_ICON };\n"],"mappings":"AAAA,MAAMA,WAAW,GAAG,eAAe;AACnC,MAAMC,UAAU,GAAG;EACjBC,GAAG,EAAEC,OAAO,CAACC,GAAG,CAACC,yBAAyB,IAAI;AAChD,CAAC;AAED,MAAMC,aAAa,GAAG;EACpBC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,YAAY,GAAG;EACnBF,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE;AACR,CAAC;AAED,MAAME,SAAS,GAAG,MAAM;AAExB,SAASV,WAAW,EAAEC,UAAU,EAAEQ,YAAY,EAAEH,aAAa,EAAEI,SAAS"}
|
package/lib-es/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { Layout } from './components';
|
|
3
3
|
import pkg from '../package.json';
|
|
4
4
|
import { PLUGIN_NAME } from './constants';
|
|
5
|
-
import
|
|
5
|
+
import menuHandler from './utils/menu-handler-singleton';
|
|
6
6
|
const Home = React.lazy(() => import( /* webpackChunkName: 'Home' */'./containers'));
|
|
7
|
-
async function load(app) {
|
|
7
|
+
async function load(app, options = {}) {
|
|
8
8
|
const home = {
|
|
9
9
|
path: '/',
|
|
10
10
|
exact: true,
|
|
@@ -12,14 +12,14 @@ async function load(app) {
|
|
|
12
12
|
component: Home
|
|
13
13
|
};
|
|
14
14
|
app.addRoute(home);
|
|
15
|
-
|
|
15
|
+
menuHandler.setApp(app);
|
|
16
16
|
app.setLayout(Layout);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
17
|
+
const {
|
|
18
|
+
menuConfig = {}
|
|
19
|
+
} = options;
|
|
20
|
+
app.events.once('admin:menu:config:load:after', ({
|
|
21
|
+
addConfig
|
|
22
|
+
}) => addConfig(menuConfig));
|
|
23
23
|
return {
|
|
24
24
|
name: PLUGIN_NAME,
|
|
25
25
|
version: pkg.version
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","Layout","pkg","PLUGIN_NAME","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","Layout","pkg","PLUGIN_NAME","menuHandler","Home","lazy","load","app","options","home","path","exact","key","component","addRoute","setApp","setLayout","menuConfig","events","once","addConfig","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { Layout } from './components';\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\nimport menuHandler from './utils/menu-handler-singleton';\n\nconst Home = React.lazy(() => import(/* webpackChunkName: 'Home' */ './containers'));\n\nasync function load(app, options = {}) {\n const home = {\n path: '/',\n exact: true,\n key: 'home',\n component: Home\n };\n\n app.addRoute(home);\n\n menuHandler.setApp(app);\n\n app.setLayout(Layout);\n\n const { menuConfig = {} } = options;\n\n app.events.once('admin:menu:config:load:after', ({ addConfig }) => addConfig(menuConfig));\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n\nexport default load;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,cAAc;AACrC,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AACzC,OAAOC,WAAW,MAAM,gCAAgC;AAExD,MAAMC,IAAI,GAAGL,KAAK,CAACM,IAAI,CAAC,MAAM,MAAM,EAAC,8BAA+B,cAAc,CAAC,CAAC;AAEpF,eAAeC,IAAIA,CAACC,GAAG,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EACrC,MAAMC,IAAI,GAAG;IACXC,IAAI,EAAE,GAAG;IACTC,KAAK,EAAE,IAAI;IACXC,GAAG,EAAE,MAAM;IACXC,SAAS,EAAET;EACb,CAAC;EAEDG,GAAG,CAACO,QAAQ,CAACL,IAAI,CAAC;EAElBN,WAAW,CAACY,MAAM,CAACR,GAAG,CAAC;EAEvBA,GAAG,CAACS,SAAS,CAAChB,MAAM,CAAC;EAErB,MAAM;IAAEiB,UAAU,GAAG,CAAC;EAAE,CAAC,GAAGT,OAAO;EAEnCD,GAAG,CAACW,MAAM,CAACC,IAAI,CAAC,8BAA8B,EAAE,CAAC;IAAEC;EAAU,CAAC,KAAKA,SAAS,CAACH,UAAU,CAAC,CAAC;EAEzF,OAAO;IACLI,IAAI,EAAEnB,WAAW;IACjBoB,OAAO,EAAErB,GAAG,CAACqB;EACf,CAAC;AACH;AAEAhB,IAAI,CAACiB,UAAU,GAAGrB,WAAW;AAE7B,eAAeI,IAAI"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import merge from 'lodash.merge';
|
|
3
|
+
let instance;
|
|
4
|
+
export class MenuHandler {
|
|
5
|
+
constructor(app) {
|
|
6
|
+
_defineProperty(this, "menuSections", new Map());
|
|
7
|
+
_defineProperty(this, "menuConfig", void 0);
|
|
8
|
+
_defineProperty(this, "app", void 0);
|
|
9
|
+
if (instance) {
|
|
10
|
+
throw new Error('You can only create one instance!');
|
|
11
|
+
}
|
|
12
|
+
instance = this;
|
|
13
|
+
this.menuConfig = {};
|
|
14
|
+
this.app = null;
|
|
15
|
+
}
|
|
16
|
+
setApp(app) {
|
|
17
|
+
this.app = app;
|
|
18
|
+
}
|
|
19
|
+
get app() {
|
|
20
|
+
return this.app;
|
|
21
|
+
}
|
|
22
|
+
get menuConfig() {
|
|
23
|
+
return this.menuConfig;
|
|
24
|
+
}
|
|
25
|
+
addConfig(newConfig) {
|
|
26
|
+
this.menuConfig = merge(this.menuConfig, newConfig);
|
|
27
|
+
}
|
|
28
|
+
async loadConfig() {
|
|
29
|
+
const addConfig = newConfig => {
|
|
30
|
+
this.addConfig(newConfig);
|
|
31
|
+
};
|
|
32
|
+
const {
|
|
33
|
+
menuConfig
|
|
34
|
+
} = this;
|
|
35
|
+
if (this.app && this.app.events) {
|
|
36
|
+
await this.app.events.emitAsync('admin:menu:config:load', {
|
|
37
|
+
addConfig
|
|
38
|
+
});
|
|
39
|
+
await this.app.events.emitAsync('admin:menu:config:load:after', {
|
|
40
|
+
addConfig,
|
|
41
|
+
menuConfig
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
getInstance() {
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
getAll() {
|
|
49
|
+
const sortedByOrder = Object.entries(this.menuConfig).sort((a, b) => a.order > b.order ? 1 : -1);
|
|
50
|
+
return sortedByOrder;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const menuHandler = new MenuHandler();
|
|
54
|
+
export default menuHandler;
|
|
55
|
+
//# sourceMappingURL=menu-handler-singleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-handler-singleton.js","names":["merge","instance","MenuHandler","constructor","app","_defineProperty","Map","Error","menuConfig","setApp","addConfig","newConfig","loadConfig","events","emitAsync","getInstance","getAll","sortedByOrder","Object","entries","sort","a","b","order","menuHandler"],"sources":["../../src/utils/menu-handler-singleton.js"],"sourcesContent":["import merge from 'lodash.merge';\n\nlet instance;\n\nexport class MenuHandler {\n menuSections = new Map();\n\n menuConfig;\n\n app;\n\n constructor(app) {\n if (instance) {\n throw new Error('You can only create one instance!');\n }\n instance = this;\n this.menuConfig = {};\n this.app = null;\n }\n\n setApp(app) {\n this.app = app;\n }\n\n get app() {\n return this.app;\n }\n\n get menuConfig() {\n return this.menuConfig;\n }\n\n addConfig(newConfig) {\n this.menuConfig = merge(this.menuConfig, newConfig);\n }\n\n async loadConfig() {\n const addConfig = newConfig => {\n this.addConfig(newConfig);\n };\n\n const { menuConfig } = this;\n\n if (this.app && this.app.events) {\n await this.app.events.emitAsync('admin:menu:config:load', { addConfig });\n await this.app.events.emitAsync('admin:menu:config:load:after', { addConfig, menuConfig });\n }\n }\n\n getInstance() {\n return this;\n }\n\n getAll() {\n const sortedByOrder = Object.entries(this.menuConfig).sort(\n (a, b) => (a.order > b.order ? 1 : -1)\n );\n\n return sortedByOrder;\n }\n}\n\nconst menuHandler = new MenuHandler();\nexport default menuHandler;\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,cAAc;AAEhC,IAAIC,QAAQ;AAEZ,OAAO,MAAMC,WAAW,CAAC;EAOvBC,WAAWA,CAACC,GAAG,EAAE;IAAAC,eAAA,uBANF,IAAIC,GAAG,CAAC,CAAC;IAAAD,eAAA;IAAAA,eAAA;IAOtB,IAAIJ,QAAQ,EAAE;MACZ,MAAM,IAAIM,KAAK,CAAC,mCAAmC,CAAC;IACtD;IACAN,QAAQ,GAAG,IAAI;IACf,IAAI,CAACO,UAAU,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WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-admin-core-ui",
|
|
3
|
-
"version": "0.131.0-admin-
|
|
3
|
+
"version": "0.131.0-project-admin-customisations.0",
|
|
4
4
|
"description": "Blaze plugin admin core ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/admin-ui-styles": "0.131.0-admin-
|
|
31
|
-
"@blaze-cms/admin-ui-utils": "0.131.0-admin-
|
|
32
|
-
"@blaze-cms/core-ui": "0.131.0-admin-
|
|
33
|
-
"@blaze-cms/plugin-search-ui": "0.131.0-admin-
|
|
34
|
-
"@blaze-cms/setup-ui": "0.131.0-admin-
|
|
30
|
+
"@blaze-cms/admin-ui-styles": "0.131.0-project-admin-customisations.0",
|
|
31
|
+
"@blaze-cms/admin-ui-utils": "0.131.0-project-admin-customisations.0",
|
|
32
|
+
"@blaze-cms/core-ui": "0.131.0-project-admin-customisations.0",
|
|
33
|
+
"@blaze-cms/plugin-search-ui": "0.131.0-project-admin-customisations.0",
|
|
34
|
+
"@blaze-cms/setup-ui": "0.131.0-project-admin-customisations.0",
|
|
35
35
|
"@blaze-react/avatar": "0.5.19",
|
|
36
36
|
"@blaze-react/button": "0.5.19",
|
|
37
37
|
"@blaze-react/input": "0.5.30",
|
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
"react-router-dom": "^5.0.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@blaze-cms/plugin-auth-ui": "0.131.0-admin-
|
|
50
|
+
"@blaze-cms/plugin-auth-ui": "0.131.0-project-admin-customisations.0",
|
|
51
|
+
"lodash.merge": "^4.6.2",
|
|
51
52
|
"waait": "1.0.5"
|
|
52
53
|
},
|
|
53
54
|
"eslintIgnore": [
|
|
54
55
|
"lib/*",
|
|
55
56
|
"lib-es/*"
|
|
56
57
|
],
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "409049b62066b81019273ca9ab431439659776ef"
|
|
58
59
|
}
|
|
@@ -11,18 +11,29 @@ import Header from '../Header';
|
|
|
11
11
|
const Layout = ({ children }) => {
|
|
12
12
|
const [isOpenMenu, setOpenMenu] = useState(true);
|
|
13
13
|
const onMenuClick = () => setOpenMenu(!isOpenMenu);
|
|
14
|
+
|
|
15
|
+
const simpleLayout = window.location !== window.parent.location;
|
|
16
|
+
|
|
17
|
+
const wrapperClass = simpleLayout ? ' grid--site-container--simle-layout' : '';
|
|
18
|
+
|
|
14
19
|
return (
|
|
15
|
-
<div className=
|
|
20
|
+
<div className={`site-container grid--site-container${wrapperClass}`}>
|
|
16
21
|
<Query query={getQuery('GET_USER_AUTH_DATA')} errorPolicy="all">
|
|
17
22
|
{({ data = {} }) => {
|
|
18
23
|
const { session: { isLoggedIn, userData = {} } = {} } = data;
|
|
19
24
|
|
|
20
25
|
return (
|
|
21
26
|
<>
|
|
22
|
-
|
|
27
|
+
{!simpleLayout && (
|
|
28
|
+
<Header isLoggedIn={isLoggedIn} onMenuClick={onMenuClick} isOpenMenu={isOpenMenu} />
|
|
29
|
+
)}
|
|
23
30
|
{isLoggedIn ? (
|
|
24
31
|
<>
|
|
25
|
-
<Grid
|
|
32
|
+
<Grid
|
|
33
|
+
isOpenMenu={isOpenMenu}
|
|
34
|
+
onMenuClick={onMenuClick}
|
|
35
|
+
userData={userData}
|
|
36
|
+
simpleLayout={simpleLayout}>
|
|
26
37
|
{children}
|
|
27
38
|
</Grid>
|
|
28
39
|
</>
|
|
@@ -1,66 +1,27 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { useApolloClient } from '@apollo/client';
|
|
4
|
-
import { getQuery, MainContextProvider } from '@blaze-cms/admin-ui-utils';
|
|
5
3
|
import SideBar from '../../../SideBar';
|
|
6
4
|
|
|
7
|
-
const Grid = ({ children, isOpenMenu, onMenuClick, userData }) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
data: { getMenuItems }
|
|
16
|
-
} = await client.query({ query: getQuery('GET_MENU_ITEMS') });
|
|
17
|
-
|
|
18
|
-
const parsedMenuItems = getMenuItems.map(([key, { header, items }]) => [
|
|
19
|
-
key,
|
|
20
|
-
{
|
|
21
|
-
header,
|
|
22
|
-
items: items.map(item => ({ ...item, isDisplayedPrompt: true }))
|
|
23
|
-
}
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
if (!menuItems) {
|
|
27
|
-
setMenuItems(parsedMenuItems);
|
|
28
|
-
}
|
|
29
|
-
})();
|
|
30
|
-
},
|
|
31
|
-
[client, menuItems]
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const updateItems = items => {
|
|
35
|
-
setMenuItems(items);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return menuItems ? (
|
|
39
|
-
<MainContextProvider value={{ menuItems, setMenuItems: items => updateItems(items) }}>
|
|
40
|
-
<div className="main-content grid grid--main-content">
|
|
41
|
-
<SideBar
|
|
42
|
-
isOpenMenu={isOpenMenu}
|
|
43
|
-
menuItems={menuItems}
|
|
44
|
-
onMenuClick={onMenuClick}
|
|
45
|
-
userData={userData}
|
|
46
|
-
/>
|
|
47
|
-
<div className="grid--main-content-wrapper">{children}</div>
|
|
48
|
-
</div>
|
|
49
|
-
</MainContextProvider>
|
|
50
|
-
) : (
|
|
51
|
-
'loading'
|
|
52
|
-
);
|
|
53
|
-
};
|
|
5
|
+
const Grid = ({ children, isOpenMenu, onMenuClick, userData, simpleLayout }) => (
|
|
6
|
+
<div className="main-content grid grid--main-content">
|
|
7
|
+
{!simpleLayout && (
|
|
8
|
+
<SideBar isOpenMenu={isOpenMenu} onMenuClick={onMenuClick} userData={userData} />
|
|
9
|
+
)}
|
|
10
|
+
{children}
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
54
13
|
|
|
55
14
|
Grid.propTypes = {
|
|
56
15
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
57
16
|
isOpenMenu: PropTypes.bool.isRequired,
|
|
58
17
|
onMenuClick: PropTypes.func.isRequired,
|
|
59
|
-
userData: PropTypes.object
|
|
18
|
+
userData: PropTypes.object,
|
|
19
|
+
simpleLayout: PropTypes.bool
|
|
60
20
|
};
|
|
61
21
|
|
|
62
22
|
Grid.defaultProps = {
|
|
63
|
-
userData: {}
|
|
23
|
+
userData: {},
|
|
24
|
+
simpleLayout: false
|
|
64
25
|
};
|
|
65
26
|
|
|
66
27
|
export default Grid;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const ChevronDown = () => (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
fill="none"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
strokeWidth={1.5}
|
|
9
|
+
width="20"
|
|
10
|
+
height="20"
|
|
11
|
+
stroke="currentColor">
|
|
12
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
|
13
|
+
</svg>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default ChevronDown;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const ChevronUp = () => (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
fill="none"
|
|
7
|
+
viewBox="0 0 22 22"
|
|
8
|
+
strokeWidth={1.5}
|
|
9
|
+
width="20"
|
|
10
|
+
height="20"
|
|
11
|
+
stroke="currentColor">
|
|
12
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
|
|
13
|
+
</svg>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default ChevronUp;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
const MenuActionItem = ({ item }) => {
|
|
5
|
+
const { label, icon: MenuSectionIcon, onClick, uri } = item;
|
|
6
|
+
|
|
7
|
+
const modifier = MenuSectionIcon ? '' : 'side-nav__list-link--noIcon';
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<li className="side-nav__list--item" key={item.label}>
|
|
11
|
+
<Link
|
|
12
|
+
to={uri}
|
|
13
|
+
className={`side-nav__list-link ${modifier}`}
|
|
14
|
+
onClick={() => {
|
|
15
|
+
if (onClick) {
|
|
16
|
+
onClick();
|
|
17
|
+
}
|
|
18
|
+
}}>
|
|
19
|
+
{MenuSectionIcon && (
|
|
20
|
+
<div className="side-nav__list-link--icon">
|
|
21
|
+
<MenuSectionIcon />
|
|
22
|
+
</div>
|
|
23
|
+
)}
|
|
24
|
+
<div className="side-nav__list-label">{label}</div>
|
|
25
|
+
</Link>
|
|
26
|
+
</li>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default MenuActionItem;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import MenuLinkItem from './MenuLinkItem';
|
|
4
|
+
|
|
5
|
+
const MenuItem = ({ item, RenderItems }) => {
|
|
6
|
+
const location = useLocation();
|
|
7
|
+
const { label, items, uri } = item;
|
|
8
|
+
|
|
9
|
+
if (label && uri) {
|
|
10
|
+
const isActive = location.pathname === uri;
|
|
11
|
+
return <MenuLinkItem item={item} isActive={isActive} root />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (label && items && Object.values(items).length > 0) {
|
|
15
|
+
const childrenMenu = Object.keys(items).map(key => items[key]);
|
|
16
|
+
|
|
17
|
+
const childrenComponents = childrenMenu.map(child => {
|
|
18
|
+
const { label: childLabel, uri: childUri } = child;
|
|
19
|
+
const isActive = location.pathname === childUri;
|
|
20
|
+
|
|
21
|
+
if (childLabel && childUri) {
|
|
22
|
+
return <MenuLinkItem item={child} isActive={isActive} root={false} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return <RenderItems item={item}>{childrenComponents}</RenderItems>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!label && items) {
|
|
32
|
+
const childrenMenu = Object.keys(items).map(key => items[key]);
|
|
33
|
+
|
|
34
|
+
return childrenMenu.map(child => {
|
|
35
|
+
const { label: childLabel, uri: childUri } = child;
|
|
36
|
+
const isActive = location.pathname === childUri;
|
|
37
|
+
|
|
38
|
+
if (childLabel && childUri) {
|
|
39
|
+
return <MenuLinkItem item={child} isActive={isActive} root />;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default MenuItem;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
const MenuLinkItem = ({ item, isActive, root = true }) => {
|
|
5
|
+
const { label, icon: MenuSectionIcon, uri } = item;
|
|
6
|
+
|
|
7
|
+
const modifier = MenuSectionIcon ? '' : 'side-nav__list-link--noIcon';
|
|
8
|
+
|
|
9
|
+
const activeModifier = isActive ? 'side-nav__list-link--active' : '';
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<li className="side-nav__list--item" key={item.label}>
|
|
13
|
+
<Link to={uri} className={`side-nav__list-link ${modifier} ${activeModifier}`}>
|
|
14
|
+
{MenuSectionIcon && (
|
|
15
|
+
<div className="side-nav__list-link--icon">
|
|
16
|
+
<MenuSectionIcon />
|
|
17
|
+
</div>
|
|
18
|
+
)}
|
|
19
|
+
<div className="side-nav__list-link--label">{label}</div>
|
|
20
|
+
</Link>
|
|
21
|
+
</li>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default MenuLinkItem;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import menuHandler from '../../utils/menu-handler-singleton';
|
|
4
|
+
import MenuSection from './Section/MenuSection';
|
|
5
|
+
|
|
6
|
+
const Menu = ({ children }) => {
|
|
7
|
+
const [config, setConfig] = useState();
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const loadConfig = async () => {
|
|
11
|
+
await menuHandler.loadConfig();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
loadConfig().then(() => setConfig(menuHandler.getAll()));
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
const MenuSections = () => {
|
|
18
|
+
if (!config) return null;
|
|
19
|
+
|
|
20
|
+
return config.map(sections => {
|
|
21
|
+
if (!sections || !Array.isArray(sections) || !sections.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const menuSections = sections.filter(section => section.items);
|
|
26
|
+
|
|
27
|
+
return menuSections.map(menuSection => <MenuSection items={menuSection} />);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="side-nav__block">
|
|
33
|
+
<ul className="side-nav__list">
|
|
34
|
+
<MenuSections />
|
|
35
|
+
</ul>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Menu.propTypes = {
|
|
41
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Menu.defaultProps = {
|
|
45
|
+
children: null
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default Menu;
|