Move all RouteParam's and URL builders to src/common (#2778)

- Prevents some circular dependencies

- Allowed main to use them as needed

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-06-10 08:52:09 -04:00
1 parent 540c6dac37
commit 5ee2ab5b4a
134 files changed
+462 -515

No files matched your search

@@ -21,51 +21,46 @@
import { navigate } from "../../navigation";
import { commandRegistry } from "../../../extensions/registries/command-registry";
import { configMapsURL } from "../+config-maps";
import { secretsURL } from "../+config-secrets";
import { resourceQuotaURL } from "../+config-resource-quotas";
import { limitRangeURL } from "../+config-limit-ranges";
import { hpaURL } from "../+config-autoscalers";
import { pdbURL } from "../+config-pod-disruption-budgets";
import * as routes from "../../../common/routes";
commandRegistry.add({
id: "cluster.viewConfigMaps",
title: "Cluster: View ConfigMaps",
scope: "entity",
action: () => navigate(configMapsURL())
action: () => navigate(routes.configMapsURL())
});
commandRegistry.add({
id: "cluster.viewSecrets",
title: "Cluster: View Secrets",
scope: "entity",
action: () => navigate(secretsURL())
action: () => navigate(routes.secretsURL())
});
commandRegistry.add({
id: "cluster.viewResourceQuotas",
title: "Cluster: View ResourceQuotas",
scope: "entity",
action: () => navigate(resourceQuotaURL())
action: () => navigate(routes.resourceQuotaURL())
});
commandRegistry.add({
id: "cluster.viewLimitRanges",
title: "Cluster: View LimitRanges",
scope: "entity",
action: () => navigate(limitRangeURL())
action: () => navigate(routes.limitRangeURL())
});
commandRegistry.add({
id: "cluster.viewHorizontalPodAutoscalers",
title: "Cluster: View HorizontalPodAutoscalers (HPA)",
scope: "entity",
action: () => navigate(hpaURL())
action: () => navigate(routes.hpaURL())
});
commandRegistry.add({
id: "cluster.viewPodDisruptionBudget",
title: "Cluster: View PodDisruptionBudgets",
scope: "entity",
action: () => navigate(pdbURL())
action: () => navigate(routes.pdbURL())
});
@@ -1,42 +0,0 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import type { RouteProps } from "react-router";
import type { IURLParams } from "../../../common/utils/buildUrl";
import { configMapsRoute, configMapsURL } from "../+config-maps/config-maps.route";
import { hpaRoute } from "../+config-autoscalers";
import { limitRangesRoute } from "../+config-limit-ranges";
import { pdbRoute } from "../+config-pod-disruption-budgets";
import { resourceQuotaRoute } from "../+config-resource-quotas";
import { secretsRoute } from "../+config-secrets";
export const configRoute: RouteProps = {
path: [
configMapsRoute,
secretsRoute,
resourceQuotaRoute,
limitRangesRoute,
hpaRoute,
pdbRoute
].map(route => route.path.toString())
};
export const configURL = (params?: IURLParams) => configMapsURL(params);
+27 -26
View File
@@ -22,74 +22,75 @@
import React from "react";
import { observer } from "mobx-react";
import { TabLayout, TabLayoutRoute } from "../layout/tab-layout";
import { ConfigMaps, configMapsRoute, configMapsURL } from "../+config-maps";
import { Secrets, secretsRoute, secretsURL } from "../+config-secrets";
import { resourceQuotaRoute, ResourceQuotas, resourceQuotaURL } from "../+config-resource-quotas";
import { pdbRoute, pdbURL, PodDisruptionBudgets } from "../+config-pod-disruption-budgets";
import { HorizontalPodAutoscalers, hpaRoute, hpaURL } from "../+config-autoscalers";
import { ConfigMaps } from "../+config-maps";
import { Secrets } from "../+config-secrets";
import { ResourceQuotas } from "../+config-resource-quotas";
import { PodDisruptionBudgets } from "../+config-pod-disruption-budgets";
import { HorizontalPodAutoscalers } from "../+config-autoscalers";
import { isAllowedResource } from "../../../common/rbac";
import { LimitRanges, limitRangesRoute, limitRangeURL } from "../+config-limit-ranges";
import { LimitRanges } from "../+config-limit-ranges";
import * as routes from "../../../common/routes";
@observer
export class Config extends React.Component {
static get tabRoutes(): TabLayoutRoute[] {
const routes: TabLayoutRoute[] = [];
const tabs: TabLayoutRoute[] = [];
if (isAllowedResource("configmaps")) {
routes.push({
tabs.push({
title: "ConfigMaps",
component: ConfigMaps,
url: configMapsURL(),
routePath: configMapsRoute.path.toString(),
url: routes.configMapsURL(),
routePath: routes.configMapsRoute.path.toString(),
});
}
if (isAllowedResource("secrets")) {
routes.push({
tabs.push({
title: "Secrets",
component: Secrets,
url: secretsURL(),
routePath: secretsRoute.path.toString(),
url: routes.secretsURL(),
routePath: routes.secretsRoute.path.toString(),
});
}
if (isAllowedResource("resourcequotas")) {
routes.push({
tabs.push({
title: "Resource Quotas",
component: ResourceQuotas,
url: resourceQuotaURL(),
routePath: resourceQuotaRoute.path.toString(),
url: routes.resourceQuotaURL(),
routePath: routes.resourceQuotaRoute.path.toString(),
});
}
if (isAllowedResource("limitranges")) {
routes.push({
tabs.push({
title: "Limit Ranges",
component: LimitRanges,
url: limitRangeURL(),
routePath: limitRangesRoute.path.toString(),
url: routes.limitRangeURL(),
routePath: routes.limitRangesRoute.path.toString(),
});
}
if (isAllowedResource("horizontalpodautoscalers")) {
routes.push({
tabs.push({
title: "HPA",
component: HorizontalPodAutoscalers,
url: hpaURL(),
routePath: hpaRoute.path.toString(),
url: routes.hpaURL(),
routePath: routes.hpaRoute.path.toString(),
});
}
if (isAllowedResource("poddisruptionbudgets")) {
routes.push({
tabs.push({
title: "Pod Disruption Budgets",
component: PodDisruptionBudgets,
url: pdbURL(),
routePath: pdbRoute.path.toString(),
url: routes.pdbURL(),
routePath: routes.pdbRoute.path.toString(),
});
}
return routes;
return tabs;
}
render() {
-1
View File
@@ -19,6 +19,5 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
export * from "./config.route";
export * from "./config";
export * from "./config.command";