You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2026/10/12 14:16:17 UTC

(streampipes) branch dev updated: fix(#5087): Store the typed value of password service configurations (#5088)

This is an automated email from the ASF dual-hosted git repository.

dominikriemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new da635f7e55 fix(#5087): Store the typed value of password service configurations (#5088)
da635f7e55 is described below

commit da635f7e554020425a535d72d652f380daaac86a
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Oct 12 16:16:12 2026 +0200

    fix(#5087): Store the typed value of password service configurations (#5088)
    
    Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
---
 .../service-configs-password.component.html        |  5 ++-
 .../service-configs-password.component.spec.ts     | 43 ++++++++++++++++++----
 .../service-configs-password.component.ts          | 15 ++++++--
 3 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.html b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.html
index 99ce8e79eb..fa12d23166 100644
--- a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.html
+++ b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.html
@@ -21,12 +21,13 @@
 
     <input
         matInput
-        [(ngModel)]="password"
+        [ngModel]="password"
+        (ngModelChange)="onPasswordChange($event)"
         [ngClass]="className"
         [placeholder]=""
         type="text"
         [ngModelOptions]="{ standalone: true }"
-        (click)="changePw()"
+        (focus)="changePw()"
     />
 
     @if (show) {
diff --git a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.spec.ts b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.spec.ts
index de2eda3c2e..84ab05c453 100644
--- a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.spec.ts
+++ b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.spec.ts
@@ -101,19 +101,48 @@ describe('ServiceConfigsPasswordComponent', () => {
         expect(component.password).toBe('*****');
     });
 
-    it(`should click button`, async () => {
+    it('should clear the placeholder on focus', async () => {
         const changePasswordSpy = vi.spyOn(component, 'changePw');
 
-        const input = fixture.debugElement.nativeElement.querySelector('input');
-        input.click();
+        const input: HTMLInputElement =
+            fixture.debugElement.nativeElement.querySelector('input');
+        input.dispatchEvent(new Event('focus'));
+        fixture.detectChanges();
         await fixture.whenStable();
 
         expect(changePasswordSpy).toHaveBeenCalled();
-        const bannerDe: DebugElement = fixture.debugElement;
+        expect(component.password).toBe('');
+        const inputDe: DebugElement = fixture.debugElement.query(
+            By.css('input'),
+        );
+        expect(inputDe.nativeElement.value).toBe('');
+    });
+
+    it('should store what is typed after focusing the field', async () => {
+        const input: HTMLInputElement =
+            fixture.debugElement.nativeElement.querySelector('input');
+        input.dispatchEvent(new Event('focus'));
+        fixture.detectChanges();
+        await fixture.whenStable();
+
+        input.value = 'new-secret';
+        input.dispatchEvent(new Event('input'));
+        fixture.detectChanges();
+        await fixture.whenStable();
+
+        expect(component.configuration.value).toBe('new-secret');
+    });
 
-        const inputDe = bannerDe.query(By.css('input'));
-        const inputValue: HTMLElement = inputDe.nativeElement;
+    it('should keep the stored value when the field is only clicked', async () => {
+        component.configuration.value = 'stored-secret';
+        const input: HTMLInputElement =
+            fixture.debugElement.nativeElement.querySelector('input');
+        // A mouse click focuses the field and then clicks it.
+        input.dispatchEvent(new Event('focus'));
+        input.click();
+        fixture.detectChanges();
+        await fixture.whenStable();
 
-        expect(inputValue.textContent).toBe('');
+        expect(component.configuration.value).toBe('stored-secret');
     });
 });
diff --git a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.ts b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.ts
index d9890e0a8d..560a3a52b7 100644
--- a/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.ts
+++ b/ui/src/app/configuration/extensions-service-management/extensions-service-configuration/service-configs/service-configs-password/service-configs-password.component.ts
@@ -73,14 +73,23 @@ export class ServiceConfigsPasswordComponent {
         this.hide = true;
     }
 
+    /**
+     * Clears the placeholder when the field gets focus. The stored value is
+     * left untouched: only typing changes it, so focusing the field and
+     * saving does not wipe an existing secret.
+     */
     changePw() {
-        if (this.password == hiddenPasswordString) {
-            this.password = this.password.replace(hiddenPasswordString, '');
+        if (this.password === hiddenPasswordString) {
+            this.password = '';
         }
-        this.configuration.value = this.password;
         this.show = true;
     }
 
+    onPasswordChange(value: string) {
+        this.password = value;
+        this.configuration.value = value;
+    }
+
     addCssClass() {
         this.hide = !this.hide;