Skip to content

Commit c97934f

Browse files
committed
feat(related-projects): added link projects button
1 parent c769028 commit c97934f

2 files changed

Lines changed: 43 additions & 11 deletions

File tree

src/app/features/analytics/components/view-related-projects/view-related-projects.component.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<osf-sub-header
22
[title]="title()"
33
[showButton]="isAuthenticated()"
4-
[buttonLabel]="'project.overview.actions.forkProjectLabel' | translate"
5-
(buttonClick)="handleForkResource()"
4+
[buttonLabel]="mainActionMessage()"
5+
(buttonClick)="handleMainAction()"
66
/>
77

88
<div class="flex flex-column flex-1 bg-white gap-5 p-3 sm:p-4">
@@ -71,13 +71,11 @@ <h2 class="flex align-items-center gap-2">
7171
/>
7272
}
7373
</div>
74-
@if (isShowingDuplicates()) {
75-
<p-button
76-
[label]="'common.buttons.view' | translate"
77-
severity="secondary"
78-
[routerLink]="['/', relatedItem.id]"
79-
/>
80-
}
74+
<p-button
75+
[label]="'common.buttons.view' | translate"
76+
severity="secondary"
77+
[routerLink]="['/', relatedItem.id]"
78+
/>
8179
</div>
8280
}
8381

src/app/features/analytics/components/view-related-projects/view-related-projects.component.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
2525

2626
import { UserSelectors } from '@core/store/user';
2727
import { RelatedItemsType } from '@osf/features/analytics/enums/related-items-type';
28-
import { DeleteComponentDialogComponent, ForkDialogComponent } from '@osf/features/project/overview/components';
28+
import {
29+
DeleteComponentDialogComponent,
30+
ForkDialogComponent,
31+
LinkResourceDialogComponent,
32+
} from '@osf/features/project/overview/components';
2933
import { ClearProjectOverview, GetProjectById, ProjectOverviewSelectors } from '@osf/features/project/overview/store';
3034
import {
3135
ClearRegistryOverview,
@@ -41,7 +45,7 @@ import {
4145
TruncatedTextComponent,
4246
} from '@osf/shared/components';
4347
import { ResourceType, UserPermissions } from '@osf/shared/enums';
44-
import { IS_SMALL } from '@osf/shared/helpers';
48+
import { IS_MEDIUM, IS_SMALL } from '@osf/shared/helpers';
4549
import { ToolbarResource } from '@osf/shared/models';
4650
import { Duplicate } from '@osf/shared/models/duplicates';
4751
import { CustomDialogService } from '@osf/shared/services';
@@ -82,6 +86,7 @@ export class ViewRelatedProjectsComponent implements OnInit {
8286
isLoading = select(RelatedSelectors.getRelatedLoading);
8387
totalDuplicates = select(RelatedSelectors.getRelatedTotalCount);
8488
isAuthenticated = select(UserSelectors.isAuthenticated);
89+
isMedium = toSignal(inject(IS_MEDIUM));
8590

8691
title = computed(() => {
8792
switch (this.itemType()) {
@@ -110,6 +115,15 @@ export class ViewRelatedProjectsComponent implements OnInit {
110115
}
111116
});
112117

118+
mainActionMessage = computed(() => {
119+
switch (this.itemType()) {
120+
case RelatedItemsType.Duplicates:
121+
return this.translateService.instant('project.overview.actions.forkProjectLabel');
122+
case RelatedItemsType.Linked:
123+
return this.translateService.instant('project.overview.components.linkProjectsButton');
124+
}
125+
});
126+
113127
readonly pageSize = 10;
114128
readonly UserPermissions = UserPermissions;
115129

@@ -241,6 +255,26 @@ export class ViewRelatedProjectsComponent implements OnInit {
241255
break;
242256
}
243257
}
258+
handleMainAction() {
259+
switch (this.itemType()) {
260+
case RelatedItemsType.Duplicates:
261+
this.handleForkResource();
262+
return;
263+
264+
case RelatedItemsType.Linked:
265+
this.openLinkProjectModal();
266+
return;
267+
}
268+
}
269+
270+
openLinkProjectModal() {
271+
const dialogWidth = this.isMedium() ? '850px' : '95vw';
272+
273+
this.customDialogService.open(LinkResourceDialogComponent, {
274+
header: 'project.overview.dialog.linkProject.header',
275+
width: dialogWidth,
276+
});
277+
}
244278

245279
handleForkResource(): void {
246280
const toolbarResource = this.toolbarResource();

0 commit comments

Comments
 (0)