Skip to content

Commit

Permalink
feat: fixed admin app navigation issue (#1298)
Browse files Browse the repository at this point in the history
* feat: moved community and source to plugins

* feat: plugin changes

* feat: updated code formatting
  • Loading branch information
BhuwanChandra committed Oct 19, 2020
1 parent 144036b commit 460de7c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/app-admin/src/assets/icons/info.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/app-admin/src/assets/icons/slack-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 14 additions & 27 deletions packages/app-admin/src/plugins/Menu/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { IconButton } from "@webiny/ui/Button";
import { Icon } from "@webiny/ui/Icon";
import { css } from "emotion";
import { getPlugin, getPlugins } from "@webiny/plugins";
import { AdminMenuLogoPlugin, AdminMenuPlugin } from "@webiny/app-admin/types";
import {
AdminMenuLogoPlugin,
AdminMenuPlugin,
AdminDrawerFooterMenuPlugin
} from "@webiny/app-admin/types";
import { useNavigation, Menu, Item, Section } from "./components";
import { logoStyle, MenuFooter, MenuHeader, navContent, navHeader, subFooter } from "./Styled";
import { ReactComponent as MenuIcon } from "@webiny/app-admin/assets/icons/baseline-menu-24px.svg";
import { ReactComponent as DocsIcon } from "@webiny/app-admin/assets/icons/icon-documentation.svg";
import { ReactComponent as CommunityIcon } from "@webiny/app-admin/assets/icons/icon-community.svg";
import { ReactComponent as GithubIcon } from "@webiny/app-admin/assets/icons/github-brands.svg";
import { ReactComponent as InfoIcon } from "@webiny/app-admin/assets/icons/info.svg";
import ApiInformationDialog from "@webiny/app-admin/components/ApiInformationDialog";

Expand Down Expand Up @@ -55,6 +57,14 @@ const Navigation = () => {
);
});

const footerMenus = [];
const footerMenuPlugins = getPlugins<AdminDrawerFooterMenuPlugin>("admin-drawer-footer-menu");

footerMenuPlugins &&
footerMenuPlugins.forEach(plugin => {
footerMenus.push(<React.Fragment key={plugin.name}>{plugin.render()}</React.Fragment>);
});

return (
<Drawer modal open={menuIsShown()} onClose={hideMenu}>
<DrawerHeader className={navHeader}>
Expand Down Expand Up @@ -89,30 +99,7 @@ const Navigation = () => {
{t`Documentation`}
</ListItem>
</a>
<a
href="https://community.webiny.com/"
rel="noopener noreferrer"
target="_blank"
>
<ListItem ripple={false}>
<ListItemGraphic>
<Icon icon={<CommunityIcon />} />
</ListItemGraphic>
{t`Community`}
</ListItem>
</a>
<a
href="https://github.com/webiny/webiny-js"
rel="noopener noreferrer"
target="_blank"
>
<ListItem ripple={false}>
<ListItemGraphic>
<Icon icon={<GithubIcon />} />
</ListItemGraphic>
{t`Source`}
</ListItem>
</a>
{footerMenus}
<ListItem ripple={false} className={subFooter}>
<div>
<a
Expand Down
29 changes: 29 additions & 0 deletions packages/app-admin/src/plugins/Menu/slack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { AdminDrawerFooterMenuPlugin } from "@webiny/app-admin/types";
import { ListItem, ListItemGraphic } from "@webiny/ui/List";
import { Icon } from "@webiny/ui/Icon";
import { ReactComponent as SlackIcon } from "@webiny/app-admin/assets/icons/slack-logo.svg";

import { i18n } from "@webiny/app/i18n";
const t = i18n.ns("app-admin/navigation");

const plugin: AdminDrawerFooterMenuPlugin = {
type: "admin-drawer-footer-menu",
name: "admin-drawer-footer-menu-slack",
render() {
return (
<>
<a href="https://www.webiny.com/slack/" rel="noopener noreferrer" target="_blank">
<ListItem ripple={false}>
<ListItemGraphic>
<Icon icon={<SlackIcon />} />
</ListItemGraphic>
{t`Slack`}
</ListItem>
</a>
</>
);
}
};

export default plugin;
33 changes: 33 additions & 0 deletions packages/app-admin/src/plugins/Menu/source.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import { AdminDrawerFooterMenuPlugin } from "@webiny/app-admin/types";
import { ListItem, ListItemGraphic } from "@webiny/ui/List";
import { Icon } from "@webiny/ui/Icon";
import { ReactComponent as GithubIcon } from "@webiny/app-admin/assets/icons/github-brands.svg";

import { i18n } from "@webiny/app/i18n";
const t = i18n.ns("app-admin/navigation");

const plugin: AdminDrawerFooterMenuPlugin = {
type: "admin-drawer-footer-menu",
name: "admin-drawer-footer-menu-source",
render() {
return (
<>
<a
href="https://github.com/webiny/webiny-js"
rel="noopener noreferrer"
target="_blank"
>
<ListItem ripple={false}>
<ListItemGraphic>
<Icon icon={<GithubIcon />} />
</ListItemGraphic>
{t`Source`}
</ListItem>
</a>
</>
);
}
};

export default plugin;
4 changes: 4 additions & 0 deletions packages/app-admin/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import DefaultHandle from "@webiny/app-admin/plugins/UserMenu/plugins/DefaultHan
import Help from "@webiny/app-admin/plugins/UserMenu/plugins/Help";
import SendFeedback from "@webiny/app-admin/plugins/UserMenu/plugins/Feedback";
import install from "@webiny/app-admin/plugins/install";
import slack from "@webiny/app-admin/plugins/Menu/slack";
import source from "@webiny/app-admin/plugins/Menu/source";

import init from "./init";

Expand All @@ -40,5 +42,7 @@ export default (): PluginCollection => [
Help,
SendFeedback,
install,
slack,
source,
init
];
5 changes: 5 additions & 0 deletions packages/app-admin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export type AdminGlobalSearchPreventHotkeyPlugin = Plugin & {
preventOpen(e: React.KeyboardEvent): boolean | void;
};

export type AdminDrawerFooterMenuPlugin = Plugin & {
type: "admin-drawer-footer-menu";
render(): React.ReactElement;
};

export type AdminMenuLogoPlugin = Plugin & {
name: "admin-menu-logo";
type: "admin-menu-logo";
Expand Down

0 comments on commit 460de7c

Please sign in to comment.