-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lambda): web-view functionality and fixes for serverless land #6687
base: feature/serverlessland
Are you sure you want to change the base?
feat(lambda): web-view functionality and fixes for serverless land #6687
Conversation
|
36dc419
to
1010f9c
Compare
let createResult: Result = 'Succeeded' | ||
let reason: string | undefined | ||
let metadataManager: MetadataManager | ||
|
||
try { | ||
metadataManager = MetadataManager.getInstance() | ||
// Launch the project creation wizard | ||
const config = await launchProjectCreationWizard(extContext) | ||
const config = await launchProjectCreationWizard(extContext, ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just use globals.context
instead of plumbing it through everywhere
@@ -32,14 +32,14 @@ export const templateToOpenAppComposer = 'aws.toolkit.appComposer.templateToOpen | |||
* IMPORTANT: Views that should work in all vscode environments (node or web) | |||
* should be setup in {@link activateViewsShared}. | |||
*/ | |||
export async function activate(context: ExtContext): Promise<void> { | |||
export async function activate(context: ExtContext, ctx: vscode.ExtensionContext): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context should already have this
@@ -36,15 +37,15 @@ const serverlessLandRepo = 'serverless-patterns' | |||
* 5. Opens the README.md file if available | |||
* 6. Handles errors and emits telemetry | |||
*/ | |||
export async function createNewServerlessLandProject(extContext: ExtContext): Promise<void> { | |||
export async function createNewServerlessLandProject(extContext: ExtContext, ctx: ExtensionContext): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extContext should already have this ctx
export class WebviewService { | ||
constructor() {} | ||
|
||
public static getWebviewContent(url: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you help to add a scrnshot for webview?
@@ -142,6 +144,43 @@ export function createQuickPick<T>( | |||
const mergedOptions = { ...defaultQuickpickOptions, ...options } | |||
assign(mergedOptions, picker) | |||
picker.buttons = mergedOptions.buttons ?? [] | |||
let serverlessPanel: vscode.WebviewPanel | undefined | |||
|
|||
picker.onDidTriggerItemButton(async (event) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider something like this to avoid these if/else indents
picker.onDidTriggerItemButton(async (event) => {
const { button, item: selectedPattern } = event
const metadataManager = MetadataManager.getInstance()
// Early return if not handling GitHub or Serverless Land buttons
if (!['Open in GitHub', 'Open in Serverless Land'].includes(button.tooltip)) {
return
}
// Early return if no pattern is selected
if (!selectedPattern) {
return
}
const patternUrl = metadataManager.getUrl(selectedPattern.label)
if (!patternUrl) {
return
}
// Handle GitHub button click
if (button.tooltip === 'Open in GitHub') {
await vscode.env.openExternal(vscode.Uri.parse(patternUrl.githubUrl))
return
}
// Handle Serverless Land button click
if (!serverlessPanel) {
serverlessPanel = createServerlessPanel(selectedPattern.label)
} else {
serverlessPanel.title = selectedPattern.label
}
serverlessPanel.webview.html = WebviewService.getWebviewContent(patternUrl.previewUrl)
serverlessPanel.reveal()
})
@@ -1327,24 +1327,29 @@ | |||
"group": "1_account@3" | |||
}, | |||
{ | |||
"command": "aws.lambda.createNewSamApp", | |||
"command": "aws.toolkit.lambda.createServerlessLandProject", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why changing all these? Seem you just need to add an entry for "aws.toolkit.lambda.createServerlessLandProject"
'serverlessLand', | ||
'metadata.json' | ||
), | ||
destination: path.join('src', 'serverlessLand', 'metadata.json'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it there a reason why we can't put this file directly in this destination?
Problem
This PR adds the web view functionality for patterns. It addresses an issue with the
metadata.json
file path for the extension by specifying the path after the build step in thecopyFile.ts
file.Solution
feature/x
branches will not be squash-merged at release time.