ui(admin): add SubNavigation
This commit is contained in:
parent
2b5cc99abd
commit
2a0c99163b
3 changed files with 100 additions and 5 deletions
40
resources/scripts/components/admin/SubNavigation.tsx
Normal file
40
resources/scripts/components/admin/SubNavigation.tsx
Normal file
|
@ -0,0 +1,40 @@
|
|||
import React from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import styled from 'styled-components/macro';
|
||||
import tw from 'twin.macro';
|
||||
|
||||
export const SubNavigation = styled.div`
|
||||
${tw`h-12 flex flex-row items-center border-b border-neutral-700`};
|
||||
|
||||
& > div {
|
||||
${tw`h-full flex flex-col flex-shrink-0 justify-center`};
|
||||
|
||||
& > a {
|
||||
${tw`h-full flex flex-row items-center text-neutral-300 border-t px-4`};
|
||||
border-top-color: transparent !important;
|
||||
|
||||
& > svg {
|
||||
${tw`h-6 w-6 mr-2`};
|
||||
}
|
||||
|
||||
& > span {
|
||||
${tw`text-base whitespace-nowrap`};
|
||||
}
|
||||
|
||||
&:active, &.active {
|
||||
${tw`text-primary-300 border-b border-primary-300`};
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const SubNavigationLink = ({ to, name, children }: { to: string, name: string, children: React.ReactNode }) => {
|
||||
return (
|
||||
<div>
|
||||
<NavLink to={to} exact>
|
||||
{children}
|
||||
<span>{name}</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
import tw from 'twin.macro';
|
||||
import { useRouteMatch } from 'react-router-dom';
|
||||
import { Route, Switch, useRouteMatch } from 'react-router-dom';
|
||||
import { action, Action, Actions, createContextStore, useStoreActions } from 'easy-peasy';
|
||||
import { Node } from '@/api/admin/nodes/getNodes';
|
||||
import getNode from '@/api/admin/nodes/getNode';
|
||||
|
@ -8,6 +9,7 @@ import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
|||
import Spinner from '@/components/elements/Spinner';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import { ApplicationStore } from '@/state';
|
||||
import { SubNavigation, SubNavigationLink } from '@/components/admin/SubNavigation';
|
||||
|
||||
interface ctx {
|
||||
node: Node | undefined;
|
||||
|
@ -23,6 +25,7 @@ export const Context = createContextStore<ctx>({
|
|||
});
|
||||
|
||||
const NodeEditContainer = () => {
|
||||
const location = useLocation();
|
||||
const match = useRouteMatch<{ id?: string }>();
|
||||
|
||||
const { clearFlashes, clearAndAddHttpError } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
|
||||
|
@ -57,14 +60,68 @@ const NodeEditContainer = () => {
|
|||
|
||||
return (
|
||||
<AdminContentBlock title={'Node - ' + node.name}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-4`}>
|
||||
<div css={tw`flex flex-col flex-shrink`} style={{ minWidth: '0' }}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>{node.name}</h2>
|
||||
<p css={tw`text-base text-neutral-400 whitespace-nowrap overflow-ellipsis overflow-hidden`}>{node.uuid}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SubNavigation>
|
||||
<SubNavigationLink to={`${match.url}`} name={'About'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M4 4a2 2 0 012-2h8a2 2 0 012 2v12a1 1 0 110 2h-3a1 1 0 01-1-1v-2a1 1 0 00-1-1H9a1 1 0 00-1 1v2a1 1 0 01-1 1H4a1 1 0 110-2V4zm3 1h2v2H7V5zm2 4H7v2h2V9zm2-4h2v2h-2V5zm2 4h-2v2h2V9z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
|
||||
<SubNavigationLink to={`${match.url}/settings`} name={'Settings'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
|
||||
<SubNavigationLink to={`${match.url}/configuration`} name={'Configuration'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M12.316 3.051a1 1 0 01.633 1.265l-4 12a1 1 0 11-1.898-.632l4-12a1 1 0 011.265-.633zM5.707 6.293a1 1 0 010 1.414L3.414 10l2.293 2.293a1 1 0 11-1.414 1.414l-3-3a1 1 0 010-1.414l3-3a1 1 0 011.414 0zm8.586 0a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 11-1.414-1.414L16.586 10l-2.293-2.293a1 1 0 010-1.414z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
|
||||
<SubNavigationLink to={`${match.url}/allocations`} name={'Allocations'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M5.5 16a3.5 3.5 0 01-.369-6.98 4 4 0 117.753-1.977A4.5 4.5 0 1113.5 16h-8z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
|
||||
<SubNavigationLink to={`${match.url}/servers`} name={'Servers'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M2 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm3.293 1.293a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L7.586 10 5.293 7.707a1 1 0 010-1.414zM11 12a1 1 0 100 2h3a1 1 0 100-2h-3z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
</SubNavigation>
|
||||
|
||||
<FlashMessageRender byKey={'node'} css={tw`mb-4`}/>
|
||||
|
||||
<Switch location={location}>
|
||||
<Route path={`${match.path}`} exact>
|
||||
<p>About</p>
|
||||
</Route>
|
||||
|
||||
<Route path={`${match.path}/settings`} exact>
|
||||
<p>Settings</p>
|
||||
</Route>
|
||||
|
||||
<Route path={`${match.path}/configuration`} exact>
|
||||
<p>Configuration</p>
|
||||
</Route>
|
||||
|
||||
<Route path={`${match.path}/allocations`} exact>
|
||||
<p>Allocations</p>
|
||||
</Route>
|
||||
|
||||
<Route path={`${match.path}/servers`} exact>
|
||||
<p>Servers</p>
|
||||
</Route>
|
||||
</Switch>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -108,7 +108,7 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<Sidebar collapsed={collapsed}>
|
||||
<div className={'header'} onClick={ () => { setCollapsed(!collapsed); } }>
|
||||
{ !collapsed ?
|
||||
<h1 css={tw`text-2xl text-neutral-50 whitespace-nowrap`}>{applicationName}</h1>
|
||||
<h1 css={tw`text-2xl text-neutral-50 whitespace-nowrap font-medium`}>{applicationName}</h1>
|
||||
:
|
||||
<img src={'/favicons/android-icon-48x48.png'} alt={'Pterodactyl Icon'} />
|
||||
}
|
||||
|
@ -227,7 +227,6 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<Route
|
||||
path={`${match.path}/nodes/:id`}
|
||||
component={NodeEditContainer}
|
||||
exact
|
||||
/>
|
||||
|
||||
<Route path={`${match.path}/servers`} component={ServersContainer} exact/>
|
||||
|
@ -235,7 +234,6 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<Route
|
||||
path={`${match.path}/servers/:id`}
|
||||
component={ServerEditContainer}
|
||||
exact
|
||||
/>
|
||||
|
||||
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
|
||||
|
|
Loading…
Reference in a new issue