Skip to content

Commit

Permalink
NAS-133572: PR update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 committed Jan 21, 2025
1 parent e2308cf commit cb52e11
Show file tree
Hide file tree
Showing 95 changed files with 317 additions and 299 deletions.
2 changes: 1 addition & 1 deletion src/app/helptext/apps/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const helptextApps = {
},

dockerRegistries: {
tooltip: T('Signing in to Docker Hub is not required for Apps to function, but may help if you experience rate limiting issues.'),
tooltip: T('Signing in to a registry, such as Docker Hub, is not required for Apps to function, but may help if you experience rate limiting issues.'),
},

catalogMessage: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('DockerRegistriesListComponent', () => {

it('should show table rows', async () => {
const expectedRows = [
['Name', 'Description', 'Username', 'Uri', ''],
['Docker Hub', 'Docker Hub', 'docker', 'https://index.docker.io/v1/', ''],
['Name', 'Username', 'URI', ''],
['Docker Hub', 'docker', 'https://index.docker.io/v1/', ''],
];

expect(spectator.inject(ApiService).call).toHaveBeenCalledWith('app.registry.query');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,12 @@ export class DockerRegistriesListComponent implements OnInit {
title: this.translate.instant('Name'),
propertyName: 'name',
}),
textColumn({
title: this.translate.instant('Description'),
propertyName: 'description',
}),
textColumn({
title: this.translate.instant('Username'),
propertyName: 'username',
}),
textColumn({
title: this.translate.instant('Uri'),
title: this.translate.instant('URI'),
propertyName: 'uri',
}),
actionsColumn({
Expand All @@ -101,7 +97,7 @@ export class DockerRegistriesListComponent implements OnInit {
}),
], {
uniqueRowTag: (row) => `docker-registry-${row.uri}-${row.name}`,
ariaLabels: (row) => [row.name, row.description, this.translate.instant('Docker Registry')],
ariaLabels: (row) => [row.name, this.translate.instant('Docker Registry')],
});

constructor(
Expand Down Expand Up @@ -138,7 +134,7 @@ export class DockerRegistriesListComponent implements OnInit {
this.filterString = query;
this.dataProvider.setFilter({
query,
columnKeys: ['name', 'description', 'username', 'uri'],
columnKeys: ['name', 'username', 'uri'],
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
[label]="'URI' | translate"
[required]="true"
></ix-input>
}

<ix-input
formControlName="name"
[label]="'Name' | translate"
[required]="true"
></ix-input>
<ix-input
formControlName="name"
[label]="'Name' | translate"
[required]="true"
></ix-input>
}

<ix-input
formControlName="username"
Expand All @@ -43,11 +43,6 @@
[label]="'Password' | translate"
[required]="true"
></ix-input>

<ix-input
formControlName="description"
[label]="'Description' | translate"
></ix-input>
</ix-fieldset>

<ix-form-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('DockerRegistryFormComponent', () => {
name: 'Old Registry',
username: 'old_user',
password: '',
description: 'Old description',
};

const slideInRef: SlideInRef<undefined, unknown> = {
Expand Down Expand Up @@ -57,17 +56,33 @@ describe('DockerRegistryFormComponent', () => {
api = spectator.inject(ApiService);
});

it('initializes the form with default values', async () => {
it('initializes the form with default values for Docker Hub as a URI and submits with default values', async () => {
const form = await loader.getHarness(IxFormHarness);
const values = await form.getValues();

expect(values).toEqual({
URI: 'Docker Hub',
Name: '',
Username: '',
Password: '',
Description: '',
});

await form.fillForm({
Username: 'admin',
Password: 'password',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(api.call).toHaveBeenCalledWith('app.registry.create', [
{
uri: 'https://registry-1.docker.io/',
name: 'Docker Hub',
username: 'admin',
password: 'password',
},
]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
});

it('sends a create payload and closes the modal when the save button is clicked', async () => {
Expand All @@ -81,7 +96,6 @@ describe('DockerRegistryFormComponent', () => {
Name: 'New GHCR Registry',
Username: 'admin',
Password: 'password',
Description: 'A new test registry',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
Expand All @@ -93,7 +107,6 @@ describe('DockerRegistryFormComponent', () => {
name: 'New GHCR Registry',
username: 'admin',
password: 'password',
description: 'A new test registry',
},
]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
Expand Down Expand Up @@ -125,7 +138,6 @@ describe('DockerRegistryFormComponent', () => {
Name: 'Old Registry',
Username: 'old_user',
Password: '',
Description: 'Old description',
});

const uriSelector = await loader.getHarnessOrNull(IxSelectHarness.with({ label: 'URI' }));
Expand All @@ -139,7 +151,6 @@ describe('DockerRegistryFormComponent', () => {
Name: 'Updated Registry',
Username: 'updated_user',
Password: 'updated_password',
Description: 'Updated description',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
Expand All @@ -152,7 +163,6 @@ describe('DockerRegistryFormComponent', () => {
name: 'Updated Registry',
username: 'updated_user',
password: 'updated_password',
description: 'Updated description',
},
]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
Expand Down Expand Up @@ -184,7 +194,6 @@ describe('DockerRegistryFormComponent', () => {
Name: '',
Username: '',
Password: '',
Description: '',
});

const uriSelector = await loader.getHarnessOrNull(IxSelectHarness.with({ label: 'URI' }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FormActionsComponent } from 'app/modules/forms/ix-forms/components/form
import { IxFieldsetComponent } from 'app/modules/forms/ix-forms/components/ix-fieldset/ix-fieldset.component';
import { IxInputComponent } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.component';
import { IxSelectComponent } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component';
import { UrlValidationService } from 'app/modules/forms/ix-forms/validators/url-validation.service';
import { ModalHeaderComponent } from 'app/modules/slide-ins/components/modal-header/modal-header.component';
import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref';
import { TestDirective } from 'app/modules/test-id/test.directive';
Expand Down Expand Up @@ -58,8 +59,7 @@ export class DockerRegistryFormComponent implements OnInit {
name: ['', Validators.required],
username: ['', Validators.required],
password: ['', Validators.required],
uri: [''],
description: [''],
uri: ['', Validators.pattern(this.urlValidationService.urlRegex)],
});

get title(): string {
Expand All @@ -74,13 +74,19 @@ export class DockerRegistryFormComponent implements OnInit {
private cdr: ChangeDetectorRef,
private errorHandler: ErrorHandlerService,
private fb: FormBuilder,
private urlValidationService: UrlValidationService,
private translate: TranslateService,
) {
this.slideInRef.requireConfirmationWhen(() => {
return of(this.form.dirty);
});

this.existingDockerRegistry = this.slideInRef.getData()?.registry;
this.isLoggedInToDockerHub = this.slideInRef.getData()?.isLoggedInToDockerHub;

if (!this.isLoggedInToDockerHub && !this.existingDockerRegistry) {
this.setNameForDockerHub();
}
}

ngOnInit(): void {
Expand All @@ -90,6 +96,12 @@ export class DockerRegistryFormComponent implements OnInit {

this.form.controls.registry.valueChanges.pipe(untilDestroyed(this)).subscribe((value) => {
this.form.patchValue({ uri: value });

if (value === dockerHubRegistry) {
this.setNameForDockerHub();
} else {
this.form.controls.name.patchValue('');
}
});
}

Expand Down Expand Up @@ -137,4 +149,8 @@ export class DockerRegistryFormComponent implements OnInit {
...this.existingDockerRegistry,
});
}

private setNameForDockerHub(): void {
this.form.controls.name.patchValue(this.translate.instant('Docker Hub'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
<button
mat-menu-item
ixTest="docker-registries"
[matTooltip]="helptext.dockerRegistries.tooltip | translate"
matTooltipPosition="right"
[matTooltip]="!(dockerStore.selectedPool$ | async) ? ('Choose pool first' | translate) : helptext.dockerRegistries.tooltip | translate"
[disabled]="!(dockerStore.selectedPool$ | async)"
[routerLink]="['/apps', 'docker-registries']"
>
{{ 'Sign-in to Docker Hub or other registry' | translate }}
{{ 'Sign-in to a Docker registry' | translate }}
</button>

<button
Expand Down
6 changes: 3 additions & 3 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@
"Choose one of the presets or choose <i>Custom</i> to use the advanced scheduler.": "",
"Choose one of the presets or select <i>Custom</i> to open the advanced scheduler.": "",
"Choose pod": "",
"Choose pool first": "",
"Choose the VM operating system type.": "",
"Choose the backend to map Windows security identifiers (SIDs) to UNIX UIDs and GIDs. Click Edit to configure that backend.": "",
"Choose the hour and minute when new resilver tasks are not allowed to start. This does not affect active resilver tasks.": "",
Expand Down Expand Up @@ -4174,14 +4175,14 @@
"Sign Out": "",
"Sign up for account": "",
"Sign-in to Docker Hub": "",
"Sign-in to Docker Hub or other registry": "",
"Sign-in to a Docker registry": "",
"Signed By": "",
"Signed Certificates": "",
"Signin": "",
"Signing": "",
"Signing Certificate Authority": "",
"Signing Request": "",
"Signing in to Docker Hub is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signing in to a registry, such as Docker Hub, is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signup": "",
"Silver / Gold Coverage Customers can enable iXsystems Proactive Support. This automatically emails iXsystems when certain conditions occur on this TrueNAS system. The iX Support Team will promptly communicate with the Contacts saved below to quickly resolve any issue that may have occurred on the system.": "",
"Similar Apps": "",
Expand Down Expand Up @@ -4884,7 +4885,6 @@
"Uploading file...": "",
"Upsmon will wait up to this many seconds in master mode for the slaves to disconnect during a shutdown situation.": "",
"Uptime": "",
"Uri": "",
"Usable Capacity": "",
"Usage": "",
"Usage Collection": "",
Expand Down
6 changes: 3 additions & 3 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@
"Choose one of the presets or choose <i>Custom</i> to use the advanced scheduler.": "",
"Choose one of the presets or select <i>Custom</i> to open the advanced scheduler.": "",
"Choose pod": "",
"Choose pool first": "",
"Choose the VM operating system type.": "",
"Choose the backend to map Windows security identifiers (SIDs) to UNIX UIDs and GIDs. Click Edit to configure that backend.": "",
"Choose the hour and minute when new resilver tasks are not allowed to start. This does not affect active resilver tasks.": "",
Expand Down Expand Up @@ -4174,14 +4175,14 @@
"Sign Out": "",
"Sign up for account": "",
"Sign-in to Docker Hub": "",
"Sign-in to Docker Hub or other registry": "",
"Sign-in to a Docker registry": "",
"Signed By": "",
"Signed Certificates": "",
"Signin": "",
"Signing": "",
"Signing Certificate Authority": "",
"Signing Request": "",
"Signing in to Docker Hub is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signing in to a registry, such as Docker Hub, is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signup": "",
"Silver / Gold Coverage Customers can enable iXsystems Proactive Support. This automatically emails iXsystems when certain conditions occur on this TrueNAS system. The iX Support Team will promptly communicate with the Contacts saved below to quickly resolve any issue that may have occurred on the system.": "",
"Similar Apps": "",
Expand Down Expand Up @@ -4884,7 +4885,6 @@
"Uploading file...": "",
"Upsmon will wait up to this many seconds in master mode for the slaves to disconnect during a shutdown situation.": "",
"Uptime": "",
"Uri": "",
"Usable Capacity": "",
"Usage": "",
"Usage Collection": "",
Expand Down
6 changes: 3 additions & 3 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@
"Choose one of the presets or choose <i>Custom</i> to use the advanced scheduler.": "",
"Choose one of the presets or select <i>Custom</i> to open the advanced scheduler.": "",
"Choose pod": "",
"Choose pool first": "",
"Choose the VM operating system type.": "",
"Choose the backend to map Windows security identifiers (SIDs) to UNIX UIDs and GIDs. Click Edit to configure that backend.": "",
"Choose the hour and minute when new resilver tasks are not allowed to start. This does not affect active resilver tasks.": "",
Expand Down Expand Up @@ -4174,14 +4175,14 @@
"Sign Out": "",
"Sign up for account": "",
"Sign-in to Docker Hub": "",
"Sign-in to Docker Hub or other registry": "",
"Sign-in to a Docker registry": "",
"Signed By": "",
"Signed Certificates": "",
"Signin": "",
"Signing": "",
"Signing Certificate Authority": "",
"Signing Request": "",
"Signing in to Docker Hub is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signing in to a registry, such as Docker Hub, is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signup": "",
"Silver / Gold Coverage Customers can enable iXsystems Proactive Support. This automatically emails iXsystems when certain conditions occur on this TrueNAS system. The iX Support Team will promptly communicate with the Contacts saved below to quickly resolve any issue that may have occurred on the system.": "",
"Similar Apps": "",
Expand Down Expand Up @@ -4884,7 +4885,6 @@
"Uploading file...": "",
"Upsmon will wait up to this many seconds in master mode for the slaves to disconnect during a shutdown situation.": "",
"Uptime": "",
"Uri": "",
"Usable Capacity": "",
"Usage": "",
"Usage Collection": "",
Expand Down
6 changes: 3 additions & 3 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@
"Choose one of the presets or choose <i>Custom</i> to use the advanced scheduler.": "",
"Choose one of the presets or select <i>Custom</i> to open the advanced scheduler.": "",
"Choose pod": "",
"Choose pool first": "",
"Choose the VM operating system type.": "",
"Choose the backend to map Windows security identifiers (SIDs) to UNIX UIDs and GIDs. Click Edit to configure that backend.": "",
"Choose the hour and minute when new resilver tasks are not allowed to start. This does not affect active resilver tasks.": "",
Expand Down Expand Up @@ -4174,14 +4175,14 @@
"Sign Out": "",
"Sign up for account": "",
"Sign-in to Docker Hub": "",
"Sign-in to Docker Hub or other registry": "",
"Sign-in to a Docker registry": "",
"Signed By": "",
"Signed Certificates": "",
"Signin": "",
"Signing": "",
"Signing Certificate Authority": "",
"Signing Request": "",
"Signing in to Docker Hub is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signing in to a registry, such as Docker Hub, is not required for Apps to function, but may help if you experience rate limiting issues.": "",
"Signup": "",
"Silver / Gold Coverage Customers can enable iXsystems Proactive Support. This automatically emails iXsystems when certain conditions occur on this TrueNAS system. The iX Support Team will promptly communicate with the Contacts saved below to quickly resolve any issue that may have occurred on the system.": "",
"Similar Apps": "",
Expand Down Expand Up @@ -4884,7 +4885,6 @@
"Uploading file...": "",
"Upsmon will wait up to this many seconds in master mode for the slaves to disconnect during a shutdown situation.": "",
"Uptime": "",
"Uri": "",
"Usable Capacity": "",
"Usage": "",
"Usage Collection": "",
Expand Down
Loading

0 comments on commit cb52e11

Please sign in to comment.