aws-toolkit-vscode icon indicating copy to clipboard operation
aws-toolkit-vscode copied to clipboard

feat(ui): support multipick prompter

Open roger-zhangg opened this issue 1 year ago • 2 comments

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

image

// 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.

roger-zhangg avatar Oct 19 '24 01:10 roger-zhangg

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.

github-actions[bot] avatar Oct 19 '24 01:10 github-actions[bot]

This pull request implements a feature or fix, so it must include a changelog entry. See CONTRIBUTING.md#changelog for instructions.

github-actions[bot] avatar Oct 19 '24 01:10 github-actions[bot]

The code itself looks fine to me but I think we should really have tests for something like this before we merge it

jpinkney-aws avatar Oct 21 '24 14:10 jpinkney-aws

Thanks @jpinkney-aws I'm working on that, will ping you once added

roger-zhangg avatar Oct 21 '24 17:10 roger-zhangg

Hi @jpinkney-aws Please take another look when available. Thanks!

roger-zhangg avatar Oct 21 '24 23:10 roger-zhangg

/runintegrationtests

justinmk3 avatar Oct 22 '24 18:10 justinmk3

The failing integ tests are perf tests, unrelated to this PR.

justinmk3 avatar Oct 22 '24 19:10 justinmk3