Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Electron 14.2.4 #4625

Merged
merged 19 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
disturl "https://atom.io/download/electron"
target "13.6.1"
target "14.2.4"
runtime "electron"
4 changes: 3 additions & 1 deletion integration/__tests__/app-preferences.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
import type { ElectronApplication, Page } from "playwright";
import * as utils from "../helpers/utils";
import { isWindows } from "../../src/common/vars";

describe("preferences page tests", () => {
let window: Page, cleanup: () => Promise<void>;
Expand All @@ -33,7 +34,8 @@ describe("preferences page tests", () => {
await cleanup();
}, 10*60*1000);

it('shows "preferences" and can navigate through the tabs', async () => {
// skip on windows due to suspected playwright issue with Electron 14
utils.itIf(!isWindows)('shows "preferences" and can navigate through the tabs', async () => {
const pages = [
{
id: "application",
Expand Down
4 changes: 3 additions & 1 deletion integration/__tests__/command-palette.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import type { ElectronApplication, Page } from "playwright";
import * as utils from "../helpers/utils";
import { isWindows } from "../../src/common/vars";

describe("Lens command palette", () => {
let window: Page, cleanup: () => Promise<void>, app: ElectronApplication;
Expand All @@ -19,7 +20,8 @@ describe("Lens command palette", () => {
}, 10*60*1000);

describe("menu", () => {
it("opens command dialog from menu", async () => {
// skip on windows due to suspected playwright issue with Electron 14
utils.itIf(!isWindows)("opens command dialog from menu", async () => {
await app.evaluate(async ({ app }) => {
await app.applicationMenu
.getMenuItemById("view")
Expand Down
15 changes: 14 additions & 1 deletion integration/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
throw new Error(`Lens did not open the main window within ${timeout}ms`);
}

export async function start() {
async function attemptStart() {
const CICD = path.join(os.tmpdir(), "lens-integration-testing", uuid.v4());

// Make sure that the directory is clear
Expand Down Expand Up @@ -76,6 +76,19 @@ export async function start() {
}
}

export async function start() {
// this is an attempted workaround for an issue with playwright not always getting the main window when using Electron 14.2.4 (observed on windows)
for (let i = 0; ; i++) {
try {
return await attemptStart();
} catch (error) {
if (i === 4) {
throw error;
}
}
}
}

export async function clickWelcomeButton(window: Page) {
await window.click("[data-testid=welcome-menu-container] li a");
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@
}
},
"dependencies": {
"@electron/remote": "^1.2.2",
"@hapi/call": "^8.0.1",
"@hapi/subtext": "^7.0.3",
"@kubernetes/client-node": "^0.16.1",
Expand Down Expand Up @@ -334,7 +333,7 @@
"css-loader": "^5.2.7",
"deepdash": "^5.3.9",
"dompurify": "^2.3.4",
"electron": "^13.6.1",
"electron": "^14.2.4",
"electron-builder": "^22.14.5",
"electron-notarize": "^0.3.0",
"esbuild": "^0.13.15",
Expand Down
10 changes: 5 additions & 5 deletions src/common/catalog-entities/kubernetes-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus, CatalogCategory, CatalogCategorySpec } from "../catalog";
import { clusterActivateHandler, clusterDisconnectHandler } from "../cluster-ipc";
import { ClusterStore } from "../cluster-store/cluster-store";
import { broadcastMessage, requestMain } from "../ipc";
import { broadcastMessage } from "../ipc";
import { app } from "electron";
import type { CatalogEntitySpec } from "../catalog/catalog-entity";
import { IpcRendererNavigationEvents } from "../../renderer/navigation/events";
import { requestClusterActivation, requestClusterDisconnection } from "../../renderer/ipc";

export interface KubernetesClusterPrometheusMetrics {
address?: {
Expand Down Expand Up @@ -69,15 +69,15 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
if (app) {
await ClusterStore.getInstance().getById(this.metadata.uid)?.activate();
} else {
await requestMain(clusterActivateHandler, this.metadata.uid, false);
await requestClusterActivation(this.metadata.uid, false);
}
}

async disconnect(): Promise<void> {
if (app) {
ClusterStore.getInstance().getById(this.metadata.uid)?.disconnect();
} else {
await requestMain(clusterDisconnectHandler, this.metadata.uid, false);
await requestClusterDisconnection(this.metadata.uid, false);
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
context.menuItems.push({
title: "Disconnect",
icon: "link_off",
onClick: () => requestMain(clusterDisconnectHandler, this.metadata.uid),
onClick: () => requestClusterDisconnection(this.metadata.uid),
});
break;
case LensKubernetesClusterStatus.DISCONNECTED:
Expand Down
18 changes: 9 additions & 9 deletions src/common/cluster-store/cluster-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/


import { ipcMain, ipcRenderer, webFrame } from "electron";
import { action, comparer, computed, makeObservable, observable, reaction } from "mobx";
Expand All @@ -11,16 +11,16 @@ import { Cluster } from "../cluster/cluster";
import migrations from "../../migrations/cluster-store";
import logger from "../../main/logger";
import { appEventBus } from "../app-event-bus/event-bus";
import { ipcMainHandle, requestMain } from "../ipc";
import { ipcMainHandle } from "../ipc";
import { disposer, toJS } from "../utils";
import type { ClusterModel, ClusterId, ClusterState } from "../cluster-types";
import { requestInitialClusterStates } from "../../renderer/ipc";
import { clusterStates } from "../ipc/cluster";

export interface ClusterStoreModel {
clusters?: ClusterModel[];
}

const initialStates = "cluster:states";

interface Dependencies {
createCluster: (model: ClusterModel) => Cluster
}
Expand Down Expand Up @@ -49,18 +49,18 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
async loadInitialOnRenderer() {
logger.info("[CLUSTER-STORE] requesting initial state sync");

for (const { id, state } of await requestMain(initialStates)) {
for (const { id, state } of await requestInitialClusterStates()) {
this.getById(id)?.setState(state);
}
}

provideInitialFromMain() {
ipcMainHandle(initialStates, () => {
return this.clustersList.map(cluster => ({
ipcMainHandle(clusterStates, () => (
this.clustersList.map(cluster => ({
id: cluster.id,
state: cluster.getState(),
}));
});
}))
));
}

protected pushStateToViewsAutomatically() {
Expand Down
5 changes: 3 additions & 2 deletions src/common/cluster/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ipcMain } from "electron";
import { action, comparer, computed, makeObservable, observable, reaction, when } from "mobx";
import { broadcastMessage, ClusterListNamespaceForbiddenChannel } from "../ipc";
import { broadcastMessage } from "../ipc";
import type { ContextHandler } from "../../main/context-handler/context-handler";
import { AuthorizationV1Api, CoreV1Api, HttpError, KubeConfig, V1ResourceAttributes } from "@kubernetes/client-node";
import type { Kubectl } from "../../main/kubectl/kubectl";
Expand All @@ -20,6 +20,7 @@ import type { ClusterState, ClusterRefreshOptions, ClusterMetricsResourceType, C
import { ClusterMetadataKey, initialNodeShellImage, ClusterStatus } from "../cluster-types";
import { disposer, toJS } from "../utils";
import type { Response } from "request";
import { clusterListNamespaceForbiddenChannel } from "../ipc/cluster";

interface Dependencies {
directoryForKubeConfigs: string,
Expand Down Expand Up @@ -641,7 +642,7 @@ export class Cluster implements ClusterModel, ClusterState {
const { response } = error as HttpError & { response: Response };

logger.info("[CLUSTER]: listing namespaces is forbidden, broadcasting", { clusterId: this.id, error: response.body });
broadcastMessage(ClusterListNamespaceForbiddenChannel, this.id);
broadcastMessage(clusterListNamespaceForbiddenChannel, this.id);
}

return namespaceList;
Expand Down
5 changes: 3 additions & 2 deletions src/common/hotbar-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { toJS } from "./utils";
import { CatalogEntity } from "./catalog";
import { catalogEntity } from "../main/catalog-sources/general";
import logger from "../main/logger";
import { broadcastMessage, HotbarTooManyItems } from "./ipc";
import { broadcastMessage } from "./ipc";
import { defaultHotbarCells, getEmptyHotbar, Hotbar, CreateHotbarData, CreateHotbarOptions } from "./hotbar-types";
import { hotbarTooManyItemsChannel } from "./ipc/hotbar";

export interface HotbarStoreModel {
hotbars: Hotbar[];
Expand Down Expand Up @@ -182,7 +183,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
if (emptyCellIndex != -1) {
hotbar.items[emptyCellIndex] = newItem;
} else {
broadcastMessage(HotbarTooManyItems);
broadcastMessage(hotbarTooManyItemsChannel);
}
} else if (0 <= cellIndex && cellIndex < hotbar.items.length) {
hotbar.items[cellIndex] = newItem;
Expand Down
23 changes: 13 additions & 10 deletions src/common/ipc/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/

export enum CatalogIpcEvents {
/**
* This is broadcast on whenever there is an update to any catalog item
*/
ITEMS = "catalog:items",
/**
* This is used to activate a specific entity in the renderer main frame
*/
export const catalogEntityRunListener = "catalog-entity:run";

/**
* This can be sent from renderer to main to initialize a broadcast of ITEMS
*/
INIT = "catalog:init",
}
/**
* This is broadcast on whenever there is an update to any catalog item
*/
export const catalogItemsChannel = "catalog:items";

/**
* This can be sent from renderer to main to initialize a broadcast of ITEMS
*/
export const catalogInitChannel = "catalog:init";
16 changes: 0 additions & 16 deletions src/common/ipc/cluster.ipc.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/common/cluster-ipc.ts → src/common/ipc/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ export const clusterSetDeletingHandler = "cluster:deleting:set";
export const clusterClearDeletingHandler = "cluster:deleting:clear";
export const clusterKubectlApplyAllHandler = "cluster:kubectl-apply-all";
export const clusterKubectlDeleteAllHandler = "cluster:kubectl-delete-all";
export const clusterStates = "cluster:states";

/**
* This channel is broadcast on whenever the cluster fails to list namespaces
* during a refresh and no `accessibleNamespaces` have been set.
*/
export const clusterListNamespaceForbiddenChannel = "cluster:list-namespace-forbidden";

export type ListNamespaceForbiddenArgs = [clusterId: string];

export function isListNamespaceForbiddenArgs(args: unknown[]): args is ListNamespaceForbiddenArgs {
return args.length === 1 && typeof args[0] === "string";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/

import * as dialog from "./dialog";

export { dialog };
export const openFilePickingDialogChannel = "dialog:open:file-picking";
9 changes: 9 additions & 0 deletions src/common/ipc/extension-handling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/

export const extensionDiscoveryStateChannel = "extension-discovery:state";
export const bundledExtensionsLoaded = "extension-loader:bundled-extensions-loaded";
export const extensionLoaderFromMainChannel = "extension-loader:main:state";
export const extensionLoaderFromRendererChannel = "extension-loader:renderer:state";
5 changes: 0 additions & 5 deletions src/common/ipc/extension-loader.ipc.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/ipc/hotbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/

export const HotbarTooManyItems = "hotbar:too-many-items";
export const hotbarTooManyItemsChannel = "hotbar:too-many-items";
8 changes: 1 addition & 7 deletions src/common/ipc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/

export const dialogShowOpenDialogHandler = "dialog:show-open-dialog";
export const catalogEntityRunListener = "catalog-entity:run";

export * from "./ipc";
export * from "./invalid-kubeconfig";
export * from "./update-available.ipc";
export * from "./cluster.ipc";
export * from "./update-available";
export * from "./type-enforced-ipc";
export * from "./hotbar";
export * from "./extension-loader.ipc";
Loading