UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

51 lines (50 loc) 4.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EntityListActionButtons = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const ButtonEdit_1 = require("./ButtonEdit"); const ButtonClone_1 = require("./ButtonClone"); const ButtonDelete_1 = require("./ButtonDelete"); const ButtonShare_1 = require("./ButtonShare"); const SuspendToggleButton_1 = require("./SuspendToggleButton/SuspendToggleButton"); const Flex_1 = require("../../../components/Flex"); const clsx_1 = tslib_1.__importDefault(require("clsx")); const stopPropagation = (e) => { e.stopPropagation(); }; class EntityListActionButtons extends React.Component { static defaultProps = { // Adaptable: null, suspendableObject: null, showEdit: true, showDelete: true, showShare: false, showSuspend: false, overrideDisableEdit: false, overrideDisableDelete: false, overrideDisableClone: false, overrideDisableShare: false, confirmDeleteAction: null, entityType: '', accessLevel: 'Full', editSize: 'xsmall', deleteSize: 'xsmall', shareSize: 'xsmall', }; render() { const { justifyContent } = this.props; const justifyContentClassName = (0, clsx_1.default)({ 'twa:justify-start': justifyContent === 'start', 'twa:justify-center': justifyContent === 'center', 'twa:justify-end': justifyContent === 'end', }) || 'twa:justify-center'; return (React.createElement(Flex_1.Flex, { className: `${justifyContentClassName} twa:m-0 twa:p-0`, onClick: stopPropagation }, this.props.showEdit && (React.createElement(ButtonEdit_1.ButtonEdit, { onClick: () => (this.props.editClick ? this.props.editClick() : null), className: `twa:ml-0 twa:mr-[2px] twa:my-[2px] twa:text-text-on-edit twa:bg-action-edit twa:fill-text-on-edit`, disabled: this.props.overrideDisableEdit || this.props.accessLevel == 'ReadOnly', tooltip: this.props.overrideTooltipEdit, accessLevel: this.props.accessLevel })), this.props.showClone && (React.createElement(ButtonClone_1.ButtonClone, { onClick: () => (this.props.cloneClick ? this.props.cloneClick() : null), className: `twa:ml-0 twa:mr-[2px] twa:my-[2px] twa:text-text-on-clone twa:bg-action-clone twa:fill-text-on-clone`, children: null, disabled: this.props.overrideDisableClone || this.props.cloneAccessLevel == 'ReadOnly', tooltip: this.props.overrideTooltipClone, accessLevel: this.props.cloneAccessLevel })), this.props.showDelete && (React.createElement(ButtonDelete_1.ButtonDelete, { "data-name": "delete", className: `twa:mx-[px] twa:my-[2px] twa:text-text-on-delete twa:bg-action-delete twa:fill-text-on-delete`, disabled: this.props.overrideDisableDelete || this.props.accessLevel == 'ReadOnly', tooltip: this.props.overrideTooltipDelete, ConfirmAction: this.props.confirmDeleteAction, ConfirmationMsg: 'Are you sure you want to delete this ' + this.props.entityType + '?', ConfirmationTitle: 'Delete ' + this.props.entityType, accessLevel: this.props.accessLevel })), this.props.showShare && (React.createElement(ButtonShare_1.ButtonShare, { className: `twa:mx-[1px] twa:my-[2px] twa:text-text-on-share twa:bg-action-share twa:fill-text-on-share`, onShare: (config) => this.props.shareClick ? this.props.shareClick(config) : null, Header: `TeamSharing ${this.props.entityType}`, disabled: this.props.overrideDisableShare || this.props.accessLevel == 'ReadOnly', tooltip: this.props.overrideTooltipShare, accessLevel: this.props.accessLevel })), this.props.showSuspend && this.props.suspendableObject && (React.createElement(SuspendToggleButton_1.SuspendToggleButton, { className: `twa:ml-[2px] twa:align-self-center`, onSuspend: this.props.onSuspend, onUnSuspend: this.props.onUnSuspend, suspendableObject: this.props.suspendableObject, disabled: this.props.accessLevel == 'ReadOnly' })))); } } exports.EntityListActionButtons = EntityListActionButtons;