mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
fix: sidebar selected menu issue
This commit is contained in:
parent
ae0fa99870
commit
4bd4d4bd4c
@ -59,9 +59,6 @@ export default function App() {
|
||||
|
||||
useEffect(() => {
|
||||
setDarkMode(windowQuery.matches)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
getUser().then(() => {
|
||||
setIsAuthenticated(true)
|
||||
if (location.pathname === '/login') navigate('/home')
|
||||
|
||||
@ -16,14 +16,15 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import {Menu} from "antd";
|
||||
import React from "react";
|
||||
import {useNavigate} from "react-router-dom";
|
||||
import {useLocation, useNavigate} from "react-router-dom";
|
||||
|
||||
export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
|
||||
const menuItems: ItemType[] = [
|
||||
{
|
||||
key: 'home',
|
||||
key: '/home',
|
||||
label: t`Home`,
|
||||
icon: <HomeOutlined/>,
|
||||
onClick: () => navigate('/home')
|
||||
@ -34,7 +35,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
icon: <SearchOutlined/>,
|
||||
children: [
|
||||
{
|
||||
key: 'domain-finder',
|
||||
key: '/search/domain',
|
||||
icon: <CompassOutlined/>,
|
||||
label: t`Domain`,
|
||||
title: t`Domain Finder`,
|
||||
@ -42,7 +43,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
onClick: () => navigate('/search/domain')
|
||||
},
|
||||
{
|
||||
key: 'tld-list',
|
||||
key: '/search/tld',
|
||||
icon: <BankOutlined/>,
|
||||
label: t`TLD`,
|
||||
title: t`TLD list`,
|
||||
@ -66,7 +67,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
disabled: true,
|
||||
onClick: () => navigate('/search/nameserver')
|
||||
}
|
||||
*/
|
||||
*/
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -75,21 +76,21 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
icon: <AimOutlined/>,
|
||||
children: [
|
||||
{
|
||||
key: 'watchlist',
|
||||
key: '/tracking/watchlist',
|
||||
icon: <FileSearchOutlined/>,
|
||||
label: t`My Watchlists`,
|
||||
disabled: !isAuthenticated,
|
||||
onClick: () => navigate('/tracking/watchlist')
|
||||
},
|
||||
{
|
||||
key: 'tracked-domain',
|
||||
key: '/tracking/domains',
|
||||
icon: <TableOutlined/>,
|
||||
label: t`Tracked domain names`,
|
||||
disabled: !isAuthenticated,
|
||||
onClick: () => navigate('/tracking/domains')
|
||||
},
|
||||
{
|
||||
key: 'connectors',
|
||||
key: '/tracking/connectors',
|
||||
icon: <ApiOutlined/>,
|
||||
label: t`My Connectors`,
|
||||
disabled: !isAuthenticated,
|
||||
@ -98,7 +99,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'stats',
|
||||
key: '/stats',
|
||||
icon: <LineChartOutlined/>,
|
||||
label: t`Statistics`,
|
||||
disabled: !isAuthenticated,
|
||||
@ -108,12 +109,12 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
|
||||
if (isAuthenticated) {
|
||||
menuItems.push(...[{
|
||||
key: 'account',
|
||||
key: '/user',
|
||||
icon: <UserOutlined/>,
|
||||
label: t`My Account`,
|
||||
onClick: () => navigate('/user')
|
||||
}, {
|
||||
key: 'logout',
|
||||
key: '/logout',
|
||||
icon: <LogoutOutlined/>,
|
||||
label: t`Log out`,
|
||||
danger: true,
|
||||
@ -121,7 +122,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
}])
|
||||
} else {
|
||||
menuItems.push({
|
||||
key: 'login',
|
||||
key: '/login',
|
||||
icon: <LoginOutlined/>,
|
||||
label: t`Log in`,
|
||||
onClick: () => navigate('/login')
|
||||
@ -130,6 +131,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
|
||||
|
||||
return <Menu
|
||||
defaultOpenKeys={['search', 'info', 'tracking', 'doc']}
|
||||
selectedKeys={[location.pathname.includes('/search/domain') ? '/search/domain' : location.pathname]}
|
||||
mode="inline"
|
||||
theme="dark"
|
||||
items={menuItems}
|
||||
|
||||
@ -3,34 +3,34 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
|
||||
|
||||
#: assets/App.tsx:123
|
||||
#: assets/App.tsx:120
|
||||
msgid "TOS"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:124
|
||||
#: assets/App.tsx:121
|
||||
msgid "Privacy Policy"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:125
|
||||
#: assets/App.tsx:122
|
||||
msgid "FAQ"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:128
|
||||
#: assets/App.tsx:125
|
||||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:131
|
||||
#: assets/App.tsx:128
|
||||
#, javascript-format
|
||||
msgid ""
|
||||
"${ ProjectLink } is an open source project distributed under the ${ "
|
||||
"LicenseLink } license."
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:144
|
||||
#: assets/App.tsx:141
|
||||
msgid "Official git repository"
|
||||
msgstr ""
|
||||
|
||||
#: assets/App.tsx:147
|
||||
#: assets/App.tsx:144
|
||||
msgid "Submit an issue"
|
||||
msgstr ""
|
||||
|
||||
@ -114,63 +114,63 @@ msgstr ""
|
||||
msgid "This domain name does not appear to be valid"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:27
|
||||
#: assets/components/Sider.tsx:28
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:33
|
||||
#: assets/components/Sider.tsx:34
|
||||
msgid "Search"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:39
|
||||
#: assets/components/Sider.tsx:40
|
||||
#: assets/components/tracking/watchlist/TrackedDomainTable.tsx:69
|
||||
msgid "Domain"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:40
|
||||
#: assets/components/Sider.tsx:41
|
||||
msgid "Domain Finder"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:47
|
||||
#: assets/components/Sider.tsx:48
|
||||
#: assets/pages/search/TldPage.tsx:65
|
||||
msgid "TLD"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:48
|
||||
#: assets/components/Sider.tsx:49
|
||||
msgid "TLD list"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:74
|
||||
#: assets/components/Sider.tsx:75
|
||||
msgid "Tracking"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:80
|
||||
#: assets/components/Sider.tsx:81
|
||||
msgid "My Watchlists"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:87
|
||||
#: assets/components/Sider.tsx:88
|
||||
#: assets/pages/StatisticsPage.tsx:68
|
||||
msgid "Tracked domain names"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:94
|
||||
#: assets/components/Sider.tsx:95
|
||||
msgid "My Connectors"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:103
|
||||
#: assets/components/Sider.tsx:104
|
||||
msgid "Statistics"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:113
|
||||
#: assets/components/Sider.tsx:114
|
||||
#: assets/pages/UserPage.tsx:16
|
||||
msgid "My Account"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:118
|
||||
#: assets/components/Sider.tsx:119
|
||||
msgid "Log out"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/Sider.tsx:126
|
||||
#: assets/components/Sider.tsx:127
|
||||
#: assets/pages/LoginPage.tsx:25
|
||||
#: assets/pages/LoginPage.tsx:33
|
||||
msgid "Log in"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user