mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 17:11:43 +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/>
|
||||
}
|
||||
|
||||
const server = staticSite ? serverUUID : encodeURIComponent(serverName);
|
||||
const redirectBasedOnPermissions = () => {
|
||||
if (isProxy && user.permissions.includes('page.network')) {
|
||||
return (<Navigate to={"/network/overview"} replace={true}/>)
|
||||
} else if (user.permissions.includes('page.server')) {
|
||||
return (<Navigate to={"/server/" + server + "/overview"}
|
||||
return (<Navigate to={"/server/" + serverUUID + "/overview"}
|
||||
replace={true}/>)
|
||||
} else if (user.permissions.includes('page.player.other')) {
|
||||
return (<Navigate to={"/players"} replace={true}/>)
|
||||
@ -82,7 +81,7 @@ const MainPageRedirect = () => {
|
||||
return redirectBasedOnPermissions();
|
||||
} else {
|
||||
return (<Navigate
|
||||
to={isProxy ? "/network/overview" : "/server/" + server + "/overview"}
|
||||
to={isProxy ? "/network/overview" : "/server/" + serverUUID + "/overview"}
|
||||
replace={true}/>)
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ const PageNavigationItem = ({page}) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (networkMetadata) {
|
||||
const hasProxy = networkMetadata.servers.filter(server => server.proxy).length
|
||||
|
||||
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: '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) {
|
||||
newItems.unshift({id: 'page', displayName: page, href: location.pathname, permission: undefined})
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
if (!currentPage || !items.length) {
|
||||
if (!items.length) {
|
||||
return <li className={"nav-item nav-button nav-link"}
|
||||
style={{
|
||||
padding: "0.5rem",
|
||||
@ -77,9 +85,9 @@ const PageNavigationItem = ({page}) => {
|
||||
aria-label="Page selector"
|
||||
className="form-select form-select-sm scrollbar"
|
||||
id="pageSelector"
|
||||
defaultValue={currentPage}>
|
||||
defaultValue={currentPage ? currentPage : items[0].id}>
|
||||
{items.map((item, i) =>
|
||||
<option key={i} value={item.id}>{item.displayName}</option>)}
|
||||
<option key={item.id} value={item.id}>{item.displayName}</option>)}
|
||||
</select>
|
||||
</InputGroup>
|
||||
</li>
|
||||
|
@ -13,11 +13,9 @@ export const MetadataContextProvider = ({children}) => {
|
||||
const {data, error} = await fetchPlanMetadata();
|
||||
if (data) {
|
||||
setMetadata(data);
|
||||
if (data.isProxy) {
|
||||
const {data: networkMetadata} = await fetchNetworkMetadata(); // error ignored
|
||||
if (networkMetadata) {
|
||||
setMetadata({...data, networkMetadata})
|
||||
}
|
||||
const {data: networkMetadata} = await fetchNetworkMetadata(); // error ignored
|
||||
if (networkMetadata) {
|
||||
setMetadata({...data, networkMetadata})
|
||||
}
|
||||
} else if (error) {
|
||||
setMetadata({metadataError: error})
|
||||
|
@ -188,6 +188,7 @@ const LoginPage = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<style>{'#wrapper{background-image:none;}'}</style>
|
||||
<main className="container">
|
||||
<Logo/>
|
||||
<LoginCard>
|
||||
|
@ -171,6 +171,7 @@ const RegisterPage = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<style>{'#wrapper{background-image:none;}'}</style>
|
||||
<main className="container">
|
||||
<Logo/>
|
||||
<RegisterCard>
|
||||
|
Loading…
Reference in New Issue
Block a user