From fba4b7235f4766d8f5a08abfd7dc82c0953a3006 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 14 Mar 2019 17:24:22 -0600 Subject: [PATCH] Add a confirmation prompt when upgrading the room via slashcommand Wording is questionable here, but the idea is to discourage non-power-users from accidentally upgrading their room. They should already be receiving a bunch of warnings if they should consider upgrading in the first place. --- src/SlashCommands.js | 39 ++++++++++++++++++++++++++++++++++++- src/i18n/strings/en_EN.json | 6 +++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 711346c4a7..11018df081 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -28,6 +28,7 @@ import {MATRIXTO_URL_PATTERN} from "./linkify-matrix"; import * as querystring from "querystring"; import MultiInviter from './utils/MultiInviter'; import { linkifyAndSanitizeHtml } from './HtmlUtils'; +import QuestionDialog from "./components/views/dialogs/QuestionDialog"; class Command { constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) { @@ -105,7 +106,43 @@ export const CommandMap = { description: _td('Upgrades a room to a new version'), runFn: function(roomId, args) { if (args) { - return success(MatrixClientPeg.get().upgradeRoom(roomId, args)); + const room = MatrixClientPeg.get().getRoom(roomId); + Modal.createTrackedDialog('Slash Commands', 'upgrade room confirmation', + QuestionDialog, { + title: _t('Room upgrade confirmation'), + description: ( +
+ { _t( + "Upgrading your room in this way can be dangerous or unnecessary. Room upgrades " + + "are usually done to change the server's behaviour in a given room and not so much " + + "anything to do with client (Riot) behaviour.", + ) } +
+
+ { _t( + "Members of the room will be required to click a link to join the new room. No " + + "one will be automatically joined or invited to the new room.", + ) } +
+
+ { _t( + "Please confirm that you'd like to go forward with upgrading this room from " + + "%(oldVersion)s to %(newVersion)s", + { + oldVersion: room ? room.getVersion() : "1", + newVersion: args, + }, + ) } +
+ ), + button: _t("Upgrade Room"), + onFinished: (confirm) => { + if (!confirm) return; + + MatrixClientPeg.get().upgradeRoom(roomId, args); + }, + }); + return success(); } return reject(this.getUsage()); }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bfb8828fd3..26113d3d4f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -132,6 +132,11 @@ "/ddg is not a command": "/ddg is not a command", "To use it, just wait for autocomplete results to load and tab through them.": "To use it, just wait for autocomplete results to load and tab through them.", "Upgrades a room to a new version": "Upgrades a room to a new version", + "Room upgrade confirmation": "Room upgrade confirmation", + "Upgrading your room in this way can be dangerous or unnecessary. Room upgrades are usually done to change the server's behaviour in a given room and not so much anything to do with client (Riot) behaviour.": "Upgrading your room in this way can be dangerous or unnecessary. Room upgrades are usually done to change the server's behaviour in a given room and not so much anything to do with client (Riot) behaviour.", + "Members of the room will be required to click a link to join the new room. No one will be automatically joined or invited to the new room.": "Members of the room will be required to click a link to join the new room. No one will be automatically joined or invited to the new room.", + "Please confirm that you'd like to go forward with upgrading this room from %(oldVersion)s to %(newVersion)s": "Please confirm that you'd like to go forward with upgrading this room from %(oldVersion)s to %(newVersion)s", + "Upgrade Room": "Upgrade Room", "Changes your display nickname": "Changes your display nickname", "Changes your display nickname in the current room only": "Changes your display nickname in the current room only", "Changes colour scheme of current room": "Changes colour scheme of current room", @@ -581,7 +586,6 @@ "Camera": "Camera", "Voice & Video": "Voice & Video", "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", - "Members of the room will be required to click a link to join the new room. No one will be automatically joined or invited to the new room.": "Members of the room will be required to click a link to join the new room. No one will be automatically joined or invited to the new room.", "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", "Room information": "Room information", "Internal room ID:": "Internal room ID:",