feat: add download as image button to explore (#10297)

This commit is contained in:
Erik Ritter
2020-07-14 16:40:12 -07:00
committed by GitHub
parent 518dbd05b6
commit 6ae9f3af8e
8 changed files with 32 additions and 7 deletions

View File

@@ -41,7 +41,7 @@ import { t } from '@superset-ui/translation';
import getClientErrorObject from '../../utils/getClientErrorObject';
import CopyToClipboard from './../../components/CopyToClipboard';
import { getChartDataRequest } from '../../chart/chartAction';
import downloadAsImage from '../../utils/downloadAsImage';
import Loading from '../../components/Loading';
import ModalTrigger from './../../components/ModalTrigger';
import Button from '../../components/Button';
@@ -63,6 +63,7 @@ const propTypes = {
animation: PropTypes.bool,
queryResponse: PropTypes.object,
chartStatus: PropTypes.string,
chartHeight: PropTypes.string.isRequired,
latestQueryFormData: PropTypes.object.isRequired,
slice: PropTypes.object,
};
@@ -219,7 +220,7 @@ export class DisplayQueryButton extends React.PureComponent {
return null;
}
render() {
const { animation, slice } = this.props;
const { animation, chartHeight, slice } = this.props;
return (
<DropdownButton
noCaret
@@ -279,6 +280,18 @@ export class DisplayQueryButton extends React.PureComponent {
{t('Run in SQL Lab')}
</MenuItem>
)}
<MenuItem
onClick={downloadAsImage(
'.chart-container',
// eslint-disable-next-line camelcase
slice?.slice_name ?? t('New chart'),
{
height: parseInt(chartHeight, 10),
},
)}
>
{t('Download as image')}
</MenuItem>
</DropdownButton>
);
}