@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
45 lines (44 loc) • 2.89 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { connect } from 'react-redux';
import * as InternalRedux from '../../Redux/ActionsReducers/InternalRedux';
import SimpleButton from '../../components/SimpleButton';
import { AdaptableObjectCollection } from '../Components/AdaptableObjectCollection';
import AdaptableHelper from '../../Utilities/Helpers/AdaptableHelper';
import { SystemStatusEntityRow } from './SystemStatusEntityRow';
import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
import { PopupPanel } from '../Components/Popups/AdaptablePopup/PopupPanel';
import { SortOrder } from '../../AdaptableState/Common/Enums';
import { Box } from '../../components/Flex';
const colItems = [
{ Content: 'Message', Size: 10 },
{ Content: 'Timestamp', Size: 3 },
];
class SystemStatusPopupComponent extends React.Component {
constructor(props) {
super(props);
}
onSystemStatusMessageInfoDeleteAll() {
this.props.onSystemStatusMessageInfoDeleteAll();
}
render() {
let clearAllButton = (_jsx(SimpleButton, { onClick: () => this.onSystemStatusMessageInfoDeleteAll(), tooltip: "Clear All", tone: "neutral", variant: "raised", accessLevel: this.props.accessLevel, disabled: ArrayExtensions.IsNullOrEmpty(this.props.SystemStatusMessages), children: "Delete All Messages" }));
const messages = ArrayExtensions.sortArrayWithProperty(SortOrder.Desc, this.props.SystemStatusMessages, 'Timestamp').map((smi, index) => {
const accessLevel = AdaptableHelper.getAccessLevelForObject(smi, this.props.accessLevel);
return (_jsx(SystemStatusEntityRow, { adaptableObject: smi, onEdit: null, moduleInfo: this.props.moduleInfo, colItems: colItems, api: this.props.api, accessLevel: accessLevel, teamSharingActivated: this.props.teamSharingActivated, onDeleteConfirm: null, onShare: null }, 'smi' + index));
});
return (_jsx(PopupPanel, { button: clearAllButton, headerText: this.props.moduleInfo.FriendlyName, infoLink: this.props.moduleInfo.HelpPage, infoLinkDisabled: !this.props.api.internalApi.isDocumentationLinksDisplayed(), children: ArrayExtensions.IsNotNullOrEmpty(this.props.SystemStatusMessages) && (_jsx(Box, { className: "ab-SystemStatus-Popup-List twa:p-2", children: _jsx(AdaptableObjectCollection, { colItems: colItems, items: messages }) })) }));
}
}
function mapStateToProps(state, ownProps) {
return {
SystemStatusMessageInfos: state.Internal.SystemStatusMessages,
SystemStatusMessages: state.Internal.SystemStatusMessages,
};
}
function mapDispatchToProps(dispatch) {
return {
onSystemStatusMessageInfoDeleteAll: () => dispatch(InternalRedux.SystemStatusMessageInfoDeleteAll()),
};
}
export let SystemStatusPopup = connect(mapStateToProps, mapDispatchToProps)(SystemStatusPopupComponent);