From 3cdbbec8c7393ba811ac8fd93b9c179bf9f9deba Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Fri, 19 Feb 2021 21:45:40 -0800 Subject: [PATCH 1/7] Add Welcome content for Application Explorer View This PR fixes #1978. Signed-off-by: Denis Golovin dgolovin@redhat.com --- package.json | 6 ++++++ src/odo.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 40e08c52d..aaca60c03 100644 --- a/package.json +++ b/package.json @@ -780,6 +780,12 @@ } ] }, + "viewsWelcome": [ + { + "view": "openshiftProjectExplorer", + "contents": "You are not logged in to a Cluster or it is not accessible\n[Login](command:openshift.explorer.login)\n[Switch Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)" + } + ], "menus": { "explorer/context": [ { diff --git a/src/odo.ts b/src/odo.ts index aaec925a7..a2732fe94 100644 --- a/src/odo.ts +++ b/src/odo.ts @@ -539,12 +539,12 @@ export class OdoImpl implements Odo { const result: cliInstance.CliExitData = await this.execute( Command.printOdoVersionAndProjects(), process.cwd(), false ); - if (this.odoLoginMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { - return[new OpenShiftLoginRequired()]; - } - if (this.serverDownMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { - return [new OpenShiftClusterDown()]; - } + // if (this.odoLoginMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { + // return[new OpenShiftLoginRequired()]; + // } + // if (this.serverDownMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { + // return [new OpenShiftClusterDown()]; + // } commands.executeCommand('setContext', 'isLoggedIn', true); clusters = result.stdout.trim().split('\n').filter((value) => { return value.includes('Server:'); From a071519d84e59e8d651495b8ccf9a9de55040889 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 11:38:07 -0800 Subject: [PATCH 2/7] Update welcome text and button names Signed-off-by: Denis Golovin dgolovin@redhat.com --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aaca60c03..2ed1df71b 100644 --- a/package.json +++ b/package.json @@ -783,7 +783,7 @@ "viewsWelcome": [ { "view": "openshiftProjectExplorer", - "contents": "You are not logged in to a Cluster or it is not accessible\n[Login](command:openshift.explorer.login)\n[Switch Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)" + "contents": "Cluster is not accessible or you are not logged in\n[Login](command:openshift.explorer.login)\n[Change Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)", } ], "menus": { From a38c6373a361af96987c46cd728b9570c4d3f603 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 11:39:04 -0800 Subject: [PATCH 3/7] Fix error in package.json Signed-off-by: Denis Golovin dgolovin@redhat.com --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ed1df71b..d0d27691c 100644 --- a/package.json +++ b/package.json @@ -783,7 +783,7 @@ "viewsWelcome": [ { "view": "openshiftProjectExplorer", - "contents": "Cluster is not accessible or you are not logged in\n[Login](command:openshift.explorer.login)\n[Change Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)", + "contents": "Cluster is not accessible or you are not logged in\n[Login](command:openshift.explorer.login)\n[Change Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)" } ], "menus": { From 1d73eeec189bf5f80ad9f6a66fee607e4c9964f2 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 11:43:29 -0800 Subject: [PATCH 4/7] Fix eslint errors Signed-off-by: Denis Golovin dgolovin@redhat.com --- src/odo.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/odo.ts b/src/odo.ts index a2732fe94..a3fe7851f 100644 --- a/src/odo.ts +++ b/src/odo.ts @@ -490,12 +490,12 @@ export class OdoImpl implements Odo { '"system:anonymous"', ]; - private readonly serverDownMessages = [ - 'Unable to connect to OpenShift cluster, is it down?', - 'no such host', - 'no route to host', - 'connection refused', - ]; + // private readonly serverDownMessages = [ + // 'Unable to connect to OpenShift cluster, is it down?', + // 'no such host', + // 'no route to host', + // 'connection refused', + // ]; public readonly subject: Subject = new Subject(); From 57557e5bbb822417a873dd5d974bd6343b678fd8 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 14:17:55 -0800 Subject: [PATCH 5/7] Fix unit test errors Signed-off-by: Denis Golovin dgolovin@redhat.com --- test/unit/odo.test.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/test/unit/odo.test.ts b/test/unit/odo.test.ts index 5413eb5e6..c37f77024 100644 --- a/test/unit/odo.test.ts +++ b/test/unit/odo.test.ts @@ -614,26 +614,6 @@ suite('odo', () => { assert.equal(cluster[0].getName(), clusterUrl); }); - test('show error message if cluster is not login', async () => { - sandbox.stub(odo.OdoImpl.prototype, 'execute').onFirstCall().resolves({ - error: undefined, - stdout: '', - stderr: 'Please log in to the cluster' - }); - const cluster: odo.OpenShiftObject[] = await odo.getInstance().getClusters(); - assert.equal(cluster[0].getName(), 'Please log in to the cluster'); - }); - - test('show message if cluster is down', async () => { - sandbox.stub(odo.OdoImpl.prototype, 'execute').onFirstCall().resolves({ - error: undefined, - stdout: '', - stderr: 'Unable to connect to OpenShift cluster, is it down?' - }); - const cluster: odo.OpenShiftObject[] = await odo.getInstance().getClusters(); - assert.equal(cluster[0].getName(), 'Cannot connect to the OpenShift cluster'); - }); - test('extension uses oc version to get cluster url as a backup plan', async () => { sandbox.stub(odo.OdoImpl.prototype, 'execute').onFirstCall().resolves({ error: undefined, From 9efe88c66b833db73ebbff78acb1528a60f988b2 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 15:16:53 -0800 Subject: [PATCH 6/7] Remove commented code Signed-off-by: Denis Golovin dgolovin@redhat.com --- src/odo.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/odo.ts b/src/odo.ts index a3fe7851f..2f772aad3 100644 --- a/src/odo.ts +++ b/src/odo.ts @@ -490,13 +490,6 @@ export class OdoImpl implements Odo { '"system:anonymous"', ]; - // private readonly serverDownMessages = [ - // 'Unable to connect to OpenShift cluster, is it down?', - // 'no such host', - // 'no route to host', - // 'connection refused', - // ]; - public readonly subject: Subject = new Subject(); public static get Instance(): Odo { @@ -539,12 +532,6 @@ export class OdoImpl implements Odo { const result: cliInstance.CliExitData = await this.execute( Command.printOdoVersionAndProjects(), process.cwd(), false ); - // if (this.odoLoginMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { - // return[new OpenShiftLoginRequired()]; - // } - // if (this.serverDownMessages.some((element) => result.stderr ? result.stderr.includes(element) : false)) { - // return [new OpenShiftClusterDown()]; - // } commands.executeCommand('setContext', 'isLoggedIn', true); clusters = result.stdout.trim().split('\n').filter((value) => { return value.includes('Server:'); From b0f439ef2988fb41fcefad34f98d1437d8607eb4 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Mon, 22 Feb 2021 15:41:10 -0800 Subject: [PATCH 7/7] Update button names for view welcome page Signed-off-by: Denis Golovin dgolovin@redhat.com --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0d27691c..aae9ca10f 100644 --- a/package.json +++ b/package.json @@ -783,7 +783,7 @@ "viewsWelcome": [ { "view": "openshiftProjectExplorer", - "contents": "Cluster is not accessible or you are not logged in\n[Login](command:openshift.explorer.login)\n[Change Kubernetes context](command:openshift.explorer.switchContext)\n[Provision OpenShift Cluster](command:openshift.explorer.addCluster)" + "contents": "Cluster is not accessible or you are not logged in.\n[Login](command:openshift.explorer.login)\n[Select Kubernetes Context ](command:openshift.explorer.switchContext)\n[Add OpenShift Cluster](command:openshift.explorer.addCluster)" } ], "menus": {