This commit is contained in:
Elinor 2024-07-29 19:55:31 +03:00 коммит произвёл GitHub
Родитель c6d2789b52
Коммит 72e3f8b9b1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 48 добавлений и 28 удалений

Просмотреть файл

@ -409,6 +409,10 @@
{
"command": "kiota.regenerate",
"title": "%kiota.openApiExplorer.regenerateButton.title%"
},
{
"command": "kiota.workspace.refresh",
"title": "%kiota.openApiExplorer.refresh.title%"
}
],
"languages": [

Просмотреть файл

@ -29,5 +29,6 @@
"kiota.openApiExplorer.openFile.title": "Open file",
"kiota.workspace.name": "My Workspace",
"kiota.openApiExplorer.regenerateButton.title": "Re-generate",
"kiota.openApiExplorer.editPaths.title": "Edit paths"
"kiota.openApiExplorer.editPaths.title": "Edit paths",
"kiota.openApiExplorer.refresh.title": "Refresh"
}

Просмотреть файл

@ -444,6 +444,7 @@ export async function activate(
openApiTreeProvider.setSelectionChanged(false);
const workspaceJsonPath = getWorkspaceJsonPath();
await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, clientNameOrPluginName );
await vscode.commands.executeCommand('kiota.workspace.refresh');
await updateTreeViewIcons(treeViewId, false, true);
}
async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise<void> {

Просмотреть файл

@ -42,6 +42,7 @@ export function getWorkspaceJsonDirectory(clientNameOrPluginName?: string): stri
return workspaceFolder;
}
//used to store output in the App Package directory in the case where the workspace is a Teams Toolkit Project
export function findAppPackageDirectory(directory: string): string | null {
if (!fs.existsSync(directory)) {
return null;

Просмотреть файл

@ -6,42 +6,54 @@ import { getWorkspaceJsonPath } from './util';
export class WorkspaceTreeProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
constructor(public isWSPresent: boolean) {
}
async getChildren(element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
if (!this.isWSPresent) {
return [];
}
if (!element) {
return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)];
}
public isWSPresent: boolean;
private _onDidChangeTreeData: vscode.EventEmitter<vscode.TreeItem | undefined | null | void> = new vscode.EventEmitter<vscode.TreeItem | undefined | null | void>();
readonly onDidChangeTreeData: vscode.Event<vscode.TreeItem | undefined | null | void> = this._onDidChangeTreeData.event;
constructor( isWSPresent: boolean) {
this.isWSPresent = isWSPresent;
}
async refreshView(): Promise<void> {
this._onDidChangeTreeData.fire();
}
async getChildren(element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
if (!this.isWSPresent) {
return [];
}
getTreeItem(element: vscode.TreeItem): vscode.TreeItem {
if (element) {
element.command = {
command: 'kiota.workspace.openWorkspaceFile',
title: vscode.l10n.t("Open File"),
arguments: [vscode.Uri.file(getWorkspaceJsonPath())]
};
element.contextValue = 'file';
}
return element;
if (!element) {
return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)];
}
return [];
}
getTreeItem(element: vscode.TreeItem): vscode.TreeItem {
if (element) {
element.command = {
command: 'kiota.workspace.openWorkspaceFile',
title: vscode.l10n.t("Open File"),
arguments: [vscode.Uri.file(getWorkspaceJsonPath())]
};
element.contextValue = 'file';
}
return element;
}
}
async function openResource(resource: vscode.Uri): Promise<void> {
await vscode.window.showTextDocument(resource);
}
async function isKiotaWorkspaceFilePresent(): Promise<boolean> {
const workspaceFileDir = path.resolve(getWorkspaceJsonPath());
try {
await fs.promises.access(workspaceFileDir);
} catch (error) {
return false;
}
return true;
if(!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0){
return false;
}
const workspaceFileDir = path.resolve(getWorkspaceJsonPath());
try {
await fs.promises.access(workspaceFileDir);
} catch (error) {
return false;
}
return true;
}
export async function loadTreeView(context: vscode.ExtensionContext): Promise<void> {
@ -54,5 +66,6 @@ export async function loadTreeView(context: vscode.ExtensionContext): Promise<vo
context.subscriptions.push(vscode.commands.registerCommand('kiota.workspace.openWorkspaceFile', openResource));
context.subscriptions.push(vscode.commands.registerCommand('kiota.workspace.refresh', async () => {
treeDataProvider.isWSPresent = await isKiotaWorkspaceFilePresent();
await treeDataProvider.refreshView();
}));
}