2019-03-05 03:03:12 +08:00
|
|
|
import React from 'react';
|
2018-01-24 09:35:09 +08:00
|
|
|
import { RetinaImg } from 'mailspring-component-kit';
|
2019-03-05 03:03:12 +08:00
|
|
|
import { localized, PropTypes, Actions } from 'mailspring-exports';
|
2018-01-24 09:35:09 +08:00
|
|
|
|
2019-03-05 03:03:12 +08:00
|
|
|
export class DraftDeleteButton extends React.Component<{ selection: any }> {
|
2018-01-24 09:35:09 +08:00
|
|
|
static displayName = 'DraftDeleteButton';
|
|
|
|
static containerRequired = false;
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
selection: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
style={{ order: -100 }}
|
|
|
|
className="btn btn-toolbar"
|
2018-10-07 14:27:27 +08:00
|
|
|
title={localized('Delete')}
|
2018-01-24 09:35:09 +08:00
|
|
|
onClick={this._onDestroySelected}
|
|
|
|
>
|
|
|
|
<RetinaImg name="icon-composer-trash.png" mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroySelected = () => {
|
|
|
|
for (const item of this.props.selection.items()) {
|
|
|
|
Actions.destroyDraft(item);
|
|
|
|
}
|
|
|
|
this.props.selection.clear();
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
}
|