mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-25 01:21:41 +01:00
Fix some issues with the new navigation button
This commit is contained in:
parent
362bb44aad
commit
4e486032f3
@ -62,12 +62,11 @@ const MainPageRedirect = () => {
|
|||||||
return <RedirectPlaceholder/>
|
return <RedirectPlaceholder/>
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = staticSite ? serverUUID : encodeURIComponent(serverName);
|
|
||||||
const redirectBasedOnPermissions = () => {
|
const redirectBasedOnPermissions = () => {
|
||||||
if (isProxy && user.permissions.includes('page.network')) {
|
if (isProxy && user.permissions.includes('page.network')) {
|
||||||
return (<Navigate to={"/network/overview"} replace={true}/>)
|
return (<Navigate to={"/network/overview"} replace={true}/>)
|
||||||
} else if (user.permissions.includes('page.server')) {
|
} else if (user.permissions.includes('page.server')) {
|
||||||
return (<Navigate to={"/server/" + server + "/overview"}
|
return (<Navigate to={"/server/" + serverUUID + "/overview"}
|
||||||
replace={true}/>)
|
replace={true}/>)
|
||||||
} else if (user.permissions.includes('page.player.other')) {
|
} else if (user.permissions.includes('page.player.other')) {
|
||||||
return (<Navigate to={"/players"} replace={true}/>)
|
return (<Navigate to={"/players"} replace={true}/>)
|
||||||
@ -82,7 +81,7 @@ const MainPageRedirect = () => {
|
|||||||
return redirectBasedOnPermissions();
|
return redirectBasedOnPermissions();
|
||||||
} else {
|
} else {
|
||||||
return (<Navigate
|
return (<Navigate
|
||||||
to={isProxy ? "/network/overview" : "/server/" + server + "/overview"}
|
to={isProxy ? "/network/overview" : "/server/" + serverUUID + "/overview"}
|
||||||
replace={true}/>)
|
replace={true}/>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,9 @@ const PageNavigationItem = ({page}) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (networkMetadata) {
|
if (networkMetadata) {
|
||||||
|
const hasProxy = networkMetadata.servers.filter(server => server.proxy).length
|
||||||
|
|
||||||
let newItems = [
|
let newItems = [
|
||||||
{id: 'network', displayName: t('html.label.network'), href: "/network", permission: 'page.network'},
|
|
||||||
{id: 'players', displayName: t('html.label.players'), href: "/players", permission: 'page.players'},
|
{id: 'players', displayName: t('html.label.players'), href: "/players", permission: 'page.players'},
|
||||||
{
|
{
|
||||||
id: 'query',
|
id: 'query',
|
||||||
@ -39,12 +40,19 @@ const PageNavigationItem = ({page}) => {
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (hasProxy) {
|
||||||
|
newItems.unshift({
|
||||||
|
id: 'network',
|
||||||
|
displayName: t('html.label.network'),
|
||||||
|
href: "/network",
|
||||||
|
permission: 'page.network'
|
||||||
|
});
|
||||||
|
}
|
||||||
if (page) {
|
if (page) {
|
||||||
newItems.unshift({id: 'page', displayName: page, href: location.pathname, permission: undefined})
|
newItems.unshift({id: 'page', displayName: page, href: location.pathname, permission: undefined})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authRequired && loggedIn) {
|
if (authRequired && loggedIn) {
|
||||||
newItems = newItems.filter(item => item.permission && user.permissions.includes(item.permission))
|
newItems = newItems.filter(item => !item.permission || user.permissions.includes(item.permission))
|
||||||
}
|
}
|
||||||
setItems(newItems);
|
setItems(newItems);
|
||||||
setCurrentPage(newItems.find(item => location.pathname.startsWith(item.href))?.id);
|
setCurrentPage(newItems.find(item => location.pathname.startsWith(item.href))?.id);
|
||||||
@ -56,7 +64,7 @@ const PageNavigationItem = ({page}) => {
|
|||||||
navigate(items.find(item => item.id === selected).href);
|
navigate(items.find(item => item.id === selected).href);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentPage || !items.length) {
|
if (!items.length) {
|
||||||
return <li className={"nav-item nav-button nav-link"}
|
return <li className={"nav-item nav-button nav-link"}
|
||||||
style={{
|
style={{
|
||||||
padding: "0.5rem",
|
padding: "0.5rem",
|
||||||
@ -77,9 +85,9 @@ const PageNavigationItem = ({page}) => {
|
|||||||
aria-label="Page selector"
|
aria-label="Page selector"
|
||||||
className="form-select form-select-sm scrollbar"
|
className="form-select form-select-sm scrollbar"
|
||||||
id="pageSelector"
|
id="pageSelector"
|
||||||
defaultValue={currentPage}>
|
defaultValue={currentPage ? currentPage : items[0].id}>
|
||||||
{items.map((item, i) =>
|
{items.map((item, i) =>
|
||||||
<option key={i} value={item.id}>{item.displayName}</option>)}
|
<option key={item.id} value={item.id}>{item.displayName}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
</li>
|
</li>
|
||||||
|
@ -13,11 +13,9 @@ export const MetadataContextProvider = ({children}) => {
|
|||||||
const {data, error} = await fetchPlanMetadata();
|
const {data, error} = await fetchPlanMetadata();
|
||||||
if (data) {
|
if (data) {
|
||||||
setMetadata(data);
|
setMetadata(data);
|
||||||
if (data.isProxy) {
|
const {data: networkMetadata} = await fetchNetworkMetadata(); // error ignored
|
||||||
const {data: networkMetadata} = await fetchNetworkMetadata(); // error ignored
|
if (networkMetadata) {
|
||||||
if (networkMetadata) {
|
setMetadata({...data, networkMetadata})
|
||||||
setMetadata({...data, networkMetadata})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
setMetadata({metadataError: error})
|
setMetadata({metadataError: error})
|
||||||
|
@ -188,6 +188,7 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<style>{'#wrapper{background-image:none;}'}</style>
|
||||||
<main className="container">
|
<main className="container">
|
||||||
<Logo/>
|
<Logo/>
|
||||||
<LoginCard>
|
<LoginCard>
|
||||||
|
@ -171,6 +171,7 @@ const RegisterPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<style>{'#wrapper{background-image:none;}'}</style>
|
||||||
<main className="container">
|
<main className="container">
|
||||||
<Logo/>
|
<Logo/>
|
||||||
<RegisterCard>
|
<RegisterCard>
|
||||||
|
Loading…
Reference in New Issue
Block a user