Mailspring/app/internal_packages/message-list/lib/thread-archive-button.jsx

51 lines
1.2 KiB
React
Raw Normal View History

2017-09-27 02:33:08 +08:00
import { RetinaImg } from 'nylas-component-kit';
import {
Actions,
React,
2017-09-27 02:33:08 +08:00
PropTypes,
TaskFactory,
DOMUtils,
FocusedPerspectiveStore,
} from 'nylas-exports';
export default class ThreadArchiveButton extends React.Component {
2017-09-27 02:33:08 +08:00
static displayName = 'ThreadArchiveButton';
static containerRequired = false;
static propTypes = {
2017-09-27 02:33:08 +08:00
thread: PropTypes.object.isRequired,
};
2017-09-27 02:33:08 +08:00
_onArchive = e => {
if (!DOMUtils.nodeIsVisible(e.currentTarget)) {
return;
}
const tasks = TaskFactory.tasksForArchiving({
threads: [this.props.thread],
2017-09-27 02:33:08 +08:00
source: 'Toolbar Button: Message List',
});
Actions.queueTasks(tasks);
Actions.popSheet();
e.stopPropagation();
2017-09-27 02:33:08 +08:00
};
render() {
2017-09-27 02:33:08 +08:00
const canArchiveThreads = FocusedPerspectiveStore.current().canArchiveThreads([
this.props.thread,
]);
if (!canArchiveThreads) {
2017-09-27 02:33:08 +08:00
return <span />;
}
return (
<button
className="btn btn-toolbar btn-archive"
2017-09-27 02:33:08 +08:00
style={{ order: -107 }}
title="Archive"
onClick={this._onArchive}
>
<RetinaImg name="toolbar-archive.png" mode={RetinaImg.Mode.ContentIsMask} />
</button>
);
}
}