Skip to content

Commit

Permalink
[explore-v2] fix errors on table view (#1675)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Alanna Scott authored Nov 29, 2016

Verified

This commit was signed with the committer’s verified signature.
mikz Michal Cichra
1 parent 18c43aa commit 56b917a
Showing 3 changed files with 37 additions and 23 deletions.
54 changes: 34 additions & 20 deletions superset/assets/javascripts/explorev2/components/ChartContainer.jsx
Original file line number Diff line number Diff line change
@@ -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}

<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}`}
{this.renderChartTitle()}

{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"
>
<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,
};
}

4 changes: 2 additions & 2 deletions superset/templates/superset/explorev2.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "superset/basic.html" %}

{% block title %}
{% if slice_name %}
[slice] {{ slice_name }}
{% if slc %}
[slice] {{ slc.slice_name }}
{% else %}
[explore] {{ table_name }}
{% endif %}
2 changes: 1 addition & 1 deletion superset/views.py
Original file line number Diff line number Diff line change
@@ -1454,7 +1454,7 @@ def explore(self, datasource_type, datasource_id):
return self.render_template(
"superset/explorev2.html",
bootstrap_data=json.dumps(bootstrap_data),
slice_name=slc.slice_name,
slice=slc,
table_name=viz_obj.datasource.table_name)
else:
return self.render_template(

0 comments on commit 56b917a

Please sign in to comment.