-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat(annotations): Don't show highlight button if no download permission #1253
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2302,6 +2302,7 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { | |
stubs.isFindDisabled = sandbox.stub(docBase, 'isFindDisabled'); | ||
stubs.areNewAnnotationsEnabled = sandbox.stub(docBase, 'areNewAnnotationsEnabled').returns(true); | ||
stubs.hasCreatePermission = sandbox.stub(docBase, 'hasAnnotationCreatePermission').returns(true); | ||
stubs.checkPermission.withArgs(docBase.options.file, PERMISSION_DOWNLOAD).returns(true); | ||
}); | ||
|
||
it('should add the correct controls', () => { | ||
|
@@ -2380,6 +2381,18 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { | |
}), | ||
); | ||
|
||
it('should not showHighlightText if file has no download permission', () => { | ||
stubs.checkPermission.withArgs(docBase.options.file, PERMISSION_DOWNLOAD).returns(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any way we can avoid using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this but it turns out |
||
|
||
docBase.bindControlListeners(); | ||
|
||
expect(docBase.annotationControls.init).to.be.calledWith( | ||
sinon.match({ | ||
showHighlightText: false, | ||
}), | ||
); | ||
}); | ||
|
||
it('should not add the toggle thumbnails control if the option is not enabled', () => { | ||
// Create a new instance that has enableThumbnailsSidebar as false | ||
docBase.options.enableThumbnailsSidebar = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the
canDownload
util from lib/file.js?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like
canDownload
fromlib/file.js
checks a lot more than just the download permission related to actually being able to download the file. Might be too restrictive?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fair point. It also looks like we only check the permission for
textLayerMode
. Should be good to go here.