feat core
routes
: start work on nestids
This commit is contained in:
parent
7eb9197f79
commit
3d49023252
3 changed files with 12 additions and 5 deletions
13
blueprint.sh
13
blueprint.sh
|
@ -876,6 +876,8 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) || ( $2 == "-add" ) ]]; then VCMD="
|
|||
if [[ $child == "Components_Navigation_Routes_"+([0-9])"_Component" ]]; then COMPONENTS_ROUTE_COMP="${!child}"; fi
|
||||
# Route admin
|
||||
if [[ $child == "Components_Navigation_Routes_"+([0-9])"_AdminOnly" ]]; then COMPONENTS_ROUTE_ADMI="${!child}"; fi
|
||||
# Route nests
|
||||
if [[ $child == "Components_Navigation_Routes_"+([0-9])"_Nests" ]]; then COMPONENTS_ROUTE_NEST="${!child}"; fi
|
||||
done
|
||||
|
||||
# Route identifier
|
||||
|
@ -943,10 +945,9 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) || ( $2 == "-add" ) ]]; then VCMD="
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Assign value to ROUTE_ADMI if empty
|
||||
if [[ $COMPONENTS_ROUTE_ADMI != "true" ]]; then
|
||||
COMPONENTS_ROUTE_ADMI="false"
|
||||
fi
|
||||
# Assign value to ROUTE_ADMI and ROUTE_NEST if empty
|
||||
if [[ $COMPONENTS_ROUTE_ADMI != "true" ]]; then COMPONENTS_ROUTE_ADMI="false"; fi
|
||||
if [[ $COMPONENTS_ROUTE_NEST != "" ]]; then COMPONENTS_ROUTE_NEST="nests: [$COMPONENTS_ROUTE_NEST]"; fi
|
||||
|
||||
|
||||
# Apply routes.
|
||||
|
@ -960,7 +961,7 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) || ( $2 == "-add" ) ]]; then VCMD="
|
|||
elif [[ $COMPONENTS_ROUTE_TYPE == "server" ]]; then
|
||||
# Server routes
|
||||
COMPONENTS_IMPORT="import $COMPONENTS_ROUTE_IDEN from '@/blueprint/extensions/$identifier/$COMPONENTS_ROUTE_COMP';"
|
||||
COMPONENTS_ROUTE="{ path: '$COMPONENTS_ROUTE_PATH', permission: null, name: '$COMPONENTS_ROUTE_NAME', component: $COMPONENTS_ROUTE_IDEN, adminOnly: $COMPONENTS_ROUTE_ADMI },"
|
||||
COMPONENTS_ROUTE="{ path: '$COMPONENTS_ROUTE_PATH', permission: null, name: '$COMPONENTS_ROUTE_NAME', component: $COMPONENTS_ROUTE_IDEN, adminOnly: $COMPONENTS_ROUTE_ADMI, $COMPONENTS_ROUTE_NEST },"
|
||||
|
||||
sed -i "s~/\* \[import] \*/~/* [import] */""$COMPONENTS_IMPORT""~g" $ImportConstructor
|
||||
sed -i "s~/\* \[routes] \*/~/* [routes] */""$COMPONENTS_ROUTE""~g" $ServerRouteConstructor
|
||||
|
@ -975,6 +976,8 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) || ( $2 == "-add" ) ]]; then VCMD="
|
|||
COMPONENTS_ROUTE_TYPE=""
|
||||
COMPONENTS_ROUTE_COMP=""
|
||||
COMPONENTS_ROUTE_IDEN=""
|
||||
COMPONENTS_ROUTE_ADMI=""
|
||||
COMPONENTS_ROUTE_NEST=""
|
||||
done
|
||||
|
||||
sed -i "s~/\* \[import] \*/~~g" $ImportConstructor
|
||||
|
|
|
@ -7,12 +7,14 @@ import Spinner from '@/components/elements/Spinner';
|
|||
import { NotFound } from '@/components/elements/ScreenBlock';
|
||||
import { useLocation } from 'react-router';
|
||||
import { useStoreState } from 'easy-peasy';
|
||||
import { ServerContext } from '@/state/server';
|
||||
|
||||
import routes from '@/routers/routes';
|
||||
import blueprintRoutes from './routes';
|
||||
|
||||
export const NavigationLinks = () => {
|
||||
const rootAdmin = useStoreState((state) => state.user.data!.rootAdmin);
|
||||
const serverNest = ServerContext.useStoreState((state) => state.server.data?.nestId);
|
||||
const match = useRouteMatch<{ id: string }>();
|
||||
const to = (value: string, url = false) => {
|
||||
if (value === '/') {
|
||||
|
@ -46,6 +48,7 @@ export const NavigationLinks = () => {
|
|||
{blueprintRoutes.server.length > 0 && blueprintRoutes.server
|
||||
.filter((route) => !!route.name)
|
||||
.filter((route) => route.adminOnly ? rootAdmin : true)
|
||||
.filter((route) => route.nests && serverNest ? route.nests.includes(serverNest) : true )
|
||||
.map((route) =>
|
||||
route.permission ? (
|
||||
<Can key={route.path} action={route.permission} matchAny>
|
||||
|
|
|
@ -11,6 +11,7 @@ interface RouteDefinition {
|
|||
}
|
||||
interface ServerRouteDefinition extends RouteDefinition {
|
||||
permission: string | string[] | null;
|
||||
nests?: number[];
|
||||
}
|
||||
interface Routes {
|
||||
account: RouteDefinition[];
|
||||
|
|
Loading…
Reference in a new issue