Skip to content

Commit da7ee8e

Browse files
authored
Merge pull request #54 from UNIwise/feature/RC-34-copy-of-annotation-the-copied-annotation-should-be-of-Private
feat(RC-34): copy button only appears on original annotations
2 parents 0202557 + b11ff18 commit da7ee8e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/components/NotePopup/NotePopupContainer.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import NotePopup from './NotePopup';
44
import { useTranslation } from 'react-i18next';
55
import { useSelector } from 'react-redux';
66
import selectors from 'selectors';
7+
import { setAnnotationShareType } from 'helpers/annotationShareType';
8+
import ShareTypes from 'constants/shareTypes';
79

810
function NotePopupContainer(props) {
911
const [
@@ -45,14 +47,22 @@ function NotePopupContainer(props) {
4547

4648
const handleCopy = React.useCallback(() => {
4749
const annotManager = core.getAnnotationManager(activeDocumentViewerKey);
50+
const currentUser = core.getCurrentUser(activeDocumentViewerKey);
4851
annotManager.deselectAllAnnotations();
4952
const copiedAnnotation = annotManager.getAnnotationCopy(annotation);
53+
const applyPrivateDefaults = (annot) => {
54+
setAnnotationShareType(annot, ShareTypes.NONE);
55+
annot.Author = currentUser;
56+
annot.setCustomData('isCopy', 'true');
57+
};
5058
if (Array.isArray(copiedAnnotation)) {
5159
copiedAnnotation.forEach((copiedAnnot) => {
60+
applyPrivateDefaults(copiedAnnot);
5261
annotManager.addAnnotation(copiedAnnot);
5362
annotManager.redrawAnnotation(copiedAnnot);
5463
});
5564
} else if (copiedAnnotation) {
65+
applyPrivateDefaults(copiedAnnotation);
5666
annotManager.addAnnotation(copiedAnnotation);
5767
annotManager.redrawAnnotation(copiedAnnotation);
5868
}
@@ -66,7 +76,7 @@ function NotePopupContainer(props) {
6676

6777
const isEditable = canModifyContents;
6878
const isDeletable = canModify && !annotation?.NoDelete;
69-
const isCopyable = true;
79+
const isCopyable = annotation?.getCustomData('isCopy') !== 'true';
7080

7181
const passProps = {
7282
handleEdit,

0 commit comments

Comments
 (0)