mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix tree refresh (#8625)
* first part * remove another refresh collapse expand * Fix scriptable nodes * Fix test
This commit is contained in:
@@ -56,7 +56,6 @@ export class RefreshAction extends Action {
|
|||||||
|
|
||||||
if (treeNode) {
|
if (treeNode) {
|
||||||
try {
|
try {
|
||||||
await this._tree.collapse(this.element);
|
|
||||||
try {
|
try {
|
||||||
await this._objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
|
await this._objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -64,7 +63,6 @@ export class RefreshAction extends Action {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
await this._tree.refresh(this.element);
|
await this._tree.refresh(this.element);
|
||||||
return this._tree.expand(this.element);
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
this._logService.error(ex);
|
this._logService.error(ex);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
|||||||
|
|
||||||
// Contribute refresh action for scriptable objects via contribution
|
// Contribute refresh action for scriptable objects via contribution
|
||||||
if (!this.isScriptableObject(context)) {
|
if (!this.isScriptableObject(context)) {
|
||||||
actions.push(this._instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL, context.tree, context.profile));
|
actions.push(this._instantiationService.createInstance(RefreshAction, RefreshAction.ID, RefreshAction.LABEL, context.tree, context.treeNode || context.profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
|
|||||||
@@ -428,7 +428,6 @@ suite('SQL Connection Tree Action tests', () => {
|
|||||||
objectExplorerService.verify(x => x.getObjectExplorerNode(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
objectExplorerService.verify(x => x.getObjectExplorerNode(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||||
objectExplorerService.verify(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
objectExplorerService.verify(x => x.refreshTreeNode(TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||||
tree.verify(x => x.refresh(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
tree.verify(x => x.refresh(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
||||||
tree.verify(x => x.expand(TypeMoq.It.isAny()), TypeMoq.Times.atLeastOnce());
|
|
||||||
}).then(() => done(), (err) => {
|
}).then(() => done(), (err) => {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -311,34 +311,18 @@ CommandsRegistry.registerCommand({
|
|||||||
CommandsRegistry.registerCommand({
|
CommandsRegistry.registerCommand({
|
||||||
id: OE_REFRESH_COMMAND_ID,
|
id: OE_REFRESH_COMMAND_ID,
|
||||||
handler: async (accessor, args: ObjectExplorerActionsContext): Promise<void> => {
|
handler: async (accessor, args: ObjectExplorerActionsContext): Promise<void> => {
|
||||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
|
||||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
|
||||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||||
const logService = accessor.get(ILogService);
|
const logService = accessor.get(ILogService);
|
||||||
const notificationService = accessor.get(INotificationService);
|
const notificationService = accessor.get(INotificationService);
|
||||||
const connection = new ConnectionProfile(capabilitiesService, args.connectionProfile);
|
const treeNode = await getTreeNode(args, objectExplorerService);
|
||||||
if (connectionManagementService.isConnected(undefined, connection)) {
|
const tree = objectExplorerService.getServerTreeView().tree;
|
||||||
let treeNode = await getTreeNode(args, objectExplorerService);
|
try {
|
||||||
if (!treeNode) {
|
await objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
|
||||||
await objectExplorerService.updateObjectExplorerNodes(connection.toIConnectionProfile());
|
await tree.refresh(treeNode);
|
||||||
treeNode = objectExplorerService.getObjectExplorerNode(connection);
|
} catch (err) {
|
||||||
}
|
// Display message to the user but also log the entire error to the console for the stack trace
|
||||||
if (treeNode) {
|
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo.label, getErrorMessage(err)));
|
||||||
const tree = objectExplorerService.getServerTreeView().tree;
|
logService.error(err);
|
||||||
try {
|
|
||||||
await tree.collapse(treeNode);
|
|
||||||
await objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
|
|
||||||
await tree.refresh(treeNode);
|
|
||||||
await tree.expand(treeNode);
|
|
||||||
} catch (err) {
|
|
||||||
// Display message to the user but also log the entire error to the console for the stack trace
|
|
||||||
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo.label, getErrorMessage(err)));
|
|
||||||
logService.error(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
logService.error(`Could not find tree node for node ${args.nodeInfo.label}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user