From 5a11abe9546471f129db8d170c38392fd8d6305c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 Nov 2020 15:29:43 +0100 Subject: [PATCH] Events: Remove unused or unnecessary events (#28783) * Events: Removing unused or unnessary events * More cleanup * Updated --- .../grafana-ui/src/components/Tabs/Tab.tsx | 2 +- public/app/app.ts | 1 - .../core/components/PageHeader/PageHeader.tsx | 64 +++++++------------ public/app/core/directives/diff-view.ts | 9 +-- public/app/core/services/bridge_srv.ts | 22 +------ public/app/core/services/keybindingSrv.ts | 9 --- .../PanelHeader/PanelHeaderMenuItem.tsx | 2 +- .../app/features/plugins/AppRootPage.test.tsx | 4 +- public/app/plugins/panel/text/TextPanel.tsx | 3 - public/app/routes/dashboard_loaders.ts | 7 +- public/app/types/events.ts | 28 -------- public/sass/components/_gf-form.scss | 1 + 12 files changed, 34 insertions(+), 118 deletions(-) diff --git a/packages/grafana-ui/src/components/Tabs/Tab.tsx b/packages/grafana-ui/src/components/Tabs/Tab.tsx index e5aa26a2149..cb27db0006f 100644 --- a/packages/grafana-ui/src/components/Tabs/Tab.tsx +++ b/packages/grafana-ui/src/components/Tabs/Tab.tsx @@ -14,7 +14,7 @@ export interface TabProps extends HTMLProps { /** When provided, it is possible to use the tab as a hyperlink. Use in cases where the tabs update location. */ href?: string; icon?: IconName; - onChangeTab: (event?: React.MouseEvent) => void; + onChangeTab?: (event?: React.MouseEvent) => void; /** A number rendered next to the text. Usually used to display the number of items in a tab's view. */ counter?: number | null; } diff --git a/public/app/app.ts b/public/app/app.ts index 0acb94941f2..27d338def7a 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -106,7 +106,6 @@ export class GrafanaApp { app.config( ( - $locationProvider: angular.ILocationProvider, $controllerProvider: angular.IControllerProvider, $compileProvider: angular.ICompileProvider, $filterProvider: angular.IFilterProvider, diff --git a/public/app/core/components/PageHeader/PageHeader.tsx b/public/app/core/components/PageHeader/PageHeader.tsx index 7739fb5c6cc..c16019a46ab 100644 --- a/public/app/core/components/PageHeader/PageHeader.tsx +++ b/public/app/core/components/PageHeader/PageHeader.tsx @@ -1,9 +1,8 @@ -import React, { FormEvent } from 'react'; +import React from 'react'; import { css } from 'emotion'; import { Tab, TabsBar, Icon, IconName } from '@grafana/ui'; -import appEvents from 'app/core/app_events'; import { NavModel, NavModelItem, NavModelBreadcrumb } from '@grafana/data'; -import { CoreEvents } from 'app/types'; +import { PanelHeaderMenuItem } from 'app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenuItem'; export interface Props { model: NavModel; @@ -18,37 +17,29 @@ const SelectNav = ({ children, customCss }: { children: NavModelItem[]; customCs return navItem.active === true; }); - const gotoUrl = (evt: FormEvent) => { - const element = evt.target as HTMLSelectElement; - const url = element.options[element.selectedIndex].value; - appEvents.emit(CoreEvents.locationChange, { href: url }); - }; - return (
-
); }; @@ -58,14 +49,6 @@ const Navigation = ({ children }: { children: NavModelItem[] }) => { return null; } - const goToUrl = (index: number) => { - children.forEach((child, i) => { - if (i === index) { - appEvents.emit(CoreEvents.locationChange, { href: child.url }); - } - }); - }; - return (