"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemStatusPopup = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_redux_1 = require("react-redux");
const InternalRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/InternalRedux"));
const SimpleButton_1 = tslib_1.__importDefault(require("../../components/SimpleButton"));
const AdaptableObjectCollection_1 = require("../Components/AdaptableObjectCollection");
const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper"));
const SystemStatusEntityRow_1 = require("./SystemStatusEntityRow");
const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
const PopupPanel_1 = require("../Components/Popups/AdaptablePopup/PopupPanel");
const Enums_1 = require("../../AdaptableState/Common/Enums");
const Flex_1 = require("../../components/Flex");
const colItems = [
    { Content: 'Message', Size: 10 },
    { Content: 'Timestamp', Size: 3 },
];
class SystemStatusPopupComponent extends React.Component {
    constructor(props) {
        super(props);
        // this.state = { EditedSystemStatusText: '', EditedStyle: null };
    }
    onSystemStatusMessageInfoDeleteAll() {
        this.props.onSystemStatusMessageInfoDeleteAll();
    }
    render() {
        let clearAllButton = (React.createElement(SimpleButton_1.default, { onClick: () => this.onSystemStatusMessageInfoDeleteAll(), tooltip: "Clear All", tone: "neutral", variant: "raised", accessLevel: this.props.accessLevel, disabled: ArrayExtensions_1.default.IsNullOrEmpty(this.props.SystemStatusMessages) }, "Delete All Messages"));
        const messages = ArrayExtensions_1.default.sortArrayWithProperty(Enums_1.SortOrder.Desc, this.props.SystemStatusMessages, 'Timestamp').map((smi, index) => {
            const accessLevel = AdaptableHelper_1.default.getAccessLevelForObject(smi, this.props.accessLevel);
            return (React.createElement(SystemStatusEntityRow_1.SystemStatusEntityRow, { adaptableObject: smi, key: 'smi' + index, onEdit: null, moduleInfo: this.props.moduleInfo, colItems: colItems, api: this.props.api, accessLevel: accessLevel, teamSharingActivated: this.props.teamSharingActivated, onDeleteConfirm: null, onShare: null }));
        });
        return (React.createElement(PopupPanel_1.PopupPanel, { button: clearAllButton, headerText: this.props.moduleInfo.FriendlyName, infoLink: this.props.moduleInfo.HelpPage, infoLinkDisabled: !this.props.api.internalApi.isDocumentationLinksDisplayed() }, ArrayExtensions_1.default.IsNotNullOrEmpty(this.props.SystemStatusMessages) && (React.createElement(Flex_1.Box, { className: "ab-SystemStatus-Popup-List twa:p-2" },
            React.createElement(AdaptableObjectCollection_1.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()),
    };
}
exports.SystemStatusPopup = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(SystemStatusPopupComponent);
