-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PowerPages][create-site] Preview and Edit Site Page and Command Regi…
…stration (#1061) * Enhance CreateSiteCommand to include extension context and add ReadonlyFileSystemProvider for site page previews * Implement EditableFileSystemProvider for site page editing and update CreateSiteHelper to utilize it * Integrate CreateSiteCommand into CommandRegistry and update related components for site creation functionality * Disable copy functionality in EditableFileSystemProvider implementation * Remove ReadonlyFileSystemProvider implementation * Add telemetry constant for previewing site pages and refactor related components * Refactor CommandRegistry and add command registration utility for chat participants * Add constants for site creation parameters and refactor NL2SiteService to use them * Refactor CreateSiteCommand and CreateSiteHelper to use structured options and improve readability; add CreateSiteTypes for better type management * Add error telemetry constant for previewing site pages and handle errors in previewSitePagesContent function * Rename fileContentMap to _fileContentMap for consistency and clarity in EditableFileSystemProvider * Remove unused getUpdatedPageContent function from CreateSiteHelper to streamline code * Add ESLint disable comments for any type usage in CreateSiteHelper and CreateSiteTypes --------- Co-authored-by: amitjoshi <[email protected]>
- Loading branch information
1 parent
c7d4ff9
commit 8fad281
Showing
11 changed files
with
223 additions
and
24 deletions.
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
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
9 changes: 9 additions & 0 deletions
9
src/common/chat-participants/powerpages/commands/create-site/CreateSiteConstants.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,9 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
export const EDITABLE_SCHEME = 'editable'; | ||
export const ENGLISH = "English"; | ||
export const MIN_PAGES = 7; | ||
export const MAX_PAGES = 7; |
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
33 changes: 33 additions & 0 deletions
33
src/common/chat-participants/powerpages/commands/create-site/CreateSiteTypes.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,33 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { ITelemetry } from "../../../../OneDSLoggerTelemetry/telemetry/ITelemetry"; | ||
import * as vscode from 'vscode'; | ||
|
||
export interface ICreateSiteOptions { | ||
intelligenceEndpoint: string; | ||
intelligenceApiToken: string; | ||
userPrompt: string; | ||
sessionId: string; | ||
stream: vscode.ChatResponseStream; | ||
telemetry: ITelemetry; | ||
orgId: string; | ||
envId: string; | ||
userId: string; | ||
extensionContext: vscode.ExtensionContext; | ||
} | ||
|
||
export interface IPreviewSitePagesContentOptions { | ||
// siteName: string; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
sitePages: any[]; | ||
stream: vscode.ChatResponseStream; | ||
extensionContext: vscode.ExtensionContext; | ||
telemetry: ITelemetry; | ||
sessionId: string; | ||
orgId: string; | ||
envId: string; | ||
userId: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
|
||
export class EditableFileSystemProvider implements vscode.FileSystemProvider { | ||
private _fileContentMap: { [key: string]: Uint8Array } = {}; | ||
private _onDidChangeEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>(); | ||
readonly onDidChangeFile = this._onDidChangeEmitter.event; | ||
|
||
watch(uri: vscode.Uri, options: { readonly recursive: boolean; readonly excludes: readonly string[]; }): vscode.Disposable { | ||
// For simplicity, this implementation does not support file watching. | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
return new vscode.Disposable(() => {}); | ||
} | ||
|
||
copy(source: vscode.Uri, destination: vscode.Uri, options: { readonly overwrite: boolean; }): void | Thenable<void> { | ||
// Copy is not supported in this implementation | ||
} | ||
|
||
// Read file content | ||
readFile(uri: vscode.Uri): Uint8Array { | ||
const filePath = uri.path; | ||
return this._fileContentMap[filePath] || new Uint8Array(); | ||
} | ||
|
||
// Write file content | ||
writeFile(uri: vscode.Uri, content: Uint8Array): void { | ||
const filePath = uri.path; | ||
this._fileContentMap[filePath] = content; | ||
this._onDidChangeEmitter.fire([{ type: vscode.FileChangeType.Changed, uri }]); | ||
} | ||
|
||
// Other required methods for FileSystemProvider | ||
stat(uri: vscode.Uri): vscode.FileStat { | ||
return { type: vscode.FileType.File, ctime: Date.now(), mtime: Date.now(), size: this._fileContentMap[uri.path]?.length || 0 }; | ||
} | ||
|
||
readDirectory(uri: vscode.Uri): [string, vscode.FileType][] { | ||
return []; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
createDirectory(uri: vscode.Uri): void {} | ||
|
||
delete(uri: vscode.Uri): void { | ||
// Delete is not supported in this implementation | ||
} | ||
|
||
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { readonly overwrite: boolean; }): void { | ||
// Rename is not supported in this implementation | ||
} | ||
|
||
// Method to get file content as string | ||
getFileContent(uri: vscode.Uri): string { | ||
const filePath = uri.path; | ||
const content = this._fileContentMap[filePath]; | ||
return content ? Buffer.from(content).toString('utf8') : ''; | ||
} | ||
} |