diff --git a/src/main/cluster.ts b/src/main/cluster.ts index b7f33adc76..fd8142aa57 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -741,6 +741,6 @@ export class Cluster implements ClusterModel, ClusterState { } isInLocalKubeconfig() { - return this.kubeConfigPath.includes(storedKubeConfigFolder()); + return this.kubeConfigPath.startsWith(storedKubeConfigFolder()); } } diff --git a/src/renderer/components/delete-cluster-dialog/delete-cluster-dialog.tsx b/src/renderer/components/delete-cluster-dialog/delete-cluster-dialog.tsx index 68591ee457..60635d25b5 100644 --- a/src/renderer/components/delete-cluster-dialog/delete-cluster-dialog.tsx +++ b/src/renderer/components/delete-cluster-dialog/delete-cluster-dialog.tsx @@ -151,27 +151,44 @@ export class DeleteClusterDialog extends React.Component { ); } - renderWarning() { - const { cluster } = dialogState; - const isInternalKubeconfig = cluster.isInLocalKubeconfig(); - let warning: JSX.Element = null; + getWarningMessage() { + const { cluster, config } = dialogState; + const contexts = config.contexts.filter(context => context.name !== cluster.contextName); - if (this.isCurrentContext()) { - warning =
- This will remove active context in kubeconfig. Use drop down below to select a different one. -
; - } else if (!isInternalKubeconfig) { - warning =The contents of kubeconfig file will be changed!
; + if (!contexts.length) { + return ( ++ This will remove the last context in kubeconfig. There will be no active context. +
+ ); } - if (!warning) { - return null; + if (this.isCurrentContext()) { + return ( ++ This will remove active context in kubeconfig. Use drop down below to select a different one. +
+ ); + } + + if (cluster.isInLocalKubeconfig()) { + return ( ++ Are you sure you want to delete it? It can be re-added through the copy/paste mechanism. +
+ ); } + return ( +The contents of kubeconfig file will be changed!
+ ); + } + + renderWarning() { return (