Skip to content

Commit

Permalink
Add feature of going to default page by clicking bazarr icon
Browse files Browse the repository at this point in the history
  • Loading branch information
LASER-Yi committed Mar 29, 2021
1 parent 3744991 commit b1478da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
4 changes: 4 additions & 0 deletions frontend/src/@scss/global.scss
Expand Up @@ -20,6 +20,10 @@ td {
}
}

.cursor-pointer {
cursor: pointer;
}

.opacity-100 {
opacity: 100% !important;
}
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/App/Header.tsx
Expand Up @@ -29,7 +29,7 @@ import { useIsOffline } from "../@redux/hooks/site";
import logo from "../@static/logo64.png";
import { SystemApi } from "../apis";
import { ActionButton, SearchBar, SearchResult } from "../components";
import { useBaseUrl } from "../utilites";
import { useGotoHomepage } from "../utilites";
import "./header.scss";

async function SearchItem(text: string) {
Expand Down Expand Up @@ -106,14 +106,19 @@ const Header: FunctionComponent<Props> = () => {
SystemApi.status().finally(() => setReconnect(false));
}, []);

const baseUrl = useBaseUrl();
const goHome = useGotoHomepage();

return (
<Navbar bg="primary" className="flex-grow-1 px-0">
<div className="header-icon px-3 m-0 d-none d-md-block">
<Navbar.Brand href={baseUrl} className="">
<Image alt="brand" src={logo} width="32" height="32"></Image>
</Navbar.Brand>
<Image
alt="brand"
src={logo}
width="32"
height="32"
onClick={goHome}
className="cursor-pointer"
></Image>
</div>
<Button className="mx-2 m-0 d-md-none" onClick={toggleSidebar}>
<FontAwesomeIcon icon={faBars}></FontAwesomeIcon>
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/Sidebar/index.tsx
Expand Up @@ -11,7 +11,7 @@ import { useReduxAction, useReduxStore } from "../@redux/hooks/base";
import { useIsRadarrEnabled, useIsSonarrEnabled } from "../@redux/hooks/site";
import logo from "../@static/logo64.png";
import { SidebarToggleContext } from "../App";
import { useAutoUpdate } from "../utilites/hooks";
import { useAutoUpdate, useGotoHomepage } from "../utilites/hooks";
import {
BadgesContext,
CollapseItem,
Expand Down Expand Up @@ -106,11 +106,20 @@ const Sidebar: FunctionComponent<Props> = ({ open }) => {
[hiddenKeys]
);

const goHome = useGotoHomepage();

return (
<React.Fragment>
<aside className={cls.join(" ")}>
<Container className="sidebar-title d-flex align-items-center d-md-none">
<Image alt="brand" src={logo} width="32" height="32"></Image>
<Image
alt="brand"
src={logo}
width="32"
height="32"
onClick={goHome}
className="cursor-pointer"
></Image>
</Container>
<HiddenKeysContext.Provider value={hiddenKeys}>
<BadgesContext.Provider value={badges}>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/utilites/hooks.ts
@@ -1,4 +1,5 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { useHistory } from "react-router";
import { mergeArray } from ".";

export function useBaseUrl(slash: boolean = false) {
Expand All @@ -13,6 +14,11 @@ export function useBaseUrl(slash: boolean = false) {
}
}

export function useGotoHomepage() {
const history = useHistory();
return useCallback(() => history.push("/"), [history]);
}

export function useCanUpdateInject() {
if (process.env.NODE_ENV === "development") {
return process.env["REACT_APP_CAN_UPDATE"] === "true";
Expand Down

0 comments on commit b1478da

Please sign in to comment.