mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
PageRegistration & BaseRegistry refactoring (#1334)
Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
6432b3bb9e
commit
faa1cef307
43 files changed
+432
-369
No files matched your search
@@ -5,7 +5,7 @@ import { IURLParams } from "../../../common/utils/buildUrl";
|
||||
|
||||
export const networkRoute: RouteProps = {
|
||||
get path() {
|
||||
return Network.tabRoutes.map(({ path }) => path).flat()
|
||||
return Network.tabRoutes.map(({ routePath }) => routePath).flat()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,32 +2,26 @@ import "./network.scss"
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Redirect, Route, Switch } from "react-router";
|
||||
import { RouteComponentProps } from "react-router-dom";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { TabLayout, TabRoute } from "../layout/tab-layout";
|
||||
import { TabLayout, TabLayoutRoute } from "../layout/tab-layout";
|
||||
import { Services, servicesRoute, servicesURL } from "../+network-services";
|
||||
import { Endpoints, endpointRoute, endpointURL } from "../+network-endpoints";
|
||||
import { endpointRoute, Endpoints, endpointURL } from "../+network-endpoints";
|
||||
import { Ingresses, ingressRoute, ingressURL } from "../+network-ingresses";
|
||||
import { NetworkPolicies, networkPoliciesRoute, networkPoliciesURL } from "../+network-policies";
|
||||
import { namespaceStore } from "../+namespaces/namespace.store";
|
||||
import { networkURL } from "./network.route";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
|
||||
interface Props extends RouteComponentProps<{}> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class Network extends React.Component<Props> {
|
||||
static get tabRoutes(): TabRoute[] {
|
||||
export class Network extends React.Component {
|
||||
static get tabRoutes(): TabLayoutRoute[] {
|
||||
const query = namespaceStore.getContextParams()
|
||||
const routes: TabRoute[] = [];
|
||||
const routes: TabLayoutRoute[] = [];
|
||||
if (isAllowedResource("services")) {
|
||||
routes.push({
|
||||
title: <Trans>Services</Trans>,
|
||||
component: Services,
|
||||
url: servicesURL({ query }),
|
||||
path: servicesRoute.path,
|
||||
routePath: servicesRoute.path.toString(),
|
||||
})
|
||||
}
|
||||
if (isAllowedResource("endpoints")) {
|
||||
@@ -35,7 +29,7 @@ export class Network extends React.Component<Props> {
|
||||
title: <Trans>Endpoints</Trans>,
|
||||
component: Endpoints,
|
||||
url: endpointURL({ query }),
|
||||
path: endpointRoute.path,
|
||||
routePath: endpointRoute.path.toString(),
|
||||
})
|
||||
}
|
||||
if (isAllowedResource("ingresses")) {
|
||||
@@ -43,7 +37,7 @@ export class Network extends React.Component<Props> {
|
||||
title: <Trans>Ingresses</Trans>,
|
||||
component: Ingresses,
|
||||
url: ingressURL({ query }),
|
||||
path: ingressRoute.path,
|
||||
routePath: ingressRoute.path.toString(),
|
||||
})
|
||||
}
|
||||
if (isAllowedResource("networkpolicies")) {
|
||||
@@ -51,21 +45,15 @@ export class Network extends React.Component<Props> {
|
||||
title: <Trans>Network Policies</Trans>,
|
||||
component: NetworkPolicies,
|
||||
url: networkPoliciesURL({ query }),
|
||||
path: networkPoliciesRoute.path,
|
||||
routePath: networkPoliciesRoute.path.toString(),
|
||||
})
|
||||
}
|
||||
return routes
|
||||
}
|
||||
|
||||
render() {
|
||||
const tabRoutes = Network.tabRoutes;
|
||||
return (
|
||||
<TabLayout className="Network" tabs={tabRoutes}>
|
||||
<Switch>
|
||||
{tabRoutes.map((route, index) => <Route key={index} {...route}/>)}
|
||||
<Redirect to={networkURL({ query: namespaceStore.getContextParams() })}/>
|
||||
</Switch>
|
||||
</TabLayout>
|
||||
<TabLayout className="Network" tabs={Network.tabRoutes}/>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user