diff --git a/packages/core/src/shared/sam/sync.ts b/packages/core/src/shared/sam/sync.ts index 1c9bbc45ea5..aee8203ad3e 100644 --- a/packages/core/src/shared/sam/sync.ts +++ b/packages/core/src/shared/sam/sync.ts @@ -354,16 +354,24 @@ export class SyncWizard extends Wizard { }) this.form.ecrRepoUri.bindPrompter(({ region }) => createEcrPrompter(new DefaultEcrClient(region!)), { - showWhen: ({ template }) => !!template && hasImageBasedResources(template.data), + showWhen: ({ template, paramsSource }) => + !!template && + hasImageBasedResources(template.data) && + (paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave), }) // todo wrap with localize - this.form.syncFlags.bindPrompter(() => - createMultiPick(syncFlagItems, { - title: 'Specify parameters for sync', - placeholder: 'Press enter to proceed with highlighted option', - buttons: createCommonButtons(samSyncParamUrl), - }) + this.form.syncFlags.bindPrompter( + () => + createMultiPick(syncFlagItems, { + title: 'Specify parameters for sync', + placeholder: 'Press enter to proceed with highlighted option', + buttons: createCommonButtons(samSyncParamUrl), + }), + { + showWhen: ({ paramsSource }) => + paramsSource === ParamsSource.Flags || paramsSource === ParamsSource.SpecifyAndSave, + } ) } } diff --git a/packages/core/src/test/shared/sam/sync.test.ts b/packages/core/src/test/shared/sam/sync.test.ts index 5be06bda182..dfe73dac9cb 100644 --- a/packages/core/src/test/shared/sam/sync.test.ts +++ b/packages/core/src/test/shared/sam/sync.test.ts @@ -105,8 +105,14 @@ describe('SyncWizard', async function () { }) it('prompts for ECR repo if template has image-based resource', async function () { - const template = { uri: vscode.Uri.file('/'), data: createBaseImageTemplate() } - const tester = await createTester({ template }) + const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri || vscode.Uri.file('/') + const rootFolderUri = vscode.Uri.joinPath(workspaceUri, 'my') + const templateUri = vscode.Uri.joinPath(rootFolderUri, 'template.yaml') + const template = { uri: templateUri, data: createBaseImageTemplate() } + const tester = await createTester({ + template, + paramsSource: ParamsSource.Flags, + }) tester.ecrRepoUri.assertShow() }) @@ -116,6 +122,12 @@ describe('SyncWizard', async function () { tester.ecrRepoUri.assertDoesNotShow() }) + it('skips prompt for ECR repo if param source is to use samconfig', async function () { + const template = { uri: vscode.Uri.file('/'), data: createBaseTemplate() } + const tester = await createTester({ template, paramsSource: ParamsSource.SamConfig }) + tester.ecrRepoUri.assertDoesNotShow() + }) + it("uses the template's workspace subfolder as the project root is not set", async function () { const workspaceUri = vscode.workspace.workspaceFolders?.[0]?.uri assert.ok(workspaceUri) diff --git a/packages/toolkit/.changes/next-release/Bug Fix-2ad71338-1d0f-4bbf-a9e9-ac0f12be7a4d.json b/packages/toolkit/.changes/next-release/Bug Fix-2ad71338-1d0f-4bbf-a9e9-ac0f12be7a4d.json new file mode 100644 index 00000000000..2aa7ec68ebc --- /dev/null +++ b/packages/toolkit/.changes/next-release/Bug Fix-2ad71338-1d0f-4bbf-a9e9-ac0f12be7a4d.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "SAM: Skip unnecessary prompters for sync operation when using flag from samconfig.toml file" +}