-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task: create edit paths command (#5517)
- Loading branch information
Showing
3 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { extensionId, treeViewId } from "../constants"; | ||
import { ClientOrPluginProperties } from "../kiotaInterop"; | ||
import { OpenApiTreeProvider } from "../openApiTreeProvider"; | ||
import { updateTreeViewIcons } from "../util"; | ||
import { openTreeViewWithProgress } from "../utilities/progress"; | ||
import { Command } from "./Command"; | ||
|
||
export class EditPathsCommand extends Command { | ||
|
||
private _openApiTreeProvider: OpenApiTreeProvider; | ||
|
||
public constructor(openApiTreeProvider: OpenApiTreeProvider) { | ||
super(); | ||
this._openApiTreeProvider = openApiTreeProvider; | ||
} | ||
|
||
public getName(): string { | ||
return `${extensionId}.editPaths`; | ||
} | ||
|
||
public async execute({ clientKey, clientObject }: { clientKey: string, clientObject: ClientOrPluginProperties }): Promise<void> { | ||
await this.loadEditPaths(clientKey, clientObject); | ||
this._openApiTreeProvider.resetInitialState(); | ||
await updateTreeViewIcons(treeViewId, false, true); | ||
} | ||
|
||
private async loadEditPaths(clientKey: string, clientObject: ClientOrPluginProperties) { | ||
await openTreeViewWithProgress(() => this._openApiTreeProvider.loadEditPaths(clientKey, clientObject)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as vscode from "vscode"; | ||
|
||
import { treeViewFocusCommand } from "../constants"; | ||
|
||
function openTreeViewWithProgress<T>(callback: () => Promise<T>): Thenable<T> { | ||
return vscode.window.withProgress({ | ||
location: vscode.ProgressLocation.Notification, | ||
cancellable: false, | ||
title: vscode.l10n.t("Loading...") | ||
}, async (progress, _) => { | ||
const result = await callback(); | ||
await vscode.commands.executeCommand(treeViewFocusCommand); | ||
return result; | ||
}); | ||
} | ||
|
||
export { openTreeViewWithProgress }; |