-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into task/extension/create-updateClientsCommand
- Loading branch information
Showing
5 changed files
with
138 additions
and
80 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
vscode/microsoft-kiota/src/commands/closeDescriptionCommand.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,31 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { treeViewId } from "../constants"; | ||
import { OpenApiTreeProvider } from "../openApiTreeProvider"; | ||
import { updateTreeViewIcons } from '../util'; | ||
import { Command } from "./Command"; | ||
|
||
export class CloseDescriptionCommand extends Command { | ||
|
||
public constructor(private _openApiTreeProvider: OpenApiTreeProvider) { | ||
super(); | ||
} | ||
|
||
public getName(): string { | ||
return `${treeViewId}.closeDescription`; | ||
} | ||
|
||
public async execute(): Promise<void> { | ||
const yesAnswer = vscode.l10n.t("Yes"); | ||
const response = await vscode.window.showInformationMessage( | ||
vscode.l10n.t("Do you want to remove this API description?"), | ||
yesAnswer, | ||
vscode.l10n.t("No") | ||
); | ||
if (response === yesAnswer) { | ||
this._openApiTreeProvider.closeDescription(); | ||
await updateTreeViewIcons(treeViewId, false); | ||
} | ||
} | ||
|
||
} |
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,19 @@ | ||
import { extensionId } from "../constants"; | ||
import { OpenApiTreeProvider } from "../openApiTreeProvider"; | ||
import { loadWorkspaceFile } from "../utilities/file"; | ||
import { Command } from "./Command"; | ||
|
||
export class SelectLockCommand extends Command { | ||
constructor(private _openApiTreeProvider: OpenApiTreeProvider) { | ||
super(); | ||
} | ||
|
||
public getName(): string { | ||
return `${extensionId}.selectLock`; | ||
} | ||
|
||
public async execute(node: any): Promise<void> { | ||
await loadWorkspaceFile(node, this._openApiTreeProvider); | ||
} | ||
|
||
} |
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,24 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { statusBarCommandId } from "../constants"; | ||
import { Command } from "./Command"; | ||
|
||
export class StatusCommand extends Command { | ||
|
||
public getName(): string { | ||
return statusBarCommandId; | ||
} | ||
|
||
public async execute(): Promise<void> { | ||
const yesAnswer = vscode.l10n.t("Yes"); | ||
const response = await vscode.window.showInformationMessage( | ||
vscode.l10n.t("Open installation instructions for kiota?"), | ||
yesAnswer, | ||
vscode.l10n.t("No") | ||
); | ||
if (response === yesAnswer) { | ||
await vscode.env.openExternal(vscode.Uri.parse("https://aka.ms/get/kiota")); | ||
} | ||
} | ||
|
||
} |
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,51 @@ | ||
import * as vscode from 'vscode'; | ||
import TelemetryReporter from '@vscode/extension-telemetry'; | ||
|
||
import { OpenApiTreeProvider } from "../openApiTreeProvider"; | ||
import { validateDeepLinkQueryParams } from '../utilities/deep-linking'; | ||
import { openTreeViewWithProgress } from '../utilities/progress'; | ||
import { setDeepLinkParams, getDeepLinkParams } from './deepLinkParamsHandler'; | ||
|
||
export class UriHandler { | ||
constructor(private context: vscode.ExtensionContext, private openApiTreeProvider: OpenApiTreeProvider) { } | ||
|
||
async handleUri(uri: vscode.Uri) { | ||
if (uri.path === "/") { | ||
return; | ||
} | ||
const queryParameters = this.getQueryParameters(uri); | ||
if (uri.path.toLowerCase() === "/opendescription") { | ||
let [params, errorsArray] = validateDeepLinkQueryParams(queryParameters); | ||
setDeepLinkParams(params); | ||
|
||
const reporter = new TelemetryReporter(this.context.extension.packageJSON.telemetryInstrumentationKey); | ||
reporter.sendTelemetryEvent("DeepLink.OpenDescription initialization status", { | ||
"queryParameters": JSON.stringify(queryParameters), | ||
"validationErrors": errorsArray.join(", ") | ||
}); | ||
|
||
let deepLinkParams = getDeepLinkParams(); | ||
if (deepLinkParams.descriptionurl) { | ||
await openTreeViewWithProgress(() => this.openApiTreeProvider.setDescriptionUrl(deepLinkParams.descriptionurl!)); | ||
return; | ||
} | ||
} | ||
void vscode.window.showErrorMessage( | ||
vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") | ||
); | ||
} | ||
|
||
private getQueryParameters(uri: vscode.Uri): Record<string, string> { | ||
const query = uri.query; | ||
if (!query) { | ||
return {}; | ||
} | ||
const queryParameters = (query.startsWith('?') ? query.substring(1) : query).split("&"); | ||
const parameters = {} as Record<string, string>; | ||
queryParameters.forEach((element) => { | ||
const keyValue = element.split("="); | ||
parameters[keyValue[0].toLowerCase()] = decodeURIComponent(keyValue[1]); | ||
}); | ||
return parameters; | ||
} | ||
} |