@@ -28,6 +28,7 @@ import {
28
28
AddContributorDialogComponent ,
29
29
AddUnregisteredContributorDialogComponent ,
30
30
ContributorsTableComponent ,
31
+ RequestAccessTableComponent ,
31
32
} from '@osf/shared/components/contributors' ;
32
33
import { BIBLIOGRAPHY_OPTIONS , PERMISSION_OPTIONS } from '@osf/shared/constants' ;
33
34
import { AddContributorType , ContributorPermission , ResourceType } from '@osf/shared/enums' ;
@@ -41,6 +42,7 @@ import {
41
42
} from '@osf/shared/models' ;
42
43
import { CustomConfirmationService , CustomDialogService , ToastService } from '@osf/shared/services' ;
43
44
import {
45
+ AcceptRequestAccess ,
44
46
AddContributor ,
45
47
BulkAddContributors ,
46
48
BulkUpdateContributors ,
@@ -51,7 +53,9 @@ import {
51
53
DeleteViewOnlyLink ,
52
54
FetchViewOnlyLinks ,
53
55
GetAllContributors ,
56
+ GetRequestAccessContributors ,
54
57
GetResourceDetails ,
58
+ RejectRequestAccess ,
55
59
UpdateBibliographyFilter ,
56
60
UpdateContributorsSearchValue ,
57
61
UpdatePermissionFilter ,
@@ -71,6 +75,7 @@ import { ResourceInfoModel } from './models';
71
75
FormsModule ,
72
76
TableModule ,
73
77
ContributorsTableComponent ,
78
+ RequestAccessTableComponent ,
74
79
ViewOnlyTableComponent ,
75
80
] ,
76
81
templateUrl : './contributors.component.html' ,
@@ -99,9 +104,11 @@ export class ContributorsComponent implements OnInit {
99
104
readonly permissionsOptions : SelectOption [ ] = PERMISSION_OPTIONS ;
100
105
readonly bibliographyOptions : SelectOption [ ] = BIBLIOGRAPHY_OPTIONS ;
101
106
102
- initialContributors = select ( ContributorsSelectors . getContributors ) ;
103
107
contributors = signal < ContributorModel [ ] > ( [ ] ) ;
104
108
109
+ readonly initialContributors = select ( ContributorsSelectors . getContributors ) ;
110
+ readonly requestAccessList = select ( ContributorsSelectors . getRequestAccessList ) ;
111
+ readonly areRequestAccessListLoading = select ( ContributorsSelectors . areRequestAccessListLoading ) ;
105
112
readonly isContributorsLoading = select ( ContributorsSelectors . isContributorsLoading ) ;
106
113
readonly isViewOnlyLinksLoading = select ( ViewOnlyLinkSelectors . isViewOnlyLinksLoading ) ;
107
114
readonly currentUser = select ( UserSelectors . getCurrentUser ) ;
@@ -118,11 +125,19 @@ export class ContributorsComponent implements OnInit {
118
125
const initialContributors = this . initialContributors ( ) ;
119
126
if ( ! currentUserId ) return false ;
120
127
121
- return initialContributors . some ( ( contributor : ContributorModel ) => {
122
- return contributor . userId === currentUserId && contributor . permission === ContributorPermission . Admin ;
123
- } ) ;
128
+ return initialContributors . some (
129
+ ( contributor : ContributorModel ) =>
130
+ contributor . userId === currentUserId && contributor . permission === ContributorPermission . Admin
131
+ ) ;
124
132
} ) ;
125
133
134
+ showRequestAccessList = computed (
135
+ ( ) =>
136
+ this . isCurrentUserAdminContributor ( ) &&
137
+ this . requestAccessList ( ) . length &&
138
+ this . resourceType ( ) === ResourceType . Project
139
+ ) ;
140
+
126
141
actions = createDispatchMap ( {
127
142
getViewOnlyLinks : FetchViewOnlyLinks ,
128
143
getResourceDetails : GetResourceDetails ,
@@ -136,6 +151,9 @@ export class ContributorsComponent implements OnInit {
136
151
addContributor : AddContributor ,
137
152
createViewOnlyLink : CreateViewOnlyLink ,
138
153
deleteViewOnlyLink : DeleteViewOnlyLink ,
154
+ getRequestAccessContributors : GetRequestAccessContributors ,
155
+ acceptRequestAccess : AcceptRequestAccess ,
156
+ rejectRequestAccess : RejectRequestAccess ,
139
157
} ) ;
140
158
141
159
get hasChanges ( ) : boolean {
@@ -166,6 +184,10 @@ export class ContributorsComponent implements OnInit {
166
184
if ( id ) {
167
185
this . actions . getResourceDetails ( id , this . resourceType ( ) ) ;
168
186
this . actions . getContributors ( id , this . resourceType ( ) ) ;
187
+
188
+ if ( this . resourceType ( ) === ResourceType . Project ) {
189
+ this . actions . getRequestAccessContributors ( id , this . resourceType ( ) ) ;
190
+ }
169
191
}
170
192
171
193
this . setSearchSubscription ( ) ;
@@ -250,6 +272,38 @@ export class ContributorsComponent implements OnInit {
250
272
} ) ;
251
273
}
252
274
275
+ acceptRequest ( contributor : ContributorModel ) {
276
+ this . customConfirmationService . confirmAccept ( {
277
+ headerKey : 'project.requestAccess.acceptDialog.header' ,
278
+ messageKey : 'project.requestAccess.acceptDialog.message' ,
279
+ messageParams : { name : contributor . fullName } ,
280
+ acceptLabelKey : 'common.buttons.accept' ,
281
+ onConfirm : ( ) => {
282
+ const payload = { permissions : contributor . permission } ;
283
+
284
+ this . actions
285
+ . acceptRequestAccess ( contributor . id , this . resourceId ( ) , this . resourceType ( ) , payload )
286
+ . pipe ( takeUntilDestroyed ( this . destroyRef ) )
287
+ . subscribe ( ( ) => this . toastService . showSuccess ( 'project.requestAccess.acceptDialog.successMessage' ) ) ;
288
+ } ,
289
+ } ) ;
290
+ }
291
+
292
+ rejectRequest ( contributor : ContributorModel ) {
293
+ this . customConfirmationService . confirmDelete ( {
294
+ headerKey : 'project.requestAccess.rejectDialog.header' ,
295
+ messageKey : 'project.requestAccess.rejectDialog.message' ,
296
+ messageParams : { name : contributor . fullName } ,
297
+ acceptLabelKey : 'common.buttons.reject' ,
298
+ onConfirm : ( ) => {
299
+ this . actions
300
+ . rejectRequestAccess ( contributor . id , this . resourceId ( ) , this . resourceType ( ) )
301
+ . pipe ( takeUntilDestroyed ( this . destroyRef ) )
302
+ . subscribe ( ( ) => this . toastService . showSuccess ( 'project.requestAccess.rejectDialog.successMessage' ) ) ;
303
+ } ,
304
+ } ) ;
305
+ }
306
+
253
307
removeContributor ( contributor : ContributorModel ) {
254
308
this . customConfirmationService . confirmDelete ( {
255
309
headerKey : 'project.contributors.removeDialog.title' ,
0 commit comments