@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
75 lines (74 loc) • 4.48 kB
JavaScript
import * as React from 'react';
import { ButtonEdit } from './ButtonEdit';
import { ButtonClone } from './ButtonClone';
import { ButtonDelete } from './ButtonDelete';
import { Flex } from 'rebass';
import { ButtonShare } from './ButtonShare';
import { SuspendToggleButton } from './SuspendToggleButton/SuspendToggleButton';
const stopPropagation = (e) => {
e.stopPropagation();
};
export class EntityListActionButtons extends React.Component {
render() {
return (React.createElement(Flex, { justifyContent: this.props.justifyContent || 'center', margin: 0, padding: 0, onClick: stopPropagation },
this.props.showEdit && (React.createElement(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, { 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, { "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, { 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, { style: {
marginLeft: 2,
alignSelf: 'center',
}, onSuspend: this.props.onSuspend, onUnSuspend: this.props.onUnSuspend, suspendableObject: this.props.suspendableObject, disabled: this.props.accessLevel == 'ReadOnly' }))));
}
}
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',
};