2021-03-02 10:34:28 +00:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2021-03-02 10:34:28 +00:00
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2021-03-02 10:34:28 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-06-08 16:33:47 +01:00
|
|
|
import React, { useMemo } from "react";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type Room, type MatrixClient } from "matrix-js-sdk/src/matrix";
|
2026-01-08 15:50:02 +00:00
|
|
|
import {
|
|
|
|
|
AdminIcon,
|
|
|
|
|
AdvancedSettingsIcon,
|
|
|
|
|
SettingsSolidIcon,
|
|
|
|
|
VisibilityOnIcon,
|
|
|
|
|
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
2021-03-02 10:34:28 +00:00
|
|
|
|
2021-06-08 16:33:47 +01:00
|
|
|
import { _t, _td } from "../../../languageHandler";
|
2021-03-02 10:34:28 +00:00
|
|
|
import BaseDialog from "./BaseDialog";
|
|
|
|
|
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
2021-06-08 16:33:47 +01:00
|
|
|
import { useDispatcher } from "../../../hooks/useDispatcher";
|
|
|
|
|
import TabbedView, { Tab } from "../../structures/TabbedView";
|
|
|
|
|
import SpaceSettingsGeneralTab from "../spaces/SpaceSettingsGeneralTab";
|
|
|
|
|
import SpaceSettingsVisibilityTab from "../spaces/SpaceSettingsVisibilityTab";
|
|
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2021-06-22 22:01:18 +01:00
|
|
|
import { UIFeature } from "../../../settings/UIFeature";
|
2021-06-08 16:33:47 +01:00
|
|
|
import AdvancedRoomSettingsTab from "../settings/tabs/room/AdvancedRoomSettingsTab";
|
2021-09-10 09:41:58 +01:00
|
|
|
import RolesRoomSettingsTab from "../settings/tabs/room/RolesRoomSettingsTab";
|
2022-02-22 11:04:27 +01:00
|
|
|
import { Action } from "../../../dispatcher/actions";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type NonEmptyArray } from "../../../@types/common";
|
2021-06-08 16:33:47 +01:00
|
|
|
|
|
|
|
|
export enum SpaceSettingsTab {
|
|
|
|
|
General = "SPACE_GENERAL_TAB",
|
|
|
|
|
Visibility = "SPACE_VISIBILITY_TAB",
|
2021-09-10 09:41:58 +01:00
|
|
|
Roles = "SPACE_ROLES_TAB",
|
2021-06-08 16:33:47 +01:00
|
|
|
Advanced = "SPACE_ADVANCED_TAB",
|
|
|
|
|
}
|
2021-03-02 10:34:28 +00:00
|
|
|
|
2023-02-28 10:31:48 +00:00
|
|
|
interface IProps {
|
2021-03-02 10:34:28 +00:00
|
|
|
matrixClient: MatrixClient;
|
|
|
|
|
space: Room;
|
2023-02-28 10:31:48 +00:00
|
|
|
onFinished(): void;
|
2021-03-02 10:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SpaceSettingsDialog: React.FC<IProps> = ({ matrixClient: cli, space, onFinished }) => {
|
2022-02-22 11:04:27 +01:00
|
|
|
useDispatcher(defaultDispatcher, (payload) => {
|
|
|
|
|
if (payload.action === Action.AfterLeaveRoom && payload.room_id === space.roomId) {
|
2023-02-28 10:31:48 +00:00
|
|
|
onFinished();
|
2021-03-02 10:34:28 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-08 16:33:47 +01:00
|
|
|
const tabs = useMemo(() => {
|
|
|
|
|
return [
|
|
|
|
|
new Tab(
|
|
|
|
|
SpaceSettingsTab.General,
|
2023-09-26 13:04:17 +01:00
|
|
|
_td("common|general"),
|
2025-12-15 09:52:50 +00:00
|
|
|
<SettingsSolidIcon />,
|
2023-02-28 10:31:48 +00:00
|
|
|
<SpaceSettingsGeneralTab matrixClient={cli} space={space} />,
|
2021-06-08 16:33:47 +01:00
|
|
|
),
|
|
|
|
|
new Tab(
|
|
|
|
|
SpaceSettingsTab.Visibility,
|
2023-09-26 13:04:17 +01:00
|
|
|
_td("room_settings|visibility|title"),
|
2025-12-15 09:52:50 +00:00
|
|
|
<VisibilityOnIcon />,
|
2021-09-09 10:56:21 +01:00
|
|
|
<SpaceSettingsVisibilityTab matrixClient={cli} space={space} closeSettingsFn={onFinished} />,
|
2021-06-08 16:33:47 +01:00
|
|
|
),
|
2021-09-10 09:41:58 +01:00
|
|
|
new Tab(
|
|
|
|
|
SpaceSettingsTab.Roles,
|
2023-09-21 09:11:26 +01:00
|
|
|
_td("room_settings|permissions|title"),
|
2025-12-15 09:52:50 +00:00
|
|
|
<AdminIcon />,
|
2023-04-27 13:20:02 +12:00
|
|
|
<RolesRoomSettingsTab room={space} />,
|
2021-09-10 09:41:58 +01:00
|
|
|
),
|
2021-06-08 16:33:47 +01:00
|
|
|
SettingsStore.getValue(UIFeature.AdvancedSettings)
|
|
|
|
|
? new Tab(
|
|
|
|
|
SpaceSettingsTab.Advanced,
|
2023-09-26 13:04:17 +01:00
|
|
|
_td("common|advanced"),
|
2026-01-08 15:50:02 +00:00
|
|
|
<AdvancedSettingsIcon />,
|
2023-04-27 13:20:02 +12:00
|
|
|
<AdvancedRoomSettingsTab room={space} closeSettingsFn={onFinished} />,
|
2021-06-08 16:33:47 +01:00
|
|
|
)
|
|
|
|
|
: null,
|
2023-04-27 12:55:29 +01:00
|
|
|
].filter(Boolean) as NonEmptyArray<Tab<SpaceSettingsTab>>;
|
2021-06-08 16:33:47 +01:00
|
|
|
}, [cli, space, onFinished]);
|
2021-03-02 10:34:28 +00:00
|
|
|
|
2024-05-03 16:01:01 +01:00
|
|
|
const [activeTabId, setActiveTabId] = React.useState(SpaceSettingsTab.General);
|
|
|
|
|
|
2021-03-02 10:34:28 +00:00
|
|
|
return (
|
|
|
|
|
<BaseDialog
|
2023-09-21 09:11:26 +01:00
|
|
|
title={_t("space_settings|title", { spaceName: space.name || _t("common|unnamed_space") })}
|
2021-03-02 10:34:28 +00:00
|
|
|
className="mx_SpaceSettingsDialog"
|
|
|
|
|
contentId="mx_SpaceSettingsDialog"
|
|
|
|
|
onFinished={onFinished}
|
|
|
|
|
fixedWidth={false}
|
2021-06-08 16:33:47 +01:00
|
|
|
>
|
2023-03-06 17:14:11 +00:00
|
|
|
<div className="mx_SpaceSettingsDialog_content" id="mx_SpaceSettingsDialog">
|
2024-05-03 16:01:01 +01:00
|
|
|
<TabbedView tabs={tabs} activeTabId={activeTabId} onChange={setActiveTabId} />
|
2021-03-02 10:34:28 +00:00
|
|
|
</div>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SpaceSettingsDialog;
|