@adaptabletools/adaptable-cjs
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
80 lines (79 loc) • 4.82 kB
JavaScript
"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 rebass_1 = require("rebass");
const ButtonShare_1 = require("./ButtonShare");
const SuspendToggleButton_1 = require("./SuspendToggleButton/SuspendToggleButton");
const stopPropagation = (e) => {
e.stopPropagation();
};
class EntityListActionButtons extends React.Component {
render() {
return (React.createElement(rebass_1.Flex, { justifyContent: this.props.justifyContent || 'center', margin: 0, padding: 0, onClick: stopPropagation },
this.props.showEdit && (React.createElement(ButtonEdit_1.ButtonEdit, { onClick: () => (this.props.editClick ? this.props.editClick() : null), style: {
marginLeft: '0px',
marginTop: '2px',
marginBottom: '2px',
marginRight: '2px',
color: 'var(--ab-color-text-on-edit)',
fill: 'var(--ab-color-text-on-edit)',
background: 'var(--ab-color-action-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), style: {
marginLeft: '0px',
marginTop: '2px',
marginBottom: '2px',
marginRight: '2px',
color: 'var(--ab-color-text-on-clone)',
fill: 'var(--ab-color-text-on-clone)',
background: 'var(--ab-color-action-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", style: {
marginLeft: '1px',
marginTop: '2px',
marginBottom: '2px',
marginRight: '1px',
//TODO move those styles in ButtonDelete
color: 'var(--ab-color-text-on-delete)',
fill: 'var(--ab-color-text-on-delete)',
background: 'var(--ab-color-action-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, { style: {
marginLeft: '1px',
marginTop: '2px',
marginBottom: '2px',
marginRight: '1px',
color: 'var(--ab-color-text-on-share)',
fill: 'var(--ab-color-text-on-share)',
background: 'var(--ab-color-action-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, { style: {
marginLeft: 2,
alignSelf: 'center',
}, onSuspend: this.props.onSuspend, onUnSuspend: this.props.onUnSuspend, suspendableObject: this.props.suspendableObject, disabled: this.props.accessLevel == 'ReadOnly' }))));
}
}
exports.EntityListActionButtons = EntityListActionButtons;
EntityListActionButtons.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',
};