Skip to content

Commit

Permalink
Task: Display client/plugin name on API explorer (#4801)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW authored Jun 13, 2024
1 parent c0ad798 commit 4c97bf4
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 79 deletions.
8 changes: 4 additions & 4 deletions vscode/microsoft-kiota/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,22 @@
},
{
"command": "kiota.openApiExplorer.addToSelectedEndpoints",
"when": "view == kiota.openApiExplorer && viewItem != apiTitle",
"when": "view == kiota.openApiExplorer && viewItem != apiTitle && viewItem != clientNameOrPluginName",
"group": "inline@2"
},
{
"command": "kiota.openApiExplorer.addAllToSelectedEndpoints",
"when": "view == kiota.openApiExplorer",
"when": "view == kiota.openApiExplorer && viewItem != clientNameOrPluginName",
"group": "inline@4"
},
{
"command": "kiota.openApiExplorer.removeFromSelectedEndpoints",
"when": "view == kiota.openApiExplorer && viewItem != apiTitle",
"when": "view == kiota.openApiExplorer && viewItem != apiTitle && viewItem != clientNameOrPluginName",
"group": "inline@3"
},
{
"command": "kiota.openApiExplorer.removeAllFromSelectedEndpoints",
"when": "view == kiota.openApiExplorer",
"when": "view == kiota.openApiExplorer && viewItem != clientNameOrPluginName",
"group": "inline@5"
}
],
Expand Down
19 changes: 13 additions & 6 deletions vscode/microsoft-kiota/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function activate(
kiotaOutputChannel = vscode.window.createOutputChannel("Kiota", {
log: true,
});
const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE);
const openApiTreeProvider = new OpenApiTreeProvider(context, () => getExtensionSettings(extensionId));
const dependenciesInfoProvider = new DependenciesViewProvider(
context.extensionUri
Expand Down Expand Up @@ -225,7 +226,7 @@ export async function activate(
clientOrPluginKey = clientKey;
clientOrPluginObject = clientObject;
workspaceGenerationType = generationType;
await loadEditPaths(clientObject, openApiTreeProvider);
await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider);
await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false);
await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true);
}),
Expand Down Expand Up @@ -300,6 +301,8 @@ export async function activate(
if (result)
{
await checkForSuccess(result);
openApiTreeProvider.refreshView();
await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName);
await exportLogsAndShowErrors(result);
}
}
Expand Down Expand Up @@ -339,6 +342,8 @@ export async function activate(
if (result)
{
await checkForSuccess(result);
openApiTreeProvider.refreshView();
await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName);
await exportLogsAndShowErrors(result);
}
}
Expand Down Expand Up @@ -402,11 +407,13 @@ export async function activate(
result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) {
const WORKSPACE_FOLDER = vscode.workspace.workspaceFolders[0].uri.fsPath;
const KIOTA_WORKSPACE_PATH = path.join(WORKSPACE_FOLDER, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE);
await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH);
await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH, config.clientClassName);
}
if (result)
{
await checkForSuccess(result);
openApiTreeProvider.refreshView();
await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.clientClassName);
await exportLogsAndShowErrors(result);
}
}
Expand Down Expand Up @@ -574,13 +581,13 @@ async function showUpgradeWarningMessage(clientPath: string, context: vscode.Ext
}
}

async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider): Promise<void> {
await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath));
async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise<void> {
await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath, clientOrPluginName));
await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true);
}

async function loadEditPaths(clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise<void> {
await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientObject));
async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise<void> {
await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientOrPluginKey, clientObject));
}

async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise<void> {
Expand Down
26 changes: 7 additions & 19 deletions vscode/microsoft-kiota/src/kiotaInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface KiotaOpenApiNode {
selected?: boolean,
isOperation?: boolean;
documentationUrl?: string;
clientNameOrPluginName?: string;
}
interface CacheClearableConfiguration {
clearCache: boolean;
Expand Down Expand Up @@ -253,23 +254,10 @@ export function maturityLevelToString(level: MaturityLevel): string {
throw new Error("unknown level");
}
}
export interface LockFile {
clientClassName: string;
clientNamespaceName: string;
descriptionHash: string;
descriptionLocation: string;
deserializers: string[];
disabledValidationRules: string[];
excludeBackwardCompatible: boolean;
excludePatterns: string[];
includeAdditionalData: boolean;
includePatterns: string[];
kiotaVersion: string;
language: string;
lockFileVersion: string;
serializers: string[];
structuredMimeTypes: string[];
usesBackingStore: boolean;
export interface ConfigurationFile {
version: string;
clients: Record<string, ClientObjectProperties>;
plugins: Record<string, PluginObjectProperties>;
}

export interface GenerationConfiguration {
Expand Down Expand Up @@ -300,7 +288,7 @@ interface WorkspaceObjectProperties {
outputPath: string;
}

interface ClientObjectProperties extends WorkspaceObjectProperties {
export interface ClientObjectProperties extends WorkspaceObjectProperties {
language: string;
structuredMimeTypes: string[];
clientNamespaceName: string;
Expand All @@ -310,7 +298,7 @@ interface ClientObjectProperties extends WorkspaceObjectProperties {
disabledValidationRules: string[];
}

interface PluginObjectProperties extends WorkspaceObjectProperties {
export interface PluginObjectProperties extends WorkspaceObjectProperties {
types: string[];
}

Expand Down
Loading

0 comments on commit 4c97bf4

Please sign in to comment.