Add null checks for server tree view (#24038)

This commit is contained in:
Cheena Malhotra
2023-07-31 17:28:15 -07:00
committed by GitHub
parent ae05fdc332
commit 85f3cbc751

View File

@@ -70,12 +70,17 @@ class ConnectionProfileGroupTemplate extends Disposable {
matches: createMatches(filterData) matches: createMatches(filterData)
}); });
const actionProvider = this._objectExplorerService.getServerTreeView().treeActionProvider; let serverTreeView = this._objectExplorerService.getServerTreeView();
const tree = this._objectExplorerService.getServerTreeView().tree; if (serverTreeView) {
const actions = actionProvider.getActions(tree, element, true); const actionProvider = serverTreeView.treeActionProvider;
this._actionBar.context = this._objectExplorerService.getServerTreeView().getActionContext(element); const tree = serverTreeView.tree;
this._actionBar.clear(); const actions = actionProvider.getActions(tree, element, true);
this._actionBar.pushAction(actions, { icon: true, label: false }); this._actionBar.context = serverTreeView.getActionContext(element);
this._actionBar.clear();
this._actionBar.pushAction(actions, { icon: true, label: false });
} else {
console.log('Server Tree view not loaded, action bar will not be populated.');
}
} }
} }
@@ -150,18 +155,23 @@ class ConnectionProfileTemplate extends Disposable {
matches: createMatches(filterData) matches: createMatches(filterData)
}); });
this._root.title = treeNode?.filters?.length > 0 ? getLabelWithFilteredSuffix(element.serverInfo) : element.serverInfo; this._root.title = treeNode?.filters?.length > 0 ? getLabelWithFilteredSuffix(element.serverInfo) : element.serverInfo;
const actionProvider = this._objectExplorerService.getServerTreeView().treeActionProvider; let serverTreeView = this._objectExplorerService.getServerTreeView();
if (!this._isCompact) { if (serverTreeView) {
const tree = this._objectExplorerService.getServerTreeView().tree; const actionProvider = serverTreeView.treeActionProvider;
const actions = actionProvider.getActions(tree, element, true); if (!this._isCompact) {
this._actionBar.context = this._objectExplorerService.getServerTreeView().getActionContext(element); const tree = serverTreeView.tree;
this._actionBar.clear(); const actions = actionProvider.getActions(tree, element, true);
this._actionBar.pushAction(actions, { icon: true, label: false }); this._actionBar.context = serverTreeView.getActionContext(element);
this._actionBar.clear();
this._actionBar.pushAction(actions, { icon: true, label: false });
} else {
const actions = actionProvider.getRecentConnectionActions(element);
this._actionBar.context = undefined;
this._actionBar.clear();
this._actionBar.pushAction(actions, { icon: true, label: false });
}
} else { } else {
const actions = actionProvider.getRecentConnectionActions(element); console.log('Server Tree view not loaded, action bar will not be populated.');
this._actionBar.context = undefined;
this._actionBar.clear();
this._actionBar.pushAction(actions, { icon: true, label: false });
} }
} }
} }
@@ -247,12 +257,17 @@ class TreeNodeTemplate extends Disposable {
matches: createMatches(filterData) matches: createMatches(filterData)
}); });
this._root.title = labelText; this._root.title = labelText;
const tree = this._objectExplorerService.getServerTreeView().tree; let serverTreeView = this._objectExplorerService.getServerTreeView();
const actionProvider = this._objectExplorerService.getServerTreeView().treeActionProvider; if (serverTreeView) {
const actions = actionProvider.getActions(tree, element, true); const tree = serverTreeView.tree;
this._actionBar.context = this._objectExplorerService.getServerTreeView().getActionContext(element); const actionProvider = serverTreeView.treeActionProvider;
this._actionBar.clear(); const actions = actionProvider.getActions(tree, element, true);
this._actionBar.pushAction(actions, { icon: true, label: false }); this._actionBar.context = serverTreeView.getActionContext(element);
this._actionBar.clear();
this._actionBar.pushAction(actions, { icon: true, label: false });
} else {
console.log('Server Tree view not loaded, action bar will not be populated.');
}
} }
} }