Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 255f0f5

Browse files
authored
Disable upgraderoom command without developer mode enabled (#11744)
* Disable upgraderoom command without developer mode enabled Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent bdf2ebd commit 255f0f5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/SlashCommands.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export const Commands = [
149149
command: "upgraderoom",
150150
args: "<new_version>",
151151
description: _td("slash_command|upgraderoom"),
152-
isEnabled: (cli) => !isCurrentLocalRoom(cli),
152+
isEnabled: (cli) => !isCurrentLocalRoom(cli) && SettingsStore.getValue("developerMode"),
153153
runFn: function (cli, roomId, threadId, args) {
154154
if (args) {
155155
const room = cli.getRoom(roomId);

test/SlashCommands-test.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import WidgetUtils from "../src/utils/WidgetUtils";
2828
import { WidgetType } from "../src/widgets/WidgetType";
2929
import { warnSelfDemote } from "../src/components/views/right_panel/UserInfo";
3030
import dispatcher from "../src/dispatcher/dispatcher";
31+
import { SettingLevel } from "../src/settings/SettingLevel";
3132

3233
jest.mock("../src/components/views/right_panel/UserInfo");
3334

@@ -88,7 +89,6 @@ describe("SlashCommands", () => {
8889
});
8990

9091
describe.each([
91-
["upgraderoom"],
9292
["myroomnick"],
9393
["roomavatar"],
9494
["myroomavatar"],
@@ -126,6 +126,22 @@ describe("SlashCommands", () => {
126126
});
127127
});
128128

129+
describe("/upgraderoom", () => {
130+
beforeEach(() => {
131+
command = findCommand("upgraderoom")!;
132+
setCurrentRoom();
133+
});
134+
135+
it("should be disabled by default", () => {
136+
expect(command.isEnabled(client)).toBe(false);
137+
});
138+
139+
it("should be enabled for developerMode", () => {
140+
SettingsStore.setValue("developerMode", null, SettingLevel.DEVICE, true);
141+
expect(command.isEnabled(client)).toBe(true);
142+
});
143+
});
144+
129145
describe("/op", () => {
130146
beforeEach(() => {
131147
command = findCommand("op")!;

0 commit comments

Comments
 (0)