graceguo-supercat closed pull request #4326: [explore] fix missing CacheLabel URL: https://github.com/apache/incubator-superset/pull/4326
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx b/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx index 30b47994eb..0faf164df4 100644 --- a/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx +++ b/superset/assets/javascripts/explore/components/ExploreChartHeader.jsx @@ -74,7 +74,7 @@ class ExploreChartHeader extends React.PureComponent { json_endpoint: getExploreUrl(formData, 'json'), standalone_endpoint: getExploreUrl(formData, 'standalone'), }; - + const chartSucceeded = ['success', 'rendered'].indexOf(this.props.chart.chartStatus) > 0; return ( <div id="slice-header" @@ -115,21 +115,16 @@ class ExploreChartHeader extends React.PureComponent { /> } <div className="pull-right"> - {this.props.chart.chartStatus === 'success' && queryResponse && + {chartSucceeded && queryResponse && <RowCountLabel rowcount={queryResponse.rowcount} limit={formData.row_limit} - /> - } - {this.props.chart.chartStatus === 'success' && - queryResponse && - queryResponse.is_cached && - - <CachedLabel - onClick={this.runQuery.bind(this)} - cachedTimestamp={queryResponse.cached_dttm} - /> - } + />} + {chartSucceeded && queryResponse && queryResponse.is_cached && + <CachedLabel + onClick={this.runQuery.bind(this)} + cachedTimestamp={queryResponse.cached_dttm} + />} <Timer startTime={this.props.chart.chartUpdateStartTime} endTime={this.props.chart.chartUpdateEndTime} diff --git a/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx b/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx new file mode 100644 index 0000000000..2875e8398e --- /dev/null +++ b/superset/assets/spec/javascripts/explore/components/ExploreChartHeader_spec.jsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { expect } from 'chai'; +import { describe, it } from 'mocha'; +import { shallow } from 'enzyme'; + +import ExploreChartHeader from '../../../../javascripts/explore/components/ExploreChartHeader'; +import ExploreActionButtons from '../../../../javascripts/explore/components/ExploreActionButtons'; +import EditableTitle from '../../../../javascripts/components/EditableTitle'; + +const mockProps = { + actions: {}, + can_overwrite: true, + can_download: true, + isStarred: true, + slice: {}, + table_name: 'foo', + form_data: {}, + timeout: 1000, + chart: { + queryResponse: {}, + }, +}; + +describe('ExploreChartHeader', () => { + let wrapper; + beforeEach(() => { + wrapper = shallow(<ExploreChartHeader {...mockProps} />); + }); + + it('is valid', () => { + expect( + React.isValidElement(<ExploreChartHeader {...mockProps} />), + ).to.equal(true); + }); + + it('renders', () => { + expect(wrapper.find(EditableTitle)).to.have.lengthOf(1); + expect(wrapper.find(ExploreActionButtons)).to.have.lengthOf(1); + }); +}); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services