Implement force state for features like in the proposal

This commit is contained in:
Travis Ralston 2020-08-17 13:51:41 -06:00
parent 3659115921
commit 4f851542ac
3 changed files with 9 additions and 6 deletions

View file

@ -35,7 +35,8 @@ export class LabsSettingToggle extends React.Component {
render() { render() {
const label = SettingsStore.getDisplayName(this.props.featureId); const label = SettingsStore.getDisplayName(this.props.featureId);
const value = SettingsStore.getValue(this.props.featureId); const value = SettingsStore.getValue(this.props.featureId);
return <LabelledToggleSwitch value={value} label={label} onChange={this._onChange} />; const canChange = SettingsStore.canSetValue(this.props.featureId, null, SettingLevel.DEVICE);
return <LabelledToggleSwitch value={value} label={label} onChange={this._onChange} disabled={!canChange} />;
} }
} }

View file

@ -23,7 +23,6 @@ import AccountSettingsHandler from "./handlers/AccountSettingsHandler";
import RoomSettingsHandler from "./handlers/RoomSettingsHandler"; import RoomSettingsHandler from "./handlers/RoomSettingsHandler";
import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler"; import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler";
import { _t } from '../languageHandler'; import { _t } from '../languageHandler';
import SdkConfig from "../SdkConfig";
import dis from '../dispatcher/dispatcher'; import dis from '../dispatcher/dispatcher';
import { ISetting, SETTINGS } from "./Settings"; import { ISetting, SETTINGS } from "./Settings";
import LocalEchoWrapper from "./handlers/LocalEchoWrapper"; 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."); 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); const handler = SettingsStore.getHandler(settingName, level);
if (!handler) return false; if (!handler) return false;
return handler.canSetValue(settingName, roomId); return handler.canSetValue(settingName, roomId);

View file

@ -9,10 +9,7 @@
"integrations_ui_url": "https://scalar.vector.im/", "integrations_ui_url": "https://scalar.vector.im/",
"integrations_rest_url": "https://scalar.vector.im/api", "integrations_rest_url": "https://scalar.vector.im/api",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit", "bug_report_endpoint_url": "https://riot.im/bugreports/submit",
"features": { "showLabsSettings": true,
"feature_groups": "labs",
"feature_pinning": "labs"
},
"default_federate": true, "default_federate": true,
"welcomePageUrl": "home.html", "welcomePageUrl": "home.html",
"default_theme": "light", "default_theme": "light",