webview: Add Template Gallery view to webview package#2278
webview: Add Template Gallery view to webview package#2278gavin-aguiar wants to merge 10 commits into
Conversation
|
Thanks for putting up this PR! A couple of things I noticed:
|
@motm32 that a good call. I refactored the components to use the Fluent UI. Also fixed the linting errors. |
| if (!this.isDisposed) { | ||
| void this._panel.webview.postMessage(message); |
|
A couple of things I noticed with the new changes:
testing.mp4
|
The main reason for having 2 different options (Generate Project and Continue in Chat) is that if a function app is simple enough, we don't need to chat with the agent/llm. From my testing, the Generate Button gives good results. Only for more complicated apps when the function app might be too large to generate in a single prompt and more conversation with the agent is needed, the "Continue in Copilot chat" is useful.
I'll fix this.
The language is a dropdown where the users can choose the language of the function app based on the prompt. IMO putting it after the prompt and before the generate button makes sense since that is the order one would go through before creating a function app.
I did still keep the language color coding since it before more intuitive. If it does cause some accessibility issues, I'll change it. But for now I think keeping it color coded gives it a nicer view. |
|
|
||
| // ── Actions ── | ||
|
|
||
|
|




Summary
Adds a Template Gallery webview to @microsoft/vscode-azext-webview, enabling Azure extensions to share a common template browsing and project creation UI.
Architecture
TemplateGalleryController— Abstract class extendingWebviewBaseController<TemplateGalleryConfig>. Consumers subclass and implement:fetchTemplates()— fetch from their manifestcreateProject()— scaffold the projectgetReadme()— fetch template READMEgenerateWithCopilot(),createAiProject(),continueInChat(),fetchCachedTemplates()TemplateGalleryConfig— Initial data passed to the webview; controls header copy, AI tab visibility, display-name maps, language filter mapping, and filter ordering (languageOrder,categoryOrder,resourceOrder).TemplateGalleryConfigProvidermerges extension-provided config with package defaults, accessed viauseTemplateGalleryConfig()hook.WebviewBaseControllernow falls back toext.webviewAssetsDir(set viaregisterWebviewExtensionVariables) before thenode_modulespath, so bundled VSIXs that shipviews.js/views.cssin their owndist/folder work without each controller passing aWebviewBundleLocation.Changes
New files
src/extension/TemplateGalleryController.tssrc/webview/TemplateGallery/TemplateGalleryView.tsxsrc/webview/TemplateGallery/TemplateGalleryConfigContext.tsxsrc/webview/TemplateGallery/types.tssrc/webview/TemplateGallery/components/FilterBar.tsxsrc/webview/TemplateGallery/components/TemplateCard.tsxsrc/webview/TemplateGallery/components/TemplateConfigView.tsxsrc/webview/TemplateGallery/components/AiGenerateView.tsxsrc/webview/TemplateGallery/components/CreatingView.tsxsrc/webview/TemplateGallery/utils/renderMarkdown.tssrc/webview/styles/templateGalleryView.scssModified files
src/index.tsTemplateGalleryController, types, plusWebviewBaseController/WebviewController/WebviewBundleLocationsrc/webview/WebviewRegistry.tstemplateGalleryViewto the registrysrc/extension/WebviewBaseController.tsgetDocumentTemplate()falls back toext.webviewAssetsDirbefore thenode_modulespathConsumption example
Testing
npm run build— all four targets pass (esm, cjs, assets, webview bundle)npm run lint— clean (0 errors, 0 warnings)Screenshots
Shows the language / use case / resource filter chips with their colored borders, and the template grid with two-color cards (Featured + Explore More sections).
Click into any template card. Shows the new "Template Details" heading, the selected-template card on the left, the language dropdown / location input / "What's included" / Create Project button, and the README preview on the right.
After a successful create, capture the README markdown preview opening in the editor pane (replacing the gallery webview).