From 4f851542ac882243b52a383106dc64d588fbd0e8 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 17 Aug 2020 13:51:41 -0600 Subject: [PATCH] Implement force state for features like in the proposal --- .../views/settings/tabs/user/LabsUserSettingsTab.js | 3 ++- src/settings/SettingsStore.ts | 7 ++++++- test/end-to-end-tests/riot/config-template/config.json | 5 +---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js index 6559448dfe..eba5c6586d 100644 --- a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/LabsUserSettingsTab.js @@ -35,7 +35,8 @@ export class LabsSettingToggle extends React.Component { render() { const label = SettingsStore.getDisplayName(this.props.featureId); const value = SettingsStore.getValue(this.props.featureId); - return ; + const canChange = SettingsStore.canSetValue(this.props.featureId, null, SettingLevel.DEVICE); + return ; } } diff --git a/src/settings/SettingsStore.ts b/src/settings/SettingsStore.ts index dd75f8d1c9..9e146ad799 100644 --- a/src/settings/SettingsStore.ts +++ b/src/settings/SettingsStore.ts @@ -23,7 +23,6 @@ import AccountSettingsHandler from "./handlers/AccountSettingsHandler"; import RoomSettingsHandler from "./handlers/RoomSettingsHandler"; import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler"; import { _t } from '../languageHandler'; -import SdkConfig from "../SdkConfig"; import dis from '../dispatcher/dispatcher'; import { ISetting, SETTINGS } from "./Settings"; import LocalEchoWrapper from "./handlers/LocalEchoWrapper"; @@ -435,6 +434,12 @@ export default class SettingsStore { throw new Error("Setting '" + settingName + "' does not appear to be a setting."); } + // When features are specified in the config.json, we force them as enabled or disabled. + if (SettingsStore.isFeature(settingName)) { + const configVal = SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, roomId, true, true); + if (configVal === true || configVal === false) return false; + } + const handler = SettingsStore.getHandler(settingName, level); if (!handler) return false; return handler.canSetValue(settingName, roomId); diff --git a/test/end-to-end-tests/riot/config-template/config.json b/test/end-to-end-tests/riot/config-template/config.json index d0d3a288e4..b647d0bec8 100644 --- a/test/end-to-end-tests/riot/config-template/config.json +++ b/test/end-to-end-tests/riot/config-template/config.json @@ -9,10 +9,7 @@ "integrations_ui_url": "https://scalar.vector.im/", "integrations_rest_url": "https://scalar.vector.im/api", "bug_report_endpoint_url": "https://riot.im/bugreports/submit", - "features": { - "feature_groups": "labs", - "feature_pinning": "labs" - }, + "showLabsSettings": true, "default_federate": true, "welcomePageUrl": "home.html", "default_theme": "light",