From f70f983c8cf524b32a5f0c0baf7413cff0ab93de Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Wed, 28 Aug 2019 12:00:37 +0100
Subject: [PATCH] Expose upgrade room permissions in room settings and fix
command
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/SlashCommands.js | 21 ++++++++++++-------
.../tabs/room/RolesRoomSettingsTab.js | 2 ++
src/i18n/strings/en_EN.json | 2 ++
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/SlashCommands.js b/src/SlashCommands.js
index 72ace22cb6..5ed1adb40f 100644
--- a/src/SlashCommands.js
+++ b/src/SlashCommands.js
@@ -139,8 +139,13 @@ export const CommandMap = {
description: _td('Upgrades a room to a new version'),
runFn: function(roomId, args) {
if (args) {
- const room = MatrixClientPeg.get().getRoom(roomId);
- Modal.createTrackedDialog('Slash Commands', 'upgrade room confirmation',
+ const cli = MatrixClientPeg.get();
+ const room = cli.getRoom(roomId);
+ if (!room.currentState.mayClientSendStateEvent("m.room.tombstone", cli)) {
+ return reject(_t("You do not have the required permissions to use this command."));
+ }
+
+ const {finished} = Modal.createTrackedDialog('Slash Commands', 'upgrade room confirmation',
QuestionDialog, {
title: _t('Room upgrade confirmation'),
description: (
@@ -198,13 +203,13 @@ export const CommandMap = {
),
button: _t("Upgrade"),
- onFinished: (confirm) => {
- if (!confirm) return;
-
- MatrixClientPeg.get().upgradeRoom(roomId, args);
- },
});
- return success();
+
+ return success(finished.then((confirm) => {
+ if (!confirm) return;
+
+ return cli.upgradeRoom(roomId, args);
+ }));
}
return reject(this.getUsage());
},
diff --git a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js
index c4b1ae8ddc..581c4314bc 100644
--- a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js
+++ b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.js
@@ -30,6 +30,7 @@ const plEventsToLabels = {
"m.room.history_visibility": _td("Change history visibility"),
"m.room.power_levels": _td("Change permissions"),
"m.room.topic": _td("Change topic"),
+ "m.room.tombstone": _td("Upgrade the room"),
"im.vector.modular.widgets": _td("Modify widgets"),
};
@@ -42,6 +43,7 @@ const plEventsToShow = {
"m.room.history_visibility": {isState: true},
"m.room.power_levels": {isState: true},
"m.room.topic": {isState: true},
+ "m.room.tombstone": {isState: true},
"im.vector.modular.widgets": {isState: true},
};
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 62b6467b94..661a775781 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -146,6 +146,7 @@
"/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",
+ "You do not have the required permissions to use this command.": "You do not have the required permissions to use this command.",
"Room upgrade confirmation": "Room upgrade confirmation",
"Upgrading a room can be destructive and isn't always necessary.": "Upgrading a room can be destructive and isn't always necessary.",
"Room upgrades are usually recommended when a room version is considered unstable. Unstable room versions might have bugs, missing features, or security vulnerabilities.": "Room upgrades are usually recommended when a room version is considered unstable. Unstable room versions might have bugs, missing features, or security vulnerabilities.",
@@ -680,6 +681,7 @@
"Change history visibility": "Change history visibility",
"Change permissions": "Change permissions",
"Change topic": "Change topic",
+ "Upgrade the room": "Upgrade the room",
"Modify widgets": "Modify widgets",
"Failed to unban": "Failed to unban",
"Unban": "Unban",