Skip to content

Commit

Permalink
Add null checks for server tree view (#24038) (#24039)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Aug 1, 2023
1 parent 9423907 commit 441f2ea
Showing 1 changed file with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
}
}

Expand Down Expand Up @@ -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.');
}
}
}
Expand Down Expand Up @@ -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.');
}
}
}

Expand Down

0 comments on commit 441f2ea

Please sign in to comment.