-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: show plugins and clients in panel #5784
Open
thewahome
wants to merge
34
commits into
main
Choose a base branch
from
task/extension/show-plugins-and-clients-in-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+391
−58
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
04a13a8
load workspace content inside tree
thewahome 2c31d69
expand node if item is available
7465f16
expand if items exist
3a01185
add view action buttons to the items
thewahome fd4b56f
activate selecting the path from the tree
thewahome 9b7ec58
reorder panels in view
thewahome 14259aa
When no clients or plugins, open root collapsed
thewahome 2287b59
only show the category if it has items
thewahome 52c0bba
access properties from extension command
thewahome ffe44e8
show open folder icon when plugin/client selected
thewahome 1aadd1f
reuse the regeneration command
thewahome 7fbaeea
Merge branch 'main' into task/extension/show-plugins-and-clients-in-p…
thewahome b285a33
Merge branch 'main' into task/extension/show-plugins-and-clients-in-p…
thewahome 711294c
[partial] delete workspace item
thewahome ab673e5
reuse item generation
232f108
support workspace tree provider
thewahome 5096870
don't clean output
thewahome 4ee59e7
add remove client async and remove plugin async functions to the RPC …
thewahome 0a6763f
connect to kiota rpc functions
thewahome a104372
isolate in folder
thewahome bca6af0
remove regeneration, change icon, call select
thewahome 693033a
Merge branch 'main' into task/extension/show-plugins-and-clients-in-p…
thewahome cc8b44f
add logging dependency
thewahome 72460cd
refresh view after deleting workspace item
thewahome 8983f71
load works[ace content on refresh
thewahome 96095f0
bump version numbrt to match kiota with changes
thewahome 95f03bc
use string formating
thewahome ce5afbe
show no clients or plugins available message
thewahome b10cd3f
Merge branch 'main' into task/extension/show-plugins-and-clients-in-p…
thewahome 00a381f
use translated button names
thewahome 737146b
Merge branch 'task/extension/show-plugins-and-clients-in-panel' of ht…
thewahome cb9f26b
change error message
thewahome 084c1ac
remove unnecessary console log
thewahome c951ffe
chore: removes duplication in server removal implementation
baywet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
96 changes: 96 additions & 0 deletions
96
vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/deleteWorkspaceItemCommand.ts
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,96 @@ | ||
import TelemetryReporter from "@vscode/extension-telemetry"; | ||
import * as vscode from "vscode"; | ||
|
||
import { extensionId } from "../../constants"; | ||
import { getLogEntriesForLevel, KiotaLogEntry, LogLevel } from "../../kiotaInterop"; | ||
import { WorkspaceTreeItem } from "../../providers/workspaceTreeProvider"; | ||
import { isPluginType } from "../../util"; | ||
import { exportLogsAndShowErrors } from "../../utilities/logging"; | ||
import { Command } from "../Command"; | ||
import { removeClient, removePlugin } from "./removeItem"; | ||
|
||
export class DeleteWorkspaceItemCommand extends Command { | ||
constructor( | ||
private _context: vscode.ExtensionContext, | ||
private _kiotaOutputChannel: vscode.LogOutputChannel | ||
) { | ||
super(); | ||
} | ||
|
||
public getName(): string { | ||
return `${extensionId}.workspace.deleteItem`; | ||
} | ||
|
||
public async execute(workspaceTreeItem: WorkspaceTreeItem): Promise<void> { | ||
const result = await this.deleteItem(isPluginType(workspaceTreeItem.category!) ? "plugin" : "client", workspaceTreeItem); | ||
if (result) { | ||
const isSuccess = result.some(k => k.message.includes('removed successfully')); | ||
if (isSuccess) { | ||
void vscode.window.showInformationMessage(vscode.l10n.t('{0} removed successfully.', workspaceTreeItem.label)); | ||
await vscode.commands.executeCommand('kiota.workspace.refresh'); | ||
} else { | ||
await exportLogsAndShowErrors(result, this._kiotaOutputChannel); | ||
} | ||
} | ||
} | ||
|
||
private async deleteItem(type: string, workspaceTreeItem: WorkspaceTreeItem): Promise<KiotaLogEntry[] | undefined> { | ||
if (type === "plugin") { | ||
return await this.deletePlugin(workspaceTreeItem.label); | ||
} else { | ||
return await this.deleteClient(workspaceTreeItem.label); | ||
} | ||
} | ||
|
||
private async deletePlugin(pluginName: string): Promise<KiotaLogEntry[] | undefined> { | ||
const result = await vscode.window.withProgress({ | ||
location: vscode.ProgressLocation.Notification, | ||
cancellable: false, | ||
title: vscode.l10n.t("Removing plugin...") | ||
}, async (progress, _) => { | ||
const start = performance.now(); | ||
const result = await removePlugin( | ||
this._context, | ||
pluginName!, | ||
false, | ||
); | ||
const duration = performance.now() - start; | ||
const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; | ||
const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); | ||
reporter.sendRawTelemetryEvent(`${extensionId}.removePlugin.completed`, { | ||
"pluginType": pluginName, | ||
"errorsCount": errorsCount.toString(), | ||
}, { | ||
"duration": duration, | ||
}); | ||
return result; | ||
}); | ||
return result; | ||
} | ||
private async deleteClient(clientName: string): Promise<KiotaLogEntry[] | undefined> { | ||
const result = await vscode.window.withProgress({ | ||
location: vscode.ProgressLocation.Notification, | ||
cancellable: false, | ||
title: vscode.l10n.t("Removing client...") | ||
}, async (progress, _) => { | ||
const start = performance.now(); | ||
const result = await removeClient( | ||
this._context, | ||
clientName, | ||
false, | ||
); | ||
const duration = performance.now() - start; | ||
const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; | ||
const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); | ||
reporter.sendRawTelemetryEvent(`${extensionId}.removeClient.completed`, { | ||
"client": clientName, | ||
"errorsCount": errorsCount.toString(), | ||
}, { | ||
"duration": duration, | ||
}); | ||
return result; | ||
}); | ||
return result; | ||
} | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
vscode/microsoft-kiota/src/commands/deleteWorkspaceItem/removeItem.ts
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,32 @@ | ||
import * as vscode from "vscode"; | ||
import * as rpc from "vscode-jsonrpc/node"; | ||
|
||
import { connectToKiota, KiotaLogEntry } from "../../kiotaInterop"; | ||
|
||
export function removePlugin(context: vscode.ExtensionContext, pluginName: string, cleanOutput: boolean): Promise<KiotaLogEntry[] | undefined> { | ||
return connectToKiota(context, async (connection) => { | ||
const request = new rpc.RequestType2<string, boolean, KiotaLogEntry[], void>( | ||
"RemovePlugin" | ||
); | ||
const result = await connection.sendRequest( | ||
request, | ||
pluginName, | ||
cleanOutput | ||
); | ||
return result; | ||
}); | ||
}; | ||
|
||
export function removeClient(context: vscode.ExtensionContext, clientName: string, cleanOutput: boolean): Promise<KiotaLogEntry[] | undefined> { | ||
return connectToKiota(context, async (connection) => { | ||
const request = new rpc.RequestType2<string, boolean, KiotaLogEntry[], void>( | ||
"RemoveClient" | ||
); | ||
const result = await connection.sendRequest( | ||
request, | ||
clientName, | ||
cleanOutput | ||
); | ||
return result; | ||
}); | ||
}; |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of duplication between the two methods, I think we have an opportunity to refactor and reduce duplication here.