From 2916b483ebed3e1f5667a858b251d42d844d6f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 19 Sep 2022 13:21:41 +0200 Subject: [PATCH] Update a few more pages to use navId instead of navModel from store (#55342) --- .../core/components/ErrorPage/ErrorPage.tsx | 131 ++++++++---------- public/app/features/admin/AdminSettings.tsx | 18 +-- .../alerting/EditNotificationChannelPage.tsx | 8 +- 3 files changed, 60 insertions(+), 97 deletions(-) diff --git a/public/app/core/components/ErrorPage/ErrorPage.tsx b/public/app/core/components/ErrorPage/ErrorPage.tsx index 25e77912f6c..9324111739a 100644 --- a/public/app/core/components/ErrorPage/ErrorPage.tsx +++ b/public/app/core/components/ErrorPage/ErrorPage.tsx @@ -1,92 +1,71 @@ -import React, { PureComponent } from 'react'; -import { connect, MapStateToProps } from 'react-redux'; +import React from 'react'; -import { NavModel } from '@grafana/data'; import { config } from '@grafana/runtime'; import { Icon } from '@grafana/ui'; -import { getNavModel } from 'app/core/selectors/navModel'; -import { StoreState } from 'app/types'; import { Page } from '../Page/Page'; -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

-
+export function ErrorPage() { + 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 - - . -

-
+
+
+
+

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); +export default ErrorPage; diff --git a/public/app/features/admin/AdminSettings.tsx b/public/app/features/admin/AdminSettings.tsx index f0b90e6e2b8..e099049f8d8 100644 --- a/public/app/features/admin/AdminSettings.tsx +++ b/public/app/features/admin/AdminSettings.tsx @@ -1,27 +1,19 @@ import React from 'react'; -import { connect } from 'react-redux'; import { useAsync } from 'react-use'; -import { NavModel } from '@grafana/data'; import { getBackendSrv } from '@grafana/runtime'; import { Page } from 'app/core/components/Page/Page'; -import { getNavModel } from 'app/core/selectors/navModel'; -import { StoreState } from 'app/types'; type Settings = { [key: string]: { [key: string]: string } }; -interface Props { - navModel: NavModel; -} - -function AdminSettings({ navModel }: Props) { +function AdminSettings() { const { loading, value: settings } = useAsync( () => getBackendSrv().get('/api/admin/settings') as Promise, [] ); return ( - +
These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change @@ -53,8 +45,4 @@ function AdminSettings({ navModel }: Props) { ); } -const mapStateToProps = (state: StoreState) => ({ - navModel: getNavModel(state.navIndex, 'server-settings'), -}); - -export default connect(mapStateToProps)(AdminSettings); +export default AdminSettings; diff --git a/public/app/features/alerting/EditNotificationChannelPage.tsx b/public/app/features/alerting/EditNotificationChannelPage.tsx index 9c7c1359c7d..9860dd10d5a 100644 --- a/public/app/features/alerting/EditNotificationChannelPage.tsx +++ b/public/app/features/alerting/EditNotificationChannelPage.tsx @@ -1,13 +1,11 @@ import React, { PureComponent } from 'react'; import { MapDispatchToProps, MapStateToProps } from 'react-redux'; -import { NavModel } from '@grafana/data'; import { config } from '@grafana/runtime'; import { Form, Spinner } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import { connectWithCleanUp } from 'app/core/components/connectWithCleanUp'; import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; -import { getNavModel } from 'app/core/selectors/navModel'; import { NotificationChannelType, NotificationChannelDTO, StoreState } from 'app/types'; import { NotificationChannelForm } from './components/NotificationChannelForm'; @@ -18,7 +16,6 @@ import { mapChannelsToSelectableValue, transformSubmitData, transformTestData } interface OwnProps extends GrafanaRouteComponentProps<{ id: string }> {} interface ConnectedProps { - navModel: NavModel; notificationChannel: any; notificationChannelTypes: NotificationChannelType[]; } @@ -70,10 +67,10 @@ export class EditNotificationChannelPage extends PureComponent { }; render() { - const { navModel, notificationChannel, notificationChannelTypes } = this.props; + const { notificationChannel, notificationChannelTypes } = this.props; return ( - +

Edit notification channel

{notificationChannel && notificationChannel.id > 0 ? ( @@ -119,7 +116,6 @@ export class EditNotificationChannelPage extends PureComponent { const mapStateToProps: MapStateToProps = (state) => { return { - navModel: getNavModel(state.navIndex, 'channels'), notificationChannel: state.notificationChannel.notificationChannel, notificationChannelTypes: state.notificationChannel.notificationChannelTypes, };