Add loading spinner for connection tree element refresh (#20621)

* added loading status to tree elements during refresh

* added message

* added lambda function

* added async

* moved addtraits to below null check

* Added debug lines for now

* added wip stack

* moved loading icon logic to inside tree item code

* added dispose logic

* Added comment explaining actions

* removed reference to NodeJs Timeout

* added showLoading status to Tree creation utils

* fixed spaces

* removed unnecessary space

* removed unnecessary timer for more responsive results

* removed call in connectionTreeActions test

* added fix to test

* stick to refresh only

* added 100 ms timeout

* added request comment
This commit is contained in:
Alex Ma
2022-11-02 09:42:06 -07:00
committed by GitHub
parent bb701c4fcf
commit 8a51bc91b4
6 changed files with 36 additions and 30 deletions

View File

@@ -60,16 +60,17 @@ export class RefreshAction extends Action {
if (treeNode) {
try {
try {
const session = treeNode.getSession();
if (session) {
await this._objectExplorerService.refreshTreeNode(session, treeNode);
}
} catch (error) {
this.showError(error);
return;
}
if (this._tree instanceof AsyncServerTree) {
// Code moved here as non async tree already does it in it's refresh function (required to show loading spinner)
try {
const session = treeNode.getSession();
if (session) {
await this._objectExplorerService.refreshTreeNode(session, treeNode);
}
} catch (error) {
this.showError(error);
return;
}
await this._tree.updateChildren(this.element);
} else {
await this._tree.refresh(this.element);

View File

@@ -62,21 +62,20 @@ export class ServerTreeDataSource implements IDataSource {
return (element as ConnectionProfileGroup).getChildren();
} else if (element instanceof TreeNode) {
let node = element;
if (node.children) {
try {
// Grab the latest data from the server of the node's children.
await this._objectExplorerService.refreshTreeNode(node.getSession()!, node);
return node.children;
} else {
try {
return this._objectExplorerService.resolveTreeNodeChildren(node.getSession()!, node);
} catch (expandError) {
await node.setExpandedState(TreeItemCollapsibleState.Collapsed);
node.errorStateMessage = expandError;
this.showError(expandError);
// collapse node and refresh in case of error so remove tree cache
setTimeout(() => {
tree.collapse(element).then(() => tree.refresh(element));
});
return [];
}
}
catch (expandRefreshError) {
await node.setExpandedState(TreeItemCollapsibleState.Collapsed);
node.errorStateMessage = expandRefreshError;
this.showError(expandRefreshError);
// collapse node and refresh in case of error so remove tree cache
setTimeout(() => {
tree.collapse(element).then(() => tree.refresh(element));
});
return [];
}
}
return [];

View File

@@ -134,7 +134,8 @@ export class TreeCreationUtils {
indentPixels: 10,
twistiePixels: 20,
ariaLabel: nls.localize('treeCreation.regTreeAriaLabel', "Servers"),
horizontalScrollMode: horizontalScrollMode ? ScrollbarVisibility.Auto : ScrollbarVisibility.Hidden
horizontalScrollMode: horizontalScrollMode ? ScrollbarVisibility.Auto : ScrollbarVisibility.Hidden,
showLoading: true
});
}