Add null checks for server tree view (#24038) (#24039)

This commit is contained in:
Cheena Malhotra
2023-07-31 20:07:21 -07:00
committed by GitHub
parent 9423907f30
commit 441f2eaf35

View File

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