mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Got multiple windows open
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
5c64b48849
commit
4b660633dd
17 files changed
+281
-140
No files matched your search
@@ -23,7 +23,7 @@ import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||
import { clusterActivateHandler, clusterDeleteHandler, clusterDisconnectHandler } from "../cluster-ipc";
|
||||
import { ClusterStore } from "../cluster-store";
|
||||
import { requestMain } from "../ipc";
|
||||
import { onNewWindowForClusterHandler, requestMain } from "../ipc";
|
||||
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||
import { addClusterURL } from "../routes";
|
||||
import { app } from "electron";
|
||||
@@ -103,6 +103,19 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
}
|
||||
|
||||
async onContextMenuOpen(context: CatalogEntityContextMenuContext) {
|
||||
context.menuItems.push(
|
||||
{
|
||||
title: "Open",
|
||||
icon: "open_in_full",
|
||||
onClick: () => this.onRun(context),
|
||||
},
|
||||
{
|
||||
title: "Open in new window",
|
||||
icon: "launch",
|
||||
onClick: () => requestMain(onNewWindowForClusterHandler, this.getId()),
|
||||
},
|
||||
);
|
||||
|
||||
if (!this.metadata.source || this.metadata.source === "local") {
|
||||
context.menuItems.push(
|
||||
{
|
||||
|
||||
@@ -135,6 +135,7 @@ export interface CatalogEntitySettingsMenu {
|
||||
|
||||
export interface CatalogEntityContextMenuContext {
|
||||
navigate: (url: string) => void;
|
||||
setCommandPaletteContext: (context?: CatalogEntity) => void;
|
||||
menuItems: CatalogEntityContextMenu[];
|
||||
}
|
||||
|
||||
|
||||
@@ -24,3 +24,5 @@ export * from "./invalid-kubeconfig";
|
||||
export * from "./update-available.ipc";
|
||||
export * from "./cluster.ipc";
|
||||
export * from "./type-enforced-ipc";
|
||||
|
||||
export const onNewWindowForClusterHandler = "window:open-new:cluster";
|
||||
@@ -156,3 +156,26 @@ export function find<T>(src: Iterable<T>, match: (i: T) => any): T | undefined {
|
||||
|
||||
return void 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the zero indexed iteration value, or `undefined` if the iterator has finished
|
||||
* @param src A type that can be iterated over
|
||||
* @param index The 0-index number of items to skip before returning
|
||||
*/
|
||||
export function nth<T>(src: Iterable<T>, index: number): T | undefined {
|
||||
const iterator = src[Symbol.iterator]();
|
||||
|
||||
for (let i = 0; i < index; i += 1) {
|
||||
iterator.next();
|
||||
}
|
||||
|
||||
return iterator.next().value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A special cased version of `nth`.
|
||||
* @param src A type that can be iterated over
|
||||
*/
|
||||
export function first<T>(src: Iterable<T>): T | undefined {
|
||||
return src[Symbol.iterator]().next().value;
|
||||
}
|
||||
Reference in new issue
Block a user