Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Separate create and view permissions for annotations #358

Merged
merged 4 commits into from
Sep 1, 2017

Conversation

pramodsum
Copy link
Contributor

Enables annotations to be shown in a view-only setting with the correct scopes

Annotations permissions will be as follows:

  • can_annotate - whether a user can add any new annotations
  • can_view_annotations_all - whether a user can view all annotations
  • can_view_annotations_self - whether a user can view their own annotations (The API should return only the current user's annotations for this scope)

Enables annotations to be shown in a view-only setting with the
correct scopes

Annotations permissions will be as follows:
- can_annotate - whether a user can add any new annotations
- can_view_annotations_all - whether a user can view all annotations
- can_view_annotations_self - whether a user can view their own
  annotations (This is not yet supported as Preview is not aware of
  who the user previewing the file is in order to distinguish which
  annotations belong to the current user vs. other users)
@@ -162,7 +168,7 @@ class Annotator extends EventEmitter {
*/
showModeAnnotateButton(currentMode) {
const mode = this.modeButtons[currentMode];
if (!mode || !this.isModeAnnotatable(currentMode)) {
if (!mode || !this.permissions.canAnnotate || !this.isModeAnnotatable(currentMode)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensures button to create point/draw annotations does not display

@@ -534,12 +540,20 @@ class Annotator extends EventEmitter {
fetchAnnotations() {
this.threads = {};

// Do not load any pre-existing annotations if the user does not have
// the correct permissions
if (!this.permissions.canViewAllAnnotations || !this.permissions.canViewOwnAnnotations) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not fetch any annotations if the user cannot view any/their own annotations

// Hide delete button on plain highlights if user doesn't have
// permissions
if (annotations[0].permissions && !annotations[0].permissions.can_delete) {
if (!this.canAnnotate) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hides buttons in the plain highlight dialog if the user does not have can_annotate permissions

@pramodsum
Copy link
Contributor Author

Tests coming soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants