Step 8.5: Move tabbed integration manager dialog construction

pull/21833/head
Travis Ralston 2022-03-24 16:09:07 -06:00
parent 226700ba95
commit bcf413734b
4 changed files with 59 additions and 6 deletions

View File

@ -277,4 +277,10 @@ export enum Action {
* Payload: OpenReportEventDialogPayload. * Payload: OpenReportEventDialogPayload.
*/ */
OpenReportEventDialog = "open_report_event_dialog", OpenReportEventDialog = "open_report_event_dialog",
/**
* Fired when the tabbed integration manager dialog needs to be opened.
* Payload: OpenTabbedIntegrationManagerDialogPayload
*/
OpenTabbedIntegrationManagerDialog = "open_tabbed_imanager_dialog",
} }

View File

@ -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<Room>;
screen: Optional<string>;
integrationId: Optional<string>;
}

View File

@ -16,7 +16,7 @@ limitations under the License.
import url from 'url'; import url from 'url';
import { logger } from "matrix-js-sdk/src/logger"; 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 { MatrixEvent } from "matrix-js-sdk/src/models/event";
import type { Room } from "matrix-js-sdk/src/models/room"; import type { Room } from "matrix-js-sdk/src/models/room";
@ -24,12 +24,16 @@ import SdkConfig from '../SdkConfig';
import Modal from '../Modal'; import Modal from '../Modal';
import { IntegrationManagerInstance, Kind } from "./IntegrationManagerInstance"; import { IntegrationManagerInstance, Kind } from "./IntegrationManagerInstance";
import IntegrationsImpossibleDialog from "../components/views/dialogs/IntegrationsImpossibleDialog"; import IntegrationsImpossibleDialog from "../components/views/dialogs/IntegrationsImpossibleDialog";
import TabbedIntegrationManagerDialog from "../components/views/dialogs/TabbedIntegrationManagerDialog";
import IntegrationsDisabledDialog from "../components/views/dialogs/IntegrationsDisabledDialog"; import IntegrationsDisabledDialog from "../components/views/dialogs/IntegrationsDisabledDialog";
import WidgetUtils from "../utils/WidgetUtils"; import WidgetUtils from "../utils/WidgetUtils";
import { MatrixClientPeg } from "../MatrixClientPeg"; import { MatrixClientPeg } from "../MatrixClientPeg";
import SettingsStore from "../settings/SettingsStore"; import SettingsStore from "../settings/SettingsStore";
import { compare } from "../utils/strings"; import { compare } from "../utils/strings";
import defaultDispatcher from "../dispatcher/dispatcher";
import {
OpenTabbedIntegrationManagerDialogPayload,
} from "../dispatcher/payloads/OpenTabbedIntegrationManagerDialogPayload";
import { Action } from "../dispatcher/actions";
const KIND_PREFERENCE = [ const KIND_PREFERENCE = [
// Ordered: first is most preferred, last is least preferred. // Ordered: first is most preferred, last is least preferred.
@ -186,10 +190,12 @@ export class IntegrationManagers {
return this.openNoManagerDialog(); return this.openNoManagerDialog();
} }
Modal.createTrackedDialog( defaultDispatcher.dispatch(<OpenTabbedIntegrationManagerDialogPayload>{
'Tabbed Integration Manager', '', TabbedIntegrationManagerDialog, action: Action.OpenTabbedIntegrationManagerDialog,
{ room, screen, integrationId }, 'mx_TabbedIntegrationManagerDialog', room,
); screen,
integrationId,
});
} }
showDisabledDialog(): void { showDisabledDialog(): void {

View File

@ -23,6 +23,7 @@ import ForwardDialog from "../components/views/dialogs/ForwardDialog";
import { MatrixClientPeg } from "../MatrixClientPeg"; import { MatrixClientPeg } from "../MatrixClientPeg";
import { Action } from "../dispatcher/actions"; import { Action } from "../dispatcher/actions";
import ReportEventDialog from "../components/views/dialogs/ReportEventDialog"; 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 * Auxiliary class to listen for dialog opening over the dispatcher and
@ -65,6 +66,17 @@ export class DialogOpener {
event: payload.event, event: payload.event,
}, 'mx_Dialog_reportEvent'); }, 'mx_Dialog_reportEvent');
break; break;
case Action.OpenTabbedIntegrationManagerDialog:
Modal.createTrackedDialog(
'Tabbed Integration Manager', '', TabbedIntegrationManagerDialog,
{
room: payload.room,
screen: payload.screen,
integrationId: payload.integrationId,
},
'mx_TabbedIntegrationManagerDialog',
);
break;
} }
}; };
} }