Added Alert for ControlPanel and ChartContainer (#1626)

* Added Alert for ControlPanel and ChartContainer

Done:
 - Add alert for Control Panel when fetch_datasource_metadata failes
 - Add alert for Chart Container when update_explore query fails

* Changed color to warning-yellow

* Solve linter issue

* Fixed indent and delete error_redirect
This commit is contained in:
vera-liu
2016-11-18 11:17:06 -08:00
committed by GitHub
parent 0acf26b37c
commit a8480f5492
6 changed files with 79 additions and 22 deletions

View File

@@ -3,7 +3,7 @@ import React, { PropTypes } from 'react';
import { bindActionCreators } from 'redux';
import * as actions from '../actions/exploreActions';
import { connect } from 'react-redux';
import { Panel } from 'react-bootstrap';
import { Panel, Alert } from 'react-bootstrap';
import { visTypes, commonControlPanelSections } from '../stores/store';
import ControlPanelSection from './ControlPanelSection';
import FieldSetRow from './FieldSetRow';
@@ -15,6 +15,7 @@ const propTypes = {
isDatasourceMetaLoading: PropTypes.bool.isRequired,
form_data: PropTypes.object.isRequired,
y_axis_zero: PropTypes.any,
alert: PropTypes.string,
};
class ControlPanelsContainer extends React.Component {
@@ -53,10 +54,23 @@ class ControlPanelsContainer extends React.Component {
const viz = visTypes[this.props.form_data.viz_type];
return viz.fieldOverrides;
}
removeAlert() {
this.props.actions.removeControlPanelAlert();
}
render() {
return (
<Panel>
{this.props.alert &&
<Alert bsStyle="warning">
{this.props.alert}
<i
className="fa fa-close pull-right"
onClick={this.removeAlert.bind(this)}
style={{ cursor: 'pointer' }}
/>
</Alert>
}
{!this.props.isDatasourceMetaLoading &&
<div className="scrollbar-container">
<div className="scrollbar-content">
@@ -91,6 +105,7 @@ ControlPanelsContainer.propTypes = propTypes;
function mapStateToProps(state) {
return {
alert: state.controlPanelAlert,
isDatasourceMetaLoading: state.isDatasourceMetaLoading,
fields: state.fields,
datasource_type: state.datasource_type,