Space preferences for whether or not you see DMs in a Space (#7250)
This commit is contained in:
parent
5ee356daaa
commit
39c4b78371
22 changed files with 911 additions and 350 deletions
|
@ -29,6 +29,7 @@ import {
|
|||
showCreateNewRoom,
|
||||
showCreateNewSubspace,
|
||||
showSpaceInvite,
|
||||
showSpacePreferences,
|
||||
showSpaceSettings,
|
||||
} from "../../../utils/space";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
|
@ -166,6 +167,14 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
</>;
|
||||
}
|
||||
|
||||
const onPreferencesClick = (ev: ButtonEvent) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
showSpacePreferences(space);
|
||||
onFinished();
|
||||
};
|
||||
|
||||
const onExploreRoomsClick = (ev: ButtonEvent) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
@ -193,6 +202,11 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
|||
label={canAddRooms ? _t("Manage & explore rooms") : _t("Explore rooms")}
|
||||
onClick={onExploreRoomsClick}
|
||||
/>
|
||||
<IconizedContextMenuOption
|
||||
iconClassName="mx_SpacePanel_iconPreferences"
|
||||
label={_t("Preferences")}
|
||||
onClick={onPreferencesClick}
|
||||
/>
|
||||
{ settingsOption }
|
||||
{ leaveOption }
|
||||
{ devtoolsOption }
|
||||
|
|
99
src/components/views/dialogs/SpacePreferencesDialog.tsx
Normal file
99
src/components/views/dialogs/SpacePreferencesDialog.tsx
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
Copyright 2021 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 React, { ChangeEvent } from "react";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
import { _t, _td } from '../../../languageHandler';
|
||||
import BaseDialog from "../dialogs/BaseDialog";
|
||||
import { IDialogProps } from "./IDialogProps";
|
||||
import TabbedView, { Tab } from "../../structures/TabbedView";
|
||||
import StyledCheckbox from "../elements/StyledCheckbox";
|
||||
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",
|
||||
}
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
space: Room;
|
||||
initialTabId?: SpacePreferenceTab;
|
||||
}
|
||||
|
||||
const SpacePreferencesAppearanceTab = ({ space }: Pick<IProps, "space">) => {
|
||||
const showPeople = useSettingValue("Spaces.showPeopleInSpace", space.roomId);
|
||||
|
||||
return (
|
||||
<div className="mx_SettingsTab">
|
||||
<div className="mx_SettingsTab_heading">{ _t("Sections to show") }</div>
|
||||
|
||||
<div className="mx_SettingsTab_section">
|
||||
<StyledCheckbox
|
||||
checked={!!showPeople}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||
SettingsStore.setValue(
|
||||
"Spaces.showPeopleInSpace",
|
||||
space.roomId,
|
||||
SettingLevel.ROOM_ACCOUNT,
|
||||
!showPeople,
|
||||
);
|
||||
}}
|
||||
>
|
||||
{ _t("People") }
|
||||
</StyledCheckbox>
|
||||
<p>
|
||||
{ _t("This groups your chats with members of this space. " +
|
||||
"Turning this off will hide those chats from your view of %(spaceName)s.", {
|
||||
spaceName: space.name,
|
||||
}) }
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SpacePreferencesDialog: React.FC<IProps> = ({ space, initialTabId, onFinished }) => {
|
||||
const tabs = [
|
||||
new Tab(
|
||||
SpacePreferenceTab.Appearance,
|
||||
_td("Appearance"),
|
||||
"mx_RoomSettingsDialog_notificationsIcon",
|
||||
<SpacePreferencesAppearanceTab space={space} />,
|
||||
),
|
||||
];
|
||||
|
||||
return (
|
||||
<BaseDialog
|
||||
className="mx_SpacePreferencesDialog"
|
||||
hasCancel
|
||||
onFinished={onFinished}
|
||||
title={_t("Preferences")}
|
||||
fixedWidth={false}
|
||||
>
|
||||
<h4>
|
||||
<RoomName room={space} />
|
||||
</h4>
|
||||
<div className="mx_SettingsDialog_content">
|
||||
<TabbedView tabs={tabs} initialTabId={initialTabId} />
|
||||
</div>
|
||||
</BaseDialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default SpacePreferencesDialog;
|
|
@ -52,7 +52,7 @@ export enum UserTab {
|
|||
}
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
initialTabId?: string;
|
||||
initialTabId?: UserTab;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
|
|
|
@ -129,7 +129,7 @@ const NewRoomIntro = () => {
|
|||
let parentSpace: Room;
|
||||
if (
|
||||
SpaceStore.instance.activeSpaceRoom?.canInvite(cli.getUserId()) &&
|
||||
SpaceStore.instance.getSpaceFilteredRoomIds(SpaceStore.instance.activeSpace).has(room.roomId)
|
||||
SpaceStore.instance.isRoomInSpace(SpaceStore.instance.activeSpace, room.roomId)
|
||||
) {
|
||||
parentSpace = SpaceStore.instance.activeSpaceRoom;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import {
|
|||
SpaceKey,
|
||||
UPDATE_SUGGESTED_ROOMS,
|
||||
UPDATE_SELECTED_SPACE,
|
||||
isMetaSpace,
|
||||
} from "../../../stores/spaces";
|
||||
import { shouldShowSpaceInvite, showAddExistingRooms, showCreateNewRoom, showSpaceInvite } from "../../../utils/space";
|
||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
|
@ -62,6 +63,7 @@ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
|||
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
||||
import { ChevronFace, ContextMenuTooltipButton, useContextMenu } from "../../structures/ContextMenu";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
|
||||
interface IProps {
|
||||
onKeyDown: (ev: React.KeyboardEvent, state: IRovingTabIndexState) => void;
|
||||
|
@ -493,10 +495,10 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
|||
};
|
||||
|
||||
private onExplore = () => {
|
||||
if (this.props.activeSpace[0] === "!") {
|
||||
if (!isMetaSpace(this.props.activeSpace)) {
|
||||
defaultDispatcher.dispatch({
|
||||
action: "view_room",
|
||||
room_id: SpaceStore.instance.activeSpace,
|
||||
room_id: this.props.activeSpace,
|
||||
});
|
||||
} else {
|
||||
const initialText = RoomListStore.instance.getFirstNameFilterCondition()?.search;
|
||||
|
@ -611,7 +613,12 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
|||
if (
|
||||
(this.props.activeSpace === MetaSpace.Favourites && orderedTagId !== DefaultTagID.Favourite) ||
|
||||
(this.props.activeSpace === MetaSpace.People && orderedTagId !== DefaultTagID.DM) ||
|
||||
(this.props.activeSpace === MetaSpace.Orphans && orderedTagId === DefaultTagID.DM)
|
||||
(this.props.activeSpace === MetaSpace.Orphans && orderedTagId === DefaultTagID.DM) ||
|
||||
(
|
||||
!isMetaSpace(this.props.activeSpace) &&
|
||||
orderedTagId === DefaultTagID.DM &&
|
||||
!SettingsStore.getValue("Spaces.showPeopleInSpace", this.props.activeSpace)
|
||||
)
|
||||
) {
|
||||
alwaysVisible = false;
|
||||
}
|
||||
|
@ -668,7 +675,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
|||
kind="link"
|
||||
onClick={this.onExplore}
|
||||
>
|
||||
{ this.props.activeSpace[0] === "!" ? _t("Explore rooms") : _t("Explore all public rooms") }
|
||||
{ !isMetaSpace(this.props.activeSpace) ? _t("Explore rooms") : _t("Explore all public rooms") }
|
||||
</AccessibleButton>
|
||||
</div>;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
|||
);
|
||||
|
||||
this.state = {
|
||||
collapsed: collapsed,
|
||||
collapsed,
|
||||
childSpaces: this.childSpaces,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue