2020-06-03 01:26:07 +00:00
|
|
|
/*
|
|
|
|
Copyright 2020 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 * as React from "react";
|
2020-06-24 02:59:26 +00:00
|
|
|
import { createRef } from "react";
|
2020-06-03 01:26:07 +00:00
|
|
|
import TagPanel from "./TagPanel";
|
2020-07-20 22:51:16 +00:00
|
|
|
import CustomRoomTagPanel from "./CustomRoomTagPanel";
|
2020-06-03 01:26:07 +00:00
|
|
|
import classNames from "classnames";
|
|
|
|
import dis from "../../dispatcher/dispatcher";
|
|
|
|
import { _t } from "../../languageHandler";
|
2020-07-17 21:27:49 +00:00
|
|
|
import RoomList from "../views/rooms/RoomList";
|
2020-07-17 21:46:46 +00:00
|
|
|
import { HEADER_HEIGHT } from "../views/rooms/RoomSublist";
|
2020-06-03 01:26:07 +00:00
|
|
|
import { Action } from "../../dispatcher/actions";
|
2020-06-26 01:38:11 +00:00
|
|
|
import UserMenu from "./UserMenu";
|
2020-06-09 02:33:21 +00:00
|
|
|
import RoomSearch from "./RoomSearch";
|
2020-07-17 21:32:06 +00:00
|
|
|
import RoomBreadcrumbs from "../views/rooms/RoomBreadcrumbs";
|
2020-06-08 23:11:58 +00:00
|
|
|
import { BreadcrumbsStore } from "../../stores/BreadcrumbsStore";
|
|
|
|
import { UPDATE_EVENT } from "../../stores/AsyncStore";
|
2020-06-22 19:09:42 +00:00
|
|
|
import ResizeNotifier from "../../utils/ResizeNotifier";
|
2020-06-26 02:35:40 +00:00
|
|
|
import SettingsStore from "../../settings/SettingsStore";
|
2020-07-17 21:11:34 +00:00
|
|
|
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../stores/room-list/RoomListStore";
|
2020-07-02 21:21:10 +00:00
|
|
|
import {Key} from "../../Keyboard";
|
2020-07-06 20:32:46 +00:00
|
|
|
import IndicatorScrollbar from "../structures/IndicatorScrollbar";
|
2020-07-17 17:57:38 +00:00
|
|
|
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
|
2020-07-21 21:02:59 +00:00
|
|
|
import { OwnProfileStore } from "../../stores/OwnProfileStore";
|
|
|
|
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
2020-08-17 17:20:00 +00:00
|
|
|
import RoomListNumResults from "../views/rooms/RoomListNumResults";
|
2020-09-24 08:28:49 +00:00
|
|
|
import LeftPanelWidget from "./LeftPanelWidget";
|
2020-06-03 01:26:07 +00:00
|
|
|
|
|
|
|
interface IProps {
|
2020-06-11 20:39:28 +00:00
|
|
|
isMinimized: boolean;
|
2020-06-22 19:09:42 +00:00
|
|
|
resizeNotifier: ResizeNotifier;
|
2020-06-03 01:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
2020-06-08 23:11:58 +00:00
|
|
|
showBreadcrumbs: boolean;
|
2020-06-26 02:35:40 +00:00
|
|
|
showTagPanel: boolean;
|
2020-06-03 01:26:07 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 00:14:02 +00:00
|
|
|
// List of CSS classes which should be included in keyboard navigation within the room list
|
|
|
|
const cssClasses = [
|
|
|
|
"mx_RoomSearch_input",
|
2020-09-18 16:13:45 +00:00
|
|
|
"mx_RoomSearch_minimizedHandle", // minimized <RoomSearch />
|
2020-07-17 21:46:46 +00:00
|
|
|
"mx_RoomSublist_headerText",
|
2020-07-17 21:43:29 +00:00
|
|
|
"mx_RoomTile",
|
2020-07-17 21:46:46 +00:00
|
|
|
"mx_RoomSublist_showNButton",
|
2020-07-06 00:14:02 +00:00
|
|
|
];
|
|
|
|
|
2020-07-17 21:22:18 +00:00
|
|
|
export default class LeftPanel extends React.Component<IProps, IState> {
|
2020-06-22 19:09:42 +00:00
|
|
|
private listContainerRef: React.RefObject<HTMLDivElement> = createRef();
|
2020-06-26 02:35:40 +00:00
|
|
|
private tagPanelWatcherRef: string;
|
2020-07-21 21:02:59 +00:00
|
|
|
private bgImageWatcherRef: string;
|
2020-07-02 21:21:10 +00:00
|
|
|
private focusedElement = null;
|
2020-07-07 17:33:32 +00:00
|
|
|
private isDoingStickyHeaders = false;
|
2020-06-22 19:09:42 +00:00
|
|
|
|
2020-06-03 01:26:07 +00:00
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2020-06-08 23:11:58 +00:00
|
|
|
showBreadcrumbs: BreadcrumbsStore.instance.visible,
|
2020-06-26 02:35:40 +00:00
|
|
|
showTagPanel: SettingsStore.getValue('TagPanel.enableTagPanel'),
|
2020-06-03 01:26:07 +00:00
|
|
|
};
|
2020-06-08 23:11:58 +00:00
|
|
|
|
|
|
|
BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
2020-07-01 15:05:27 +00:00
|
|
|
RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
2020-07-21 21:02:59 +00:00
|
|
|
OwnProfileStore.instance.on(UPDATE_EVENT, this.onBackgroundImageUpdate);
|
|
|
|
this.bgImageWatcherRef = SettingsStore.watchSetting(
|
|
|
|
"RoomList.backgroundImage", null, this.onBackgroundImageUpdate);
|
2020-06-26 02:35:40 +00:00
|
|
|
this.tagPanelWatcherRef = SettingsStore.watchSetting("TagPanel.enableTagPanel", null, () => {
|
|
|
|
this.setState({showTagPanel: SettingsStore.getValue("TagPanel.enableTagPanel")});
|
|
|
|
});
|
2020-06-22 19:09:42 +00:00
|
|
|
|
|
|
|
// We watch the middle panel because we don't actually get resized, the middle panel does.
|
|
|
|
// We listen to the noisy channel to avoid choppy reaction times.
|
|
|
|
this.props.resizeNotifier.on("middlePanelResizedNoisy", this.onResize);
|
2020-06-08 23:11:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
2020-06-26 02:35:40 +00:00
|
|
|
SettingsStore.unwatchSetting(this.tagPanelWatcherRef);
|
2020-07-21 21:02:59 +00:00
|
|
|
SettingsStore.unwatchSetting(this.bgImageWatcherRef);
|
2020-06-08 23:11:58 +00:00
|
|
|
BreadcrumbsStore.instance.off(UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
2020-07-01 15:05:27 +00:00
|
|
|
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
2020-07-21 21:02:59 +00:00
|
|
|
OwnProfileStore.instance.off(UPDATE_EVENT, this.onBackgroundImageUpdate);
|
2020-06-22 19:09:42 +00:00
|
|
|
this.props.resizeNotifier.off("middlePanelResizedNoisy", this.onResize);
|
2020-06-03 01:26:07 +00:00
|
|
|
}
|
|
|
|
|
2020-06-09 02:33:21 +00:00
|
|
|
private onExplore = () => {
|
|
|
|
dis.fire(Action.ViewRoomDirectory);
|
2020-06-03 01:26:07 +00:00
|
|
|
};
|
|
|
|
|
2020-06-08 23:11:58 +00:00
|
|
|
private onBreadcrumbsUpdate = () => {
|
|
|
|
const newVal = BreadcrumbsStore.instance.visible;
|
|
|
|
if (newVal !== this.state.showBreadcrumbs) {
|
|
|
|
this.setState({showBreadcrumbs: newVal});
|
2020-07-14 02:08:12 +00:00
|
|
|
|
|
|
|
// Update the sticky headers too as the breadcrumbs will be popping in or out.
|
|
|
|
if (!this.listContainerRef.current) return; // ignore: no headers to sticky
|
|
|
|
this.handleStickyHeaders(this.listContainerRef.current);
|
2020-06-08 23:11:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-21 21:02:59 +00:00
|
|
|
private onBackgroundImageUpdate = () => {
|
|
|
|
// Note: we do this in the LeftPanel as it uses this variable most prominently.
|
|
|
|
const avatarSize = 32; // arbitrary
|
|
|
|
let avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);
|
|
|
|
const settingBgMxc = SettingsStore.getValue("RoomList.backgroundImage");
|
|
|
|
if (settingBgMxc) {
|
|
|
|
avatarUrl = MatrixClientPeg.get().mxcUrlToHttp(settingBgMxc, avatarSize, avatarSize);
|
|
|
|
}
|
|
|
|
const avatarUrlProp = `url(${avatarUrl})`;
|
|
|
|
if (document.body.style.getPropertyValue("--avatar-url") !== avatarUrlProp) {
|
|
|
|
document.body.style.setProperty("--avatar-url", avatarUrlProp);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-22 19:09:42 +00:00
|
|
|
private handleStickyHeaders(list: HTMLDivElement) {
|
2020-07-07 17:33:32 +00:00
|
|
|
if (this.isDoingStickyHeaders) return;
|
|
|
|
this.isDoingStickyHeaders = true;
|
2020-07-08 18:17:51 +00:00
|
|
|
window.requestAnimationFrame(() => {
|
2020-07-07 17:33:32 +00:00
|
|
|
this.doStickyHeaders(list);
|
|
|
|
this.isDoingStickyHeaders = false;
|
2020-07-08 18:17:51 +00:00
|
|
|
});
|
2020-07-07 17:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private doStickyHeaders(list: HTMLDivElement) {
|
2020-07-08 20:36:55 +00:00
|
|
|
const topEdge = list.scrollTop;
|
|
|
|
const bottomEdge = list.offsetHeight + list.scrollTop;
|
2020-07-17 21:46:46 +00:00
|
|
|
const sublists = list.querySelectorAll<HTMLDivElement>(".mx_RoomSublist");
|
2020-06-13 17:54:40 +00:00
|
|
|
|
2020-09-23 09:47:51 +00:00
|
|
|
const headerRightMargin = 15; // calculated from margins and widths to align with non-sticky tiles
|
2020-07-08 20:36:55 +00:00
|
|
|
const headerStickyWidth = list.clientWidth - headerRightMargin;
|
2020-06-13 17:54:40 +00:00
|
|
|
|
2020-07-08 20:53:52 +00:00
|
|
|
// We track which styles we want on a target before making the changes to avoid
|
|
|
|
// excessive layout updates.
|
|
|
|
const targetStyles = new Map<HTMLDivElement, {
|
|
|
|
stickyTop?: boolean;
|
|
|
|
stickyBottom?: boolean;
|
|
|
|
makeInvisible?: boolean;
|
|
|
|
}>();
|
|
|
|
|
2020-07-03 10:17:54 +00:00
|
|
|
let lastTopHeader;
|
2020-07-08 20:36:55 +00:00
|
|
|
let firstBottomHeader;
|
2020-06-13 17:54:40 +00:00
|
|
|
for (const sublist of sublists) {
|
2020-07-17 21:46:46 +00:00
|
|
|
const header = sublist.querySelector<HTMLDivElement>(".mx_RoomSublist_stickable");
|
2020-07-08 08:21:33 +00:00
|
|
|
header.style.removeProperty("display"); // always clear display:none first
|
2020-06-13 17:54:40 +00:00
|
|
|
|
2020-07-08 20:36:55 +00:00
|
|
|
// When an element is <=40% off screen, make it take over
|
|
|
|
const offScreenFactor = 0.4;
|
|
|
|
const isOffTop = (sublist.offsetTop + (offScreenFactor * HEADER_HEIGHT)) <= topEdge;
|
|
|
|
const isOffBottom = (sublist.offsetTop + (offScreenFactor * HEADER_HEIGHT)) >= bottomEdge;
|
|
|
|
|
|
|
|
if (isOffTop || sublist === sublists[0]) {
|
2020-07-08 20:53:52 +00:00
|
|
|
targetStyles.set(header, { stickyTop: true });
|
2020-07-03 10:17:54 +00:00
|
|
|
if (lastTopHeader) {
|
|
|
|
lastTopHeader.style.display = "none";
|
2020-07-08 20:53:52 +00:00
|
|
|
targetStyles.set(lastTopHeader, { makeInvisible: true });
|
2020-07-03 10:17:54 +00:00
|
|
|
}
|
|
|
|
lastTopHeader = header;
|
2020-07-08 20:36:55 +00:00
|
|
|
} else if (isOffBottom && !firstBottomHeader) {
|
2020-07-08 20:53:52 +00:00
|
|
|
targetStyles.set(header, { stickyBottom: true });
|
2020-07-08 20:36:55 +00:00
|
|
|
firstBottomHeader = header;
|
2020-06-13 17:54:40 +00:00
|
|
|
} else {
|
2020-07-08 20:53:52 +00:00
|
|
|
targetStyles.set(header, {}); // nothing == clear
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run over the style changes and make them reality. We check to see if we're about to
|
|
|
|
// cause a no-op update, as adding/removing properties that are/aren't there cause
|
|
|
|
// layout updates.
|
|
|
|
for (const header of targetStyles.keys()) {
|
|
|
|
const style = targetStyles.get(header);
|
|
|
|
|
|
|
|
if (style.makeInvisible) {
|
|
|
|
// we will have already removed the 'display: none', so add it back.
|
|
|
|
header.style.display = "none";
|
|
|
|
continue; // nothing else to do, even if sticky somehow
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style.stickyTop) {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (!header.classList.contains("mx_RoomSublist_headerContainer_stickyTop")) {
|
|
|
|
header.classList.add("mx_RoomSublist_headerContainer_stickyTop");
|
2020-07-08 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const newTop = `${list.parentElement.offsetTop}px`;
|
|
|
|
if (header.style.top !== newTop) {
|
|
|
|
header.style.top = newTop;
|
|
|
|
}
|
2020-07-13 20:24:43 +00:00
|
|
|
} else {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (header.classList.contains("mx_RoomSublist_headerContainer_stickyTop")) {
|
|
|
|
header.classList.remove("mx_RoomSublist_headerContainer_stickyTop");
|
2020-07-13 20:24:43 +00:00
|
|
|
}
|
|
|
|
if (header.style.top) {
|
|
|
|
header.style.removeProperty('top');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style.stickyBottom) {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (!header.classList.contains("mx_RoomSublist_headerContainer_stickyBottom")) {
|
|
|
|
header.classList.add("mx_RoomSublist_headerContainer_stickyBottom");
|
2020-07-08 20:53:52 +00:00
|
|
|
}
|
2020-09-23 10:00:19 +00:00
|
|
|
|
|
|
|
const offset = window.innerHeight - (list.parentElement.offsetTop + list.parentElement.offsetHeight);
|
|
|
|
const newBottom = `${offset}px`;
|
|
|
|
if (header.style.bottom !== newBottom) {
|
|
|
|
header.style.bottom = newBottom;
|
|
|
|
}
|
2020-07-13 20:24:43 +00:00
|
|
|
} else {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (header.classList.contains("mx_RoomSublist_headerContainer_stickyBottom")) {
|
|
|
|
header.classList.remove("mx_RoomSublist_headerContainer_stickyBottom");
|
2020-07-13 20:24:43 +00:00
|
|
|
}
|
2020-09-23 10:00:19 +00:00
|
|
|
if (header.style.bottom) {
|
|
|
|
header.style.removeProperty('bottom');
|
|
|
|
}
|
2020-07-08 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (style.stickyTop || style.stickyBottom) {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (!header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
|
|
|
header.classList.add("mx_RoomSublist_headerContainer_sticky");
|
2020-07-08 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const newWidth = `${headerStickyWidth}px`;
|
|
|
|
if (header.style.width !== newWidth) {
|
|
|
|
header.style.width = newWidth;
|
|
|
|
}
|
|
|
|
} else if (!style.stickyTop && !style.stickyBottom) {
|
2020-07-17 21:46:46 +00:00
|
|
|
if (header.classList.contains("mx_RoomSublist_headerContainer_sticky")) {
|
|
|
|
header.classList.remove("mx_RoomSublist_headerContainer_sticky");
|
2020-07-08 20:53:52 +00:00
|
|
|
}
|
|
|
|
if (header.style.width) {
|
|
|
|
header.style.removeProperty('width');
|
|
|
|
}
|
2020-06-13 17:54:40 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-08 12:49:38 +00:00
|
|
|
|
|
|
|
// add appropriate sticky classes to wrapper so it has
|
|
|
|
// the necessary top/bottom padding to put the sticky header in
|
2020-07-17 21:22:18 +00:00
|
|
|
const listWrapper = list.parentElement; // .mx_LeftPanel_roomListWrapper
|
2020-07-08 12:49:38 +00:00
|
|
|
if (lastTopHeader) {
|
2020-07-17 21:22:18 +00:00
|
|
|
listWrapper.classList.add("mx_LeftPanel_roomListWrapper_stickyTop");
|
2020-07-08 12:49:38 +00:00
|
|
|
} else {
|
2020-07-17 21:22:18 +00:00
|
|
|
listWrapper.classList.remove("mx_LeftPanel_roomListWrapper_stickyTop");
|
2020-07-08 12:49:38 +00:00
|
|
|
}
|
2020-07-08 20:36:55 +00:00
|
|
|
if (firstBottomHeader) {
|
2020-07-17 21:22:18 +00:00
|
|
|
listWrapper.classList.add("mx_LeftPanel_roomListWrapper_stickyBottom");
|
2020-07-08 20:36:55 +00:00
|
|
|
} else {
|
2020-07-17 21:22:18 +00:00
|
|
|
listWrapper.classList.remove("mx_LeftPanel_roomListWrapper_stickyBottom");
|
2020-07-08 12:49:38 +00:00
|
|
|
}
|
2020-06-22 19:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private onScroll = (ev: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
const list = ev.target as HTMLDivElement;
|
|
|
|
this.handleStickyHeaders(list);
|
|
|
|
};
|
|
|
|
|
|
|
|
private onResize = () => {
|
|
|
|
if (!this.listContainerRef.current) return; // ignore: no headers to sticky
|
|
|
|
this.handleStickyHeaders(this.listContainerRef.current);
|
2020-06-13 17:54:40 +00:00
|
|
|
};
|
|
|
|
|
2020-07-02 21:21:10 +00:00
|
|
|
private onFocus = (ev: React.FocusEvent) => {
|
|
|
|
this.focusedElement = ev.target;
|
|
|
|
};
|
|
|
|
|
|
|
|
private onBlur = () => {
|
|
|
|
this.focusedElement = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
private onKeyDown = (ev: React.KeyboardEvent) => {
|
|
|
|
if (!this.focusedElement) return;
|
|
|
|
|
|
|
|
switch (ev.key) {
|
|
|
|
case Key.ARROW_UP:
|
|
|
|
case Key.ARROW_DOWN:
|
2020-07-03 13:49:25 +00:00
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
|
|
|
this.onMoveFocus(ev.key === Key.ARROW_UP);
|
2020-07-02 21:21:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-12 18:06:47 +00:00
|
|
|
private onEnter = () => {
|
2020-07-17 21:43:29 +00:00
|
|
|
const firstRoom = this.listContainerRef.current.querySelector<HTMLDivElement>(".mx_RoomTile");
|
2020-07-12 18:06:47 +00:00
|
|
|
if (firstRoom) {
|
|
|
|
firstRoom.click();
|
2020-07-16 05:31:06 +00:00
|
|
|
return true; // to get the field to clear
|
2020-07-12 18:06:47 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-03 13:49:25 +00:00
|
|
|
private onMoveFocus = (up: boolean) => {
|
2020-07-02 21:21:10 +00:00
|
|
|
let element = this.focusedElement;
|
|
|
|
|
|
|
|
let descending = false; // are we currently descending or ascending through the DOM tree?
|
2020-07-03 13:49:25 +00:00
|
|
|
let classes: DOMTokenList;
|
2020-07-02 21:21:10 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
const child = up ? element.lastElementChild : element.firstElementChild;
|
|
|
|
const sibling = up ? element.previousElementSibling : element.nextElementSibling;
|
|
|
|
|
|
|
|
if (descending) {
|
|
|
|
if (child) {
|
|
|
|
element = child;
|
|
|
|
} else if (sibling) {
|
|
|
|
element = sibling;
|
|
|
|
} else {
|
|
|
|
descending = false;
|
|
|
|
element = element.parentElement;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (sibling) {
|
|
|
|
element = sibling;
|
|
|
|
descending = true;
|
|
|
|
} else {
|
|
|
|
element = element.parentElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element) {
|
|
|
|
classes = element.classList;
|
|
|
|
}
|
2020-07-06 00:14:02 +00:00
|
|
|
} while (element && !cssClasses.some(c => classes.contains(c)));
|
2020-07-02 21:21:10 +00:00
|
|
|
|
|
|
|
if (element) {
|
|
|
|
element.focus();
|
|
|
|
this.focusedElement = element;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-04 22:34:04 +00:00
|
|
|
private renderHeader(): React.ReactNode {
|
2020-07-13 12:52:50 +00:00
|
|
|
return (
|
2020-07-17 21:22:18 +00:00
|
|
|
<div className="mx_LeftPanel_userHeader">
|
2020-07-13 12:52:50 +00:00
|
|
|
<UserMenu isMinimized={this.props.isMinimized} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private renderBreadcrumbs(): React.ReactNode {
|
2020-07-06 20:32:46 +00:00
|
|
|
if (this.state.showBreadcrumbs && !this.props.isMinimized) {
|
2020-07-13 12:52:50 +00:00
|
|
|
return (
|
2020-07-06 20:32:46 +00:00
|
|
|
<IndicatorScrollbar
|
2020-07-17 21:22:18 +00:00
|
|
|
className="mx_LeftPanel_breadcrumbsContainer mx_AutoHideScrollbar"
|
2020-07-06 20:32:46 +00:00
|
|
|
verticalScrollsHorizontally={true}
|
2020-07-18 11:19:03 +00:00
|
|
|
// Firefox sometimes makes this element focusable due to
|
|
|
|
// overflow:scroll;, so force it out of tab order.
|
|
|
|
tabIndex={-1}
|
2020-07-06 20:32:46 +00:00
|
|
|
>
|
2020-07-17 21:32:06 +00:00
|
|
|
<RoomBreadcrumbs />
|
2020-07-06 20:32:46 +00:00
|
|
|
</IndicatorScrollbar>
|
2020-06-08 23:11:58 +00:00
|
|
|
);
|
|
|
|
}
|
2020-06-04 22:34:04 +00:00
|
|
|
}
|
2020-06-03 01:26:07 +00:00
|
|
|
|
2020-06-09 02:33:21 +00:00
|
|
|
private renderSearchExplore(): React.ReactNode {
|
|
|
|
return (
|
2020-07-05 00:07:46 +00:00
|
|
|
<div
|
2020-07-17 21:22:18 +00:00
|
|
|
className="mx_LeftPanel_filterContainer"
|
2020-07-05 00:07:46 +00:00
|
|
|
onFocus={this.onFocus}
|
|
|
|
onBlur={this.onBlur}
|
|
|
|
onKeyDown={this.onKeyDown}
|
|
|
|
>
|
2020-07-02 21:21:10 +00:00
|
|
|
<RoomSearch
|
|
|
|
isMinimized={this.props.isMinimized}
|
|
|
|
onVerticalArrow={this.onKeyDown}
|
2020-07-12 18:06:47 +00:00
|
|
|
onEnter={this.onEnter}
|
2020-07-02 21:21:10 +00:00
|
|
|
/>
|
2020-07-17 17:57:38 +00:00
|
|
|
<AccessibleTooltipButton
|
2020-07-17 21:22:18 +00:00
|
|
|
className="mx_LeftPanel_exploreButton"
|
2020-06-09 02:33:21 +00:00
|
|
|
onClick={this.onExplore}
|
2020-07-05 00:07:46 +00:00
|
|
|
title={_t("Explore rooms")}
|
2020-06-09 02:33:21 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-04 22:34:04 +00:00
|
|
|
public render(): React.ReactNode {
|
2020-06-26 02:35:40 +00:00
|
|
|
const tagPanel = !this.state.showTagPanel ? null : (
|
2020-07-17 21:22:18 +00:00
|
|
|
<div className="mx_LeftPanel_tagPanelContainer">
|
2020-08-29 00:11:08 +00:00
|
|
|
<TagPanel />
|
2020-08-17 19:12:18 +00:00
|
|
|
{SettingsStore.getValue("feature_custom_tags") ? <CustomRoomTagPanel /> : null}
|
2020-06-03 01:26:07 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2020-07-17 21:27:49 +00:00
|
|
|
const roomList = <RoomList
|
2020-07-02 21:21:10 +00:00
|
|
|
onKeyDown={this.onKeyDown}
|
2020-06-03 01:26:07 +00:00
|
|
|
resizeNotifier={null}
|
|
|
|
collapsed={false}
|
2020-07-02 21:21:10 +00:00
|
|
|
onFocus={this.onFocus}
|
|
|
|
onBlur={this.onBlur}
|
2020-06-11 20:39:28 +00:00
|
|
|
isMinimized={this.props.isMinimized}
|
2020-07-06 20:05:06 +00:00
|
|
|
onResize={this.onResize}
|
2020-06-03 01:26:07 +00:00
|
|
|
/>;
|
|
|
|
|
|
|
|
const containerClasses = classNames({
|
2020-07-17 21:22:18 +00:00
|
|
|
"mx_LeftPanel": true,
|
|
|
|
"mx_LeftPanel_hasTagPanel": !!tagPanel,
|
|
|
|
"mx_LeftPanel_minimized": this.props.isMinimized,
|
2020-06-03 01:26:07 +00:00
|
|
|
});
|
|
|
|
|
2020-07-01 14:15:18 +00:00
|
|
|
const roomListClasses = classNames(
|
2020-07-17 21:22:18 +00:00
|
|
|
"mx_LeftPanel_actualRoomListContainer",
|
2020-06-30 22:52:13 +00:00
|
|
|
"mx_AutoHideScrollbar",
|
|
|
|
);
|
|
|
|
|
2020-06-03 01:26:07 +00:00
|
|
|
return (
|
|
|
|
<div className={containerClasses}>
|
|
|
|
{tagPanel}
|
2020-07-17 21:22:18 +00:00
|
|
|
<aside className="mx_LeftPanel_roomListContainer">
|
2020-06-04 22:34:04 +00:00
|
|
|
{this.renderHeader()}
|
2020-06-09 02:33:21 +00:00
|
|
|
{this.renderSearchExplore()}
|
2020-07-13 12:52:50 +00:00
|
|
|
{this.renderBreadcrumbs()}
|
2020-08-17 17:20:00 +00:00
|
|
|
<RoomListNumResults />
|
2020-07-17 21:22:18 +00:00
|
|
|
<div className="mx_LeftPanel_roomListWrapper">
|
2020-07-08 12:49:04 +00:00
|
|
|
<div
|
|
|
|
className={roomListClasses}
|
|
|
|
onScroll={this.onScroll}
|
|
|
|
ref={this.listContainerRef}
|
|
|
|
// Firefox sometimes makes this element focusable due to
|
|
|
|
// overflow:scroll;, so force it out of tab order.
|
|
|
|
tabIndex={-1}
|
|
|
|
>
|
|
|
|
{roomList}
|
|
|
|
</div>
|
2020-07-02 21:21:10 +00:00
|
|
|
</div>
|
2020-09-24 08:28:49 +00:00
|
|
|
{ !this.props.isMinimized && <LeftPanelWidget onResize={this.onResize} /> }
|
2020-06-03 01:26:07 +00:00
|
|
|
</aside>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|