mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 16:48:02 +08:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Actions } from 'nylas-exports';
|
|
import { KeyCommandsRegion, UndoToast, ListensToFluxStore } from 'nylas-component-kit';
|
|
import UndoSendStore from './undo-send-store';
|
|
|
|
class UndoSendToast extends React.Component {
|
|
static displayName = 'UndoSendToast';
|
|
|
|
static propTypes = {
|
|
visible: PropTypes.bool,
|
|
sendActionTaskId: PropTypes.string,
|
|
};
|
|
|
|
_onUndo = () => {
|
|
Actions.cancelTask(this.props.sendActionTaskId);
|
|
};
|
|
|
|
render() {
|
|
const { visible } = this.props;
|
|
return (
|
|
<KeyCommandsRegion
|
|
globalHandlers={{
|
|
'core:undo': event => {
|
|
if (!visible) {
|
|
return;
|
|
}
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this._onUndo();
|
|
},
|
|
}}
|
|
>
|
|
<UndoToast
|
|
{...this.props}
|
|
className="undo-send-toast"
|
|
undoMessage="Sending draft"
|
|
visibleDuration={null}
|
|
onUndo={this._onUndo}
|
|
/>
|
|
</KeyCommandsRegion>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default ListensToFluxStore(UndoSendToast, {
|
|
stores: [UndoSendStore],
|
|
getStateFromStores() {
|
|
return {
|
|
visible: UndoSendStore.shouldShowUndoSend(),
|
|
sendActionTaskId: UndoSendStore.sendActionTaskId(),
|
|
};
|
|
},
|
|
});
|