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

feat(annotations): Don't show highlight button if no download permission #1253

Merged

Conversation

ConradJChan
Copy link
Contributor

No description provided.

@ConradJChan ConradJChan requested a review from a team as a code owner September 11, 2020 23:15
@ConradJChan ConradJChan changed the title feat(annotations): Disable highlight button if no download permission feat(annotations): Don't show highlight button if no download permission Sep 11, 2020
@@ -1105,11 +1105,13 @@ class DocBaseViewer extends BaseViewer {
this.controls.add(__('exit_fullscreen'), this.toggleFullscreen, 'bp-exit-fullscreen-icon', ICON_FULLSCREEN_OUT);

if (this.areNewAnnotationsEnabled() && this.hasAnnotationCreatePermission()) {
const canDownload = checkPermission(this.options.file, PERMISSION_DOWNLOAD);
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like canDownload from lib/file.js checks a lot more than just the download permission related to actually being able to download the file. Might be too restrictive?

Copy link
Collaborator

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.

@@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any way we can avoid using withArgs here? Will make converting to Jest (someday) easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into this but it turns out stubs.checkPermission is already being used in the other tests

@@ -1105,11 +1105,13 @@ class DocBaseViewer extends BaseViewer {
this.controls.add(__('exit_fullscreen'), this.toggleFullscreen, 'bp-exit-fullscreen-icon', ICON_FULLSCREEN_OUT);

if (this.areNewAnnotationsEnabled() && this.hasAnnotationCreatePermission()) {
const canDownload = checkPermission(this.options.file, PERMISSION_DOWNLOAD);
Copy link
Collaborator

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.

@ConradJChan ConradJChan merged commit b3a72d6 into box:master Sep 14, 2020
@ConradJChan ConradJChan deleted the disable-highlight-annotations-button branch September 14, 2020 18:38
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.

2 participants