Skip to content

Commit 4d2312b

Browse files
committed
Enable App Explorer welcome screen buttons after content is loaded
This PR fixes #2241. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent b7de24a commit 4d2312b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@
906906
"viewsWelcome": [
907907
{
908908
"view": "openshiftProjectExplorer",
909-
"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)"
909+
"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)",
910+
"enablement": "openshift.app.explorer.init"
910911
},
911912
{
912913
"view": "openshiftComponentsView",

src/explorer.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { WatchUtil, FileContentChangeNotifier } from './util/watch';
2727
import { KubeConfigUtils } from './util/kubeUtils';
2828
import { vsCommand } from './vscommand';
2929
import { ComponentTypesView } from './componentTypesView';
30+
import { isThenable } from './util/async';
3031

3132
const kubeConfigFolder: string = path.join(Platform.getUserHomePath(), '.kube');
3233

@@ -95,7 +96,19 @@ export class OpenShiftExplorer implements TreeDataProvider<OpenShiftObject>, Dis
9596

9697
// eslint-disable-next-line class-methods-use-this
9798
getChildren(element?: OpenShiftObject): ProviderResult<OpenShiftObject[]> {
98-
return element ? element.getChildren() : OpenShiftExplorer.odoctl.getClusters();
99+
let result;
100+
if (element) {
101+
result = element.getChildren();
102+
} else {
103+
result = OpenShiftExplorer.odoctl.getClusters();
104+
}
105+
if (isThenable(result)) {
106+
result = result.then(async (value: OpenShiftObject[]) => {
107+
await commands.executeCommand('setContext', 'openshift.app.explorer.init', value.length === 0);
108+
return value;
109+
})
110+
}
111+
return result;
99112
}
100113

101114
// eslint-disable-next-line class-methods-use-this

0 commit comments

Comments
 (0)