From f4f94e31d184c8c3635a53d1b154f84e1a0bb0a8 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 16 Sep 2020 11:38:50 +0100 Subject: [PATCH] UI Feature Flag: Disable integrations entry UI --- src/SlashCommands.tsx | 3 +++ .../views/right_panel/RoomSummaryCard.tsx | 3 ++- src/components/views/rooms/AuxPanel.js | 24 +++++++++++-------- src/components/views/rooms/MessageComposer.js | 6 ++++- .../tabs/user/GeneralUserSettingsTab.js | 3 +++ src/settings/Settings.ts | 4 ++++ src/settings/UIFeature.ts | 1 + 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index 7ba2022c6d..a6481d5b95 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -44,6 +44,8 @@ import { ViewUserPayload } from "./dispatcher/payloads/ViewUserPayload"; import { Action } from "./dispatcher/actions"; import { EffectiveMembership, getEffectiveMembership, leaveRoomBehaviour } from "./utils/membership"; import SdkConfig from "./SdkConfig"; +import SettingsStore from "./settings/SettingsStore"; +import {UIFeature} from "./settings/UIFeature"; // XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816 interface HTMLInputEvent extends Event { @@ -797,6 +799,7 @@ export const Commands = [ command: 'addwidget', args: '', description: _td('Adds a custom widget by URL to the room'), + isEnabled: () => SettingsStore.getValue(UIFeature.Widgets), runFn: function(roomId, widgetUrl) { if (!widgetUrl) { return reject(_t("Please supply a widget URL or embed code")); diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index f51f66a5ea..9d20dc1fe1 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -42,6 +42,7 @@ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import WidgetStore, {IApp} from "../../../stores/WidgetStore"; import { E2EStatus } from "../../../utils/ShieldUtils"; import RoomContext from "../../../contexts/RoomContext"; +import {UIFeature} from "../../../settings/UIFeature"; interface IProps { room: Room; @@ -242,7 +243,7 @@ const RoomSummaryCard: React.FC = ({ room, onClose }) => { - + { SettingsStore.getValue(UIFeature.Widgets) && } ; }; diff --git a/src/components/views/rooms/AuxPanel.js b/src/components/views/rooms/AuxPanel.js index 1f6f104487..f2211dba5c 100644 --- a/src/components/views/rooms/AuxPanel.js +++ b/src/components/views/rooms/AuxPanel.js @@ -28,6 +28,7 @@ import RateLimitedFunc from '../../../ratelimitedfunc'; import SettingsStore from "../../../settings/SettingsStore"; import AutoHideScrollbar from "../../structures/AutoHideScrollbar"; import CallView from "../voip/CallView"; +import {UIFeature} from "../../../settings/UIFeature"; export default class AuxPanel extends React.Component { @@ -198,18 +199,21 @@ export default class AuxPanel extends React.Component { /> ); - const appsDrawer = ; + let appsDrawer; + if (SettingsStore.getValue(UIFeature.Widgets)) { + appsDrawer = ; + } let stateViews = null; if (this.state.counters && SettingsStore.getValue("feature_state_counters")) { - let counters = []; + const counters = []; this.state.counters.forEach((counter, idx) => { const title = counter.title; @@ -218,7 +222,7 @@ export default class AuxPanel extends React.Component { const severity = counter.severity; const stateKey = counter.stateKey; - let span = { title }: { value } + let span = { title }: { value }; if (link) { span = ( diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 922cc2b11e..81c2ae7a33 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -31,6 +31,7 @@ import SettingsStore from "../../../settings/SettingsStore"; import {aboveLeftOf, ContextMenu, ContextMenuTooltipButton, useContextMenu} from "../../structures/ContextMenu"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import ReplyPreview from "./ReplyPreview"; +import {UIFeature} from "../../../settings/UIFeature"; function ComposerAvatar(props) { const MemberStatusMessageAvatar = sdk.getComponent('avatars.MemberStatusMessageAvatar'); @@ -384,9 +385,12 @@ export default class MessageComposer extends React.Component { permalinkCreator={this.props.permalinkCreator} />, , , - , ); + if (SettingsStore.getValue(UIFeature.Widgets)) { + controls.push(); + } + if (this.state.showCallButtons) { if (callInProgress) { controls.push( diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js index 1ebefae590..42e12077f2 100644 --- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js @@ -37,6 +37,7 @@ import {abbreviateUrl} from "../../../../../utils/UrlUtils"; import { getThreepidsWithBindStatus } from '../../../../../boundThreepids'; import Spinner from "../../../elements/Spinner"; import {SettingLevel} from "../../../../../settings/SettingLevel"; +import {UIFeature} from "../../../../../settings/UIFeature"; export default class GeneralUserSettingsTab extends React.Component { static propTypes = { @@ -366,6 +367,8 @@ export default class GeneralUserSettingsTab extends React.Component { } _renderIntegrationManagerSection() { + if (!SettingsStore.getValue(UIFeature.Widgets)) return null; + const SetIntegrationManager = sdk.getComponent("views.settings.SetIntegrationManager"); return ( diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 511daf5cc6..b35fa3db13 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -618,4 +618,8 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_UI_FEATURE, default: true, }, + [UIFeature.Widgets]: { + supportedLevels: LEVELS_UI_FEATURE, + default: true, + }, }; diff --git a/src/settings/UIFeature.ts b/src/settings/UIFeature.ts index e7355a98eb..99196e5d30 100644 --- a/src/settings/UIFeature.ts +++ b/src/settings/UIFeature.ts @@ -17,4 +17,5 @@ limitations under the License. // see settings.md for documentation on conventions export enum UIFeature { URLPreviews = "UIFeature.urlPreviews", + Widgets = "UIFeature.widgets", }