diff --git a/api/http/handler/stacks/stack_update.go b/api/http/handler/stacks/stack_update.go index 517ea2f76..2a757dc53 100644 --- a/api/http/handler/stacks/stack_update.go +++ b/api/http/handler/stacks/stack_update.go @@ -49,7 +49,7 @@ func (payload *updateSwarmStackPayload) Validate(r *http.Request) error { // @id StackUpdate // @summary Update a stack -// @description Update a stack. +// @description Update a stack, only for file based stacks. // @description **Access policy**: authenticated // @tags stacks // @security ApiKeyAuth @@ -123,6 +123,15 @@ func (handler *Handler) stackUpdate(w http.ResponseWriter, r *http.Request) *htt } } + // Must not be git based stack. stop the auto update job if there is any + if stack.AutoUpdate != nil { + stopAutoupdate(stack.ID, stack.AutoUpdate.JobID, *handler.Scheduler) + stack.AutoUpdate = nil + } + if stack.GitConfig != nil { + stack.FromAppTemplate = true + } + updateError := handler.updateAndDeployStack(r, stack, endpoint) if updateError != nil { return updateError diff --git a/app/portainer/services/modal.service/confirm.ts b/app/portainer/services/modal.service/confirm.ts index eb4655b05..e56fa2dd7 100644 --- a/app/portainer/services/modal.service/confirm.ts +++ b/app/portainer/services/modal.service/confirm.ts @@ -115,6 +115,21 @@ export function confirmDeletion(message: string, callback: ConfirmCallback) { }); } +export function confirmDetachment(message: string, callback: ConfirmCallback) { + const messageSanitized = sanitize(message); + confirm({ + title: 'Are you sure ?', + message: messageSanitized, + buttons: { + confirm: { + label: 'Detach', + className: 'btn-danger', + }, + }, + callback, + }); +} + export function confirmDeassociate(callback: ConfirmCallback) { const message = '
De-associating this Edge environment will mark it as non associated and will clear the registered Edge ID.
' + diff --git a/app/portainer/services/modal.service/index.ts b/app/portainer/services/modal.service/index.ts index b27596d65..95ff58ff1 100644 --- a/app/portainer/services/modal.service/index.ts +++ b/app/portainer/services/modal.service/index.ts @@ -7,6 +7,7 @@ import { confirmAsync, confirmDeassociate, confirmDeletion, + confirmDetachment, confirmDeletionAsync, confirmEndpointSnapshot, confirmImageExport, @@ -45,6 +46,7 @@ export function ModalServiceAngular() { confirmImageForceRemoval, cancelRegistryRepositoryAction, confirmDeletion, + confirmDetachment, confirmDeassociate, confirmUpdate, confirmRedeploy, diff --git a/app/portainer/views/stacks/edit/stack.html b/app/portainer/views/stacks/edit/stack.html index 985b1f083..3467c03bd 100644 --- a/app/portainer/views/stacks/edit/stack.html +++ b/app/portainer/views/stacks/edit/stack.html @@ -71,6 +71,18 @@ Create template from stack + @@ -101,8 +113,12 @@ - -