@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
23 lines (22 loc) • 1.47 kB
JavaScript
import React from 'react';
import DropdownButton from '../../components/DropdownButton';
import { Icon } from '../../components/icons';
import { useAdaptable } from '../AdaptableContext';
import { ButtonExport } from '../Components/Buttons/ButtonExport';
export const ExportDestinationPicker = ({ reportName, reportFormat, viewType, }) => {
const adaptable = useAdaptable();
const exportApi = adaptable.api.exportApi;
const handleExport = (destination) => {
exportApi.exportReport(reportName, reportFormat, destination);
};
const supportedDestinations = exportApi.getSupportedExportDestinations(reportFormat);
if (supportedDestinations.length === 0 || supportedDestinations.length === 1) {
return (React.createElement(ButtonExport, { marginRight: viewType !== 'StatusBar' ? 20 : undefined, paddingRight: 0, onClick: () => handleExport(supportedDestinations[0]), tooltip: "Export Report", disabled: reportName == undefined || reportFormat == undefined }));
}
const destinationItems = supportedDestinations.map((destination) => ({
label: destination,
onClick: () => handleExport(destination),
}));
return (React.createElement(DropdownButton, { "data-name": "report-export-selector", disabled: reportName == undefined || reportFormat == undefined, columns: ['label'], tooltip: "Export Report", variant: "text", items: destinationItems },
React.createElement(Icon, { name: "export" })));
};