diff --git a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.spec.ts b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.spec.ts index 263e936cd03..56c6ebf0ab5 100644 --- a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.spec.ts +++ b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.spec.ts @@ -9,6 +9,8 @@ import { of } from 'rxjs'; import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils'; import { mockAuth } from 'app/core/testing/utils/mock-auth.utils'; import { DialogService } from 'app/modules/dialog/dialog.service'; +import { IxInputHarness } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.harness'; +import { IxSelectHarness } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.harness'; import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness'; import { ChainedRef } from 'app/modules/slide-ins/chained-component-ref'; import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; @@ -132,4 +134,28 @@ describe('CloudSyncWhatAndWhenComponent', () => { }); expect(chainedRef.swap).toHaveBeenCalledWith(CloudSyncFormComponent, true); }); + + it('checks payload when use invalid s3 credentials', async () => { + const bucketSelect = await loader.getHarness(IxSelectHarness.with({ label: 'Bucket' })); + expect(await bucketSelect.getValue()).toBe(''); + + spectator.component.isCredentialInvalid$.next(true); + spectator.detectChanges(); + + const bucketInput = await loader.getHarness(IxInputHarness.with({ label: 'Bucket' })); + await bucketInput.setValue('selected'); + + expect(spectator.component.getPayload()).toEqual(expect.objectContaining({ + attributes: expect.objectContaining({ + bucket: 'selected', + }), + })); + + await bucketInput.setValue('test-bucket'); + expect(spectator.component.getPayload()).toEqual(expect.objectContaining({ + attributes: expect.objectContaining({ + bucket: 'test-bucket', + }), + })); + }); }); diff --git a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts index cfdd871e30a..e46ce7a526e 100644 --- a/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts +++ b/src/app/pages/data-protection/cloudsync/cloudsync-wizard/steps/cloudsync-what-and-when/cloudsync-what-and-when.component.ts @@ -12,6 +12,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateService, TranslateModule } from '@ngx-translate/core'; import { find, findIndex, isArray } from 'lodash-es'; import { + BehaviorSubject, EMPTY, Observable, catchError, combineLatest, filter, map, merge, of, tap, } from 'rxjs'; @@ -118,6 +119,7 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { bwlimit: [[] as string[]], }); + isCredentialInvalid$ = new BehaviorSubject(false); credentials: CloudSyncCredential[] = []; providers: CloudSyncProvider[] = []; bucketPlaceholder: string = helptextCloudSync.bucket_placeholder; @@ -273,6 +275,8 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { if (formValue[name] !== undefined && formValue[name] !== null && formValue[name] !== '') { if (name === 'task_encryption') { attributes[name] = formValue[name] === '' ? null : formValue[name]; + } else if (name === 'bucket_input') { + attributes['bucket'] = formValue[name]; } else { attributes[name] = formValue[name]; } @@ -438,6 +442,16 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { } }); + this.isCredentialInvalid$.pipe(untilDestroyed(this)).subscribe((value) => { + if (value) { + this.form.controls.bucket_input.enable(); + this.form.controls.bucket.disable(); + } else { + this.form.controls.bucket_input.disable(); + this.form.controls.bucket.enable(); + } + }); + this.form.controls.bucket.valueChanges.pipe( filter((selectedOption) => selectedOption === newOption), untilDestroyed(this), @@ -479,13 +493,11 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges { }); } this.bucketOptions$ = of(bucketOptions); - this.form.controls.bucket.enable(); - this.form.controls.bucket_input.disable(); + this.isCredentialInvalid$.next(false); this.cdr.markForCheck(); }, error: (error: ApiError) => { - this.form.controls.bucket.disable(); - this.form.controls.bucket_input.enable(); + this.isCredentialInvalid$.next(true); this.dialog.closeAllDialogs(); this.dialog.confirm({ title: error.extra ? (error.extra as { excerpt: string }).excerpt : `${this.translate.instant('Error: ')}${error.error}`, diff --git a/src/assets/i18n/pl.json b/src/assets/i18n/pl.json index b753fb62b17..40d76478152 100644 --- a/src/assets/i18n/pl.json +++ b/src/assets/i18n/pl.json @@ -5134,17 +5134,7 @@ "{temp}°C (Core #{core})": "", "{temp}°C ({coreCount} cores at {temp}°C)": "", "{threadCount, plural, one {# thread} other {# threads} }": "", - "{type} VDEVs": "{type} VDEVs", - "{type} at {location}": "{type} w {location}", - "{type} widget does not support {size} size.": "Widżet {type} nie obsługuje rozmiaru {size}", - "{type} widget is not supported.": "Widżet {type} nie jest obsługiwany.", "{type} | {vdevWidth} wide | ": "", - "{usage}% (All Threads)": "{usage}% Wszystkich wątków)", - "{usage}% (Thread #{thread})": "{usage}% (Wątek #{thread})", - "{usage}% ({threadCount} threads at {usage}%)": "{usage}% ({threadCount} wątków przy {usage}%)", - "{used} of {total} ({used_pct})": "{used} z {total} ({used_pct})", - "{version} is available!": "{version} jest dostępna!", - "{view} on {enclosure}": "{view} na {enclosure}", " seconds.": " sekund", "% of all cores": "% użycia wszytskich rdzeni", "(24 Hours)": "(24 Godziny)", @@ -5279,5 +5269,15 @@ "to cloud": "do chmury", "total available": "łącznie dostępne", "{name} Devices": "Urządzenia", - "{name} Sessions": "Sesji" -} + "{name} Sessions": "Sesji", + "{type} VDEVs": "{type} VDEVs", + "{type} at {location}": "{type} w {location}", + "{type} widget does not support {size} size.": "Widżet {type} nie obsługuje rozmiaru {size}", + "{type} widget is not supported.": "Widżet {type} nie jest obsługiwany.", + "{usage}% (All Threads)": "{usage}% Wszystkich wątków)", + "{usage}% (Thread #{thread})": "{usage}% (Wątek #{thread})", + "{usage}% ({threadCount} threads at {usage}%)": "{usage}% ({threadCount} wątków przy {usage}%)", + "{used} of {total} ({used_pct})": "{used} z {total} ({used_pct})", + "{version} is available!": "{version} jest dostępna!", + "{view} on {enclosure}": "{view} na {enclosure}" +} \ No newline at end of file