diff --git a/src/lib/viewers/doc/DocBaseViewer.js b/src/lib/viewers/doc/DocBaseViewer.js index c390a6150..bfb3a9e44 100644 --- a/src/lib/viewers/doc/DocBaseViewer.js +++ b/src/lib/viewers/doc/DocBaseViewer.js @@ -691,8 +691,15 @@ class DocBaseViewer extends BaseViewer { initAnnotations() { this.setupPageIds(); - const { apiHost, file, location, token } = this.options; + const { apiHost, file, location, token, sharedLink } = this.options; const fileVersionID = file.file_version.id; + + // Do not initialize annotations for shared links + // TODO(@spramod): Determine the expected behavior on shared links + if (sharedLink) { + return; + } + // Users can currently only view annotations on mobile const canAnnotate = checkPermission(file, PERMISSION_ANNOTATE) && !Browser.isMobile(); const annotationService = new AnnotationService({ diff --git a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js index abc6d8100..e551ab045 100644 --- a/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js +++ b/src/lib/viewers/doc/__tests__/DocBaseViewer-test.js @@ -1154,6 +1154,13 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => { expect(stubs.setupPageIds).to.be.called; }); + it('should do nothing if expiring embed is a shared link', () => { + stubs.checkPermission.withArgs(docBase.options.file, PERMISSION_ANNOTATE).returns(true); + docBase.options.sharedLink = 'url'; + docBase.initAnnotations(); + expect(docBase.annotator).to.be.undefined; + }); + it('should allow annotations based on browser and permissions', () => { stubs.checkPermission.withArgs(docBase.options.file, PERMISSION_ANNOTATE).returns(true); docBase.initAnnotations(); diff --git a/src/lib/viewers/image/ImageViewer.js b/src/lib/viewers/image/ImageViewer.js index f6f0485e3..cb7afc897 100644 --- a/src/lib/viewers/image/ImageViewer.js +++ b/src/lib/viewers/image/ImageViewer.js @@ -313,7 +313,14 @@ class ImageViewer extends ImageBaseViewer { } // Users can currently only view annotations on mobile - const { apiHost, file, location, token } = this.options; + const { apiHost, file, location, token, sharedLink } = this.options; + + // Do not initialize annotations for shared links + // TODO(@spramod): Determine the expected behavior on shared links + if (sharedLink) { + return; + } + const canAnnotate = checkPermission(file, PERMISSION_ANNOTATE) && !Browser.isMobile(); this.canAnnotate = canAnnotate; diff --git a/src/lib/viewers/image/__tests__/ImageViewer-test.js b/src/lib/viewers/image/__tests__/ImageViewer-test.js index 702007740..debea696e 100644 --- a/src/lib/viewers/image/__tests__/ImageViewer-test.js +++ b/src/lib/viewers/image/__tests__/ImageViewer-test.js @@ -483,6 +483,13 @@ describe('lib/viewers/image/ImageViewer', () => { expect(image.annotator).to.be.undefined; }); + it('should do nothing if expiring embed is a shared link', () => { + stubs.annotatable.returns(true); + image.options.sharedLink = 'url'; + image.initAnnotations(); + expect(image.annotator).to.be.undefined; + }); + it('should init annotations if user can annotate', () => { stubs.checkPermission.withArgs(image.options.file, PERMISSION_ANNOTATE).returns(true); stubs.annotatable.returns(true);