Skip to content

Commit 6cf8821

Browse files
committed
feat(related-projects): added link projects button
1 parent 1640b03 commit 6cf8821

2 files changed

Lines changed: 43 additions & 10 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 & 1 deletion
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,6 +45,7 @@ import {
4145
TruncatedTextComponent,
4246
} from '@osf/shared/components';
4347
import { ResourceType, UserPermissions } from '@osf/shared/enums';
48+
import { IS_MEDIUM } from '@osf/shared/helpers';
4449
import { ToolbarResource } from '@osf/shared/models';
4550
import { Duplicate } from '@osf/shared/models/duplicates';
4651
import { CustomDialogService } from '@osf/shared/services';
@@ -81,6 +86,7 @@ export class ViewRelatedProjectsComponent implements OnInit {
8186
isLoading = select(RelatedSelectors.getRelatedLoading);
8287
totalDuplicates = select(RelatedSelectors.getRelatedTotalCount);
8388
isAuthenticated = select(UserSelectors.isAuthenticated);
89+
isMedium = toSignal(inject(IS_MEDIUM));
8490

8591
title = computed(() => {
8692
switch (this.itemType()) {
@@ -109,6 +115,15 @@ export class ViewRelatedProjectsComponent implements OnInit {
109115
}
110116
});
111117

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+
112127
readonly pageSize = 10;
113128
readonly UserPermissions = UserPermissions;
114129

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

243278
handleForkResource(): void {
244279
const toolbarResource = this.toolbarResource();

0 commit comments

Comments
 (0)