Merge pull request #5926 from matrix-org/t3chguy/fix/17067
Fix issues with space hierarchy in layout and with incompatible serverspull/21833/head
commit
13a5d06e29
|
@ -26,7 +26,10 @@ limitations under the License.
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_SpaceRoomDirectory,
|
||||||
|
.mx_SpaceRoomView_landing {
|
||||||
.mx_Dialog_title {
|
.mx_Dialog_title {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
@ -56,65 +59,63 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_Dialog_content {
|
.mx_AccessibleButton_kind_link {
|
||||||
.mx_AccessibleButton_kind_link {
|
padding: 0;
|
||||||
padding: 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.mx_SearchBox {
|
.mx_SearchBox {
|
||||||
margin: 24px 0 16px;
|
margin: 24px 0 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_SpaceRoomDirectory_noResults {
|
.mx_SpaceRoomDirectory_noResults {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
font-size: $font-15px;
|
|
||||||
line-height: $font-24px;
|
|
||||||
color: $secondary-fg-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.mx_SpaceRoomDirectory_listHeader {
|
|
||||||
display: flex;
|
|
||||||
min-height: 32px;
|
|
||||||
align-items: center;
|
|
||||||
font-size: $font-15px;
|
font-size: $font-15px;
|
||||||
line-height: $font-24px;
|
line-height: $font-24px;
|
||||||
color: $primary-fg-color;
|
color: $secondary-fg-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mx_AccessibleButton {
|
.mx_SpaceRoomDirectory_listHeader {
|
||||||
padding: 2px 8px;
|
display: flex;
|
||||||
font-weight: normal;
|
min-height: 32px;
|
||||||
|
align-items: center;
|
||||||
|
font-size: $font-15px;
|
||||||
|
line-height: $font-24px;
|
||||||
|
color: $primary-fg-color;
|
||||||
|
|
||||||
& + .mx_AccessibleButton {
|
.mx_AccessibleButton {
|
||||||
margin-left: 16px;
|
padding: 2px 8px;
|
||||||
}
|
font-weight: normal;
|
||||||
}
|
|
||||||
|
|
||||||
> span {
|
& + .mx_AccessibleButton {
|
||||||
margin-left: auto;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_SpaceRoomDirectory_error {
|
> span {
|
||||||
position: relative;
|
margin-left: auto;
|
||||||
font-weight: $font-semi-bold;
|
}
|
||||||
color: $notice-primary-color;
|
}
|
||||||
font-size: $font-15px;
|
|
||||||
line-height: $font-18px;
|
|
||||||
margin: 20px auto 12px;
|
|
||||||
padding-left: 24px;
|
|
||||||
width: max-content;
|
|
||||||
|
|
||||||
&::before {
|
.mx_SpaceRoomDirectory_error {
|
||||||
content: "";
|
position: relative;
|
||||||
position: absolute;
|
font-weight: $font-semi-bold;
|
||||||
height: 16px;
|
color: $notice-primary-color;
|
||||||
width: 16px;
|
font-size: $font-15px;
|
||||||
left: 0;
|
line-height: $font-18px;
|
||||||
background-image: url("$(res)/img/element-icons/warning-badge.svg");
|
margin: 20px auto 12px;
|
||||||
}
|
padding-left: 24px;
|
||||||
|
width: max-content;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
height: 16px;
|
||||||
|
width: 16px;
|
||||||
|
left: 0;
|
||||||
|
background-image: url("$(res)/img/element-icons/warning-badge.svg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,11 +312,12 @@ export const HierarchyLevel = ({
|
||||||
|
|
||||||
// mutate argument refreshToken to force a reload
|
// mutate argument refreshToken to force a reload
|
||||||
export const useSpaceSummary = (cli: MatrixClient, space: Room, refreshToken?: any): [
|
export const useSpaceSummary = (cli: MatrixClient, space: Room, refreshToken?: any): [
|
||||||
|
null,
|
||||||
ISpaceSummaryRoom[],
|
ISpaceSummaryRoom[],
|
||||||
Map<string, Map<string, ISpaceSummaryEvent>>,
|
Map<string, Map<string, ISpaceSummaryEvent>>?,
|
||||||
Map<string, Set<string>>,
|
Map<string, Set<string>>?,
|
||||||
Map<string, Set<string>>,
|
Map<string, Set<string>>?,
|
||||||
] | [] => {
|
] | [Error] => {
|
||||||
// TODO pagination
|
// TODO pagination
|
||||||
return useAsyncMemo(async () => {
|
return useAsyncMemo(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -336,13 +337,12 @@ export const useSpaceSummary = (cli: MatrixClient, space: Room, refreshToken?: a
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return [data.rooms as ISpaceSummaryRoom[], parentChildRelations, viaMap, childParentRelations];
|
return [null, data.rooms as ISpaceSummaryRoom[], parentChildRelations, viaMap, childParentRelations];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e); // TODO
|
console.error(e); // TODO
|
||||||
|
return [e];
|
||||||
}
|
}
|
||||||
|
}, [space, refreshToken], [undefined]);
|
||||||
return [];
|
|
||||||
}, [space, refreshToken], []);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
|
export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
|
||||||
|
@ -358,7 +358,7 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
|
||||||
|
|
||||||
const [selected, setSelected] = useState(new Map<string, Set<string>>()); // Map<parentId, Set<childId>>
|
const [selected, setSelected] = useState(new Map<string, Set<string>>()); // Map<parentId, Set<childId>>
|
||||||
|
|
||||||
const [rooms, parentChildMap, viaMap, childParentMap] = useSpaceSummary(cli, space, refreshToken);
|
const [summaryError, rooms, parentChildMap, viaMap, childParentMap] = useSpaceSummary(cli, space, refreshToken);
|
||||||
|
|
||||||
const roomsMap = useMemo(() => {
|
const roomsMap = useMemo(() => {
|
||||||
if (!rooms) return null;
|
if (!rooms) return null;
|
||||||
|
@ -397,6 +397,10 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
|
||||||
const [removing, setRemoving] = useState(false);
|
const [removing, setRemoving] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
|
if (summaryError) {
|
||||||
|
return <p>{_t("Your server does not support showing space hierarchies.")}</p>;
|
||||||
|
}
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
if (roomsMap) {
|
if (roomsMap) {
|
||||||
const numRooms = Array.from(roomsMap.values()).filter(r => r.room_type !== RoomType.Space).length;
|
const numRooms = Array.from(roomsMap.values()).filter(r => r.room_type !== RoomType.Space).length;
|
||||||
|
@ -538,10 +542,8 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
|
||||||
{ children }
|
{ children }
|
||||||
</AutoHideScrollbar>
|
</AutoHideScrollbar>
|
||||||
</>;
|
</>;
|
||||||
} else if (!rooms) {
|
|
||||||
content = <Spinner />;
|
|
||||||
} else {
|
} else {
|
||||||
content = <p>{_t("Your server does not support showing space hierarchies.")}</p>;
|
content = <Spinner />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO loading state/error state
|
// TODO loading state/error state
|
||||||
|
|
|
@ -2638,6 +2638,7 @@
|
||||||
"%(count)s rooms|one": "%(count)s room",
|
"%(count)s rooms|one": "%(count)s room",
|
||||||
"This room is suggested as a good one to join": "This room is suggested as a good one to join",
|
"This room is suggested as a good one to join": "This room is suggested as a good one to join",
|
||||||
"Suggested": "Suggested",
|
"Suggested": "Suggested",
|
||||||
|
"Your server does not support showing space hierarchies.": "Your server does not support showing space hierarchies.",
|
||||||
"%(count)s rooms and %(numSpaces)s spaces|other": "%(count)s rooms and %(numSpaces)s spaces",
|
"%(count)s rooms and %(numSpaces)s spaces|other": "%(count)s rooms and %(numSpaces)s spaces",
|
||||||
"%(count)s rooms and %(numSpaces)s spaces|one": "%(count)s room and %(numSpaces)s spaces",
|
"%(count)s rooms and %(numSpaces)s spaces|one": "%(count)s room and %(numSpaces)s spaces",
|
||||||
"%(count)s rooms and 1 space|other": "%(count)s rooms and 1 space",
|
"%(count)s rooms and 1 space|other": "%(count)s rooms and 1 space",
|
||||||
|
@ -2648,7 +2649,6 @@
|
||||||
"Mark as suggested": "Mark as suggested",
|
"Mark as suggested": "Mark as suggested",
|
||||||
"No results found": "No results found",
|
"No results found": "No results found",
|
||||||
"You may want to try a different search or check for typos.": "You may want to try a different search or check for typos.",
|
"You may want to try a different search or check for typos.": "You may want to try a different search or check for typos.",
|
||||||
"Your server does not support showing space hierarchies.": "Your server does not support showing space hierarchies.",
|
|
||||||
"Search names and description": "Search names and description",
|
"Search names and description": "Search names and description",
|
||||||
"If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.": "If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.",
|
"If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.": "If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.",
|
||||||
"Create room": "Create room",
|
"Create room": "Create room",
|
||||||
|
|
Loading…
Reference in New Issue