diff --git a/public/app/core/components/ErrorPage/ErrorPage.tsx b/public/app/core/components/ErrorPage/ErrorPage.tsx new file mode 100644 index 00000000000..c9740f40eb7 --- /dev/null +++ b/public/app/core/components/ErrorPage/ErrorPage.tsx @@ -0,0 +1,90 @@ +import React, { PureComponent } from 'react'; +import { connect, MapStateToProps } from 'react-redux'; +import { NavModel } from '@grafana/data'; +import { config } from '@grafana/runtime'; +import { Icon } from '@grafana/ui'; +import Page from '../Page/Page'; +import { getNavModel } from 'app/core/selectors/navModel'; +import { StoreState } from 'app/types'; + +interface ConnectedProps { + navModel: NavModel; +} + +interface OwnProps {} + +type Props = ConnectedProps; + +export class ErrorPage extends PureComponent { + render() { + const { navModel } = this.props; + return ( + + +
+
+
+
+
+

100%

+

80%

+

60%

+

40%

+

20%

+

0%

+
+
+ graph +
+

Then

+

Now

+
+
+
+
+
+
+

current

+
+
+ +
+
+

Chances you are on the page you are looking for.

+

0%

+
+
+

Sorry for the inconvenience

+

+ Please go back to your{' '} + + home dashboard + {' '} + and try again. +

+

+ If the error persists, seek help on the{' '} + + community site + + . +

+
+
+
+
+
+
+
+
+ ); + } +} + +const mapStateToProps: MapStateToProps = state => { + return { + navModel: getNavModel(state.navIndex, 'not-found'), + }; +}; + +export default connect(mapStateToProps)(ErrorPage); diff --git a/public/app/core/controllers/all.ts b/public/app/core/controllers/all.ts index ab658d75acf..f7f9f4c0486 100644 --- a/public/app/core/controllers/all.ts +++ b/public/app/core/controllers/all.ts @@ -1,5 +1,4 @@ import './invited_ctrl'; import './signup_ctrl'; import './reset_password_ctrl'; -import './error_ctrl'; import './json_editor_ctrl'; diff --git a/public/app/core/controllers/error_ctrl.ts b/public/app/core/controllers/error_ctrl.ts deleted file mode 100644 index 780b0ecfce0..00000000000 --- a/public/app/core/controllers/error_ctrl.ts +++ /dev/null @@ -1,24 +0,0 @@ -import config from 'app/core/config'; -import coreModule from '../core_module'; -import appEvents from 'app/core/app_events'; -import { CoreEvents } from 'app/types'; - -export class ErrorCtrl { - /** @ngInject */ - constructor($scope: any, contextSrv: any, navModelSrv: any) { - $scope.navModel = navModelSrv.getNotFoundNav(); - $scope.appSubUrl = config.appSubUrl; - - if (!contextSrv.isSignedIn) { - appEvents.emit(CoreEvents.toggleSidemenuHidden); - } - - $scope.$on('destroy', () => { - if (!contextSrv.isSignedIn) { - appEvents.emit(CoreEvents.toggleSidemenuHidden); - } - }); - } -} - -coreModule.controller('ErrorCtrl', ErrorCtrl); diff --git a/public/app/core/reducers/navModel.ts b/public/app/core/reducers/navModel.ts index 2c89a509e9a..d974e82efc7 100644 --- a/public/app/core/reducers/navModel.ts +++ b/public/app/core/reducers/navModel.ts @@ -1,5 +1,5 @@ import { AnyAction, createAction } from '@reduxjs/toolkit'; -import { NavIndex, NavModelItem } from '@grafana/data'; +import { NavIndex, NavModel, NavModelItem } from '@grafana/data'; import config from 'app/core/config'; @@ -21,6 +21,21 @@ function buildNavIndex(navIndex: NavIndex, children: NavModelItem[], parentItem? buildNavIndex(navIndex, node.children, node); } } + + navIndex['not-found'] = { ...buildWarningNav('Page not found', '404 Error').node }; +} + +function buildWarningNav(text: string, subTitle?: string): NavModel { + const node = { + text, + subTitle, + icon: 'exclamation-triangle', + }; + return { + breadcrumbs: [node], + node: node, + main: node, + }; } export const initialState: NavIndex = {}; diff --git a/public/app/partials/error.html b/public/app/partials/error.html deleted file mode 100644 index c25addeba51..00000000000 --- a/public/app/partials/error.html +++ /dev/null @@ -1,50 +0,0 @@ - - -
-
-
-
-
-

100%

-

80%

-

60%

-

40%

-

20%

-

0%

-
-
- -
-

Then

-

Now

-
-
-
-
-
-
-

current

-
-
- -
-
-

Chances you are on the page you are looking for.

-

0%

-
-
-

Sorry for the inconvenience

-

Please go back to your home dashboard and try again.

-

- If the error persists, seek help on the - community site. -

-
-
-
-
- -
-
- -