Add support for giving reason when redacting

Signed-off-by: Daniel Maslowski <info@orangecms.org>
pull/21833/head
Daniel Maslowski 2020-09-09 20:35:26 +02:00
parent 8bf4ef5766
commit 43ff97c178
3 changed files with 9 additions and 4 deletions

View File

@ -145,7 +145,7 @@ export default class MessageContextMenu extends React.Component {
onRedactClick = () => { onRedactClick = () => {
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog"); const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
Modal.createTrackedDialog('Confirm Redact Dialog', '', ConfirmRedactDialog, { Modal.createTrackedDialog('Confirm Redact Dialog', '', ConfirmRedactDialog, {
onFinished: async (proceed) => { onFinished: async (proceed, reason) => {
if (!proceed) return; if (!proceed) return;
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
@ -153,6 +153,8 @@ export default class MessageContextMenu extends React.Component {
await cli.redactEvent( await cli.redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getRoomId(),
this.props.mxEvent.getId(), this.props.mxEvent.getId(),
undefined,
reason ? { reason } : {},
); );
} catch (e) { } catch (e) {
const code = e.errcode || e.statusCode; const code = e.errcode || e.statusCode;

View File

@ -23,15 +23,17 @@ import { _t } from '../../../languageHandler';
*/ */
export default class ConfirmRedactDialog extends React.Component { export default class ConfirmRedactDialog extends React.Component {
render() { render() {
const QuestionDialog = sdk.getComponent('views.dialogs.QuestionDialog'); const TextInputDialog = sdk.getComponent('views.dialogs.TextInputDialog');
return ( return (
<QuestionDialog onFinished={this.props.onFinished} <TextInputDialog onFinished={this.props.onFinished}
title={_t("Confirm Removal")} title={_t("Confirm Removal")}
description={ description={
_t("Are you sure you wish to remove (delete) this event? " + _t("Are you sure you wish to remove (delete) this event? " +
"Note that if you delete a room name or topic change, it could undo the change.")} "Note that if you delete a room name or topic change, it could undo the change.")}
placeholder={_t("Reason (optional)")}
focus
button={_t("Remove")}> button={_t("Remove")}>
</QuestionDialog> </TextInputDialog>
); );
} }
} }

View File

@ -1624,6 +1624,7 @@
"Removing…": "Removing…", "Removing…": "Removing…",
"Confirm Removal": "Confirm Removal", "Confirm Removal": "Confirm Removal",
"Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.": "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.", "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.": "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.",
"Reason (optional)": "Reason (optional)",
"Clear all data in this session?": "Clear all data in this session?", "Clear all data in this session?": "Clear all data in this session?",
"Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.": "Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.", "Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.": "Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.",
"Clear all data": "Clear all data", "Clear all data": "Clear all data",