Skip to content

Commit 43a31c3

Browse files
committed
Add check for OpenShift cluster when opening developer console
Signed-off-by: Jessica He <jhe@redhat.com>
1 parent 48ed462 commit 43a31c3

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@
12111211
},
12121212
{
12131213
"command": "openshift.open.developerConsole",
1214-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sContext",
1214+
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sContext && isOpenshiftCluster",
12151215
"group": "c0"
12161216
},
12171217
{
@@ -1385,7 +1385,7 @@
13851385
},
13861386
{
13871387
"command": "openshift.resource.openInDeveloperConsole",
1388-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject || viewItem == openshift.k8sObject.helm"
1388+
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject && isOpenshiftCluster || openshift.k8sObject.helm && isOpenshiftCluster"
13891389
}
13901390
]
13911391
},

src/explorer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
231231
} else {
232232
result = [...await this.odo3.getDeploymentConfigs(), ...await this.odo3.getDeployments()];
233233
}
234+
// don't show Open In Developer Dashboard if not openshift cluster
235+
const openshiftResources = await CliChannel.getInstance().executeTool(Command.isOpenshiftCluster());
236+
let isOpenshiftCluster = true;
237+
if (openshiftResources.stdout.length === 0){
238+
isOpenshiftCluster = false;
239+
}
240+
void commands.executeCommand('setContext', 'isOpenshiftCluster', isOpenshiftCluster);
234241

235242
if (!element) {
236243
await commands.executeCommand('setContext', 'openshift.app.explorer.init', result.length === 0);

src/odo/command.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,9 @@ export class Command {
315315
static canCreatePod(): CommandText {
316316
return new CommandText('oc auth can-i create pod');
317317
}
318+
319+
static isOpenshiftCluster(): CommandText {
320+
return new CommandText('oc api-resources | grep openshift');
321+
}
322+
318323
}

0 commit comments

Comments
 (0)