Skip to content

Commit

Permalink
Task: create open documentation page command (#5515)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Oct 2, 2024
1 parent f0d2c1a commit f837b76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as vscode from "vscode";

import { treeViewId } from "../../constants";
import { OpenApiTreeNode } from "../../openApiTreeProvider";
import { Command } from "../Command";

export class OpenDocumentationPageCommand extends Command {

public getName(): string {
return `${treeViewId}.openDocumentationPage`;
}

public async execute(node: OpenApiTreeNode): Promise<void> {
node.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(node.documentationUrl));
}

}
7 changes: 3 additions & 4 deletions vscode/microsoft-kiota/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { MigrateFromLockFileCommand } from './commands/migrateFromLockFileComman
import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-view/addAllToSelectedEndpointsCommand';
import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-view/addToSelectedEndpointsCommand';
import { FilterDescriptionCommand } from './commands/open-api-tree-view/filterDescriptionCommand';
import { OpenDocumentationPageCommand } from './commands/open-api-tree-view/openDocumentationPageCommand';
import { RemoveAllFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeAllFromSelectedEndpointsCommand';
import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-view/removeFromSelectedEndpointsCommand';
import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants";
Expand Down Expand Up @@ -73,6 +74,7 @@ export async function activate(
const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider);
const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider);
const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider);
const openDocumentationPageCommand = new OpenDocumentationPageCommand();

await loadTreeView(context);
await checkForLockFileAndPrompt(context);
Expand Down Expand Up @@ -126,10 +128,7 @@ export async function activate(
dependenciesInfoProvider
),
vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider),
registerCommandWithTelemetry(reporter,
`${treeViewId}.openDocumentationPage`,
(x: OpenApiTreeNode) => x.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(x.documentationUrl))
),
registerCommandWithTelemetry(reporter, openDocumentationPageCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await openDocumentationPageCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, addToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addToSelectedEndpointsCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, addAllToSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await addAllToSelectedEndpointsCommand.execute(openApiTreeNode)),
registerCommandWithTelemetry(reporter, removeFromSelectedEndpointsCommand.getName(), async (openApiTreeNode: OpenApiTreeNode) => await removeFromSelectedEndpointsCommand.execute(openApiTreeNode)),
Expand Down

0 comments on commit f837b76

Please sign in to comment.