From bcf413734ba655efee0f03c0c26f50487c24a6e6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 24 Mar 2022 16:09:07 -0600 Subject: [PATCH] Step 8.5: Move tabbed integration manager dialog construction --- src/dispatcher/actions.ts | 6 ++++ ...enTabbedIntegrationManagerDialogPayload.ts | 29 +++++++++++++++++++ src/integrations/IntegrationManagers.ts | 18 ++++++++---- src/utils/DialogOpener.ts | 12 ++++++++ 4 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 src/dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload.ts diff --git a/src/dispatcher/actions.ts b/src/dispatcher/actions.ts index 165438e86b..5662da1de5 100644 --- a/src/dispatcher/actions.ts +++ b/src/dispatcher/actions.ts @@ -277,4 +277,10 @@ export enum Action { * Payload: OpenReportEventDialogPayload. */ OpenReportEventDialog = "open_report_event_dialog", + + /** + * Fired when the tabbed integration manager dialog needs to be opened. + * Payload: OpenTabbedIntegrationManagerDialogPayload + */ + OpenTabbedIntegrationManagerDialog = "open_tabbed_imanager_dialog", } diff --git a/src/dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload.ts b/src/dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload.ts new file mode 100644 index 0000000000..891d126169 --- /dev/null +++ b/src/dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload.ts @@ -0,0 +1,29 @@ +/* +Copyright 2022 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 { Room } from "matrix-js-sdk/src/models/room"; +import { Optional } from "matrix-events-sdk"; + +import { ActionPayload } from "../payloads"; +import { Action } from "../actions"; + +export interface OpenTabbedIntegrationManagerDialogPayload extends ActionPayload { + action: Action.OpenTabbedIntegrationManagerDialog; + + room: Optional; + screen: Optional; + integrationId: Optional; +} diff --git a/src/integrations/IntegrationManagers.ts b/src/integrations/IntegrationManagers.ts index 68c82ab55c..32bb224f74 100644 --- a/src/integrations/IntegrationManagers.ts +++ b/src/integrations/IntegrationManagers.ts @@ -16,7 +16,7 @@ limitations under the License. import url from 'url'; import { logger } from "matrix-js-sdk/src/logger"; -import { MatrixClient, ClientEvent } from "matrix-js-sdk/src/client"; +import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client"; import type { MatrixEvent } from "matrix-js-sdk/src/models/event"; import type { Room } from "matrix-js-sdk/src/models/room"; @@ -24,12 +24,16 @@ import SdkConfig from '../SdkConfig'; import Modal from '../Modal'; import { IntegrationManagerInstance, Kind } from "./IntegrationManagerInstance"; import IntegrationsImpossibleDialog from "../components/views/dialogs/IntegrationsImpossibleDialog"; -import TabbedIntegrationManagerDialog from "../components/views/dialogs/TabbedIntegrationManagerDialog"; import IntegrationsDisabledDialog from "../components/views/dialogs/IntegrationsDisabledDialog"; import WidgetUtils from "../utils/WidgetUtils"; import { MatrixClientPeg } from "../MatrixClientPeg"; import SettingsStore from "../settings/SettingsStore"; import { compare } from "../utils/strings"; +import defaultDispatcher from "../dispatcher/dispatcher"; +import { + OpenTabbedIntegrationManagerDialogPayload, +} from "../dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload"; +import { Action } from "../dispatcher/actions"; const KIND_PREFERENCE = [ // Ordered: first is most preferred, last is least preferred. @@ -186,10 +190,12 @@ export class IntegrationManagers { return this.openNoManagerDialog(); } - Modal.createTrackedDialog( - 'Tabbed Integration Manager', '', TabbedIntegrationManagerDialog, - { room, screen, integrationId }, 'mx_TabbedIntegrationManagerDialog', - ); + defaultDispatcher.dispatch({ + action: Action.OpenTabbedIntegrationManagerDialog, + room, + screen, + integrationId, + }); } showDisabledDialog(): void { diff --git a/src/utils/DialogOpener.ts b/src/utils/DialogOpener.ts index 1b21b1b871..b18c88ea6f 100644 --- a/src/utils/DialogOpener.ts +++ b/src/utils/DialogOpener.ts @@ -23,6 +23,7 @@ import ForwardDialog from "../components/views/dialogs/ForwardDialog"; import { MatrixClientPeg } from "../MatrixClientPeg"; import { Action } from "../dispatcher/actions"; import ReportEventDialog from "../components/views/dialogs/ReportEventDialog"; +import TabbedIntegrationManagerDialog from "../components/views/dialogs/TabbedIntegrationManagerDialog"; /** * Auxiliary class to listen for dialog opening over the dispatcher and @@ -65,6 +66,17 @@ export class DialogOpener { event: payload.event, }, 'mx_Dialog_reportEvent'); break; + case Action.OpenTabbedIntegrationManagerDialog: + Modal.createTrackedDialog( + 'Tabbed Integration Manager', '', TabbedIntegrationManagerDialog, + { + room: payload.room, + screen: payload.screen, + integrationId: payload.integrationId, + }, + 'mx_TabbedIntegrationManagerDialog', + ); + break; } }; }