mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix navigation issues, delete modal not showing, and observability
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
b604902c72
commit
fb12a2fb58
@ -172,7 +172,10 @@ export interface CatalogEntitySettingsMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CatalogEntityContextMenuContext {
|
export interface CatalogEntityContextMenuContext {
|
||||||
navigate: (url: string) => void;
|
/**
|
||||||
|
* Navigate to the specified pathname
|
||||||
|
*/
|
||||||
|
navigate: (pathname: string) => void;
|
||||||
menuItems: CatalogEntityContextMenu[];
|
menuItems: CatalogEntityContextMenu[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const appsRoute: RouteProps = {
|
export const appsRoute: RouteProps = {
|
||||||
path: "/apps",
|
path: "/cluster/apps",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const appsURL = buildURL(appsRoute.path);
|
export const appsURL = buildURL(appsRoute.path);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const clusterRoute: RouteProps = {
|
export const clusterRoute: RouteProps = {
|
||||||
path: "/cluster"
|
path: "/cluster/overview"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clusterURL = buildURL(clusterRoute.path);
|
export const clusterURL = buildURL(clusterRoute.path);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const configMapsRoute: RouteProps = {
|
export const configMapsRoute: RouteProps = {
|
||||||
path: "/configmaps"
|
path: "/cluster/configmaps"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ConfigMapsRouteParams {
|
export interface ConfigMapsRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const crdRoute: RouteProps = {
|
export const crdRoute: RouteProps = {
|
||||||
path: "/crd"
|
path: "/cluster/crd"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const crdDefinitionsRoute: RouteProps = {
|
export const crdDefinitionsRoute: RouteProps = {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const endpointRoute: RouteProps = {
|
export const endpointRoute: RouteProps = {
|
||||||
path: "/endpoints"
|
path: "/cluster/endpoints"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface EndpointRouteParams {
|
export interface EndpointRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const eventRoute: RouteProps = {
|
export const eventRoute: RouteProps = {
|
||||||
path: "/events"
|
path: "/cluster/events"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const eventsURL = buildURL(eventRoute.path);
|
export const eventsURL = buildURL(eventRoute.path);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const hpaRoute: RouteProps = {
|
export const hpaRoute: RouteProps = {
|
||||||
path: "/hpa"
|
path: "/cluster/hpa"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface HpaRouteParams {
|
export interface HpaRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const ingressRoute: RouteProps = {
|
export const ingressRoute: RouteProps = {
|
||||||
path: "/ingresses"
|
path: "/cluster/ingresses"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IngressRouteParams {
|
export interface IngressRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const limitRangesRoute: RouteProps = {
|
export const limitRangesRoute: RouteProps = {
|
||||||
path: "/limitranges"
|
path: "/cluster/limitranges"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface LimitRangeRouteParams {
|
export interface LimitRangeRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const namespacesRoute: RouteProps = {
|
export const namespacesRoute: RouteProps = {
|
||||||
path: "/namespaces"
|
path: "/cluster/namespaces"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface NamespacesRouteParams {
|
export interface NamespacesRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const networkPoliciesRoute: RouteProps = {
|
export const networkPoliciesRoute: RouteProps = {
|
||||||
path: "/network-policies"
|
path: "/cluster/network-policies"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface NetworkPoliciesRouteParams {
|
export interface NetworkPoliciesRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const nodesRoute: RouteProps = {
|
export const nodesRoute: RouteProps = {
|
||||||
path: "/nodes"
|
path: "/cluster/nodes"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface NodesRouteParams {
|
export interface NodesRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const pdbRoute: RouteProps = {
|
export const pdbRoute: RouteProps = {
|
||||||
path: "/poddisruptionbudgets"
|
path: "/cluster/poddisruptionbudgets"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface PodDisruptionBudgetsRouteParams {
|
export interface PodDisruptionBudgetsRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const portForwardsRoute: RouteProps = {
|
export const portForwardsRoute: RouteProps = {
|
||||||
path: "/port-forwards"
|
path: "/cluster/port-forwards"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface PortForwardsRouteParams {
|
export interface PortForwardsRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const resourceQuotaRoute: RouteProps = {
|
export const resourceQuotaRoute: RouteProps = {
|
||||||
path: "/resourcequotas"
|
path: "/cluster/resourcequotas"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ResourceQuotaRouteParams {
|
export interface ResourceQuotaRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const secretsRoute: RouteProps = {
|
export const secretsRoute: RouteProps = {
|
||||||
path: "/secrets"
|
path: "/cluster/secrets"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface SecretsRouteParams {
|
export interface SecretsRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const servicesRoute: RouteProps = {
|
export const servicesRoute: RouteProps = {
|
||||||
path: "/services"
|
path: "/cluster/services"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ServicesRouteParams {
|
export interface ServicesRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const storageClassesRoute: RouteProps = {
|
export const storageClassesRoute: RouteProps = {
|
||||||
path: "/storage-classes"
|
path: "/cluster/storage-classes"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface StorageClassesRouteParams {
|
export interface StorageClassesRouteParams {
|
||||||
|
|||||||
@ -24,22 +24,22 @@ import { buildURL, URLParams } from "../utils/buildUrl";
|
|||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
export const serviceAccountsRoute: RouteProps = {
|
export const serviceAccountsRoute: RouteProps = {
|
||||||
path: "/service-accounts"
|
path: "/cluster/service-accounts"
|
||||||
};
|
};
|
||||||
export const podSecurityPoliciesRoute: RouteProps = {
|
export const podSecurityPoliciesRoute: RouteProps = {
|
||||||
path: "/pod-security-policies"
|
path: "/cluster/pod-security-policies"
|
||||||
};
|
};
|
||||||
export const rolesRoute: RouteProps = {
|
export const rolesRoute: RouteProps = {
|
||||||
path: "/roles"
|
path: "/cluster/roles"
|
||||||
};
|
};
|
||||||
export const clusterRolesRoute: RouteProps = {
|
export const clusterRolesRoute: RouteProps = {
|
||||||
path: "/cluster-roles"
|
path: "/cluster/cluster-roles"
|
||||||
};
|
};
|
||||||
export const roleBindingsRoute: RouteProps = {
|
export const roleBindingsRoute: RouteProps = {
|
||||||
path: "/role-bindings"
|
path: "/cluster/role-bindings"
|
||||||
};
|
};
|
||||||
export const clusterRoleBindingsRoute: RouteProps = {
|
export const clusterRoleBindingsRoute: RouteProps = {
|
||||||
path: "/cluster-role-bindings"
|
path: "/cluster/cluster-role-bindings"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const usersManagementRoute: RouteProps = {
|
export const usersManagementRoute: RouteProps = {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const volumeClaimsRoute: RouteProps = {
|
export const volumeClaimsRoute: RouteProps = {
|
||||||
path: "/persistent-volume-claims"
|
path: "/cluster/persistent-volume-claims"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface VolumeClaimsRouteParams {
|
export interface VolumeClaimsRouteParams {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import type { RouteProps } from "react-router";
|
|||||||
import { buildURL } from "../utils/buildUrl";
|
import { buildURL } from "../utils/buildUrl";
|
||||||
|
|
||||||
export const volumesRoute: RouteProps = {
|
export const volumesRoute: RouteProps = {
|
||||||
path: "/persistent-volumes"
|
path: "/cluster/persistent-volumes"
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface VolumesRouteParams {
|
export interface VolumesRouteParams {
|
||||||
|
|||||||
@ -25,28 +25,28 @@ import type { KubeResource } from "../rbac";
|
|||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
export const overviewRoute: RouteProps = {
|
export const overviewRoute: RouteProps = {
|
||||||
path: "/workloads"
|
path: "/cluster/workloads"
|
||||||
};
|
};
|
||||||
export const podsRoute: RouteProps = {
|
export const podsRoute: RouteProps = {
|
||||||
path: "/pods"
|
path: "/cluster/pods"
|
||||||
};
|
};
|
||||||
export const deploymentsRoute: RouteProps = {
|
export const deploymentsRoute: RouteProps = {
|
||||||
path: "/deployments"
|
path: "/cluster/deployments"
|
||||||
};
|
};
|
||||||
export const daemonSetsRoute: RouteProps = {
|
export const daemonSetsRoute: RouteProps = {
|
||||||
path: "/daemonsets"
|
path: "/cluster/daemonsets"
|
||||||
};
|
};
|
||||||
export const statefulSetsRoute: RouteProps = {
|
export const statefulSetsRoute: RouteProps = {
|
||||||
path: "/statefulsets"
|
path: "/cluster/statefulsets"
|
||||||
};
|
};
|
||||||
export const replicaSetsRoute: RouteProps = {
|
export const replicaSetsRoute: RouteProps = {
|
||||||
path: "/replicasets"
|
path: "/cluster/replicasets"
|
||||||
};
|
};
|
||||||
export const jobsRoute: RouteProps = {
|
export const jobsRoute: RouteProps = {
|
||||||
path: "/jobs"
|
path: "/cluster/jobs"
|
||||||
};
|
};
|
||||||
export const cronJobsRoute: RouteProps = {
|
export const cronJobsRoute: RouteProps = {
|
||||||
path: "/cronjobs"
|
path: "/cluster/cronjobs"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const workloadsRoute: RouteProps = {
|
export const workloadsRoute: RouteProps = {
|
||||||
|
|||||||
@ -75,6 +75,7 @@ import type { ClusterId } from "../../common/cluster-types";
|
|||||||
import { watchHistoryState } from "../remote-helpers/history-updater";
|
import { watchHistoryState } from "../remote-helpers/history-updater";
|
||||||
import { unmountComponentAtNode } from "react-dom";
|
import { unmountComponentAtNode } from "react-dom";
|
||||||
import { PortForwardDialog } from "../port-forward";
|
import { PortForwardDialog } from "../port-forward";
|
||||||
|
import { DeleteClusterDialog } from "./delete-cluster-dialog";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class App extends React.Component {
|
export class App extends React.Component {
|
||||||
@ -220,6 +221,7 @@ export class App extends React.Component {
|
|||||||
<Route component={Apps} {...routes.appsRoute}/>
|
<Route component={Apps} {...routes.appsRoute}/>
|
||||||
{this.renderExtensionTabLayoutRoutes()}
|
{this.renderExtensionTabLayoutRoutes()}
|
||||||
{this.renderExtensionRoutes()}
|
{this.renderExtensionRoutes()}
|
||||||
|
<Redirect exact from="/cluster" to={this.startUrl}/>
|
||||||
<Redirect exact from="/" to={this.startUrl}/>
|
<Redirect exact from="/" to={this.startUrl}/>
|
||||||
<Route component={NotFound}/>
|
<Route component={NotFound}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
@ -233,6 +235,7 @@ export class App extends React.Component {
|
|||||||
<ReplicaSetScaleDialog/>
|
<ReplicaSetScaleDialog/>
|
||||||
<CronJobTriggerDialog/>
|
<CronJobTriggerDialog/>
|
||||||
<PortForwardDialog/>
|
<PortForwardDialog/>
|
||||||
|
<DeleteClusterDialog/>
|
||||||
<CommandContainer clusterId={App.clusterId}/>
|
<CommandContainer clusterId={App.clusterId}/>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
@ -42,9 +42,11 @@ import * as routes from "../../../common/routes";
|
|||||||
import { Config } from "../+config";
|
import { Config } from "../+config";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
||||||
import { observable } from "mobx";
|
import { makeObservable, observable } from "mobx";
|
||||||
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
|
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
|
||||||
import { HotbarStore } from "../../../common/hotbar-store";
|
import { HotbarStore } from "../../../common/hotbar-store";
|
||||||
|
import { broadcastMessage } from "../../../common/ipc";
|
||||||
|
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -55,9 +57,22 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
static displayName = "Sidebar";
|
static displayName = "Sidebar";
|
||||||
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
||||||
menuItems: [],
|
menuItems: [],
|
||||||
navigate: (url: string) => navigate(url),
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
makeObservable(this);
|
||||||
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
crdStore.reloadAll();
|
crdStore.reloadAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,6 +63,7 @@ function bindClusterManagerRouteEvents() {
|
|||||||
ipcRendererOn(IpcRendererNavigationEvents.NAVIGATE_IN_APP, (event, url: string) => {
|
ipcRendererOn(IpcRendererNavigationEvents.NAVIGATE_IN_APP, (event, url: string) => {
|
||||||
logger.info(`[IPC]: navigate to ${url}`, { currentLocation: location.href });
|
logger.info(`[IPC]: navigate to ${url}`, { currentLocation: location.href });
|
||||||
navigate(url);
|
navigate(url);
|
||||||
|
window.focus(); // make sure that the main frame is focused
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user