Skip to content

Commit bcdd4eb

Browse files
committed
fix(registries): added add new button
1 parent 33f4ab8 commit bcdd4eb

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section class="registries-hero-container py-5 px-3 flex flex-column gap-4 md:py-6 md:px-4">
2-
<div class="flex flex-column align-items-start gap-4 md:flex-row">
2+
<div class="flex flex-column align-items-start justify-content-between gap-4 md:flex-row">
33
<div class="flex align-items-center gap-2">
44
@if (isProviderLoading()) {
55
<p-skeleton width="3rem" height="1.5rem" />
@@ -13,6 +13,8 @@
1313
/>
1414
}
1515
</div>
16+
17+
<p-button [label]="'registries.addRegistration' | translate" (onClick)="navigateToCreatePage()"></p-button>
1618
</div>
1719

1820
<div class="provider-description">

src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
22

3+
import { Button } from 'primeng/button';
34
import { DialogService } from 'primeng/dynamicdialog';
45
import { Skeleton } from 'primeng/skeleton';
56

67
import { TitleCasePipe } from '@angular/common';
78
import { ChangeDetectionStrategy, Component, effect, inject, input, output } from '@angular/core';
89
import { FormControl } from '@angular/forms';
10+
import { Router } from '@angular/router';
911

1012
import { PreprintsHelpDialogComponent } from '@osf/features/preprints/components';
1113
import { RegistryProviderDetails } from '@osf/features/registries/models/registry-provider.model';
@@ -16,14 +18,15 @@ import { HeaderStyleHelper } from '@shared/utils';
1618

1719
@Component({
1820
selector: 'osf-registry-provider-hero',
19-
imports: [DecodeHtmlPipe, SearchInputComponent, Skeleton, TitleCasePipe, TranslatePipe],
21+
imports: [DecodeHtmlPipe, SearchInputComponent, Skeleton, TitleCasePipe, TranslatePipe, Button],
2022
templateUrl: './registry-provider-hero.component.html',
2123
styleUrl: './registry-provider-hero.component.scss',
2224
changeDetection: ChangeDetectionStrategy.OnPush,
2325
})
2426
export class RegistryProviderHeroComponent {
25-
protected translateService = inject(TranslateService);
26-
protected dialogService = inject(DialogService);
27+
private readonly router = inject(Router);
28+
private readonly translateService = inject(TranslateService);
29+
private readonly dialogService = inject(DialogService);
2730

2831
searchControl = input<FormControl>(new FormControl());
2932
provider = input.required<RegistryProviderDetails | null>();
@@ -58,4 +61,14 @@ export class RegistryProviderHeroComponent {
5861
closable: true,
5962
});
6063
}
64+
65+
navigateToCreatePage() {
66+
const providerId = this.provider()?.id;
67+
68+
if (!providerId) {
69+
return;
70+
}
71+
72+
this.router.navigate([`/registries/${providerId}/new`]);
73+
}
6174
}

0 commit comments

Comments
 (0)