Skip to content

Commit 33bbce9

Browse files
committed
Fixes
1 parent 34077ff commit 33bbce9

File tree

3 files changed

+59
-12
lines changed

3 files changed

+59
-12
lines changed

packages/core/src/awsService/cloudformation/ui/diffWebviewProvider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { DiffViewHelper } from './diffViewHelper'
99
import { commandKey } from '../utils'
1010
import { StackViewCoordinator } from './stackViewCoordinator'
1111
import { showWarningConfirmation } from './message'
12+
import { ChangeSetStatus } from '@aws-sdk/client-cloudformation'
1213

1314
const webviewCommandOpenDiff = 'openDiff'
1415

@@ -153,7 +154,9 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
153154
<body>
154155
<p>No changes detected for stack: ${this.stackName}</p>
155156
${
156-
this.changeSetName
157+
this.changeSetName &&
158+
(this.changeSetStatus === ChangeSetStatus.CREATE_COMPLETE ||
159+
this.changeSetStatus === ChangeSetStatus.FAILED)
157160
? `
158161
<div class="deletion-button" style="margin: 10px 0; text-align: left; display: inline-block;">
159162
${deletionButton}
@@ -381,11 +384,14 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
381384
`
382385

383386
const deploymentButtons =
384-
this.changeSetName && this.enableDeployments
387+
this.changeSetName &&
388+
this.enableDeployments &&
389+
(this.changeSetStatus === ChangeSetStatus.CREATE_COMPLETE ||
390+
this.changeSetStatus === ChangeSetStatus.FAILED)
385391
? `
386392
<div class="deployment-actions" style="margin: 10px 0; text-align: left; display: inline-block;">
387393
${
388-
this.changeSetStatus === 'CREATE_COMPLETE'
394+
this.changeSetStatus === ChangeSetStatus.CREATE_COMPLETE
389395
? `
390396
<button id="confirmDeploy" onclick="confirmDeploy()" style="
391397
background-color: var(--vscode-button-background);

packages/core/src/test/awsService/cloudformation/ui/diffWebviewProvider.test.ts

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,8 @@ describe('DiffWebviewProvider', function () {
339339
})
340340

341341
it('should not show deploy button when changeset is not CREATE_COMPLETE', function () {
342-
const changes: StackChange[] = [
343-
{
344-
resourceChange: {
345-
action: 'Add',
346-
logicalResourceId: 'TestResource',
347-
},
348-
},
349-
]
342+
// changes are not available if a changeset is not created
343+
const changes: StackChange[] = []
350344

351345
void provider.updateData(
352346
'test-stack',
@@ -407,6 +401,53 @@ describe('DiffWebviewProvider', function () {
407401
assert.ok(!mockWebview.webview.html.includes('Deploy Changes'))
408402
assert.ok(!mockWebview.webview.html.includes('deployment-actions'))
409403
})
404+
405+
it('should not show deployment buttons when changeset status is DELETE_PENDING', function () {
406+
const changes: StackChange[] = [
407+
{
408+
resourceChange: {
409+
action: 'Add',
410+
logicalResourceId: 'TestResource',
411+
},
412+
},
413+
]
414+
415+
void provider.updateData(
416+
'test-stack',
417+
changes,
418+
'test-changeset',
419+
true,
420+
undefined,
421+
undefined,
422+
'DELETE_PENDING'
423+
)
424+
const mockWebview = createMockWebview()
425+
provider.resolveWebviewView(mockWebview as any)
426+
427+
assert.ok(!mockWebview.webview.html.includes('Deploy Changes'))
428+
assert.ok(!mockWebview.webview.html.includes('Delete Changeset'))
429+
assert.ok(!mockWebview.webview.html.includes('deployment-actions'))
430+
})
431+
432+
it('should not show deployment buttons when changeset status is CREATE_PENDING', function () {
433+
const changes: StackChange[] = []
434+
435+
void provider.updateData(
436+
'test-stack',
437+
changes,
438+
'test-changeset',
439+
true,
440+
undefined,
441+
undefined,
442+
'CREATE_PENDING'
443+
)
444+
const mockWebview = createMockWebview()
445+
provider.resolveWebviewView(mockWebview as any)
446+
447+
assert.ok(!mockWebview.webview.html.includes('Deploy Changes'))
448+
assert.ok(!mockWebview.webview.html.includes('Delete Changeset'))
449+
assert.ok(!mockWebview.webview.html.includes('deployment-actions'))
450+
})
410451
})
411452

412453
describe('pagination', function () {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type": "Bug Fix",
3-
"description": "hide deployment button when change set is not deployable, add delete button when change set has no changes"
3+
"description": "CloudFormation: hide deployment button when change set is not deployable, add delete button when change set has no changes"
44
}

0 commit comments

Comments
 (0)