@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
58 lines (57 loc) • 5.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportViewPanel = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_redux_1 = require("react-redux");
const rebass_1 = require("rebass");
const join_1 = tslib_1.__importDefault(require("../../components/utils/join"));
const ExportRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/ExportRedux"));
const PopupRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/PopupRedux"));
const GeneralConstants = tslib_1.__importStar(require("../../Utilities/Constants/GeneralConstants"));
const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper"));
const ObjectFactory_1 = tslib_1.__importDefault(require("../../Utilities/ObjectFactory"));
const ButtonDelete_1 = require("../Components/Buttons/ButtonDelete");
const ButtonEdit_1 = require("../Components/Buttons/ButtonEdit");
const ButtonNew_1 = require("../Components/Buttons/ButtonNew");
const ButtonSchedule_1 = require("../Components/Buttons/ButtonSchedule");
const ReportNameSelector_1 = require("./ReportNameSelector");
const ReportFormatSelector_1 = require("./ReportFormatSelector");
const ExportDestinationPicker_1 = require("./ExportDestinationPicker");
const ExportViewPanel = (props) => {
const dispatch = (0, react_redux_1.useDispatch)();
const exportApi = props.api.exportApi;
const userReports = (0, react_redux_1.useSelector)((state) => state.Export.Reports);
const currentReportName = (0, react_redux_1.useSelector)((state) => state.Export.CurrentReport);
const currentFormat = (0, react_redux_1.useSelector)((state) => state.Export.CurrentFormat);
const currentReport = exportApi.getReportByName(currentReportName);
const accessLevel = AdaptableHelper_1.default.getAccessLevelForObject(currentReport, props.accessLevel);
const deleteMessage = currentReport
? `Are you sure you want to delete '${currentReport.Name}'?`
: 'Are you sure you want to delete this report?';
const elementType = props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
return (React.createElement(rebass_1.Flex, { style: { gap: 5 }, flexDirection: "row", className: `ab-${elementType}__Export__panel`, flexWrap: props.viewType === 'ToolPanel' ? 'wrap' : 'nowrap' },
React.createElement(ReportNameSelector_1.ReportNameSelector, { viewType: props.viewType, reportName: currentReportName, userReports: userReports, onReportNameSelected: (reportName) => exportApi.selectReport(reportName) }),
React.createElement(ReportFormatSelector_1.ReportFormatSelector, { viewType: props.viewType, reportName: currentReportName, reportFormat: currentFormat, onReportFormatSelected: (reportFormat) => exportApi.selectFormat(reportFormat) }),
React.createElement(rebass_1.Flex, { className: (0, join_1.default)(accessLevel == 'ReadOnly' ? GeneralConstants.READ_ONLY_STYLE : '', `ab-${elementType}__Export__controls`), style: { width: '100%' } },
React.createElement(ExportDestinationPicker_1.ExportDestinationPicker, { viewType: props.viewType, reportName: currentReportName, reportFormat: currentFormat }),
React.createElement(ButtonEdit_1.ButtonEdit, { onClick: () => dispatch(PopupRedux.PopupShowScreen(ModuleConstants.ExportModuleId, props.moduleInfo.Popup, {
action: 'Edit',
source: 'Toolbar',
})), tooltip: "Edit Report", className: `ab-${elementType}__Export__edit`, disabled: currentReport == null, accessLevel: accessLevel }),
React.createElement(ButtonNew_1.ButtonNew, { variant: "text", className: `ab-${elementType}__Export__new`, tone: "neutral", children: null, onClick: () => dispatch(PopupRedux.PopupShowScreen(ModuleConstants.ExportModuleId, props.moduleInfo.Popup, {
action: 'New',
source: 'Toolbar',
})), tooltip: "Create New Report", accessLevel: props.accessLevel }),
React.createElement(ButtonDelete_1.ButtonDelete, { tooltip: "Delete Report", className: `ab-${elementType}__Export__delete`, disabled: currentReport == null, ConfirmAction: ExportRedux.ReportDelete(currentReport), ConfirmationMsg: deleteMessage, ConfirmationTitle: 'Delete Report', accessLevel: accessLevel }),
props.api.entitlementApi.isModuleFullEntitlement('Schedule') && (React.createElement(ButtonSchedule_1.ButtonSchedule, { marginLeft: 1, className: `ab-${elementType}__Export__schedule`, onClick: () => {
const reportSchedule = ObjectFactory_1.default.CreateReportSchedule(currentReportName, currentFormat);
dispatch(PopupRedux.PopupShowScreen(ModuleConstants.ScheduleModuleId, 'SchedulePopup', {
action: 'New',
source: 'Toolbar',
value: reportSchedule,
}));
}, tooltip: "Schedule", disabled: currentReport == null, accessLevel: props.accessLevel })))));
};
exports.ExportViewPanel = ExportViewPanel;