Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ export function viewChangeSetCommand(client: LanguageClient, diffProvider: DiffW
params.changeSetName,
true,
[],
describeChangeSetResult.deploymentMode
describeChangeSetResult.deploymentMode,
describeChangeSetResult.status
)
void commands.executeCommand(commandKey('diff.focus'))
} catch (error) {
Expand Down Expand Up @@ -483,7 +484,7 @@ async function changeSetSteps(
try {
environmentFile = await environmentManager.selectEnvironmentFile(templateUri, paramDefinition)
} catch (error) {
getLogger().warn(`Failed to select environment file:: ${extractErrorMessage(error)}`)
getLogger().warn(`Failed to select environment file: ${extractErrorMessage(error)}`)
}

if (paramDefinition.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { v4 as uuidv4 } from 'uuid'
import { Parameter, Capability } from '@aws-sdk/client-cloudformation'
import { Parameter, Capability, ChangeSetStatus } from '@aws-sdk/client-cloudformation'
import {
StackActionPhase,
StackChange,
Expand Down Expand Up @@ -163,7 +163,8 @@ export class Validation {
this.changeSetName,
this.shouldEnableDeployment,
validationDetail,
deploymentMode
deploymentMode,
ChangeSetStatus.CREATE_COMPLETE
)
void commands.executeCommand(commandKey('diff.focus'))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DiffViewHelper } from './diffViewHelper'
import { commandKey } from '../utils'
import { StackViewCoordinator } from './stackViewCoordinator'
import { showWarningConfirmation } from './message'
import { ChangeSetStatus } from '@aws-sdk/client-cloudformation'

const webviewCommandOpenDiff = 'openDiff'

Expand All @@ -24,6 +25,7 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
private readonly disposables: Disposable[] = []
private validationDetail: ValidationDetail[] = []
private deploymentMode?: DeploymentMode
private changeSetStatus?: string

constructor(private readonly coordinator: StackViewCoordinator) {
this.disposables.push(
Expand All @@ -46,7 +48,8 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
changeSetName?: string,
enableDeployments = false,
validationDetail?: ValidationDetail[],
deploymentMode?: DeploymentMode
deploymentMode?: DeploymentMode,
changeSetStatus?: string
) {
this.stackName = stackName
this.changes = changes
Expand All @@ -58,6 +61,7 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
this.validationDetail = validationDetail
}
this.deploymentMode = deploymentMode
this.changeSetStatus = changeSetStatus

await this.coordinator.setChangeSetMode(stackName, true)
if (this._view) {
Expand Down Expand Up @@ -120,6 +124,23 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
const displayedChanges = changes.slice(startIndex, endIndex)
const hasNext = this.currentPage < this.totalPages - 1
const hasPrev = this.currentPage > 0
const terminalChangeSetStatuses: string[] = [
ChangeSetStatus.CREATE_COMPLETE,
ChangeSetStatus.FAILED,
ChangeSetStatus.DELETE_FAILED,
]

const deletionButton = `
<button id="deleteChangeSet" onclick="deleteChangeSet()" style="
background-color: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
border: none;
padding: 8px 16px;
margin: 0 5px;
cursor: pointer;
border-radius: 2px;
">Delete Changeset</button>
`

if (!changes || changes.length === 0) {
return `
Expand All @@ -137,6 +158,23 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
</head>
<body>
<p>No changes detected for stack: ${this.stackName}</p>
${
this.changeSetName &&
this.changeSetStatus &&
terminalChangeSetStatuses.includes(this.changeSetStatus)
? `
<div class="deletion-button" style="margin: 10px 0; text-align: left; display: inline-block;">
${deletionButton}
</div>
<script>
const vscode = acquireVsCodeApi();
function deleteChangeSet() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think you need to move this out of the if block so it can be used by the button below (when there are non-zero changes)

vscode.postMessage({ command: 'deleteChangeSet' });
}
</script>
`
: ''
}
</body>
</html>
`
Expand Down Expand Up @@ -351,9 +389,15 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
`

const deploymentButtons =
this.changeSetName && this.enableDeployments
this.changeSetName &&
this.enableDeployments &&
this.changeSetStatus &&
terminalChangeSetStatuses.includes(this.changeSetStatus)
? `
<div class="deployment-actions" style="margin: 10px 0; text-align: left; display: inline-block;">
${
this.changeSetStatus === ChangeSetStatus.CREATE_COMPLETE
? `
<button id="confirmDeploy" onclick="confirmDeploy()" style="
background-color: var(--vscode-button-background);
color: var(--vscode-button-foreground);
Expand All @@ -362,16 +406,10 @@ export class DiffWebviewProvider implements WebviewViewProvider, Disposable {
margin: 0 5px;
cursor: pointer;
border-radius: 2px;
">Deploy Changes</button>
<button id="deleteChangeSet" onclick="deleteChangeSet()" style="
background-color: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
border: none;
padding: 8px 16px;
margin: 0 5px;
cursor: pointer;
border-radius: 2px;
">Delete Changeset</button>
">Deploy Changes</button>`
: ''
}
${deletionButton}
</div>
`
: ''
Expand Down
Loading
Loading