Skip to content

Commit

Permalink
add 'run flux install ?' dialog (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
juozasg authored Dec 6, 2023
1 parent 7e6cdff commit 52dfee8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/commands/enableDisableGitOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fluxTools } from 'cli/flux/fluxTools';
import { detectClusterProvider } from 'cli/kubernetes/clusterProvider';
import { kubeConfig } from 'cli/kubernetes/kubernetesConfig';
import { refreshAllTreeViewsCommand } from 'commands/refreshTreeViews';
import { disableConfirmations, telemetry } from 'extension';
import { skipConfirmations, telemetry } from 'extension';
import { ClusterProvider } from 'types/kubernetes/clusterProvider';
import { TelemetryEvent } from 'types/telemetryEventNames';
import { ClusterNode } from 'ui/treeviews/nodes/cluster/clusterNode';
Expand Down Expand Up @@ -34,12 +34,21 @@ async function enableDisableGitOps(clusterNode: ClusterNode | undefined, enableG
return;
}

if(!disableConfirmations && !enableGitOps ) {
const confirm = await window.showWarningMessage(`Do you want to disable GitOps on the "${clusterName}" cluster?`, {
modal: true,
}, 'Disable');
if (confirm !== 'Disable') {
return;
if(!skipConfirmations) {
if(!enableGitOps) {
const confirm = await window.showWarningMessage(`Do you want to disable GitOps (run \`flux uninstall\`) on the "${clusterName}" cluster?`, {
modal: true,
}, 'Disable');
if (confirm !== 'Disable') {
return;
}
} else {
const confirm = await window.showInformationMessage(`Do you want to enable GitOps (run \`flux install\`) on the "${clusterName}" cluster?`, {
modal: true,
}, 'Enable');
if (confirm !== 'Enable') {
return;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { statusBar } from './ui/statusBar';
import { clusterDataProvider, createTreeViews, sourceDataProvider, workloadDataProvider } from './ui/treeviews/treeViews';

/** Disable interactive modal dialogs, useful for testing */
export let disableConfirmations = false;
export let skipConfirmations = false;
export let experimentalFlag = false;

/*
Expand Down Expand Up @@ -61,7 +61,7 @@ export async function activate(context: ExtensionContext) {
// set vscode context: developing extension. test is also dev
setVSCodeContext(ContextId.IsDev, context.extensionMode === ExtensionMode.Development || context.extensionMode === ExtensionMode.Test );
if(context.extensionMode === ExtensionMode.Test) {
disableConfirmations = true;
skipConfirmations = true;
}


Expand Down

0 comments on commit 52dfee8

Please sign in to comment.