"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModuleToolbarWrapper = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const PanelDashboard_1 = require("../Components/Panels/PanelDashboard");
const PopupRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/PopupRedux"));
const DashboardRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/DashboardRedux"));
const AdaptableContext_1 = require("../AdaptableContext");
const ModuleToolbarWrapper = (props) => {
    const moduleName = props.moduleInfo.ModuleName;
    const moduleFriendlyName = props.moduleInfo.FriendlyName;
    const { api } = (0, AdaptableContext_1.useAdaptable)();
    const isConfigurable = moduleName !== 'OpenFin' && moduleName !== 'IPushPull';
    return (React.createElement(PanelDashboard_1.PanelDashboard, { className: `ab-DashboardToolbar__${moduleName}`, "data-name": `ab-DashboardToolbar__${moduleName}`, headerText: moduleFriendlyName, showConfigureActionButton: isConfigurable, onConfigure: () => {
            const maxWidth = api.internalApi.getModuleService().getPopupMaxWidth(moduleName);
            const popupParams = maxWidth
                ? { maxWidth, source: 'Toolbar' }
                : { source: 'Toolbar' };
            api.internalApi.dispatchReduxAction(PopupRedux.PopupShowScreen(moduleName, props.moduleInfo.Popup, popupParams));
        }, onClose: () => api.internalApi.dispatchReduxAction(DashboardRedux.DashboardCloseToolbar(moduleName)), accessLevel: props.accessLevel }, props.children));
};
exports.ModuleToolbarWrapper = ModuleToolbarWrapper;
