import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import { DataSource, Plugin } from 'app/types'; export interface Props { dataSource: DataSource; dataSourceMeta: Plugin; } interface State { name: string; } enum DataSourceStates { Alpha = 'alpha', Beta = 'beta', } export class DataSourceSettings extends PureComponent { constructor(props) { super(props); this.state = { name: props.dataSource.name, }; } onNameChange = event => { this.setState({ name: event.target.value, }); }; onSubmit = event => { event.preventDefault(); console.log(event); }; onDelete = event => { console.log(event); }; isReadyOnly() { return this.props.dataSource.readOnly === true; } shouldRenderInfoBox() { const { state } = this.props.dataSourceMeta; return state === DataSourceStates.Alpha || state === DataSourceStates.Beta; } getInfoText() { const { dataSourceMeta } = this.props; switch (dataSourceMeta.state) { case DataSourceStates.Alpha: return ( 'This plugin is marked as being in alpha state, which means it is in early development phase and updates' + ' will include breaking changes.' ); case DataSourceStates.Beta: return ( '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.' ); } return null; } render() { const { name } = this.state; return (

Settings

Name
{this.shouldRenderInfoBox() &&
{this.getInfoText()}
} {this.isReadyOnly() && (
This datasource was added by config and cannot be modified using the UI. Please contact your server admin to update this datasource.
)}
Back
); } } function mapStateToProps(state) { return { dataSource: state.dataSources.dataSource, dataSourceMeta: state.dataSources.dataSourceMeta, }; } export default connect(mapStateToProps)(DataSourceSettings);