mirror of https://github.com/vector-im/riot-web
Step 8.5: Move "add existing to space" dialog construction
parent
3ab21224df
commit
9a75acba17
|
@ -307,4 +307,9 @@ export enum Action {
|
|||
* Opens the invite dialog. Used with a OpenInviteDialogPayload.
|
||||
*/
|
||||
OpenInviteDialog = "open_invite_dialog",
|
||||
|
||||
/**
|
||||
* Opens a dialog to add an existing object to a space. Used with a OpenAddExistingToSpaceDialogPayload.
|
||||
*/
|
||||
OpenAddToExistingSpaceDialog = "open_add_to_existing_space_dialog",
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
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 { ActionPayload } from "../payloads";
|
||||
import { Action } from "../actions";
|
||||
|
||||
export interface OpenAddExistingToSpaceDialogPayload extends ActionPayload {
|
||||
action: Action.OpenAddToExistingSpaceDialog;
|
||||
|
||||
space: Room;
|
||||
}
|
|
@ -27,6 +27,10 @@ import TabbedIntegrationManagerDialog from "../components/views/dialogs/TabbedIn
|
|||
import SpacePreferencesDialog from "../components/views/dialogs/SpacePreferencesDialog";
|
||||
import SpaceSettingsDialog from "../components/views/dialogs/SpaceSettingsDialog";
|
||||
import InviteDialog from "../components/views/dialogs/InviteDialog";
|
||||
import AddExistingToSpaceDialog from "../components/views/dialogs/AddExistingToSpaceDialog";
|
||||
import { ButtonEvent } from "../components/views/elements/AccessibleButton";
|
||||
import PosthogTrackers from "../PosthogTrackers";
|
||||
import { showAddExistingSubspace, showCreateNewRoom } from "./space";
|
||||
|
||||
/**
|
||||
* Auxiliary class to listen for dialog opening over the dispatcher and
|
||||
|
@ -101,6 +105,29 @@ export class DialogOpener {
|
|||
payload.onFinishedCallback?.(results);
|
||||
});
|
||||
break;
|
||||
case Action.OpenAddToExistingSpaceDialog: {
|
||||
const space = payload.space;
|
||||
Modal.createTrackedDialog(
|
||||
"Space Landing",
|
||||
"Add Existing",
|
||||
AddExistingToSpaceDialog,
|
||||
{
|
||||
onCreateRoomClick: (ev: ButtonEvent) => {
|
||||
showCreateNewRoom(space);
|
||||
PosthogTrackers.trackInteraction("WebAddExistingToSpaceDialogCreateRoomButton", ev);
|
||||
},
|
||||
onAddSubspaceClick: () => showAddExistingSubspace(space),
|
||||
space,
|
||||
onFinished: (added: boolean) => {
|
||||
if (added && RoomViewStore.instance.getRoomId() === space.roomId) {
|
||||
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
|
||||
}
|
||||
},
|
||||
},
|
||||
"mx_AddExistingToSpaceDialog_wrapper",
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
|||
|
||||
import { calculateRoomVia } from "./permalinks/Permalinks";
|
||||
import Modal from "../Modal";
|
||||
import AddExistingToSpaceDialog from "../components/views/dialogs/AddExistingToSpaceDialog";
|
||||
import CreateRoomDialog from "../components/views/dialogs/CreateRoomDialog";
|
||||
import createRoom, { IOpts } from "../createRoom";
|
||||
import { _t } from "../languageHandler";
|
||||
|
@ -34,13 +33,12 @@ import defaultDispatcher from "../dispatcher/dispatcher";
|
|||
import { RoomViewStore } from "../stores/RoomViewStore";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
import Spinner from "../components/views/elements/Spinner";
|
||||
import PosthogTrackers from "../PosthogTrackers";
|
||||
import { ButtonEvent } from "../components/views/elements/AccessibleButton";
|
||||
import { shouldShowComponent } from "../customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../settings/UIFeature";
|
||||
import { OpenSpacePreferencesPayload, SpacePreferenceTab } from "../dispatcher/payloads/OpenSpacePreferencesPayload";
|
||||
import { OpenSpaceSettingsPayload } from "../dispatcher/payloads/OpenSpaceSettingsPayload";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { OpenAddExistingToSpaceDialogPayload } from "../dispatcher/payloads/OpenAddExistingToSpaceDialogPayload";
|
||||
|
||||
export const shouldShowSpaceSettings = (space: Room) => {
|
||||
const userId = space.client.getUserId();
|
||||
|
@ -68,25 +66,10 @@ export function showSpaceSettings(space: Room) {
|
|||
}
|
||||
|
||||
export const showAddExistingRooms = (space: Room): void => {
|
||||
Modal.createTrackedDialog(
|
||||
"Space Landing",
|
||||
"Add Existing",
|
||||
AddExistingToSpaceDialog,
|
||||
{
|
||||
onCreateRoomClick: (ev: ButtonEvent) => {
|
||||
showCreateNewRoom(space);
|
||||
PosthogTrackers.trackInteraction("WebAddExistingToSpaceDialogCreateRoomButton", ev);
|
||||
},
|
||||
onAddSubspaceClick: () => showAddExistingSubspace(space),
|
||||
space,
|
||||
onFinished: (added: boolean) => {
|
||||
if (added && RoomViewStore.instance.getRoomId() === space.roomId) {
|
||||
defaultDispatcher.fire(Action.UpdateSpaceHierarchy);
|
||||
}
|
||||
},
|
||||
},
|
||||
"mx_AddExistingToSpaceDialog_wrapper",
|
||||
);
|
||||
dis.dispatch({
|
||||
action: Action.OpenAddToExistingSpaceDialog,
|
||||
space,
|
||||
} as OpenAddExistingToSpaceDialogPayload);
|
||||
};
|
||||
|
||||
export const showCreateNewRoom = async (space: Room): Promise<boolean> => {
|
||||
|
|
Loading…
Reference in New Issue