Skip to content

Add support to enable/disable experimental mode #2696

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

Merged
merged 1 commit into from
Dec 15, 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
32 changes: 23 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,11 @@
},
{
"command": "openshift.experimental.mode.enable",
"when": "view == openshiftComponentsView && !config.openshiftToolkit.enableExperimentialMode"
"when": "view == openshiftComponentsView && !config.openshiftToolkit.experimentalFeatures"
},
{
"command": "openshift.experimental.mode.disable",
"when": "view == openshiftComponentsView && config.openshiftToolkit.enableExperimentialMode"
"when": "view == openshiftComponentsView && config.openshiftToolkit.experimentalFeatures"
}
],
"view/item/context": [
Expand Down Expand Up @@ -1244,7 +1244,7 @@
},
{
"command": "openshift.component.dev.onPodman",
"when": "view == openshiftComponentsView && config.openshiftToolkit.enableExperimentialMode && viewItem =~ /openshift\\.component.*\\.dev-nrn.*/",
"when": "view == openshiftComponentsView && config.openshiftToolkit.experimentalFeatures && viewItem =~ /openshift\\.component.*\\.dev-nrn.*/",
"group": "c1@2"
},
{
Expand Down Expand Up @@ -1446,11 +1446,6 @@
"default": true,
"description": "Show Welcome Page when using OpenShift Toolkit Extension."
},
"openshiftToolkit.enableExperimentialMode": {
"type": "boolean",
"default": false,
"description": "Show OpenShift Toolkit Experimental Features."
},
"openshiftToolkit.showChannelOnOutput": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -1525,7 +1520,26 @@
"default": 100000
}
}
}
},
{
"type": "object",
"order": 4,
"title": "Experimental Features",
"properties": {
"openshiftToolkit.experimentalFeatures": {
"order": 1,
"description": "Show OpenShift Toolkit Experimental Features.",
"type": "boolean",
"default": true
},
"openshiftToolkit.devModeRunOnPodman": {
"order": 2,
"description": "Show warning about experimental feature",
"type": "boolean",
"default": true
}
}
}
]
},
"extensionDependencies": [
Expand Down
13 changes: 9 additions & 4 deletions src/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
import { workspace } from 'vscode';
import { vsCommand } from './vscommand';

async function setShowExperimentalFeatures(set: boolean): Promise<void> {
await workspace.getConfiguration('openshiftToolkit').update('experimentalFeatures', set);
}

export class ExperimentalMode {

@vsCommand('openshift.experimental.mode.enable')
public static enable() {
workspace.getConfiguration('openshiftToolkit').update('enableExperimentialMode', true);
public static async enable() {
await setShowExperimentalFeatures(true);
}

@vsCommand('openshift.experimental.mode.disable')
public static disable() {
workspace.getConfiguration('openshiftToolkit').update('enableExperimentialMode', false);
public static async disable() {
await setShowExperimentalFeatures(false);
}

}
21 changes: 21 additions & 0 deletions src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,27 @@ export class Component extends OpenShiftItem {

@vsCommand('openshift.component.dev.onPodman')
static async devOnPodman(component: ComponentWorkspaceFolder) {
if (workspace.getConfiguration('openshiftToolkit').get('devModeRunOnPodman')) {
let choice = 'Cancel';
do {
const choices = ['About Podman', 'Continue', 'Continue and don\'t ask again'];
choice = await window.showWarningMessage(
'The command \'Start Dev on Podman\' is experimental. It requires Podman to be installed and configured. It isn\'t guaranteed to work.',
...choices);
switch (choice) {
case choices[0]: // open link to external site with podman documentation
await commands.executeCommand('vscode.open', Uri.parse('https://docs.podman.io/en/latest/index.html'));
break;
case choices[1]: // continue with execution
break;
case choices[2]: // save request to not show warning again
await workspace.getConfiguration('openshiftToolkit').update('devModeRunOnPodman', false);
break;
default:
return;
}
} while (choice === 'About Podman')
}
return Component.dev(component, 'podman');
}

Expand Down