From 13a06c8df9c0ce09d39f9cd33137f0264ee42445 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 30 Mar 2021 09:54:42 -0400 Subject: [PATCH] add check for invalid cluster ID, rename storage to seen_workspaces Signed-off-by: Sebastian Malton --- src/renderer/components/+landing-page/landing-page.tsx | 2 +- src/renderer/ipc/index.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/+landing-page/landing-page.tsx b/src/renderer/components/+landing-page/landing-page.tsx index 9660027997..ee29f85df8 100644 --- a/src/renderer/components/+landing-page/landing-page.tsx +++ b/src/renderer/components/+landing-page/landing-page.tsx @@ -12,7 +12,7 @@ import { createStorage } from "../../utils"; @observer export class LandingPage extends React.Component { - private static storage = createStorage("landing_page", []); + private static storage = createStorage("seen_workspaces", []); @computed get workspace() { return workspaceStore.currentWorkspace; diff --git a/src/renderer/ipc/index.tsx b/src/renderer/ipc/index.tsx index fae7cd5071..b7d1b9d58d 100644 --- a/src/renderer/ipc/index.tsx +++ b/src/renderer/ipc/index.tsx @@ -8,6 +8,7 @@ import { invalidKubeconfigHandler } from "./invalid-kubeconfig-handler"; import { clusterStore } from "../../common/cluster-store"; import { navigate } from "../navigation"; import { clusterSettingsURL } from "../components/+cluster-settings"; +import logger from "../../main/logger"; function sendToBackchannel(backchannel: string, notificationId: string, data: BackchannelArg): void { notificationsStore.remove(notificationId); @@ -59,6 +60,12 @@ const listNamespacesForbiddenHandlerDisplayedAt = new Map(); const intervalBetweenNotifications = 1000 * 60; // 60s function ListNamespacesForbiddenHandler(event: IpcRendererEvent, ...[clusterId]: ListNamespaceForbiddenArgs): void { + const cluster = clusterStore.getById(clusterId); + + if (!cluster) { + return void logger.warn("[ListNamespacesForbiddenHandler]: received event but was given an unknown cluster ID", { clusterId }); + } + const lastDisplayedAt = listNamespacesForbiddenHandlerDisplayedAt.get(clusterId); const wasDisplayed = Boolean(lastDisplayedAt); const now = Date.now(); @@ -76,7 +83,7 @@ function ListNamespacesForbiddenHandler(event: IpcRendererEvent, ...[clusterId]: (
Add Accessible Namespaces -

Cluster {clusterStore.getById(clusterId).name} does not have permissions to list namespaces. Please add the namespaces you have access to.

+

Cluster {cluster.name} does not have permissions to list namespaces. Please add the namespaces you have access to.