diff --git a/.betterer.results b/.betterer.results index a9418f5dcc4..e28a6d35745 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1,5 +1,5 @@ // BETTERER RESULTS V2. -// +// // If this file contains merge conflicts, use `betterer merge` to automatically resolve them: // https://phenomnomnominal.github.io/betterer/docs/results-file/#merge // @@ -2128,9 +2128,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], - "public/app/angular/services/nav_model_srv.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/angular/services/ng_react.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], diff --git a/public/app/angular/services/nav_model_srv.ts b/public/app/angular/services/nav_model_srv.ts index 38051e4dcd7..5b3bad4c1c2 100644 --- a/public/app/angular/services/nav_model_srv.ts +++ b/public/app/angular/services/nav_model_srv.ts @@ -1,6 +1,7 @@ -import { NavModel, NavModelItem } from '@grafana/data'; +import { NavModelItem } from '@grafana/data'; import coreModule from 'app/angular/core_module'; import config from 'app/core/config'; +import { getNotFoundNav } from 'app/core/navigation/errorModels'; interface Nav { breadcrumbs: NavModelItem[]; @@ -55,25 +56,4 @@ export class NavModelSrv { } } -export function getExceptionNav(error: any): NavModel { - console.error(error); - return getWarningNav('Exception thrown', 'See console for details'); -} - -export function getNotFoundNav(): NavModel { - return getWarningNav('Page not found', '404 Error'); -} - -export function getWarningNav(text: string, subTitle?: string): NavModel { - const node: NavModelItem = { - text, - subTitle, - icon: 'exclamation-triangle', - }; - return { - node: node, - main: node, - }; -} - coreModule.service('navModelSrv', NavModelSrv); diff --git a/public/app/core/navigation/errorModels.ts b/public/app/core/navigation/errorModels.ts new file mode 100644 index 00000000000..68aa937101b --- /dev/null +++ b/public/app/core/navigation/errorModels.ts @@ -0,0 +1,22 @@ +import { NavModel, NavModelItem } from '@grafana/data'; + +export function getExceptionNav(error: unknown): NavModel { + console.error(error); + return getWarningNav('Exception thrown', 'See console for details'); +} + +export function getNotFoundNav(): NavModel { + return getWarningNav('Page not found', '404 Error'); +} + +export function getWarningNav(text: string, subTitle?: string): NavModel { + const node: NavModelItem = { + text, + subTitle, + icon: 'exclamation-triangle', + }; + return { + node: node, + main: node, + }; +} diff --git a/public/app/features/plugins/components/AppRootPage.tsx b/public/app/features/plugins/components/AppRootPage.tsx index d5b18275907..d4ab24d0d80 100644 --- a/public/app/features/plugins/components/AppRootPage.tsx +++ b/public/app/features/plugins/components/AppRootPage.tsx @@ -6,10 +6,10 @@ import { useLocation, useRouteMatch } from 'react-router-dom'; import { AppEvents, AppPlugin, AppPluginMeta, NavModel, NavModelItem, PluginType } from '@grafana/data'; import { config, locationSearchToObject } from '@grafana/runtime'; -import { getNotFoundNav, getWarningNav, getExceptionNav } from 'app/angular/services/nav_model_srv'; import { Page } from 'app/core/components/Page/Page'; import PageLoader from 'app/core/components/PageLoader/PageLoader'; import { appEvents } from 'app/core/core'; +import { getNotFoundNav, getWarningNav, getExceptionNav } from 'app/core/navigation/errorModels'; import { getPluginSettings } from '../pluginSettings'; import { importAppPlugin } from '../plugin_loader';