diff --git a/app/javascript/controllers/terminal_controller.js b/app/javascript/controllers/terminal_controller.js
index 133957699..58d2a735e 100644
--- a/app/javascript/controllers/terminal_controller.js
+++ b/app/javascript/controllers/terminal_controller.js
@@ -136,26 +136,44 @@ export default class extends Controller {
}
async #requestConfirmation(commands) {
- const message = commands[0]
-
this.element.classList.add(this.confirmationClass)
- this.inputTarget.value = `${message}? [Y/n] `
+
+ if (commands.length > 1) {
+ this.#requestMultiLineConfirmation(commands)
+ } else {
+ this.#requestSingleLineConfirmation(commands)
+ }
this.waitingForConfirmationValue = true
}
+ #requestMultiLineConfirmation(commands) {
+ const commandsDescription = commands.map(command => `- ${command}`).join(`
`)
+ const message = `This will:
${commandsDescription}`
+ this.#showOutput(message)
+ this.inputTarget.value = `Do you confirm? [Y/n] `
+ }
+
+ #requestSingleLineConfirmation(commands) {
+ const message = commands[0]
+ this.inputTarget.value = `${message}? [Y/n] `
+ }
+
#handleConfirmationKey(key) {
if (key === "enter" || key === "y") {
this.#submitWithConfirmation()
} else if (key === "escape" || key === "n") {
this.#reset(this.originalInputValue)
+ this.#hideOutput()
}
}
#submitWithConfirmation() {
this.inputTarget.value = this.originalInputValue
this.confirmationTarget.value = "confirmed"
+ this.#hideOutput()
this.formTarget.requestSubmit()
+ this.#reset()
}
#submitAfterRedirection() {