mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
1 parent
540c6dac37
commit
5ee2ab5b4a
134 files changed
+462
-515
No files matched your search
@@ -27,11 +27,11 @@ import type { RouteComponentProps } from "react-router";
|
||||
import type { ClusterRoleBinding } from "../../../api/endpoints";
|
||||
import { KubeObjectListLayout } from "../../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
||||
import type { ClusterRoleBindingsRouteParams } from "../user-management.route";
|
||||
import { ClusterRoleBindingDialog } from "./dialog";
|
||||
import { clusterRoleBindingsStore } from "./store";
|
||||
import { clusterRolesStore } from "../+cluster-roles/store";
|
||||
import { serviceAccountsStore } from "../+service-accounts/store";
|
||||
import type { ClusterRoleBindingsRouteParams } from "../../../../common/routes";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
|
||||
@@ -27,9 +27,9 @@ import type { RouteComponentProps } from "react-router";
|
||||
import type { ClusterRole } from "../../../api/endpoints";
|
||||
import { KubeObjectListLayout } from "../../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
||||
import type { ClusterRolesRouteParams } from "../user-management.route";
|
||||
import { AddClusterRoleDialog } from "./add-dialog";
|
||||
import { clusterRolesStore } from "./store";
|
||||
import type { ClusterRolesRouteParams } from "../../../../common/routes";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
|
||||
@@ -26,12 +26,12 @@ import type { RouteComponentProps } from "react-router";
|
||||
import type { RoleBinding } from "../../../api/endpoints";
|
||||
import { KubeObjectListLayout } from "../../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
||||
import type { RoleBindingsRouteParams } from "../user-management.route";
|
||||
import { RoleBindingDialog } from "./dialog";
|
||||
import { roleBindingsStore } from "./store";
|
||||
import { rolesStore } from "../+roles/store";
|
||||
import { clusterRolesStore } from "../+cluster-roles/store";
|
||||
import { serviceAccountsStore } from "../+service-accounts/store";
|
||||
import type { RoleBindingsRouteParams } from "../../../../common/routes";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
|
||||
@@ -27,9 +27,9 @@ import type { RouteComponentProps } from "react-router";
|
||||
import type { Role } from "../../../api/endpoints";
|
||||
import { KubeObjectListLayout } from "../../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../../kube-object-status-icon";
|
||||
import type { RolesRouteParams } from "../user-management.route";
|
||||
import { AddRoleDialog } from "./add-dialog";
|
||||
import { rolesStore } from "./store";
|
||||
import type { RolesRouteParams } from "../../../../common/routes";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
|
||||
@@ -24,7 +24,6 @@ import "./view.scss";
|
||||
import { observer } from "mobx-react";
|
||||
import React from "react";
|
||||
import type { RouteComponentProps } from "react-router";
|
||||
import type { ServiceAccountsRouteParams } from "../user-management.route";
|
||||
import { kubeObjectMenuRegistry } from "../../../../extensions/registries/kube-object-menu-registry";
|
||||
import type { ServiceAccount } from "../../../api/endpoints/service-accounts.api";
|
||||
import { Icon } from "../../icon";
|
||||
@@ -35,6 +34,7 @@ import { openServiceAccountKubeConfig } from "../../kubeconfig-dialog";
|
||||
import { MenuItem } from "../../menu";
|
||||
import { CreateServiceAccountDialog } from "./create-dialog";
|
||||
import { serviceAccountsStore } from "./store";
|
||||
import type { ServiceAccountsRouteParams } from "../../../../common/routes";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
|
||||
@@ -20,4 +20,3 @@
|
||||
*/
|
||||
|
||||
export * from "./user-management";
|
||||
export * from "./user-management.route";
|
||||
@@ -1,80 +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 { buildURL, IURLParams } from "../../../common/utils/buildUrl";
|
||||
|
||||
import type { RouteProps } from "react-router";
|
||||
|
||||
// Routes
|
||||
export const serviceAccountsRoute: RouteProps = {
|
||||
path: "/service-accounts"
|
||||
};
|
||||
export const podSecurityPoliciesRoute: RouteProps = {
|
||||
path: "/pod-security-policies"
|
||||
};
|
||||
export const rolesRoute: RouteProps = {
|
||||
path: "/roles"
|
||||
};
|
||||
export const clusterRolesRoute: RouteProps = {
|
||||
path: "/cluster-roles"
|
||||
};
|
||||
export const roleBindingsRoute: RouteProps = {
|
||||
path: "/role-bindings"
|
||||
};
|
||||
export const clusterRoleBindingsRoute: RouteProps = {
|
||||
path: "/cluster-role-bindings"
|
||||
};
|
||||
|
||||
export const usersManagementRoute: RouteProps = {
|
||||
path: [
|
||||
serviceAccountsRoute,
|
||||
podSecurityPoliciesRoute,
|
||||
roleBindingsRoute,
|
||||
clusterRoleBindingsRoute,
|
||||
rolesRoute,
|
||||
clusterRolesRoute,
|
||||
].map(route => route.path.toString())
|
||||
};
|
||||
|
||||
// Route params
|
||||
export interface ServiceAccountsRouteParams {
|
||||
}
|
||||
|
||||
export interface RoleBindingsRouteParams {
|
||||
}
|
||||
|
||||
export interface ClusterRoleBindingsRouteParams {
|
||||
}
|
||||
|
||||
export interface RolesRouteParams {
|
||||
}
|
||||
|
||||
export interface ClusterRolesRouteParams {
|
||||
}
|
||||
|
||||
// URL-builders
|
||||
export const usersManagementURL = (params?: IURLParams) => serviceAccountsURL(params);
|
||||
export const serviceAccountsURL = buildURL<ServiceAccountsRouteParams>(serviceAccountsRoute.path);
|
||||
export const podSecurityPoliciesURL = buildURL(podSecurityPoliciesRoute.path);
|
||||
export const roleBindingsURL = buildURL<RoleBindingsRouteParams>(roleBindingsRoute.path);
|
||||
export const clusterRoleBindingsURL = buildURL<ClusterRoleBindingsRouteParams>(clusterRoleBindingsRoute.path);
|
||||
export const rolesURL = buildURL<RoleBindingsRouteParams>(rolesRoute.path);
|
||||
export const clusterRolesURL = buildURL<ClusterRoleBindingsRouteParams>(clusterRolesRoute.path);
|
||||
@@ -21,31 +21,17 @@
|
||||
|
||||
import "./user-management.scss";
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
import React from "react";
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
import { TabLayout, TabLayoutRoute } from "../layout/tab-layout";
|
||||
import { PodSecurityPolicies } from "../+pod-security-policies";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
import { TabLayout, TabLayoutRoute } from "../layout/tab-layout";
|
||||
import { ClusterRoles } from "./+cluster-roles";
|
||||
import * as routes from "../../../common/routes";
|
||||
import { ClusterRoleBindings } from "./+cluster-role-bindings";
|
||||
import { ServiceAccounts } from "./+service-accounts";
|
||||
import { Roles } from "./+roles";
|
||||
import { RoleBindings } from "./+role-bindings";
|
||||
import { ServiceAccounts } from "./+service-accounts";
|
||||
import {
|
||||
clusterRoleBindingsRoute,
|
||||
clusterRoleBindingsURL,
|
||||
clusterRolesRoute,
|
||||
clusterRolesURL,
|
||||
podSecurityPoliciesRoute,
|
||||
podSecurityPoliciesURL,
|
||||
roleBindingsRoute,
|
||||
roleBindingsURL,
|
||||
rolesRoute,
|
||||
rolesURL,
|
||||
serviceAccountsRoute,
|
||||
serviceAccountsURL,
|
||||
} from "./user-management.route";
|
||||
import { ClusterRoles } from "./+cluster-roles";
|
||||
|
||||
@observer
|
||||
export class UserManagement extends React.Component {
|
||||
@@ -56,8 +42,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Service Accounts",
|
||||
component: ServiceAccounts,
|
||||
url: serviceAccountsURL(),
|
||||
routePath: serviceAccountsRoute.path.toString(),
|
||||
url: routes.serviceAccountsURL(),
|
||||
routePath: routes.serviceAccountsRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,8 +51,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Cluster Roles",
|
||||
component: ClusterRoles,
|
||||
url: clusterRolesURL(),
|
||||
routePath: clusterRolesRoute.path.toString(),
|
||||
url: routes.clusterRolesURL(),
|
||||
routePath: routes.clusterRolesRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,8 +60,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Roles",
|
||||
component: Roles,
|
||||
url: rolesURL(),
|
||||
routePath: rolesRoute.path.toString(),
|
||||
url: routes.rolesURL(),
|
||||
routePath: routes.rolesRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,8 +69,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Cluster Role Bindings",
|
||||
component: ClusterRoleBindings,
|
||||
url: clusterRoleBindingsURL(),
|
||||
routePath: clusterRoleBindingsRoute.path.toString(),
|
||||
url: routes.clusterRoleBindingsURL(),
|
||||
routePath: routes.clusterRoleBindingsRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,8 +78,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Role Bindings",
|
||||
component: RoleBindings,
|
||||
url: roleBindingsURL(),
|
||||
routePath: roleBindingsRoute.path.toString(),
|
||||
url: routes.roleBindingsURL(),
|
||||
routePath: routes.roleBindingsRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,8 +87,8 @@ export class UserManagement extends React.Component {
|
||||
tabRoutes.push({
|
||||
title: "Pod Security Policies",
|
||||
component: PodSecurityPolicies,
|
||||
url: podSecurityPoliciesURL(),
|
||||
routePath: podSecurityPoliciesRoute.path.toString(),
|
||||
url: routes.podSecurityPoliciesURL(),
|
||||
routePath: routes.podSecurityPoliciesRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user