Skip to content

Commit

Permalink
fix: sidebar selected menu issue
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Dec 28, 2024
1 parent ae0fa99 commit 4bd4d4b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
3 changes: 0 additions & 3 deletions assets/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ export default function App() {

useEffect(() => {
setDarkMode(windowQuery.matches)
}, [])

useEffect(() => {
getUser().then(() => {
setIsAuthenticated(true)
if (location.pathname === '/login') navigate('/home')
Expand Down
26 changes: 14 additions & 12 deletions assets/components/Sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -34,15 +35,15 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
icon: <SearchOutlined/>,
children: [
{
key: 'domain-finder',
key: '/search/domain',
icon: <CompassOutlined/>,
label: t`Domain`,
title: t`Domain Finder`,
disabled: !isAuthenticated,
onClick: () => navigate('/search/domain')
},
{
key: 'tld-list',
key: '/search/tld',
icon: <BankOutlined/>,
label: t`TLD`,
title: t`TLD list`,
Expand All @@ -66,7 +67,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
disabled: true,
onClick: () => navigate('/search/nameserver')
}
*/
*/
]
},
{
Expand All @@ -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,
Expand All @@ -98,7 +99,7 @@ export function Sider({isAuthenticated}: { isAuthenticated: boolean }) {
]
},
{
key: 'stats',
key: '/stats',
icon: <LineChartOutlined/>,
label: t`Statistics`,
disabled: !isAuthenticated,
Expand All @@ -108,20 +109,20 @@ 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,
onClick: () => window.location.replace("/logout")
}])
} else {
menuItems.push({
key: 'login',
key: '/login',
icon: <LoginOutlined/>,
label: t`Log in`,
onClick: () => navigate('/login')
Expand All @@ -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}
Expand Down
42 changes: 21 additions & 21 deletions translations/translations.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4bd4d4b

Please sign in to comment.