import angular from 'angular'; import React from 'react'; import ReactDOM from 'react-dom'; import ModalContext from 'liveblog-common/components/modal/context'; import withModalContext from 'liveblog-common/components/modal/withContext'; import Modal from 'liveblog-common/components/modal/modal'; interface IInactivityModalProps { onKeepWorking: () => void; onSaveAndClose: () => void; onClose: () => void; } class InactivityModal extends React.Component { favicon: JQuery; initialIcon: string; constructor(props) { super(props); this.favicon = $('link[rel="icon"]'); this.initialIcon = this.favicon.attr('href'); } handleKeepWorking(closeModal: () => void) { this.props.onKeepWorking(); closeModal(); } handleSaveAndClose(closeModal: () => void) { this.props.onSaveAndClose(); closeModal(); } handleClose(closeModal: () => void) { this.props.onClose(); closeModal(); } modalActions() { return ( {({ closeModal }) => ( )} ); } iconTabAlert() { this.favicon.attr('href', 'favicon-alert.ico'); } resetBrowserTab() { this.favicon.attr('href', this.initialIcon); } render() { const bodyText = ` The current post has been inactive in the editor for some time so the warning message of being edited by you has been removed. Please be careful about saving the post as the work from other users in this post could get overwritten.`; const footerBtns = this.modalActions(); return ( ); } } export default angular.module('liveblog.edit.components.inactivityModal', []) .factory('InactivityModal', () => { class InactiveModal { constructor(props: IInactivityModalProps) { const targetEl = document.createElement('div'); document.body.appendChild(targetEl); const InactivityAlert = withModalContext(InactivityModal); // eslint-disable-next-line return ReactDOM.render(, targetEl); } } return InactiveModal; });