Merge branch 'develop' into ctrl-enter-send
This commit is contained in:
commit
1346416d20
451 changed files with 25135 additions and 10894 deletions
|
@ -33,6 +33,9 @@ import { SettingLevel } from "./SettingLevel";
|
|||
import SettingController from "./controllers/SettingController";
|
||||
import { RightPanelPhases } from "../stores/RightPanelStorePhases";
|
||||
import { isMac } from '../Keyboard';
|
||||
import UIFeatureController from "./controllers/UIFeatureController";
|
||||
import { UIFeature } from "./UIFeature";
|
||||
import { OrderedMultiController } from "./controllers/OrderedMultiController";
|
||||
|
||||
// These are just a bunch of helper arrays to avoid copy/pasting a bunch of times
|
||||
const LEVELS_ROOM_SETTINGS = [
|
||||
|
@ -70,6 +73,10 @@ const LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG = [
|
|||
SettingLevel.DEVICE,
|
||||
SettingLevel.CONFIG,
|
||||
];
|
||||
const LEVELS_UI_FEATURE = [
|
||||
SettingLevel.CONFIG,
|
||||
// in future we might have a .well-known level or something
|
||||
];
|
||||
|
||||
export interface ISetting {
|
||||
// Must be set to true for features. Default is 'false'.
|
||||
|
@ -180,6 +187,12 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
},
|
||||
"feature_dehydration": {
|
||||
isFeature: true,
|
||||
displayName: _td("Offline encrypted messaging using dehydrated devices"),
|
||||
supportedLevels: LEVELS_FEATURE,
|
||||
default: false,
|
||||
},
|
||||
"advancedRoomListLogging": {
|
||||
// TODO: Remove flag before launch: https://github.com/vector-im/element-web/issues/14231
|
||||
displayName: _td("Enable advanced debugging for the room list"),
|
||||
|
@ -276,16 +289,6 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
displayName: _td('Autoplay GIFs and videos'),
|
||||
default: false,
|
||||
},
|
||||
"alwaysShowEncryptionIcons": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Always show encryption icons'),
|
||||
default: true,
|
||||
},
|
||||
"showRoomRecoveryReminder": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Show a reminder to enable Secure Message Recovery in encrypted rooms'),
|
||||
default: true,
|
||||
},
|
||||
"enableSyntaxHighlightLanguageDetection": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
displayName: _td('Enable automatic language detection for syntax highlighting'),
|
||||
|
@ -342,6 +345,8 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
displayName: _td('Enable Community Filter Panel'),
|
||||
default: true,
|
||||
invertedSettingName: 'TagPanel.disableTagPanel',
|
||||
// We force the value to true because the invertedSettingName causes it to flip
|
||||
controller: new UIFeatureController(UIFeature.Communities, true),
|
||||
},
|
||||
"theme": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
|
@ -444,6 +449,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
"room-device": _td('Never send encrypted messages to unverified sessions in this room from this session'),
|
||||
},
|
||||
default: false,
|
||||
controller: new UIFeatureController(UIFeature.AdvancedEncryption),
|
||||
},
|
||||
"urlPreviewsEnabled": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
|
@ -453,6 +459,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
"room": _td("Enable URL previews by default for participants in this room"),
|
||||
},
|
||||
default: true,
|
||||
controller: new UIFeatureController(UIFeature.URLPreviews),
|
||||
},
|
||||
"urlPreviewsEnabled_e2ee": {
|
||||
supportedLevels: [SettingLevel.ROOM_DEVICE, SettingLevel.ROOM_ACCOUNT],
|
||||
|
@ -460,6 +467,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
"room-account": _td("Enable URL previews for this room (only affects you)"),
|
||||
},
|
||||
default: false,
|
||||
controller: new UIFeatureController(UIFeature.URLPreviews),
|
||||
},
|
||||
"roomColor": {
|
||||
supportedLevels: LEVELS_ROOM_SETTINGS_WITH_ROOM,
|
||||
|
@ -572,7 +580,7 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
},
|
||||
"lastRightPanelPhaseForRoom": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
default: RightPanelPhases.RoomMemberInfo,
|
||||
default: RightPanelPhases.RoomSummary,
|
||||
},
|
||||
"lastRightPanelPhaseForGroup": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
|
@ -591,14 +599,21 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
"showCallButtonsInComposer": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG,
|
||||
default: true,
|
||||
controller: new UIFeatureController(UIFeature.Voip),
|
||||
},
|
||||
"e2ee.manuallyVerifyAllSessions": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
displayName: _td("Manually verify all remote sessions"),
|
||||
default: false,
|
||||
controller: new PushToMatrixClientController(
|
||||
MatrixClient.prototype.setCryptoTrustCrossSignedDevices, true,
|
||||
),
|
||||
controller: new OrderedMultiController([
|
||||
// Apply the feature controller first to ensure that the setting doesn't
|
||||
// show up and can't be toggled. PushToMatrixClientController doesn't
|
||||
// do any overrides anyways.
|
||||
new UIFeatureController(UIFeature.AdvancedEncryption),
|
||||
new PushToMatrixClientController(
|
||||
MatrixClient.prototype.setCryptoTrustCrossSignedDevices, true,
|
||||
),
|
||||
]),
|
||||
},
|
||||
"ircDisplayNameWidth": {
|
||||
// We specifically want to have room-device > device so that users may set a device default
|
||||
|
@ -613,4 +628,80 @@ export const SETTINGS: {[setting: string]: ISetting} = {
|
|||
displayName: _td("Enable experimental, compact IRC style layout"),
|
||||
default: false,
|
||||
},
|
||||
"Widgets.pinned": {
|
||||
supportedLevels: LEVELS_ROOM_OR_ACCOUNT,
|
||||
default: {},
|
||||
},
|
||||
"Widgets.leftPanel": {
|
||||
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||
default: null,
|
||||
},
|
||||
[UIFeature.RoomHistorySettings]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.AdvancedEncryption]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.URLPreviews]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Widgets]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Voip]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Feedback]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Registration]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.PasswordReset]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Deactivate]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.ShareQRCode]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.ShareSocial]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.IdentityServer]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
// Identity Server (Discovery) Settings make no sense if 3PIDs in general are hidden
|
||||
controller: new UIFeatureController(UIFeature.ThirdPartyID),
|
||||
},
|
||||
[UIFeature.ThirdPartyID]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.Flair]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
// Disable Flair when Communities are disabled
|
||||
controller: new UIFeatureController(UIFeature.Communities),
|
||||
},
|
||||
[UIFeature.Communities]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
[UIFeature.AdvancedSettings]: {
|
||||
supportedLevels: LEVELS_UI_FEATURE,
|
||||
default: true,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -257,6 +257,17 @@ export default class SettingsStore {
|
|||
return SETTINGS[settingName].isFeature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a setting is enabled.
|
||||
* If a setting is disabled then it should be hidden from the user.
|
||||
* @param {string} settingName The setting to look up.
|
||||
* @return {boolean} True if the setting is enabled.
|
||||
*/
|
||||
public static isEnabled(settingName: string): boolean {
|
||||
if (!SETTINGS[settingName]) return false;
|
||||
return SETTINGS[settingName].controller ? !SETTINGS[settingName].controller.settingDisabled : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a setting. The room ID is optional if the setting is not to
|
||||
* be applied to any particular room, otherwise it should be supplied.
|
||||
|
|
35
src/settings/UIFeature.ts
Normal file
35
src/settings/UIFeature.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// see settings.md for documentation on conventions
|
||||
export enum UIFeature {
|
||||
AdvancedEncryption = "UIFeature.advancedEncryption",
|
||||
URLPreviews = "UIFeature.urlPreviews",
|
||||
Widgets = "UIFeature.widgets",
|
||||
Voip = "UIFeature.voip",
|
||||
Feedback = "UIFeature.feedback",
|
||||
Registration = "UIFeature.registration",
|
||||
PasswordReset = "UIFeature.passwordReset",
|
||||
Deactivate = "UIFeature.deactivate",
|
||||
ShareQRCode = "UIFeature.shareQrCode",
|
||||
ShareSocial = "UIFeature.shareSocial",
|
||||
IdentityServer = "UIFeature.identityServer",
|
||||
ThirdPartyID = "UIFeature.thirdPartyId",
|
||||
Flair = "UIFeature.flair",
|
||||
Communities = "UIFeature.communities",
|
||||
AdvancedSettings = "UIFeature.advancedSettings",
|
||||
RoomHistorySettings = "UIFeature.roomHistorySettings",
|
||||
}
|
|
@ -24,7 +24,7 @@ import {PushProcessor} from "matrix-js-sdk/src/pushprocessor";
|
|||
|
||||
// .m.rule.master being enabled means all events match that push rule
|
||||
// default action on this rule is dont_notify, but it could be something else
|
||||
function isPushNotifyDisabled(): boolean {
|
||||
export function isPushNotifyDisabled(): boolean {
|
||||
// Return the value of the master push rule as a default
|
||||
const processor = new PushProcessor(MatrixClientPeg.get());
|
||||
const masterRule = processor.getPushRuleById(".m.rule.master");
|
||||
|
|
59
src/settings/controllers/OrderedMultiController.ts
Normal file
59
src/settings/controllers/OrderedMultiController.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import SettingController from "./SettingController";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
|
||||
/**
|
||||
* Allows for multiple controllers to affect a setting. The first controller
|
||||
* provided to this class which overrides the setting value will affect
|
||||
* the value - other controllers are not called. Change notification handlers
|
||||
* are proxied through to all controllers.
|
||||
*
|
||||
* Similarly, the first controller which indicates that a setting is disabled
|
||||
* will be used - other controllers will not be considered.
|
||||
*/
|
||||
export class OrderedMultiController extends SettingController {
|
||||
constructor(public readonly controllers: SettingController[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getValueOverride(
|
||||
level: SettingLevel,
|
||||
roomId: string,
|
||||
calculatedValue: any,
|
||||
calculatedAtLevel: SettingLevel,
|
||||
): any {
|
||||
for (const controller of this.controllers) {
|
||||
const override = controller.getValueOverride(level, roomId, calculatedValue, calculatedAtLevel);
|
||||
if (override !== undefined && override !== null) return override;
|
||||
}
|
||||
return null; // no override
|
||||
}
|
||||
|
||||
public onChange(level: SettingLevel, roomId: string, newValue: any) {
|
||||
for (const controller of this.controllers) {
|
||||
controller.onChange(level, roomId, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public get settingDisabled(): boolean {
|
||||
for (const controller of this.controllers) {
|
||||
if (controller.settingDisabled) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -55,4 +55,11 @@ export default abstract class SettingController {
|
|||
public onChange(level: SettingLevel, roomId: string, newValue: any) {
|
||||
// do nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the setting has been disabled due to this controller.
|
||||
*/
|
||||
public get settingDisabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
49
src/settings/controllers/UIFeatureController.ts
Normal file
49
src/settings/controllers/UIFeatureController.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import SettingController from "./SettingController";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
import SettingsStore from "../SettingsStore";
|
||||
|
||||
/**
|
||||
* Enforces that a boolean setting cannot be enabled if the corresponding
|
||||
* UI feature is disabled. If the UI feature is enabled, the setting value
|
||||
* is unchanged.
|
||||
*
|
||||
* Settings using this controller are assumed to return `false` when disabled.
|
||||
*/
|
||||
export default class UIFeatureController extends SettingController {
|
||||
public constructor(private uiFeatureName: string, private forcedValue = false) {
|
||||
super();
|
||||
}
|
||||
|
||||
public getValueOverride(
|
||||
level: SettingLevel,
|
||||
roomId: string,
|
||||
calculatedValue: any,
|
||||
calculatedAtLevel: SettingLevel,
|
||||
): any {
|
||||
if (this.settingDisabled) {
|
||||
// per the docs: we force a disabled state when the feature isn't active
|
||||
return this.forcedValue;
|
||||
}
|
||||
return null; // no override
|
||||
}
|
||||
|
||||
public get settingDisabled(): boolean {
|
||||
return !SettingsStore.getValue(this.uiFeatureName);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue