[explore-v2] fix errors on table view (#1675)

* render table name if in table view

* only render fave star and edit button if slice, not table

* fix error when table view

* use [table-name] - untitled format

* remove extra fave star
This commit is contained in:
Alanna Scott
2016-11-28 21:04:43 -08:00
committed by GitHub
parent 18c43aaea2
commit 56b917a5c2
3 changed files with 35 additions and 21 deletions

View File

@@ -25,6 +25,7 @@ const propTypes = {
isChartLoading: PropTypes.bool,
isStarred: PropTypes.bool.isRequired,
alert: PropTypes.string,
table_name: PropTypes.string,
};
class ChartContainer extends React.Component {
@@ -133,6 +134,16 @@ class ChartContainer extends React.Component {
visMap[this.props.viz_type](this.state.mockSlice).render();
}
renderChartTitle() {
let title;
if (this.props.slice_name) {
title = this.props.slice_name;
} else {
title = `[${this.props.table_name}] - untitled`;
}
return title;
}
render() {
return (
<div className="chart-container">
@@ -143,27 +154,29 @@ class ChartContainer extends React.Component {
id="slice-header"
className="clearfix panel-title-large"
>
<div className="pull-left">
{this.props.slice_name}
{this.renderChartTitle()}
<FaveStar
sliceId={this.props.slice_id}
actions={this.props.actions}
isStarred={this.props.isStarred}
/>
{this.props.slice_id &&
<span>
<FaveStar
sliceId={this.props.slice_id}
actions={this.props.actions}
isStarred={this.props.isStarred}
/>
<TooltipWrapper
label="edit-desc"
tooltip="Edit Description"
>
<a
className="edit-desc-icon"
href={`/slicemodelview/edit/${this.props.slice_id}`}
<TooltipWrapper
label="edit-desc"
tooltip="Edit Description"
>
<i className="fa fa-edit" />
</a>
</TooltipWrapper>
</div>
<a
className="edit-desc-icon"
href={`/slicemodelview/edit/${this.props.slice_id}`}
>
<i className="fa fa-edit" />
</a>
</TooltipWrapper>
</span>
}
<div className="pull-right">
<ExploreActionButtons
@@ -217,6 +230,7 @@ function mapStateToProps(state) {
isChartLoading: state.isChartLoading,
isStarred: state.isStarred,
alert: state.chartAlert,
table_name: state.viz.form_data.datasource_name,
};
}