1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
7 import { PluginConfig } from '~/common/plugintypes';
8 import * as React from 'react';
9 import { Dispatch } from 'redux';
10 import { RootState } from '~/store/store';
11 import { push } from "react-router-redux";
12 import { Typography } from "@material-ui/core";
13 import { Route, matchPath } from "react-router";
14 import { RootStore } from '~/store/store';
15 import { activateSidePanelTreeItem } from '~/store/side-panel-tree/side-panel-tree-actions';
16 import { setSidePanelBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
18 const categoryName = "Plugin Example";
19 export const routePath = "/examplePlugin";
21 const ExamplePluginMainPanel = (props: {}) => {
23 This is a example main panel plugin.
27 export const register = (pluginConfig: PluginConfig) => {
29 pluginConfig.centerPanelList.push((elms) => {
30 elms.push(<Route path={routePath} component={ExamplePluginMainPanel} />);
34 pluginConfig.navigateToHandlers.push((dispatch: Dispatch, getState: () => RootState, uuid: string) => {
35 if (uuid === categoryName) {
36 dispatch(push(routePath));
42 pluginConfig.sidePanelCategories.push((cats: string[]): string[] => { cats.push(categoryName); return cats; });
44 pluginConfig.locationChangeHandlers.push((store: RootStore, pathname: string): boolean => {
45 if (matchPath(pathname, { path: routePath, exact: true })) {
46 store.dispatch(activateSidePanelTreeItem(categoryName));
47 store.dispatch<any>(setSidePanelBreadcrumbs(categoryName));