Skip to content

Commit

Permalink
[explore] allow URL shortner even if no slice exist (apache#4457)
Browse files Browse the repository at this point in the history
recent regression perhaps from the PR that moved to using POST .
  • Loading branch information
mistercrunch authored and michellethomas committed May 23, 2018
1 parent f782ef5 commit 2b83054
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ import { exportChart } from '../exploreUtils';

const propTypes = {
canDownload: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired,
slice: PropTypes.object,
chartStatus: PropTypes.string,
latestQueryFormData: PropTypes.object,
queryResponse: PropTypes.object,
};

export default function ExploreActionButtons({
canDownload, slice, chartStatus, latestQueryFormData, queryResponse }) {
canDownload, chartStatus, latestQueryFormData, queryResponse }) {
const exportToCSVClasses = cx('btn btn-default btn-sm', {
'disabled disabledButton': !canDownload,
});
const doExportCSV = exportChart.bind(this, latestQueryFormData, 'csv');
const doExportChart = exportChart.bind(this, latestQueryFormData, 'json');

if (slice) {
return (
<div className="btn-group results" role="group">
<URLShortLinkButton latestQueryFormData={latestQueryFormData} />
return (
<div className="btn-group results" role="group">
{latestQueryFormData &&
<URLShortLinkButton latestQueryFormData={latestQueryFormData} />}

<EmbedCodeButton latestQueryFormData={latestQueryFormData} />
{latestQueryFormData &&
<EmbedCodeButton latestQueryFormData={latestQueryFormData} />}

{latestQueryFormData &&
<a
onClick={doExportChart}
className="btn btn-default btn-sm"
Expand All @@ -38,8 +39,8 @@ export default function ExploreActionButtons({
rel="noopener noreferrer"
>
<i className="fa fa-file-code-o" /> .json
</a>

</a>}
{latestQueryFormData &&
<a
onClick={doExportCSV}
className={exportToCSVClasses}
Expand All @@ -48,18 +49,13 @@ export default function ExploreActionButtons({
rel="noopener noreferrer"
>
<i className="fa fa-file-text-o" /> .csv
</a>

<DisplayQueryButton
queryResponse={queryResponse}
latestQueryFormData={latestQueryFormData}
chartStatus={chartStatus}
/>
</div>
);
}
return (
<DisplayQueryButton latestQueryFormData={latestQueryFormData} />
</a>}
<DisplayQueryButton
queryResponse={queryResponse}
latestQueryFormData={latestQueryFormData}
chartStatus={chartStatus}
/>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import ExploreActionButtons from
describe('ExploreActionButtons', () => {
const defaultProps = {
canDownload: 'True',
slice: {
data: {
csv_endpoint: '',
json_endpoint: '',
},
},
latestQueryFormData: {},
queryEndpoint: 'localhost',
};

Expand Down

0 comments on commit 2b83054

Please sign in to comment.