From 6a39a5cf44b199cc515792d4c88c801520630948 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Tue, 22 Jun 2021 12:41:50 +0300 Subject: [PATCH] fix(git-form): show git form and clear auth values (#5224) * fix(custom-templates): show git form fix [EE-1025] * fix(git-form): empty auth values when auth is off --- .../git-form-auth-fieldset.controller.js | 36 ++++++++++++++++++- .../createCustomTemplateView.html | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) 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 @@ - +