Got multiple windows open

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2021-07-26 13:53:05 -04:00
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(
{
+1
View File
@@ -135,6 +135,7 @@ export interface CatalogEntitySettingsMenu {
export interface CatalogEntityContextMenuContext {
navigate: (url: string) => void;
setCommandPaletteContext: (context?: CatalogEntity) => void;
menuItems: CatalogEntityContextMenu[];
}
+2
View File
@@ -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";
+23
View File
@@ -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;
}