Dashboard refactory (#3581)

Create Chart component for all chart fetching and rendering, and apply redux architecture in dashboard view.
This commit is contained in:
Grace Guo
2017-11-08 10:46:21 -08:00
committed by GitHub
parent 39e502faae
commit 4fa1f0ab17
47 changed files with 2048 additions and 876 deletions

View File

@@ -3,22 +3,32 @@ import PropTypes from 'prop-types';
import Controls from './Controls';
import EditableTitle from '../../components/EditableTitle';
import FaveStar from '../../components/FaveStar';
const propTypes = {
dashboard: PropTypes.object,
};
const defaultProps = {
dashboard: PropTypes.object.isRequired,
userId: PropTypes.string.isRequired,
isStarred: PropTypes.bool,
addSlicesToDashboard: PropTypes.func,
onSave: PropTypes.func,
onChange: PropTypes.func,
fetchFaveStar: PropTypes.func,
readFilters: PropTypes.func,
renderSlices: PropTypes.func,
saveFaveStar: PropTypes.func,
serialize: PropTypes.func,
startPeriodicRender: PropTypes.func,
updateDashboardTitle: PropTypes.func,
};
class Header extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
};
this.handleSaveTitle = this.handleSaveTitle.bind(this);
}
handleSaveTitle(title) {
this.props.dashboard.updateDashboardTitle(title);
this.props.updateDashboardTitle(title);
}
render() {
const dashboard = this.props.dashboard;
@@ -32,12 +42,29 @@ class Header extends React.PureComponent {
onSaveTitle={this.handleSaveTitle}
noPermitTooltip={'You don\'t have the rights to alter this dashboard.'}
/>
<span is class="favstar" class_name="Dashboard" obj_id={dashboard.id} />
<span className="favstar">
<FaveStar
itemId={dashboard.id}
fetchFaveStar={this.props.fetchFaveStar}
saveFaveStar={this.props.saveFaveStar}
isStarred={this.props.isStarred}
/>
</span>
</h1>
</div>
<div className="pull-right" style={{ marginTop: '35px' }}>
{!this.props.dashboard.standalone_mode &&
<Controls dashboard={dashboard} />
<Controls
dashboard={dashboard}
userId={this.props.userId}
addSlicesToDashboard={this.props.addSlicesToDashboard}
onSave={this.props.onSave}
onChange={this.props.onChange}
readFilters={this.props.readFilters}
renderSlices={this.props.renderSlices}
serialize={this.props.serialize}
startPeriodicRender={this.props.startPeriodicRender}
/>
}
</div>
<div className="clearfix" />
@@ -46,6 +73,5 @@ class Header extends React.PureComponent {
}
}
Header.propTypes = propTypes;
Header.defaultProps = defaultProps;
export default Header;