aws-toolkit-vscode
aws-toolkit-vscode copied to clipboard
feat(ui): support multipick prompter
Problem
Currently prompter doesn't support multipick
Solution
Add a new function createMultiPick that supports multipick and can be used in Wizard.
The returned result will be a list encoded by JSON.stringify , use JSON.parse to recover the list
Proposed UX
// define DataQuickPickItem, note you can use picked: true to pre-select items in the multipick
const syncFlagItems: DataQuickPickItem<string>[] = [
{
label: 'Build in source',
data: '--build-in-source',
description: 'Opts in to build project in the source folder. Only for node apps',
},
{
label: 'Code',
data: '--code',
description: 'Sync only code resources (Lambda Functions, API Gateway, Step Functions)',
picked: true,
}
]
export interface SyncParams {
readonly syncFlags: string
}
// define the wizard
export class SyncWizard extends Wizard<SyncParams> {
public constructor() {
super()
this.form.syncFlags.bindPrompter(() => {
return createMultiPick(syncFlagItems, {
title: 'Specify parameters for sync',
placeholder: 'Press enter to proceed with highlighted option',
buttons: createCommonButtons(samSyncUrl),
})
})
}
}
// run the wizard
result = await new SyncWizard(
{ deployType, ...(await prepareSyncParams(input, validate)) },
registry
).run()
// decode to list -> ['--build-in-source','--code']
console.log(JSON.parse(result.syncFlags))
TODO
Add Tests
License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.
This pull request implements a feature or fix, so it must include a changelog entry. See CONTRIBUTING.md#changelog for instructions.
The code itself looks fine to me but I think we should really have tests for something like this before we merge it
Thanks @jpinkney-aws I'm working on that, will ping you once added
Hi @jpinkney-aws Please take another look when available. Thanks!
/runintegrationtests
The failing integ tests are perf tests, unrelated to this PR.