diff --git a/app/portainer/components/forms/git-form/git-form-auth-fieldset/git-form-auth-fieldset.controller.js b/app/portainer/components/forms/git-form/git-form-auth-fieldset/git-form-auth-fieldset.controller.js index 1fac1f4fd..1bc7db19e 100644 --- a/app/portainer/components/forms/git-form/git-form-auth-fieldset/git-form-auth-fieldset.controller.js +++ b/app/portainer/components/forms/git-form/git-form-auth-fieldset/git-form-auth-fieldset.controller.js @@ -1,8 +1,13 @@ class GitFormComposeAuthFieldsetController { /* @ngInject */ constructor() { + this.authValues = { + username: '', + password: '', + }; + this.onChangeField = this.onChangeField.bind(this); - this.onChangeAuth = this.onChangeField('RepositoryAuthentication'); + this.onChangeAuth = this.onChangeAuth.bind(this); this.onChangeUsername = this.onChangeField('RepositoryUsername'); this.onChangePassword = this.onChangeField('RepositoryPassword'); } @@ -15,6 +20,35 @@ class GitFormComposeAuthFieldsetController { }); }; } + + onChangeAuth(auth) { + if (!auth) { + this.authValues.username = this.model.RepositoryUsername; + this.authValues.password = this.model.RepositoryPassword; + this.onChange({ + ...this.model, + RepositoryAuthentication: true, + RepositoryUsername: '', + RepositoryPassword: '', + }); + + return; + } + + this.onChange({ + ...this.model, + RepositoryAuthentication: false, + RepositoryUsername: this.authValues.username, + RepositoryPassword: this.authValues.password, + }); + } + + $onInit() { + if (this.model.RepositoryAuthentication) { + this.authValues.username = this.model.RepositoryUsername; + this.authValues.password = this.model.RepositoryPassword; + } + } } export default GitFormComposeAuthFieldsetController; diff --git a/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html b/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html index c84198744..049fcdfc3 100644 --- a/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html +++ b/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html @@ -103,7 +103,7 @@ - +