mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding home button
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
d6d66682f6
commit
a709f7ae43
@ -28,6 +28,9 @@ import { webContents } from "@electron/remote";
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { ipcRendererOn } from "../../../common/ipc";
|
import { ipcRendererOn } from "../../../common/ipc";
|
||||||
import { watchHistoryState } from "../../remote-helpers/history-updater";
|
import { watchHistoryState } from "../../remote-helpers/history-updater";
|
||||||
|
import { isActiveRoute, navigate } from "../../navigation";
|
||||||
|
import { catalogRoute, catalogURL } from "../../../common/routes";
|
||||||
|
import { previousActiveTab } from "../+catalog";
|
||||||
|
|
||||||
interface Props extends React.HTMLAttributes<any> {
|
interface Props extends React.HTMLAttributes<any> {
|
||||||
}
|
}
|
||||||
@ -68,6 +71,10 @@ export const TopBar = observer(({ children, ...rest }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const goHome = () => {
|
||||||
|
navigate(`${catalogURL()}/${previousActiveTab.get()}`);
|
||||||
|
};
|
||||||
|
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
webContents.getAllWebContents().find((webContent) => webContent.getType() === "window")?.goBack();
|
webContents.getAllWebContents().find((webContent) => webContent.getType() === "window")?.goBack();
|
||||||
};
|
};
|
||||||
@ -85,6 +92,13 @@ export const TopBar = observer(({ children, ...rest }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.topBar} {...rest}>
|
<div className={styles.topBar} {...rest}>
|
||||||
<div className={styles.history}>
|
<div className={styles.history}>
|
||||||
|
<Icon
|
||||||
|
data-testid="home-buttton"
|
||||||
|
material="home"
|
||||||
|
className="ml-5"
|
||||||
|
onClick={goHome}
|
||||||
|
disabled={isActiveRoute(catalogRoute)}
|
||||||
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
data-testid="history-back"
|
data-testid="history-back"
|
||||||
material="arrow_back"
|
material="arrow_back"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user