Skip to content

Commit

Permalink
[Visualization] Add default filename when exporting if no filename pr…
Browse files Browse the repository at this point in the history
…ovided (#54003) (#54062)
  • Loading branch information
Maja Grubic authored Jan 7, 2020
1 parent 1b2b6ce commit c368391
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

import { EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
import { DataViewColumn, DataViewRow } from '../types';
Expand Down Expand Up @@ -66,8 +67,14 @@ class DataDownloadOptions extends Component<DataDownloadOptionsProps, DataDownlo
};

exportCsv = (customParams: any = {}) => {
let filename = this.props.title;
if (!filename || filename.length === 0) {
filename = i18n.translate('inspector.data.downloadOptionsUnsavedFilename', {
defaultMessage: 'unsaved',
});
}
exportAsCsv({
filename: `${this.props.title}.csv`,
filename: `${filename}.csv`,
columns: this.props.columns,
rows: this.props.rows,
csvSeparator: this.props.csvSeparator,
Expand Down

0 comments on commit c368391

Please sign in to comment.