diff --git a/public/app/features/datasources/NewDataSourcePage.tsx b/public/app/features/datasources/NewDataSourcePage.tsx new file mode 100644 index 00000000000..422f4c7db87 --- /dev/null +++ b/public/app/features/datasources/NewDataSourcePage.tsx @@ -0,0 +1,110 @@ +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 { NavModel } from 'app/types'; +import { getNavModel } from 'app/core/selectors/navModel'; + +export interface Props { + navModel: NavModel; +} + +export interface State { + name: string; + type: string; + dataSourceOptions: Array<{ value: string; label: string }>; +} + +class NewDataSourcePage extends PureComponent { + state = { + name: '', + type: '', + dataSourceOptions: [ + { value: 'prometheus', label: 'Prometheus' }, + { value: 'graphite', label: 'Graphite' }, + { value: 'mysql', label: 'MySql' }, + { value: 'influxdb', label: 'InfluxDB' }, + ], + }; + + onChangeName = event => { + this.setState({ + name: event.target.value, + }); + }; + + onTypeChanged = type => { + this.setState({ + type: type, + }); + }; + + submitForm = () => { + if (!this.isFieldsEmpty()) { + // post + } + }; + + isFieldsEmpty = () => { + const { name, type } = this.state; + + if (name === '' && type === '') { + return true; + } else if (name !== '' && type === '') { + return true; + } else { + return name === '' && type !== ''; + } + }; + + render() { + const { navModel } = this.props; + const { dataSourceOptions, name, type } = this.state; + + return ( +
+ +
+

New Data source

+
+
+ Name + +
+
+ Type +