Support adding space-restricted joins on rooms not members of those spaces (#9017)

* Support adding space-restricted joins on rooms not members of those spaces

* add react dependencies

* Add snapshot test

* Fix snapshot stability

* Update snapshot

* Increase coverage

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Travis Ralston 2023-08-03 09:56:53 -06:00 committed by GitHub
parent bbab65a4cd
commit 771d7e95e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 349 additions and 4 deletions

View file

@ -93,11 +93,13 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
const [query, setQuery] = useState("");
const lcQuery = query.toLowerCase().trim();
const [spacesContainingRoom, otherEntries] = useMemo(() => {
const [spacesContainingRoom, otherJoinedSpaces, otherEntries] = useMemo(() => {
const parents = new Set<Room>();
addAllParents(parents, room);
return [
Array.from(parents),
SpaceStore.instance.spacePanelSpaces.filter((s) => !parents.has(s)),
filterBoolean(
selected.map((roomId) => {
const room = cli.getRoom(roomId);
@ -112,12 +114,13 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
];
}, [cli, selected, room]);
const [filteredSpacesContainingRoom, filteredOtherEntries] = useMemo(
const [filteredSpacesContainingRoom, filteredOtherJoinedSpaces, filteredOtherEntries] = useMemo(
() => [
spacesContainingRoom.filter((r) => r.name.toLowerCase().includes(lcQuery)),
otherJoinedSpaces.filter((r) => r.name.toLowerCase().includes(lcQuery)),
otherEntries.filter((r) => r.name.toLowerCase().includes(lcQuery)),
],
[spacesContainingRoom, otherEntries, lcQuery],
[spacesContainingRoom, otherJoinedSpaces, otherEntries, lcQuery],
);
const onChange = (checked: boolean, room: Room): void => {
@ -138,6 +141,8 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
);
}
const totalResults =
filteredSpacesContainingRoom.length + filteredOtherJoinedSpaces.length + filteredOtherEntries.length;
return (
<BaseDialog
title={_t("Select spaces")}
@ -206,7 +211,25 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
</div>
) : null}
{filteredSpacesContainingRoom.length + filteredOtherEntries.length < 1 ? (
{filteredOtherJoinedSpaces.length > 0 ? (
<div className="mx_ManageRestrictedJoinRuleDialog_section">
<h3>{_t("Other spaces you know")}</h3>
{filteredOtherJoinedSpaces.map((space) => {
return (
<Entry
key={space.roomId}
room={space}
checked={newSelected.has(space.roomId)}
onChange={(checked: boolean) => {
onChange(checked, space);
}}
/>
);
})}
</div>
) : null}
{totalResults < 1 ? (
<span className="mx_ManageRestrictedJoinRuleDialog_noResults">{_t("No results")}</span>
) : undefined}
</AutoHideScrollbar>

View file

@ -2970,6 +2970,7 @@
"Spaces you know that contain this room": "Spaces you know that contain this room",
"Other spaces or rooms you might not know": "Other spaces or rooms you might not know",
"These are likely ones other room admins are a part of.": "These are likely ones other room admins are a part of.",
"Other spaces you know": "Other spaces you know",
"Confirm by comparing the following with the User Settings in your other session:": "Confirm by comparing the following with the User Settings in your other session:",
"Confirm this user's session by comparing the following with their User Settings:": "Confirm this user's session by comparing the following with their User Settings:",
"Session name": "Session name",