1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Revert adding /cluster prefix, change settings navigation call

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-10-18 10:09:52 -04:00
parent fd825cc441
commit c7e5e530b5
27 changed files with 83 additions and 90 deletions

View File

@ -73,7 +73,7 @@ function isTopPageTest(test: CommonPageTest): test is TopPageTest {
const commonPageTests: CommonPageTest[] = [{
page: {
name: "Cluster",
href: "/cluster/overview",
href: "/overview",
expectedSelector: "div.ClusterOverview div.label",
expectedText: "CPU"
}
@ -81,7 +81,7 @@ const commonPageTests: CommonPageTest[] = [{
{
page: {
name: "Nodes",
href: "/cluster/nodes",
href: "/nodes",
expectedSelector: "h5.title",
expectedText: "Nodes"
}
@ -91,49 +91,49 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Overview",
href: "/cluster/workloads",
href: "/workloads",
expectedSelector: "h5.box",
expectedText: "Overview"
},
{
name: "Pods",
href: "/cluster/pods",
href: "/pods",
expectedSelector: "h5.title",
expectedText: "Pods"
},
{
name: "Deployments",
href: "/cluster/deployments",
href: "/deployments",
expectedSelector: "h5.title",
expectedText: "Deployments"
},
{
name: "DaemonSets",
href: "/cluster/daemonsets",
href: "/daemonsets",
expectedSelector: "h5.title",
expectedText: "Daemon Sets"
},
{
name: "StatefulSets",
href: "/cluster/statefulsets",
href: "/statefulsets",
expectedSelector: "h5.title",
expectedText: "Stateful Sets"
},
{
name: "ReplicaSets",
href: "/cluster/replicasets",
href: "/replicasets",
expectedSelector: "h5.title",
expectedText: "Replica Sets"
},
{
name: "Jobs",
href: "/cluster/jobs",
href: "/jobs",
expectedSelector: "h5.title",
expectedText: "Jobs"
},
{
name: "CronJobs",
href: "/cluster/cronjobs",
href: "/cronjobs",
expectedSelector: "h5.title",
expectedText: "Cron Jobs"
},
@ -144,37 +144,37 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "ConfigMaps",
href: "/cluster/configmaps",
href: "/configmaps",
expectedSelector: "h5.title",
expectedText: "Config Maps"
},
{
name: "Secrets",
href: "/cluster/secrets",
href: "/secrets",
expectedSelector: "h5.title",
expectedText: "Secrets"
},
{
name: "Resource Quotas",
href: "/cluster/resourcequotas",
href: "/resourcequotas",
expectedSelector: "h5.title",
expectedText: "Resource Quotas"
},
{
name: "Limit Ranges",
href: "/cluster/limitranges",
href: "/limitranges",
expectedSelector: "h5.title",
expectedText: "Limit Ranges"
},
{
name: "HPA",
href: "/cluster/hpa",
href: "/hpa",
expectedSelector: "h5.title",
expectedText: "Horizontal Pod Autoscalers"
},
{
name: "Pod Disruption Budgets",
href: "/cluster/poddisruptionbudgets",
href: "/poddisruptionbudgets",
expectedSelector: "h5.title",
expectedText: "Pod Disruption Budgets"
},
@ -185,25 +185,25 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Services",
href: "/cluster/services",
href: "/services",
expectedSelector: "h5.title",
expectedText: "Services"
},
{
name: "Endpoints",
href: "/cluster/endpoints",
href: "/endpoints",
expectedSelector: "h5.title",
expectedText: "Endpoints"
},
{
name: "Ingresses",
href: "/cluster/ingresses",
href: "/ingresses",
expectedSelector: "h5.title",
expectedText: "Ingresses"
},
{
name: "Network Policies",
href: "/cluster/network-policies",
href: "/network-policies",
expectedSelector: "h5.title",
expectedText: "Network Policies"
},
@ -214,19 +214,19 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Persistent Volume Claims",
href: "/cluster/persistent-volume-claims",
href: "/persistent-volume-claims",
expectedSelector: "h5.title",
expectedText: "Persistent Volume Claims"
},
{
name: "Persistent Volumes",
href: "/cluster/persistent-volumes",
href: "/persistent-volumes",
expectedSelector: "h5.title",
expectedText: "Persistent Volumes"
},
{
name: "Storage Classes",
href: "/cluster/storage-classes",
href: "/storage-classes",
expectedSelector: "h5.title",
expectedText: "Storage Classes"
},
@ -235,7 +235,7 @@ const commonPageTests: CommonPageTest[] = [{
{
page: {
name: "Namespaces",
href: "/cluster/namespaces",
href: "/namespaces",
expectedSelector: "h5.title",
expectedText: "Namespaces"
}
@ -243,7 +243,7 @@ const commonPageTests: CommonPageTest[] = [{
{
page: {
name: "Events",
href: "/cluster/events",
href: "/events",
expectedSelector: "h5.title",
expectedText: "Events"
}
@ -253,12 +253,12 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Charts",
href: "/cluster/apps/charts",
href: "/apps/charts",
expectedSelector: "div.HelmCharts input",
},
{
name: "Releases",
href: "/cluster/apps/releases",
href: "/apps/releases",
expectedSelector: "h5.title",
expectedText: "Releases"
},
@ -269,37 +269,37 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Service Accounts",
href: "/cluster/service-accounts",
href: "/service-accounts",
expectedSelector: "h5.title",
expectedText: "Service Accounts"
},
{
name: "Roles",
href: "/cluster/roles",
href: "/roles",
expectedSelector: "h5.title",
expectedText: "Roles"
},
{
name: "Cluster Roles",
href: "/cluster/cluster-roles",
href: "/cluster-roles",
expectedSelector: "h5.title",
expectedText: "Cluster Roles"
},
{
name: "Role Bindings",
href: "/cluster/role-bindings",
href: "/role-bindings",
expectedSelector: "h5.title",
expectedText: "Role Bindings"
},
{
name: "Cluster Role Bindings",
href: "/cluster/cluster-role-bindings",
href: "/cluster-role-bindings",
expectedSelector: "h5.title",
expectedText: "Cluster Role Bindings"
},
{
name: "Pod Security Policies",
href: "/cluster/pod-security-policies",
href: "/pod-security-policies",
expectedSelector: "h5.title",
expectedText: "Pod Security Policies"
},
@ -310,7 +310,7 @@ const commonPageTests: CommonPageTest[] = [{
pages: [
{
name: "Definitions",
href: "/cluster/crd/definitions",
href: "/crd/definitions",
expectedSelector: "h5.title",
expectedText: "Custom Resources"
},
@ -363,8 +363,8 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
}, 10*60*1000);
it("show logs and highlight the log search entries", async () => {
await frame.click(`a[href="/cluster/workloads"]`);
await frame.click(`a[href="/cluster/pods"]`);
await frame.click(`a[href="/workloads"]`);
await frame.click(`a[href="/pods"]`);
const namespacesSelector = await frame.waitForSelector(".NamespaceSelect");
@ -401,13 +401,13 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
}, 10*60*1000);
it("should show the default namespaces", async () => {
await frame.click('a[href="/cluster/namespaces"]');
await frame.click('a[href="/namespaces"]');
await frame.waitForSelector("div.TableCell >> text='default'");
await frame.waitForSelector("div.TableCell >> text='kube-system'");
}, 10*60*1000);
it(`should create the ${TEST_NAMESPACE} and a pod in the namespace`, async () => {
await frame.click('a[href="/cluster/namespaces"]');
await frame.click('a[href="/namespaces"]');
await frame.click("button.add-button");
await frame.waitForSelector("div.AddNamespaceDialog >> text='Create Namespace'");
@ -418,11 +418,11 @@ utils.describeIf(minikubeReady(TEST_NAMESPACE))("Minikube based tests", () => {
await frame.waitForSelector(`div.TableCell >> text=${TEST_NAMESPACE}`);
if ((await frame.innerText(`a[href^="/cluster/workloads"] .expand-icon`)) === "keyboard_arrow_down") {
await frame.click(`a[href^="/cluster/workloads"]`);
if ((await frame.innerText(`a[href^="/workloads"] .expand-icon`)) === "keyboard_arrow_down") {
await frame.click(`a[href^="/workloads"]`);
}
await frame.click(`a[href^="/cluster/pods"]`);
await frame.click(`a[href^="/pods"]`);
const namespacesSelector = await frame.waitForSelector(".NamespaceSelect");

View File

@ -23,10 +23,11 @@ import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
import { clusterActivateHandler, clusterDisconnectHandler } from "../cluster-ipc";
import { ClusterStore } from "../cluster-store";
import { requestMain } from "../ipc";
import { broadcastMessage, requestMain } from "../ipc";
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
import { app } from "electron";
import type { CatalogEntitySpec } from "../catalog/catalog-entity";
import { IpcRendererNavigationEvents } from "../../renderer/navigation/events";
export interface KubernetesClusterPrometheusMetrics {
address?: {
@ -105,7 +106,10 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
context.menuItems.push({
title: "Settings",
icon: "edit",
onClick: () => context.navigate(`/entity/${this.metadata.uid}/settings`)
onClick: () => broadcastMessage(
IpcRendererNavigationEvents.NAVIGATE_IN_APP,
`/entity/${this.metadata.uid}/settings`,
),
});
}

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const appsRoute: RouteProps = {
path: "/cluster/apps",
path: "/apps",
};
export const appsURL = buildURL(appsRoute.path);

View File

@ -28,7 +28,7 @@ export interface ClusterViewRouteParams {
export const clusterViewRoute: RouteProps = {
exact: true,
path: "/cluster/:clusterId",
path: "/:clusterId",
};
export const clusterViewURL = buildURL<ClusterViewRouteParams>(clusterViewRoute.path);

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const clusterRoute: RouteProps = {
path: "/cluster/overview"
path: "/overview"
};
export const clusterURL = buildURL(clusterRoute.path);

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const configMapsRoute: RouteProps = {
path: "/cluster/configmaps"
path: "/configmaps"
};
export interface ConfigMapsRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const crdRoute: RouteProps = {
path: "/cluster/crd"
path: "/crd"
};
export const crdDefinitionsRoute: RouteProps = {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const endpointRoute: RouteProps = {
path: "/cluster/endpoints"
path: "/endpoints"
};
export interface EndpointRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const eventRoute: RouteProps = {
path: "/cluster/events"
path: "/events"
};
export const eventsURL = buildURL(eventRoute.path);

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const hpaRoute: RouteProps = {
path: "/cluster/hpa"
path: "/hpa"
};
export interface HpaRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const ingressRoute: RouteProps = {
path: "/cluster/ingresses"
path: "/ingresses"
};
export interface IngressRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const limitRangesRoute: RouteProps = {
path: "/cluster/limitranges"
path: "/limitranges"
};
export interface LimitRangeRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const namespacesRoute: RouteProps = {
path: "/cluster/namespaces"
path: "/namespaces"
};
export interface NamespacesRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const networkPoliciesRoute: RouteProps = {
path: "/cluster/network-policies"
path: "/network-policies"
};
export interface NetworkPoliciesRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const nodesRoute: RouteProps = {
path: "/cluster/nodes"
path: "/nodes"
};
export interface NodesRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const pdbRoute: RouteProps = {
path: "/cluster/poddisruptionbudgets"
path: "/poddisruptionbudgets"
};
export interface PodDisruptionBudgetsRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const portForwardsRoute: RouteProps = {
path: "/cluster/port-forwards"
path: "/port-forwards"
};
export interface PortForwardsRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const resourceQuotaRoute: RouteProps = {
path: "/cluster/resourcequotas"
path: "/resourcequotas"
};
export interface ResourceQuotaRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const secretsRoute: RouteProps = {
path: "/cluster/secrets"
path: "/secrets"
};
export interface SecretsRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const servicesRoute: RouteProps = {
path: "/cluster/services"
path: "/services"
};
export interface ServicesRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const storageClassesRoute: RouteProps = {
path: "/cluster/storage-classes"
path: "/storage-classes"
};
export interface StorageClassesRouteParams {

View File

@ -24,22 +24,22 @@ import { buildURL, URLParams } from "../utils/buildUrl";
// Routes
export const serviceAccountsRoute: RouteProps = {
path: "/cluster/service-accounts"
path: "/service-accounts"
};
export const podSecurityPoliciesRoute: RouteProps = {
path: "/cluster/pod-security-policies"
path: "/pod-security-policies"
};
export const rolesRoute: RouteProps = {
path: "/cluster/roles"
path: "/roles"
};
export const clusterRolesRoute: RouteProps = {
path: "/cluster/cluster-roles"
path: "/cluster-roles"
};
export const roleBindingsRoute: RouteProps = {
path: "/cluster/role-bindings"
path: "/role-bindings"
};
export const clusterRoleBindingsRoute: RouteProps = {
path: "/cluster/cluster-role-bindings"
path: "/cluster-role-bindings"
};
export const usersManagementRoute: RouteProps = {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const volumeClaimsRoute: RouteProps = {
path: "/cluster/persistent-volume-claims"
path: "/persistent-volume-claims"
};
export interface VolumeClaimsRouteParams {

View File

@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
import { buildURL } from "../utils/buildUrl";
export const volumesRoute: RouteProps = {
path: "/cluster/persistent-volumes"
path: "/persistent-volumes"
};
export interface VolumesRouteParams {

View File

@ -25,28 +25,28 @@ import type { KubeResource } from "../rbac";
// Routes
export const overviewRoute: RouteProps = {
path: "/cluster/workloads"
path: "/workloads"
};
export const podsRoute: RouteProps = {
path: "/cluster/pods"
path: "/pods"
};
export const deploymentsRoute: RouteProps = {
path: "/cluster/deployments"
path: "/deployments"
};
export const daemonSetsRoute: RouteProps = {
path: "/cluster/daemonsets"
path: "/daemonsets"
};
export const statefulSetsRoute: RouteProps = {
path: "/cluster/statefulsets"
path: "/statefulsets"
};
export const replicaSetsRoute: RouteProps = {
path: "/cluster/replicasets"
path: "/replicasets"
};
export const jobsRoute: RouteProps = {
path: "/cluster/jobs"
path: "/jobs"
};
export const cronJobsRoute: RouteProps = {
path: "/cluster/cronjobs"
path: "/cronjobs"
};
export const workloadsRoute: RouteProps = {

View File

@ -221,7 +221,6 @@ export class App extends React.Component {
<Route component={Apps} {...routes.appsRoute}/>
{this.renderExtensionTabLayoutRoutes()}
{this.renderExtensionRoutes()}
<Redirect exact from="/cluster" to={this.startUrl}/>
<Redirect exact from="/" to={this.startUrl}/>
<Route component={NotFound}/>
</Switch>

View File

@ -45,8 +45,6 @@ import { HotbarIcon } from "../hotbar/hotbar-icon";
import { makeObservable, observable } from "mobx";
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
import { HotbarStore } from "../../../common/hotbar-store";
import { broadcastMessage } from "../../../common/ipc";
import { IpcRendererNavigationEvents } from "../../navigation/events";
interface Props {
className?: string;
@ -57,15 +55,7 @@ export class Sidebar extends React.Component<Props> {
static displayName = "Sidebar";
@observable private contextMenu: CatalogEntityContextMenuContext = {
menuItems: [],
navigate: (pathname: string) => {
if (pathname.startsWith("/cluster/")) {
// assume in-frame navigation
// FIXME: this is not entirely correct because of extension navigation rules
navigate(pathname);
} else {
broadcastMessage(IpcRendererNavigationEvents.NAVIGATE_IN_APP, pathname);
}
},
navigate,
};
constructor(props: Props) {