diff --git a/public/app/core/components/PageHeader/PageHeader.tsx b/public/app/core/components/PageHeader/PageHeader.tsx index 83066054f88..623070651d1 100644 --- a/public/app/core/components/PageHeader/PageHeader.tsx +++ b/public/app/core/components/PageHeader/PageHeader.tsx @@ -80,7 +80,7 @@ const Navigation = ({ main }: { main: NavModelItem }) => { }; export default class PageHeader extends React.Component { - constructor(props) { + constructor(props: Props) { super(props); } diff --git a/public/app/core/components/PageLoader/PageLoader.tsx b/public/app/core/components/PageLoader/PageLoader.tsx index 3182695e5e5..6deeabf9a41 100644 --- a/public/app/core/components/PageLoader/PageLoader.tsx +++ b/public/app/core/components/PageLoader/PageLoader.tsx @@ -4,7 +4,7 @@ interface Props { pageName?: string; } -const PageLoader: FC = ({ pageName }) => { +const PageLoader: FC = ({ pageName = '' }) => { const loadingText = `Loading ${pageName}...`; return (
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.test.tsx b/public/app/features/alerting/AlertRuleList.test.tsx index 2d1cf653540..ce3b8d47142 100644 --- a/public/app/features/alerting/AlertRuleList.test.tsx +++ b/public/app/features/alerting/AlertRuleList.test.tsx @@ -18,6 +18,7 @@ const setup = (propOverrides?: object) => { togglePauseAlertRule: jest.fn(), stateFilter: '', search: '', + isLoading: false }; Object.assign(props, propOverrides); @@ -121,7 +122,7 @@ describe('Functions', () => { describe('State filter changed', () => { it('should update location', () => { const { instance } = setup(); - const mockEvent = { target: { value: 'alerting' } }; + const mockEvent = { target: { value: 'alerting' } } as React.ChangeEvent; instance.onStateFilterChanged(mockEvent); @@ -146,7 +147,7 @@ describe('Functions', () => { describe('Search query change', () => { it('should set search query', () => { const { instance } = setup(); - const mockEvent = { target: { value: 'dashboard' } }; + const mockEvent = { target: { value: 'dashboard' } } as React.ChangeEvent; instance.onSearchQueryChange(mockEvent); diff --git a/public/app/features/alerting/AlertRuleList.tsx b/public/app/features/alerting/AlertRuleList.tsx index f94134f3ee1..3a16703ef54 100644 --- a/public/app/features/alerting/AlertRuleList.tsx +++ b/public/app/features/alerting/AlertRuleList.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { hot } from 'react-hot-loader'; import { connect } from 'react-redux'; -import PageHeader from 'app/core/components/PageHeader/PageHeader'; +import Page from 'app/core/components/Page/Page'; import AlertRuleItem from './AlertRuleItem'; import appEvents from 'app/core/app_events'; import { updateLocation } from 'app/core/actions'; @@ -19,6 +19,7 @@ export interface Props { togglePauseAlertRule: typeof togglePauseAlertRule; stateFilter: string; search: string; + isLoading: boolean; } export class AlertRuleList extends PureComponent { @@ -54,9 +55,9 @@ export class AlertRuleList extends PureComponent { return 'all'; } - onStateFilterChanged = event => { + onStateFilterChanged = (evt: React.ChangeEvent) => { this.props.updateLocation({ - query: { state: event.target.value }, + query: { state: evt.target.value }, }); }; @@ -68,8 +69,8 @@ export class AlertRuleList extends PureComponent { }); }; - onSearchQueryChange = event => { - const { value } = event.target; + onSearchQueryChange = (evt: React.ChangeEvent) => { + const { value } = evt.target; this.props.setSearchQuery(value); }; @@ -77,7 +78,7 @@ export class AlertRuleList extends PureComponent { this.props.togglePauseAlertRule(rule.id, { paused: rule.state !== 'paused' }); }; - alertStateFilterOption = ({ text, value }) => { + alertStateFilterOption = ({ text, value }: { text: string; value: string; }) => { return (