From ab62a09fe6346bd2b372929d1a3992d8870dfc76 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Mon, 28 Jan 2019 22:27:19 +0100 Subject: [PATCH] chore: Fix typings and add Page-component to ServerStats #14762 --- public/app/features/admin/ServerStats.tsx | 20 +- .../__snapshots__/ServerStats.test.tsx.snap | 322 +++++++++++++----- .../app/features/alerting/AlertRuleList.tsx | 1 - 3 files changed, 242 insertions(+), 101 deletions(-) diff --git a/public/app/features/admin/ServerStats.tsx b/public/app/features/admin/ServerStats.tsx index 40be87ed4d3..5247e48515e 100644 --- a/public/app/features/admin/ServerStats.tsx +++ b/public/app/features/admin/ServerStats.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { NavModel, StoreState } from 'app/types'; import { getNavModel } from 'app/core/selectors/navModel'; import { getServerStats, ServerStat } from './state/apis'; -import PageHeader from 'app/core/components/PageHeader/PageHeader'; +import Page from 'app/core/components/Page/Page'; interface Props { navModel: NavModel; @@ -13,21 +13,24 @@ interface Props { interface State { stats: ServerStat[]; + isLoading: boolean; } export class ServerStats extends PureComponent { - constructor(props) { + constructor(props: Props) { super(props); this.state = { stats: [], + isLoading: false }; } async componentDidMount() { try { + this.setState({ isLoading: true }); const stats = await this.props.getServerStats(); - this.setState({ stats }); + this.setState({ stats, isLoading: false }); } catch (error) { console.error(error); } @@ -35,12 +38,11 @@ export class ServerStats extends PureComponent { render() { const { navModel } = this.props; - const { stats } = this.state; + const { stats, isLoading } = this.state; return ( -
- -
+ + @@ -50,8 +52,8 @@ export class ServerStats extends PureComponent { {stats.map(StatItem)}
-
-
+ + ); } } diff --git a/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap b/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap index 02e8784adc5..e6c3f0f841e 100644 --- a/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap +++ b/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap @@ -1,118 +1,258 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ServerStats Should render table with stats 1`] = ` -
+
- - -
-

- Admin -

- subTitle +
+ + + +
+

+ Admin +

+
+ subTitle +
+
+
+
- +
-
-
- - - - - - - - - - - - - - - - - -
- Name - - Value -
- Total dashboards - - 10 -
- Total Users - - 1 -
+
+
+
+
+
`; diff --git a/public/app/features/alerting/AlertRuleList.tsx b/public/app/features/alerting/AlertRuleList.tsx index a6c770aad9b..3a16703ef54 100644 --- a/public/app/features/alerting/AlertRuleList.tsx +++ b/public/app/features/alerting/AlertRuleList.tsx @@ -2,7 +2,6 @@ import React, { PureComponent } from 'react'; import { hot } from 'react-hot-loader'; import { connect } from 'react-redux'; import Page from 'app/core/components/Page/Page'; -// import PageHeader from 'app/core/components/PageHeader/PageHeader'; import AlertRuleItem from './AlertRuleItem'; import appEvents from 'app/core/app_events'; import { updateLocation } from 'app/core/actions';