85 lines
2.7 KiB
JavaScript
Executable file
85 lines
2.7 KiB
JavaScript
Executable file
import React from 'react';
|
|
import ConfirmModal from './ConfirmModal';
|
|
import ModalActionCreators from '../actions/ModalActionCreators';
|
|
import i18n from '../i18n';
|
|
import MessageGroup from './MessageGroup';
|
|
import MessageActionCreators from '../actions/MessageActionCreators';
|
|
import ChannelPinActionCreators from '../actions/ChannelPinActionCreators';
|
|
import Protip from './common/Protip';
|
|
|
|
function confirmPin(channel, message) {
|
|
ModalActionCreators.push(props => {
|
|
let prompt;
|
|
if (channel.isPrivate()) {
|
|
prompt = i18n.Messages.PIN_MESSAGE_BODY_PRIVATE_CHANNEL;
|
|
} else {
|
|
prompt = i18n.Messages.PIN_MESSAGE_BODY.format({channelName: channel.toString()});
|
|
}
|
|
|
|
return (
|
|
<ConfirmModal
|
|
className="confirm-message-modal"
|
|
red={false}
|
|
header={i18n.Messages.PIN_MESSAGE_TITLE}
|
|
confirmText={i18n.Messages.PIN_CONFIRM}
|
|
cancelText={i18n.Messages.CANCEL}
|
|
onConfirm={() => ChannelPinActionCreators.pinMessage(channel, message.id)}
|
|
{...props}>
|
|
<p>{prompt}</p>
|
|
<MessageGroup channel={channel} messages={[message]} enableInteraction={false} />
|
|
</ConfirmModal>
|
|
);
|
|
});
|
|
}
|
|
|
|
function confirmUnpin(channel, message) {
|
|
ModalActionCreators.push(props => {
|
|
return (
|
|
<ConfirmModal
|
|
className="confirm-message-modal"
|
|
header={i18n.Messages.UNPIN_MESSAGE_TITLE}
|
|
confirmText={i18n.Messages.UNPIN_CONFIRM}
|
|
cancelText={i18n.Messages.CANCEL}
|
|
onConfirm={() => ChannelPinActionCreators.unpinMessage(channel, message.id)}
|
|
{...props}>
|
|
<p>{i18n.Messages.UNPIN_MESSAGE_BODY}</p>
|
|
<MessageGroup channel={channel} messages={[message]} enableInteraction={false} />
|
|
<Protip tip={i18n.Messages.UNPIN_MESSAGE_CONTEXT_MENU_HINT.format()} />
|
|
</ConfirmModal>
|
|
);
|
|
});
|
|
}
|
|
|
|
function confirmDelete(channel, message, showContextMenuHint = false) {
|
|
let contextHint = null;
|
|
if (showContextMenuHint) {
|
|
contextHint = <Protip tip={i18n.Messages.DELETE_MESSAGE_CONTEXT_MENU_HINT.format()} />;
|
|
}
|
|
|
|
ModalActionCreators.push(props => {
|
|
return (
|
|
<ConfirmModal
|
|
className="confirm-message-modal"
|
|
header={i18n.Messages.DELETE_MESSAGE_TITLE}
|
|
confirmText={i18n.Messages.DELETE}
|
|
cancelText={i18n.Messages.CANCEL}
|
|
onConfirm={() => MessageActionCreators.deleteMessage(channel.id, message.id)}
|
|
{...props}>
|
|
<p>{i18n.Messages.DELETE_MESSAGE_BODY}</p>
|
|
<MessageGroup channel={channel} messages={[message]} enableInteraction={false} />
|
|
{contextHint}
|
|
</ConfirmModal>
|
|
);
|
|
});
|
|
}
|
|
|
|
export default {
|
|
confirmPin,
|
|
confirmUnpin,
|
|
confirmDelete,
|
|
};
|
|
|
|
|
|
|
|
// WEBPACK FOOTER //
|
|
// ./discord_app/components/MessageAlerts.js
|