From 262fee0a42aad3b59a1fa2d53b3405d3a8e301e7 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Wed, 3 Oct 2018 16:04:30 +0200 Subject: [PATCH] new grid layout add data source --- .../datasources/NewDataSourcePage.tsx | 103 ++++-------------- .../app/features/datasources/state/actions.ts | 6 +- .../features/datasources/state/reducers.ts | 4 +- public/app/types/datasources.ts | 8 +- public/app/types/index.ts | 3 +- public/sass/_grafana.scss | 1 + public/sass/components/_add_data_source.scss | 35 ++++++ 7 files changed, 64 insertions(+), 96 deletions(-) create mode 100644 public/sass/components/_add_data_source.scss diff --git a/public/app/features/datasources/NewDataSourcePage.tsx b/public/app/features/datasources/NewDataSourcePage.tsx index 6ef46480e6d..f03304327a6 100644 --- a/public/app/features/datasources/NewDataSourcePage.tsx +++ b/public/app/features/datasources/NewDataSourcePage.tsx @@ -1,114 +1,51 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import { hot } from 'react-hot-loader'; -import Select from 'react-select'; import PageHeader from 'app/core/components/PageHeader/PageHeader'; -import { DataSourceType, NavModel } from 'app/types'; +import { NavModel, Plugin } from 'app/types'; import { addDataSource, loadDataSourceTypes } from './state/actions'; import { updateLocation } from '../../core/actions'; import { getNavModel } from 'app/core/selectors/navModel'; export interface Props { navModel: NavModel; - dataSourceTypes: DataSourceType[]; + dataSourceTypes: Plugin[]; addDataSource: typeof addDataSource; loadDataSourceTypes: typeof loadDataSourceTypes; updateLocation: typeof updateLocation; } -export interface State { - name: string; - type: { value: string; label: string }; -} - -class NewDataSourcePage extends PureComponent { - state = { - name: '', - type: null, - }; - +class NewDataSourcePage extends PureComponent { componentDidMount() { this.props.loadDataSourceTypes(); } - onChangeName = event => { - this.setState({ - name: event.target.value, - }); - }; - - onTypeChanged = type => { - this.setState({ - type: type, - }); - }; - - submitForm = event => { - event.preventDefault(); - - if (!this.isFieldsEmpty()) { - this.props.addDataSource(this.state.name, this.state.type.value); - } - }; - - goBack = () => { - this.props.updateLocation({ path: '/datasources' }); - }; - - isFieldsEmpty = () => { - const { name, type } = this.state; - - if (name === '' && !type) { - return true; - } else if (name !== '' && !type) { - return true; - } else { - return !!(name === '' && type); - } + onDataSourceTypeClicked = type => { + this.props.addDataSource(type.name, type.value); }; render() { const { navModel, dataSourceTypes } = this.props; - const { name, type } = this.state; return (
-

New Data source

-
-
- Name - -
-
- Type -