mirror of https://github.com/vector-im/riot-web
Step 8.5: Move some space settings dialog construction
parent
c8582c7199
commit
528482f74d
|
@ -26,10 +26,7 @@ import { useSettingValue } from "../../../hooks/useSettings";
|
|||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import { SettingLevel } from "../../../settings/SettingLevel";
|
||||
import RoomName from "../elements/RoomName";
|
||||
|
||||
export enum SpacePreferenceTab {
|
||||
Appearance = "SPACE_PREFERENCE_APPEARANCE_TAB",
|
||||
}
|
||||
import { SpacePreferenceTab } from "../../../dispatcher/payloads/OpenSpacePreferencesPayload";
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
space: Room;
|
||||
|
|
|
@ -292,4 +292,14 @@ export enum Action {
|
|||
* No payload.
|
||||
*/
|
||||
TriggerLogout = "trigger_logout",
|
||||
|
||||
/**
|
||||
* Opens the user's preferences for the given space. Used with a OpenSpacePreferencesPayload.
|
||||
*/
|
||||
OpenSpacePreferences = "open_space_preferences",
|
||||
|
||||
/**
|
||||
* Opens the settings for the given space. Used with a OpenSpaceSettingsPayload.
|
||||
*/
|
||||
OpenSpaceSettings = "open_space_settings",
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
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 enum SpacePreferenceTab {
|
||||
Appearance = "SPACE_PREFERENCE_APPEARANCE_TAB",
|
||||
}
|
||||
|
||||
export interface OpenSpacePreferencesPayload extends ActionPayload {
|
||||
action: Action.OpenSpacePreferences;
|
||||
|
||||
/**
|
||||
* The space to open preferences for.
|
||||
*/
|
||||
space: Room;
|
||||
|
||||
/**
|
||||
* Optional tab to open specifically, otherwise the dialog's internal default.
|
||||
*/
|
||||
initialTabId?: SpacePreferenceTab;
|
||||
}
|
|
@ -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 { ActionPayload } from "../payloads";
|
||||
import { Action } from "../actions";
|
||||
|
||||
export interface OpenSpaceSettingsPayload extends ActionPayload {
|
||||
action: Action.OpenSpaceSettings;
|
||||
|
||||
/**
|
||||
* The space to open settings for.
|
||||
*/
|
||||
space: Room;
|
||||
}
|
|
@ -24,6 +24,8 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
|
|||
import { Action } from "../dispatcher/actions";
|
||||
import ReportEventDialog from "../components/views/dialogs/ReportEventDialog";
|
||||
import TabbedIntegrationManagerDialog from "../components/views/dialogs/TabbedIntegrationManagerDialog";
|
||||
import SpacePreferencesDialog from "../components/views/dialogs/SpacePreferencesDialog";
|
||||
import SpaceSettingsDialog from "../components/views/dialogs/SpaceSettingsDialog";
|
||||
|
||||
/**
|
||||
* Auxiliary class to listen for dialog opening over the dispatcher and
|
||||
|
@ -77,6 +79,18 @@ export class DialogOpener {
|
|||
'mx_TabbedIntegrationManagerDialog',
|
||||
);
|
||||
break;
|
||||
case Action.OpenSpacePreferences:
|
||||
Modal.createTrackedDialog("Space preferences", "", SpacePreferencesDialog, {
|
||||
initialTabId: payload.initalTabId,
|
||||
space: payload.space,
|
||||
}, null, false, true);
|
||||
break;
|
||||
case Action.OpenSpaceSettings:
|
||||
Modal.createTrackedDialog("Space Settings", "", SpaceSettingsDialog, {
|
||||
matrixClient: payload.space.client,
|
||||
space: payload.space,
|
||||
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
|||
|
||||
import { calculateRoomVia } from "./permalinks/Permalinks";
|
||||
import Modal from "../Modal";
|
||||
import SpaceSettingsDialog from "../components/views/dialogs/SpaceSettingsDialog";
|
||||
import AddExistingToSpaceDialog from "../components/views/dialogs/AddExistingToSpaceDialog";
|
||||
import CreateRoomDialog from "../components/views/dialogs/CreateRoomDialog";
|
||||
import createRoom, { IOpts } from "../createRoom";
|
||||
|
@ -35,11 +34,13 @@ import defaultDispatcher from "../dispatcher/dispatcher";
|
|||
import { RoomViewStore } from "../stores/RoomViewStore";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
import Spinner from "../components/views/elements/Spinner";
|
||||
import SpacePreferencesDialog, { SpacePreferenceTab } from "../components/views/dialogs/SpacePreferencesDialog";
|
||||
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";
|
||||
|
||||
export const shouldShowSpaceSettings = (space: Room) => {
|
||||
const userId = space.client.getUserId();
|
||||
|
@ -59,12 +60,12 @@ export const makeSpaceParentEvent = (room: Room, canonical = false) => ({
|
|||
state_key: room.roomId,
|
||||
});
|
||||
|
||||
export const showSpaceSettings = (space: Room) => {
|
||||
Modal.createTrackedDialog("Space Settings", "", SpaceSettingsDialog, {
|
||||
matrixClient: space.client,
|
||||
export function showSpaceSettings(space: Room) {
|
||||
dis.dispatch<OpenSpaceSettingsPayload>({
|
||||
action: Action.OpenSpaceSettings,
|
||||
space,
|
||||
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export const showAddExistingRooms = (space: Room): void => {
|
||||
Modal.createTrackedDialog(
|
||||
|
@ -181,9 +182,10 @@ export const bulkSpaceBehaviour = async (
|
|||
}
|
||||
};
|
||||
|
||||
export const showSpacePreferences = (space: Room, initialTabId?: SpacePreferenceTab): Promise<unknown> => {
|
||||
return Modal.createTrackedDialog("Space preferences", "", SpacePreferencesDialog, {
|
||||
initialTabId,
|
||||
export function showSpacePreferences(space: Room, initialTabId?: SpacePreferenceTab) {
|
||||
dis.dispatch<OpenSpacePreferencesPayload>({
|
||||
action: Action.OpenSpacePreferences,
|
||||
space,
|
||||
}, null, false, true).finished;
|
||||
};
|
||||
initialTabId,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue