diff --git a/public/app/features/datasources/settings/DataSourceSettingsPage.tsx b/public/app/features/datasources/settings/DataSourceSettingsPage.tsx index 87efed266b0..bb784fd928b 100644 --- a/public/app/features/datasources/settings/DataSourceSettingsPage.tsx +++ b/public/app/features/datasources/settings/DataSourceSettingsPage.tsx @@ -4,8 +4,7 @@ import { hot } from 'react-hot-loader'; import { connect } from 'react-redux'; // Components -import PageHeader from 'app/core/components/PageHeader/PageHeader'; -import PageLoader from 'app/core/components/PageLoader/PageLoader'; +import Page from 'app/core/components/Page/Page'; import PluginSettings from './PluginSettings'; import BasicSettings from './BasicSettings'; import ButtonRow from './ButtonRow'; @@ -51,7 +50,7 @@ enum DataSourceStates { } export class DataSourceSettingsPage extends PureComponent { - constructor(props) { + constructor(props: Props) { super(props); this.state = { @@ -65,8 +64,8 @@ export class DataSourceSettingsPage extends PureComponent { await loadDataSource(pageId); } - onSubmit = async event => { - event.preventDefault(); + onSubmit = async (evt: React.FormEvent) => { + evt.preventDefault(); await this.props.updateDataSource({ ...this.state.dataSource, name: this.props.dataSource.name }); @@ -89,7 +88,7 @@ export class DataSourceSettingsPage extends PureComponent { this.props.deleteDataSource(); }; - onModelChange = dataSource => { + onModelChange = (dataSource: DataSourceSettings) => { this.setState({ dataSource: dataSource, }); @@ -170,17 +169,18 @@ export class DataSourceSettingsPage extends PureComponent { }); } + get hasDataSource() { + return Object.keys(this.props.dataSource).length > 0; + } + render() { const { dataSource, dataSourceMeta, navModel, setDataSourceName, setIsDefault } = this.props; const { testingMessage, testingStatus } = this.state; return ( -
- - {Object.keys(dataSource).length === 0 ? ( - - ) : ( -
+ + + {this.hasDataSource &&
{this.isReadOnly() && this.renderIsReadOnlyMessage()} @@ -225,9 +225,9 @@ export class DataSourceSettingsPage extends PureComponent { />
-
- )} -
+
} + + ); } } diff --git a/public/app/features/datasources/settings/__snapshots__/DataSourceSettingsPage.test.tsx.snap b/public/app/features/datasources/settings/__snapshots__/DataSourceSettingsPage.test.tsx.snap index bcd8237ff39..af7895ac6b8 100644 --- a/public/app/features/datasources/settings/__snapshots__/DataSourceSettingsPage.test.tsx.snap +++ b/public/app/features/datasources/settings/__snapshots__/DataSourceSettingsPage.test.tsx.snap @@ -1,415 +1,426 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Render should render alpha info text 1`] = ` -
- -
+ -
-
-
- This plugin is marked as being in alpha state, which means it is in early development phase and updates will include breaking changes. -
- - -
- +
+ - + > +
+ This plugin is marked as being in alpha state, which means it is in early development phase and updates will include breaking changes. +
+ + +
+ + +
-
-
+
+ `; exports[`Render should render beta info text 1`] = ` -
- -
+ -
-
-
- This plugin is marked as being in a beta development state. This means it is in currently in active development and could be missing important features. -
- - -
- +
+ - + > +
+ This plugin is marked as being in a beta development state. This means it is in currently in active development and could be missing important features. +
+ + +
+ + +
-
-
+
+ `; exports[`Render should render component 1`] = ` -
- -
+ -
-
- - -
- +
+ - + > + + +
+ + +
-
-
+
+ `; exports[`Render should render is ready only message 1`] = ` -
- -
+ -
-
-
- This datasource was added by config and cannot be modified using the UI. Please contact your server admin to update this datasource. -
- - -
- +
+ - + > +
+ This datasource was added by config and cannot be modified using the UI. Please contact your server admin to update this datasource. +
+ + +
+ + +
-
-
+
+ `; exports[`Render should render loader 1`] = ` -
- + - -
+ `;