From b4fa8e69af5429da361aae1eea93301b6c1d725f Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 26 Feb 2021 23:43:35 -0500 Subject: [PATCH] 17426: Add plugin ability to override app bar. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- src/common/plugintypes.ts | 6 ++++ src/plugins.tsx | 7 +++-- src/plugins/blank/index.tsx | 5 ++++ .../main-app-bar/main-app-bar.tsx | 15 +++++----- .../main-content-bar/main-content-bar.tsx | 28 ++++++++++++++----- 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/common/plugintypes.ts b/src/common/plugintypes.ts index 489568ea..dfbe7c45 100644 --- a/src/common/plugintypes.ts +++ b/src/common/plugintypes.ts @@ -26,4 +26,10 @@ export interface PluginConfig { // Add handlers for navigation actions locationChangeHandlers: LocationChangeMatcher[]; + + appBarLeft?: React.ReactElement; + + appBarMiddle?: React.ReactElement; + + appBarRight?: React.ReactElement; } diff --git a/src/plugins.tsx b/src/plugins.tsx index fb52aade..83593f23 100644 --- a/src/plugins.tsx +++ b/src/plugins.tsx @@ -9,12 +9,15 @@ export const pluginConfig: PluginConfig = { sidePanelCategories: [], dialogs: [], navigateToHandlers: [], - locationChangeHandlers: [] + locationChangeHandlers: [], + appBarLeft: undefined, + appBarMiddle: undefined, + appBarRight: undefined, }; // Starting here, import and register your Workbench 2 plugins. // -// import { register as blankUIPluginRegister } from '~/plugins/blank/index'; +import { register as blankUIPluginRegister } from '~/plugins/blank/index'; import { register as examplePluginRegister, routePath as exampleRoutePath } from '~/plugins/example/index'; import { register as rootRedirectRegister } from '~/plugins/root-redirect/index'; diff --git a/src/plugins/blank/index.tsx b/src/plugins/blank/index.tsx index 416de42d..9471372d 100644 --- a/src/plugins/blank/index.tsx +++ b/src/plugins/blank/index.tsx @@ -5,10 +5,15 @@ // Example plugin. import { PluginConfig } from '~/common/plugintypes'; +import * as React from 'react'; export const register = (pluginConfig: PluginConfig) => { pluginConfig.centerPanelList.push((elms) => []); pluginConfig.sidePanelCategories.push((cats: string[]): string[] => []); + + pluginConfig.appBarLeft = ; + pluginConfig.appBarMiddle = ; + pluginConfig.appBarRight = ; }; diff --git a/src/views-components/main-app-bar/main-app-bar.tsx b/src/views-components/main-app-bar/main-app-bar.tsx index ce1cab4c..7bec7b24 100644 --- a/src/views-components/main-app-bar/main-app-bar.tsx +++ b/src/views-components/main-app-bar/main-app-bar.tsx @@ -14,6 +14,7 @@ import { AccountMenu } from "~/views-components/main-app-bar/account-menu"; import { HelpMenu } from '~/views-components/main-app-bar/help-menu'; import { ReactNode } from "react"; import { AdminMenu } from "~/views-components/main-app-bar/admin-menu"; +import { pluginConfig } from '~/plugins'; type CssRules = 'toolbar' | 'link'; @@ -42,20 +43,20 @@ export const MainAppBar = withStyles(styles)( return - + {pluginConfig.appBarLeft || ({props.uuidPrefix}) {props.buildInfo} - + } - {props.user && props.user.isActive && } + {pluginConfig.appBarMiddle || (props.user && props.user.isActive && )} - {props.user - ? <> + {pluginConfig.appBarRight || + (props.user ? <> {props.user.isAdmin && } - - : } + : + )} diff --git a/src/views-components/main-content-bar/main-content-bar.tsx b/src/views-components/main-content-bar/main-content-bar.tsx index cad73a3a..60adab66 100644 --- a/src/views-components/main-content-bar/main-content-bar.tsx +++ b/src/views-components/main-content-bar/main-content-bar.tsx @@ -30,13 +30,27 @@ interface MainContentBarProps { const isButtonVisible = ({ router }: RootState) => { const pathname = router.location ? router.location.pathname : ''; - return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) && - !Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) && - !Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) && - !Routes.matchSiteManagerRoute(pathname) && - !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) && - !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) && - !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname); + return Routes.matchCollectionsContentAddressRoute(pathname) || + Routes.matchPublicFavoritesRoute(pathname) || + Routes.matchGroupDetailsRoute(pathname) || + Routes.matchGroupsRoute(pathname) || + Routes.matchUsersRoute(pathname) || + Routes.matchSearchResultsRoute(pathname) || + Routes.matchSharedWithMeRoute(pathname) || + Routes.matchProcessRoute(pathname) || + Routes.matchCollectionRoute(pathname) || + Routes.matchProjectRoute(pathname) || + Routes.matchAllProcessesRoute(pathname) || + Routes.matchTrashRoute(pathname) || + Routes.matchFavoritesRoute(pathname); + + /* return !Routes.matchWorkflowRoute(pathname) && !Routes.matchUserVirtualMachineRoute(pathname) && + * !Routes.matchAdminVirtualMachineRoute(pathname) && !Routes.matchRepositoriesRoute(pathname) && + * !Routes.matchSshKeysAdminRoute(pathname) && !Routes.matchSshKeysUserRoute(pathname) && + * !Routes.matchSiteManagerRoute(pathname) && + * !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) && + * !Routes.matchApiClientAuthorizationsRoute(pathname) && !Routes.matchUsersRoute(pathname) && + * !Routes.matchMyAccountRoute(pathname) && !Routes.matchLinksRoute(pathname); */ }; export const MainContentBar = -- 2.30.2