Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-132767 / 24.10.1 / Fix payload for cloud sync task (by denysbutenko) #11148

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { of } from 'rxjs';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.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 { ChainedRef } from 'app/modules/forms/ix-forms/components/ix-slide-in/chained-component-ref';
import { IxSlideInRef } from 'app/modules/forms/ix-forms/components/ix-slide-in/ix-slide-in-ref';
import { IxFormsModule } from 'app/modules/forms/ix-forms/ix-forms.module';
Expand Down Expand Up @@ -135,4 +137,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',
}),
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import _ from 'lodash';
import {
BehaviorSubject,
EMPTY,
Observable, catchError, combineLatest, filter, map, merge, of, tap,
} from 'rxjs';
Expand Down Expand Up @@ -88,6 +89,7 @@ export class CloudSyncWhatAndWhenComponent implements OnInit, OnChanges {
bwlimit: [[] as string[]],
});

isCredentialInvalid$ = new BehaviorSubject(false);
credentials: CloudSyncCredential[] = [];
providers: CloudSyncProvider[] = [];
bucketPlaceholder: string = helptextCloudSync.bucket_placeholder;
Expand Down Expand Up @@ -242,6 +244,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];
}
Expand Down Expand Up @@ -407,6 +411,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),
Expand Down Expand Up @@ -448,13 +462,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: WebSocketError) => {
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}`,
Expand Down
44 changes: 22 additions & 22 deletions src/assets/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4880,7 +4880,6 @@
"dRAID1": "",
"dRAID2": "",
"dRAID3": "",
"details": "",
"disk stats": "",
"disk writes": "",
"everyone@": "",
Expand All @@ -4905,21 +4904,14 @@
"lzjb (legacy, not recommended)": "",
"mountd(8) bind port": "",
"never ran": "",
"of": "",
"on this enclosure.": "",
"or": "",
"owner@": "",
"pCloud": "",
"pbkdf2iters": "",
"pigz (all rounder)": "",
"plzip (best compression)": "",
"readonly": "",
"rpc.lockd(8) bind port": "",
"rpc.statd(8) bind port": "",
"standby": "",
"to another TrueNAS": "",
"to cloud": "",
"total available": "",
"was successfully attached.": "",
"zle (runs of zeros)": "",
"zstd (default level, 3)": "",
"zstd-5 (slow)": "",
Expand Down Expand Up @@ -4970,8 +4962,6 @@
"{n, plural, one {Failed Disk} other {Failed Disks}}": "",
"{n, plural, one {Pool in Enclosure} other {Pools in Enclosure}}": "",
"{n, plural, one {SAS Expander} other {SAS Expanders}}": "",
"{name} Devices": "",
"{name} Sessions": "",
"{name} and {n, plural, one {# other pool} other {# other pools}} are not healthy.": "",
"{nic} Address": "",
"{n} (applies to descendants)": "",
Expand All @@ -4993,17 +4983,7 @@
"{temp}°C (Core #{core})": "",
"{temp}°C ({coreCount} cores at {temp}°C)": "",
"{threadCount, plural, one {# thread} other {# threads} }": "",
"{type} VDEVs": "",
"{type} at {location}": "",
"{type} widget does not support {size} size.": "",
"{type} widget is not supported.": "",
"{type} | {vdevWidth} wide | ": "",
"{usage}% (All Threads)": "",
"{usage}% (Thread #{thread})": "",
"{usage}% ({threadCount} threads at {usage}%)": "",
"{used} of {total} ({used_pct})": "",
"{version} is available!": "",
"{view} on {enclosure}": "",
" seconds.": " sekund",
"% of all cores": "% użycia wszytskich rdzeni",
"(24 Hours)": "(24 Godziny)",
Expand Down Expand Up @@ -5118,5 +5098,25 @@
"Wipe": "Wyczyść",
"Wipe this disk?": "Czy wyczyścić ten dysk?",
"[Use fewer transactions in exchange for more RAM.](https://rclone.org/docs/#fast-list) This can also speed up or slow down the transfer.": "[Use fewer transactions in exchange for more RAM.](https://rclone.org/docs/\\#fast-list) This can also speed up or slow down the transfer.",
"was successfully attached.": "został pomyślanie powiązany."
"details": "szczegóły",
"of": "z",
"or": "lub",
"owner@": "właściciel@",
"readonly": "tylko do odczytu",
"standby": "czuwanie",
"to another TrueNAS": "do innego TrueNAS",
"to cloud": "do chmury",
"total available": "łącznie dostępne",
"{name} Devices": "Urządzenia",
"{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}"
}
Loading