-
Notifications
You must be signed in to change notification settings - Fork 583
/
menus.tsx
48 lines (43 loc) · 1.77 KB
/
menus.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from "react";
import { ReactComponent as PagesIcon } from "@webiny/app-page-builder/admin/assets/round-ballot-24px.svg";
import { i18n } from "@webiny/app/i18n";
import { SecureView } from "@webiny/app-security/components";
import { AdminMenuPlugin } from "@webiny/app-admin/types";
const t = i18n.ns("app-form-builder/admin/menus");
const ROLE_PB_MENUS = ["pb:menus:crud"];
const ROLE_PB_CATEGORIES = ["pb:category:crud"];
const ROLE_PB_EDITOR = ["pb:page:crud"];
const plugin: AdminMenuPlugin = {
type: "admin-menu",
name: "admin-menu-page-builder",
render({ Menu, Section, Item }) {
return (
<SecureView
scopes={{
menus: ROLE_PB_MENUS,
categories: ROLE_PB_CATEGORIES,
editor: ROLE_PB_EDITOR
}}
>
{({ scopes }) => {
const { menus, categories, editor } = scopes;
if (!menus && !categories && !editor) {
return null;
}
return (
<Menu name="app-page-builder" label={t`Page Builder`} icon={<PagesIcon />}>
<Section label={t`Pages`}>
{categories && (
<Item label={t`Categories`} path="/page-builder/categories" />
)}
{editor && <Item label={t`Pages`} path="/page-builder/pages" />}
{menus && <Item label={t`Menus`} path="/page-builder/menus" />}
</Section>
</Menu>
);
}}
</SecureView>
);
}
};
export default plugin;