-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09e94e9
commit 48a6572
Showing
18 changed files
with
152 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/SIL.XForge.Scripture/ClientApp/src/app/shared/share/share-base.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Operation } from 'realtime-server/lib/esm/common/models/project-rights'; | ||
import { SF_PROJECT_RIGHTS, SFProjectDomain } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-rights'; | ||
import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-role'; | ||
import { SubscriptionDisposable } from 'xforge-common/subscription-disposable'; | ||
import { UserService } from 'xforge-common/user.service'; | ||
import { SFProjectProfileDoc } from '../../core/models/sf-project-profile-doc'; | ||
import { SF_PROJECT_ROLES } from '../../core/models/sf-project-role-info'; | ||
|
||
export abstract class ShareBaseComponent extends SubscriptionDisposable { | ||
protected projectDoc?: SFProjectProfileDoc; | ||
|
||
constructor(protected readonly userService: UserService) { | ||
super(); | ||
} | ||
|
||
get availableRoles(): SFProjectRole[] { | ||
return SF_PROJECT_ROLES.filter(info => info.canBeShared && this.userShareableRoles.includes(info.role)).map( | ||
r => r.role | ||
) as SFProjectRole[]; | ||
} | ||
|
||
protected get userShareableRoles(): string[] { | ||
const project = this.projectDoc?.data; | ||
if (project == null) { | ||
return []; | ||
} | ||
const userRole = project.userRoles[this.userService.currentUserId]; | ||
return [ | ||
{ | ||
role: SFProjectRole.CommunityChecker, | ||
permission: | ||
project.checkingConfig.checkingEnabled && | ||
SF_PROJECT_RIGHTS.hasRight(project, this.userService.currentUserId, SFProjectDomain.Questions, Operation.View) | ||
}, | ||
{ | ||
role: SFProjectRole.Viewer, | ||
permission: | ||
SF_PROJECT_RIGHTS.hasRight(project, this.userService.currentUserId, SFProjectDomain.Texts, Operation.View) && | ||
userRole !== SFProjectRole.CommunityChecker | ||
}, | ||
{ | ||
role: SFProjectRole.Commenter, | ||
permission: SF_PROJECT_RIGHTS.hasRight( | ||
project, | ||
this.userService.currentUserId, | ||
SFProjectDomain.Notes, | ||
Operation.Create | ||
) | ||
} | ||
] | ||
.filter( | ||
info => | ||
info.permission && | ||
SF_PROJECT_RIGHTS.hasRight( | ||
this.projectDoc.data, | ||
this.userService.currentUserId, | ||
SFProjectDomain.UserInvites, | ||
Operation.Create | ||
) | ||
) | ||
.map(info => info.role as string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.