Merge pull request #4771 from matrix-org/travis/room-list/home
Add a home button to the new room list menu when availablepull/21833/head
commit
36d911529d
|
@ -32,6 +32,8 @@ import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
|
||||||
import {getCustomTheme} from "../../theme";
|
import {getCustomTheme} from "../../theme";
|
||||||
import {getHostingLink} from "../../utils/HostingLink";
|
import {getHostingLink} from "../../utils/HostingLink";
|
||||||
import AccessibleButton, {ButtonEvent} from "../views/elements/AccessibleButton";
|
import AccessibleButton, {ButtonEvent} from "../views/elements/AccessibleButton";
|
||||||
|
import SdkConfig from "../../SdkConfig";
|
||||||
|
import {getHomePageUrl} from "../../utils/pages";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,10 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get hasHomePage(): boolean {
|
||||||
|
return !!getHomePageUrl(SdkConfig.get());
|
||||||
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
||||||
this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged);
|
this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged);
|
||||||
|
@ -147,6 +153,13 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
|
||||||
this.setState({menuDisplayed: false}); // also close the menu
|
this.setState({menuDisplayed: false}); // also close the menu
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onHomeClick = (ev: ButtonEvent) => {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
|
defaultDispatcher.dispatch({action: 'view_home_page'});
|
||||||
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
let contextMenu;
|
let contextMenu;
|
||||||
if (this.state.menuDisplayed) {
|
if (this.state.menuDisplayed) {
|
||||||
|
@ -172,6 +185,18 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let homeButton = null;
|
||||||
|
if (this.hasHomePage) {
|
||||||
|
homeButton = (
|
||||||
|
<li>
|
||||||
|
<AccessibleButton onClick={this.onHomeClick}>
|
||||||
|
<img src={require("../../../res/img/feather-customised/home.svg")} width={16} />
|
||||||
|
<span>{_t("Home")}</span>
|
||||||
|
</AccessibleButton>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const elementRect = this.buttonRef.current.getBoundingClientRect();
|
const elementRect = this.buttonRef.current.getBoundingClientRect();
|
||||||
contextMenu = (
|
contextMenu = (
|
||||||
<ContextMenu
|
<ContextMenu
|
||||||
|
@ -205,6 +230,7 @@ export default class UserMenuButton extends React.Component<IProps, IState> {
|
||||||
{hostingLink}
|
{hostingLink}
|
||||||
<div className="mx_IconizedContextMenu_optionList mx_IconizedContextMenu_optionList_notFirst">
|
<div className="mx_IconizedContextMenu_optionList mx_IconizedContextMenu_optionList_notFirst">
|
||||||
<ul>
|
<ul>
|
||||||
|
{homeButton}
|
||||||
<li>
|
<li>
|
||||||
<AccessibleButton onClick={(e) => this.onSettingsOpen(e, USER_NOTIFICATIONS_TAB)}>
|
<AccessibleButton onClick={(e) => this.onSettingsOpen(e, USER_NOTIFICATIONS_TAB)}>
|
||||||
<img src={require("../../../res/img/feather-customised/notifications.svg")} width={16} />
|
<img src={require("../../../res/img/feather-customised/notifications.svg")} width={16} />
|
||||||
|
|
Loading…
Reference in New Issue