Skip to content

Commit 53fc799

Browse files
authored
Merge pull request #742 from CDLUC3/bug/228/JS-prevent-removal-of-a-primary-collaborator
Return an error when trying to remove a Primary collaborator
2 parents a4e315f + 248548b commit 53fc799

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
- added data-migration to fix question JSON so that `"selected": 0` is now `"selected": false` (and `1` -> `true`).
8585

8686
### Updated
87+
- Updated `removeProjectCollaborator` to return error when trying to remove a `Primary` collaborator, since there always has to be one `Primary` [#228]
8788
- Updated dependencies flagged by dependabot and renovate.
8889
- Updated jest and @dmptool dependencies.
8990
- Updated `saveMaDMPVersion` function to include a `dmpId` argument and to properly convert the app name to a maDMP acceptable format

src/resolvers/collaborator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ export const resolvers: Resolvers = {
330330

331331
// If the user has permission on the Project
332332
if (await hasPermissionOnProject(context, project)) {
333+
if (projectCollaborator.accessLevel === ProjectCollaboratorAccessLevel.PRIMARY) {
334+
// Cannot remove a collaborator that has PRIMARY access, they must be demoted first
335+
if (!projectCollaborator.errors['general']) {
336+
projectCollaborator.addError('general', 'Cannot remove a collaborator that has PRIMARY access level');
337+
}
338+
return projectCollaborator;
339+
}
333340
return await projectCollaborator.delete(context);
334341
}
335342

0 commit comments

Comments
 (0)