@manuscripts/style-guide 0.30.23 → 0.30.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +20 -38
  2. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +4 -4
  3. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +5 -5
  4. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +4 -5
  5. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +8 -8
  6. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +2 -2
  7. package/dist/cjs/components/FileManager/FileSectionState.js +1 -16
  8. package/dist/cjs/components/FileManager/FilesSection.js +1 -6
  9. package/dist/cjs/components/FileManager/InlineFilesSection.js +6 -3
  10. package/dist/cjs/components/FileManager/util.js +7 -23
  11. package/dist/cjs/components/icons/attach.js +26 -0
  12. package/dist/cjs/components/icons/index.js +5 -1
  13. package/dist/cjs/components/icons/upload.js +13 -0
  14. package/dist/cjs/lib/inlineFiles.js +23 -15
  15. package/dist/es/components/FileManager/FileManager.js +21 -39
  16. package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +4 -4
  17. package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +5 -5
  18. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +4 -5
  19. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +8 -8
  20. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +2 -2
  21. package/dist/es/components/FileManager/FileSectionState.js +1 -16
  22. package/dist/es/components/FileManager/FilesSection.js +1 -6
  23. package/dist/es/components/FileManager/InlineFilesSection.js +6 -3
  24. package/dist/es/components/FileManager/util.js +5 -19
  25. package/dist/es/components/icons/attach.js +21 -0
  26. package/dist/es/components/icons/index.js +2 -0
  27. package/dist/es/components/icons/upload.js +8 -0
  28. package/dist/es/lib/inlineFiles.js +23 -15
  29. package/dist/types/components/FileManager/FileManager.d.ts +6 -5
  30. package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +2 -1
  31. package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +2 -1
  32. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +2 -2
  33. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +14 -4
  34. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +4 -2
  35. package/dist/types/components/FileManager/FileSectionState.d.ts +2 -7
  36. package/dist/types/components/FileManager/FilesSection.d.ts +1 -1
  37. package/dist/types/components/FileManager/InlineFilesSection.d.ts +2 -1
  38. package/dist/types/components/FileManager/UploadFileArea.d.ts +1 -1
  39. package/dist/types/components/FileManager/util.d.ts +5 -6
  40. package/dist/types/components/icons/attach.d.ts +18 -0
  41. package/dist/types/components/icons/index.d.ts +2 -0
  42. package/dist/types/components/icons/upload.d.ts +3 -0
  43. package/package.json +1 -1
@@ -19,50 +19,32 @@ import { actions, getInitialState, reducer } from './FileSectionState';
19
19
  import { FilesSection } from './FilesSection';
20
20
  import { InlineFilesSection } from './InlineFilesSection';
21
21
  import { TooltipDiv } from './TooltipDiv';
22
- import { Designation, designationWithFileSectionsMap, FileSectionType, generateExternalFilesTitles, namesWithDesignationMap, sortExternalFiles, } from './util';
22
+ import { Designation, designationWithFileSectionsMap, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
23
23
  export const PermissionsContext = createContext(null);
24
- export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
24
+ export const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
25
25
  const [state, dispatch] = useReducer(reducer, getInitialState());
26
- const handleReplaceFile = useCallback((submissionId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
27
27
  dispatch(actions.HANDLE_UPLOAD_ACTION());
28
28
  dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
29
- const res = yield handleReplace(submissionId, name, file, typeId);
30
- if (res) {
31
- dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
32
- }
29
+ const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
33
30
  dispatch(actions.HANDLE_FINISH_UPLOAD());
34
31
  return res;
35
32
  }), [handleReplace]);
36
33
  const handleUploadFile = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
37
- try {
38
- dispatch(actions.HANDLE_UPLOAD_ACTION());
39
- if (namesWithDesignationMap.get(designation) == Designation.Supplementary) {
40
- dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
41
- }
42
- const res = yield handleUpload(submissionId, file, designation);
43
- if (res) {
44
- dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
45
- }
46
- dispatch(actions.HANDLE_FINISH_UPLOAD());
47
- return res;
48
- }
49
- catch (e) {
50
- console.error(e);
51
- return false;
34
+ dispatch(actions.HANDLE_UPLOAD_ACTION());
35
+ if (namesWithDesignationMap.get(designation) == Designation.Supplementary) {
36
+ dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
52
37
  }
38
+ const res = yield handleUpload(submissionId, file, designation);
39
+ dispatch(actions.HANDLE_FINISH_UPLOAD());
40
+ return res;
53
41
  }), [handleUpload]);
54
- const handleChangeDesignationFile = useCallback((submissionId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
55
- try {
56
- const res = yield handleChangeDesignation(submissionId, typeId, name);
57
- if (res) {
58
- dispatch(actions.HANDLE_SUCCESS_MESSAGE());
59
- }
60
- return res;
61
- }
62
- catch (e) {
63
- console.log(e);
64
- return false;
42
+ const handleChangeDesignationFile = useCallback((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
43
+ const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
44
+ if (res) {
45
+ dispatch(actions.HANDLE_SUCCESS_MESSAGE());
65
46
  }
47
+ return res;
66
48
  }), [handleChangeDesignation]);
67
49
  const handleDownloadFile = useCallback((publicUrl) => {
68
50
  return handleDownload(publicUrl);
@@ -70,12 +52,12 @@ export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragA
70
52
  const getFileSectionExternalFile = (fileSection) => {
71
53
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
72
54
  fileSection === FileSectionType.OtherFile;
73
- const itemsData = externalFiles.filter((element) => {
74
- const designation = namesWithDesignationMap.get(element.designation);
55
+ const itemsData = attachments.filter((element) => {
56
+ const designation = namesWithDesignationMap.get(element.type.label);
75
57
  return (designation !== undefined &&
76
58
  designationWithFileSectionsMap.get(designation) === fileSection);
77
59
  });
78
- const itemsDataWithTitle = generateExternalFilesTitles(sortExternalFiles(itemsData), fileSection);
60
+ const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
79
61
  const filesItems = itemsDataWithTitle.map((element) => {
80
62
  const itemProps = {
81
63
  submissionId: submissionId,
@@ -89,10 +71,10 @@ export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragA
89
71
  dispatch: dispatch,
90
72
  };
91
73
  if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
92
- return (React.createElement(DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile._id })));
74
+ return (React.createElement(DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id })));
93
75
  }
94
76
  else {
95
- return (React.createElement(FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile._id, isEditor: enableDragAndDrop })));
77
+ return (React.createElement(FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id, isEditor: enableDragAndDrop })));
96
78
  }
97
79
  });
98
80
  return filesItems;
@@ -123,7 +105,7 @@ export const FileManager = ({ submissionId, externalFiles, modelMap, enableDragA
123
105
  React.createElement("div", null, "Files excluded from the final submission.")))),
124
106
  React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
125
107
  React.createElement(InspectorTabPanel, null,
126
- React.createElement(InlineFilesSection, { modelMap: modelMap, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, dispatch: dispatch })),
108
+ React.createElement(InlineFilesSection, { modelMap: modelMap, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
127
109
  React.createElement(InspectorTabPanel, null,
128
110
  React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
129
111
  React.createElement(InspectorTabPanel, null,
@@ -4,7 +4,7 @@ import BottomArrowIcon from '../../icons/BottomArrowIcon';
4
4
  import { ConfirmationPopUp } from '../ConfirmationPopUp';
5
5
  import { designationWithReadableNamesMap, getDesignationActionsList, } from '../util';
6
6
  import { DesignationActionsList } from './DesignationActionsList';
7
- export const DesignationActions = ({ designation, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
7
+ export const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, submissionId, fileName, dispatch, }) => {
8
8
  const [isActionsShown, setIsActionsShown] = useState(false);
9
9
  const [confirmationPopUpData, setConfirmationPopUpData] = useState({
10
10
  isConfirmationPopUpOpen: false,
@@ -20,7 +20,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
20
20
  const hideActionsList = () => {
21
21
  setIsActionsShown(false);
22
22
  };
23
- if (designation && fileExtension) {
23
+ if (designation !== undefined && fileExtension) {
24
24
  const designationActionsList = getDesignationActionsList(designation, fileExtension);
25
25
  if (!designationActionsList.length) {
26
26
  return null;
@@ -35,7 +35,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
35
35
  };
36
36
  const handleMoveAction = () => {
37
37
  handleChangeDesignation &&
38
- handleChangeDesignation(submissionId, confirmationPopUpData.selectedDesignation, fileName);
38
+ handleChangeDesignation(submissionId, attachmentId, confirmationPopUpData.selectedDesignation, fileName);
39
39
  handleCloseAction();
40
40
  };
41
41
  const handleCloseAction = () => {
@@ -51,7 +51,7 @@ export const DesignationActions = ({ designation, fileExtension, handleChangeDes
51
51
  React.createElement(SecondaryActionsText, null, designationWithReadableNamesMap.get(designation)),
52
52
  React.createElement(BottomArrowIcon, null),
53
53
  isActionsShown && (React.createElement(ActionsListContainer, null,
54
- React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
54
+ React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
55
55
  confirmationPopUpData.isConfirmationPopUpOpen && (React.createElement(ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
56
56
  ? confirmationPopUpData.confirmationPopUpHeader
57
57
  : '', popUpMessage: confirmationPopUpData.confirmationPopUpMessage !== undefined
@@ -2,17 +2,17 @@ import React from 'react';
2
2
  import { actions } from '../FileSectionState';
3
3
  import { ActionsBox, ActionsItem, ActionsLabel, ActionsSeparator, } from '../ItemsAction';
4
4
  import { Designation, designationWithFileSectionsMap, designationWithReadableNamesMap, FileSectionType, getDesignationName, } from '../util';
5
- export const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, dispatch, handleOpenConfirmationPopup, }) => {
5
+ export const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
6
6
  const handleChangeOtherFilesTabDesignation = (designation, isMoveInOtherFileSection, confirmationPopupHeader, confirmationPopupMessage, successMoveMessage) => {
7
7
  if (isMoveInOtherFileSection) {
8
8
  if (dispatch) {
9
- dispatch(actions.MOVE_FILE(submissionId, getDesignationName(designation), fileName, successMoveMessage));
9
+ dispatch(actions.MOVE_FILE(submissionId, attachmentId, getDesignationName(designation), fileName, successMoveMessage));
10
10
  handleOpenConfirmationPopup(confirmationPopupHeader, confirmationPopupMessage, getDesignationName(designation));
11
11
  }
12
12
  }
13
13
  else {
14
14
  handleChangeDesignation &&
15
- handleChangeDesignation(submissionId, getDesignationName(designation), fileName);
15
+ handleChangeDesignation(submissionId, attachmentId, getDesignationName(designation), fileName);
16
16
  }
17
17
  };
18
18
  const isSupplementaryActionIncluded = designationActionsList.indexOf(Designation.Supplementary) !== -1;
@@ -21,7 +21,7 @@ export const DesignationActionsList = ({ handleChangeDesignation, designationAct
21
21
  .map((value) => {
22
22
  return (React.createElement(ActionsItem, { key: value, onClick: () => {
23
23
  let isMoveToOtherFileSection = true;
24
- if (designation) {
24
+ if (designation !== undefined) {
25
25
  isMoveToOtherFileSection =
26
26
  designationWithFileSectionsMap.get(designation) !==
27
27
  FileSectionType.OtherFile;
@@ -37,7 +37,7 @@ export const DesignationActionsList = ({ handleChangeDesignation, designationAct
37
37
  React.createElement(ActionsSeparator, null),
38
38
  React.createElement(ActionsItem, { onClick: () => {
39
39
  let isMoveToOtherFileSection = true;
40
- if (designation) {
40
+ if (designation !== undefined) {
41
41
  isMoveToOtherFileSection =
42
42
  designationWithFileSectionsMap.get(designation) !==
43
43
  FileSectionType.Supplements;
@@ -2,14 +2,14 @@ import React, { useContext } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { PermissionsContext } from '../FileManager';
4
4
  import { DesignationActions } from './DesignationActions';
5
- export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, description, handleChangeDesignation, submissionId, dispatch, }) => {
5
+ export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, submissionId, dispatch, }) => {
6
6
  const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
7
7
  const can = useContext(PermissionsContext);
8
8
  return (React.createElement(FileInfoContainer, null,
9
9
  (can === null || can === void 0 ? void 0 : can.changeDesignation) &&
10
10
  showDesignationActions &&
11
- designation &&
12
- submissionId && (React.createElement(DesignationActions, { designation: designation, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
11
+ designation !== undefined &&
12
+ submissionId && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch })),
13
13
  React.createElement(FileNameTitleContainer, null,
14
14
  React.createElement(FileTitle, null,
15
15
  !showAttachmentName ? fileName : title,
@@ -18,8 +18,7 @@ export const FileInfo = ({ showAttachmentName, showDesignationActions, title, su
18
18
  React.createElement(FileName, null, fileName),
19
19
  React.createElement("div", null,
20
20
  ".",
21
- fileExtension)))),
22
- description && React.createElement(FileDescription, null, description)));
21
+ fileExtension))))));
23
22
  };
24
23
  export const FileInfoContainer = styled.div `
25
24
  margin-left: 8px;
@@ -10,20 +10,20 @@ import { FileTypeIcon } from './FileTypeIcon';
10
10
  import { ItemActions } from './ItemActions';
11
11
  export const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
12
12
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
13
- const fileExtension = externalFile.filename.substring(externalFile.filename.lastIndexOf('.') + 1);
14
- const designation = namesWithDesignationMap.get(externalFile.designation);
13
+ const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
14
+ const designation = namesWithDesignationMap.get(externalFile.type.label);
15
15
  const isMainManuscript = designation === Designation.MainManuscript;
16
- const isSelected = externalFile._id == window.location.hash.substr(1);
16
+ const isSelected = externalFile.id == window.location.hash.substr(1);
17
17
  return (React.createElement(Item, { ref: dragRef, className: className, style: style },
18
18
  React.createElement(ItemContainer, { onClick: () => {
19
19
  window.location.hash =
20
- isEditor && !isSelected ? `#${externalFile._id}` : '#';
20
+ isEditor && !isSelected ? `#${externalFile.id}` : '#';
21
21
  if (isSelected) {
22
- window.location.hash = `#${externalFile._id}`;
22
+ window.location.hash = `#${externalFile.id}`;
23
23
  }
24
24
  } },
25
- React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.filename }),
26
- React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.filename, title: title, designation: designation, description: externalFile.description, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
25
+ React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
26
+ React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
27
27
  onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
28
28
  e.preventDefault();
29
29
  onClose();
@@ -32,7 +32,7 @@ export const FileSectionItem = ({ submissionId, externalFile, title, showAttachm
32
32
  handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
33
33
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
34
34
  React.createElement(DotsIcon, null)),
35
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch }))))));
35
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
36
36
  };
37
37
  const IconCloseButton = styled.button `
38
38
  border: none;
@@ -3,7 +3,7 @@ import { DropdownList } from '../../Dropdown';
3
3
  import { PermissionsContext } from '../FileManager';
4
4
  import { actions } from '../FileSectionState';
5
5
  import { ActionsItem } from '../ItemsAction';
6
- export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
6
+ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
7
7
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
8
8
  const fileInputRef = useRef(null);
9
9
  const [selectedFile, setSelectedFile] = useState();
@@ -15,7 +15,7 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
15
15
  if (dispatch) {
16
16
  dispatch(actions.UPLOAD_FILE(file));
17
17
  }
18
- replaceAttachmentHandler(submissionId, fileName, file, attachmentDesignation);
18
+ replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
19
19
  hideActionList();
20
20
  }
21
21
  };
@@ -1,7 +1,6 @@
1
1
  export const getInitialState = () => ({
2
2
  uploadedFile: undefined,
3
3
  isUploadFile: false,
4
- isFileUploaded: false,
5
4
  moveToOtherState: undefined,
6
5
  successMessage: '',
7
6
  isShowSuccessMessage: false,
@@ -17,8 +16,6 @@ var ActionTypes;
17
16
  ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
18
17
  ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
19
18
  ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
20
- ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
21
- ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
22
19
  })(ActionTypes || (ActionTypes = {}));
23
20
  export const reducer = (state, action) => {
24
21
  switch (action.type) {
@@ -44,15 +41,9 @@ export const reducer = (state, action) => {
44
41
  case ActionTypes.HANDLE_FINISH_UPLOAD: {
45
42
  return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
46
43
  }
47
- case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
48
- return Object.assign(Object.assign({}, state), { isFileUploaded: true });
49
- }
50
44
  case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
51
45
  return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
52
46
  }
53
- case ActionTypes.CLOSE_FILE_UPLOADED_ALERT: {
54
- return Object.assign(Object.assign({}, state), { isFileUploaded: false });
55
- }
56
47
  }
57
48
  return state;
58
49
  };
@@ -71,7 +62,7 @@ export const actions = {
71
62
  type: ActionTypes.SELECT_DESIGNATION,
72
63
  designation,
73
64
  }),
74
- MOVE_FILE: (submissionId, typeId, name, successMoveMessage) => ({
65
+ MOVE_FILE: (submissionId, attachmentId, typeId, name, successMoveMessage) => ({
75
66
  type: ActionTypes.MOVE_FILE,
76
67
  submissionId,
77
68
  typeId,
@@ -81,12 +72,6 @@ export const actions = {
81
72
  HANDLE_FINISH_UPLOAD: () => ({
82
73
  type: ActionTypes.HANDLE_FINISH_UPLOAD,
83
74
  }),
84
- SHOW_FILE_UPLOADED_ALERT: () => ({
85
- type: ActionTypes.SHOW_FILE_UPLOADED_ALERT,
86
- }),
87
- CLOSE_FILE_UPLOADED_ALERT: () => ({
88
- type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
89
- }),
90
75
  HANDLE_SUCCESS_MESSAGE: () => ({
91
76
  type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
92
77
  }),
@@ -1,5 +1,4 @@
1
1
  import React, { useContext } from 'react';
2
- import { AlertMessage, AlertMessageType } from '../AlertMessage';
3
2
  import { DragItemArea } from './DragItemArea';
4
3
  import { PermissionsContext } from './FileManager';
5
4
  import { FileSectionUploadItem } from './FileSectionItem/FileSectionUploadItem';
@@ -26,11 +25,7 @@ export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fi
26
25
  (isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
27
26
  state.isUploadFile &&
28
27
  state.uploadedFile &&
29
- state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })),
30
- state.isFileUploaded && (React.createElement(AlertMessage, { type: AlertMessageType.info, hideCloseButton: true, dismissButton: {
31
- action: () => dispatch(actions.CLOSE_FILE_UPLOADED_ALERT()),
32
- text: 'Close',
33
- } }, "File uploaded successfully. It may take a few moments to show the new file in the Inspector.")))),
28
+ state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
34
29
  state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
35
30
  dispatch(actions.HANDLE_CANCEL_UPLOAD());
36
31
  }, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
@@ -7,16 +7,19 @@ import { FileDescription, FileInfoContainer, FileNameTitleContainer, FileTitle,
7
7
  import { ActionsIcon, Item } from './FileSectionItem/FileSectionItem';
8
8
  import { ItemActions } from './FileSectionItem/ItemActions';
9
9
  import { extensionsWithFileTypesMap, fileTypesWithIconMap } from './util';
10
- export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, dispatch }) => {
10
+ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, modelMap, isEditor, dispatch, }) => {
11
11
  const inlineFiles = useMemo(() => getInlineFiles(modelMap), [modelMap]);
12
12
  const onElementClick = useCallback((e) => {
13
+ if (!isEditor) {
14
+ return;
15
+ }
13
16
  const { id } = e.currentTarget;
14
17
  const isSelected = id == window.location.hash.substr(1);
15
18
  window.location.hash = !isSelected ? `#${id}` : '#';
16
19
  if (isSelected) {
17
20
  window.location.hash = `#${id}`;
18
21
  }
19
- }, []);
22
+ }, [isEditor]);
20
23
  return (React.createElement("div", null, inlineFiles.map((file, index) => {
21
24
  var _a;
22
25
  return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
@@ -42,7 +45,7 @@ const FileReference = ({ externalFile, submissionId, handleReplace, handleDownlo
42
45
  handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
43
46
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
44
47
  React.createElement(DotsIcon, null)),
45
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
48
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: undefined, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
46
49
  };
47
50
  const ElementItem = styled(Item) `
48
51
  display: flex;
@@ -50,8 +50,8 @@ export var Designation;
50
50
  Designation[Designation["MainManuscript"] = 13] = "MainManuscript";
51
51
  })(Designation || (Designation = {}));
52
52
  export const designationWithFileSectionsMap = new Map([
53
- [Designation.Figure, FileSectionType.Inline],
54
- [Designation.Table, FileSectionType.Inline],
53
+ [Designation.Figure, FileSectionType.OtherFile],
54
+ [Designation.Table, FileSectionType.OtherFile],
55
55
  [Designation.Supplementary, FileSectionType.Supplements],
56
56
  [Designation.ConflictOfInterest, FileSectionType.OtherFile],
57
57
  [Designation.Document, FileSectionType.OtherFile],
@@ -346,15 +346,15 @@ export const fileTypesWithIconMap = new Map([
346
346
  ],
347
347
  [undefined, React.createElement(UnknownFormatFileIcon, { key: undefined })],
348
348
  ]);
349
- export const generateExternalFilesTitles = (externalFiles, fileSectionType) => {
349
+ export const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
350
350
  const titleCountersMap = new Map();
351
351
  const externalFilesWithTitlesMap = new Map();
352
352
  externalFiles.forEach((element) => {
353
- const fileExtension = element.filename.substring(element.filename.lastIndexOf('.') + 1);
353
+ const fileExtension = element.name.substring(element.name.lastIndexOf('.') + 1);
354
354
  const fileType = extensionsWithFileTypesMap.get(fileExtension.toLowerCase());
355
355
  const fileTitle = fileTypesWithTitlesMap.get(fileType);
356
356
  if (fileSectionType === FileSectionType.Inline) {
357
- externalFilesWithTitlesMap.set(element.filename, element);
357
+ externalFilesWithTitlesMap.set(element.name, element);
358
358
  }
359
359
  else {
360
360
  if (fileTitle !== undefined) {
@@ -377,13 +377,6 @@ export const generateExternalFilesTitles = (externalFiles, fileSectionType) => {
377
377
  }));
378
378
  return result;
379
379
  };
380
- export const sortExternalFiles = (externalFile) => externalFile
381
- .sort((a, b) => Number(a.createdAt) - Number(b.createdAt))
382
- .sort((a, b) => b.designation === 'main-manuscript'
383
- ? 1
384
- : a.designation === 'main-manuscript'
385
- ? -1
386
- : 0);
387
380
  export const getDesignationActionsList = (designation, fileExtension) => {
388
381
  const allowedDesignationsToTransition = designationWithAllowedDesignationsToTransitionMap.get(designation);
389
382
  if (allowedDesignationsToTransition) {
@@ -467,10 +460,3 @@ export const droppableSections = [
467
460
  FileSectionType.Supplements,
468
461
  FileSectionType.OtherFile,
469
462
  ];
470
- const isOfDesignation = (file, designation) => {
471
- const formats = designationWithAllowedMediaTypesMap.get(designation);
472
- return !!(formats === null || formats === void 0 ? void 0 : formats.find((type) => file.MIME.indexOf('/' + type) >= 0));
473
- };
474
- export const isFigure = (file) => {
475
- return isOfDesignation(file, Designation.Figure);
476
- };
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * © 2022 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import React from 'react';
17
+ const AttachIcon = () => {
18
+ return (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
19
+ React.createElement("path", { d: "M8.85683 5.35715L5.85183 8.36215C5.16883 9.04515 5.16883 10.1531 5.85183 10.8371C6.53483 11.5201 7.64283 11.5201 8.32683 10.8371L12.3928 6.77115C13.7598 5.40415 13.7598 3.18815 12.3928 1.82115C11.0258 0.454148 8.80983 0.454148 7.44283 1.82115L3.02383 6.24115C0.973828 8.29115 0.973828 11.6151 3.02383 13.6661C5.07383 15.7161 8.39783 15.7161 10.4488 13.6661L14.5138 9.60015", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
20
+ };
21
+ export default AttachIcon;
@@ -32,3 +32,5 @@ export { default as ZoomOutIcon } from './zoom-out';
32
32
  export { default as TaskStepCurrentIcon } from './task-step-current';
33
33
  export { default as TaskStepDoneIcon } from './task-step-done';
34
34
  export { default as TaskStepNextIcon } from './task-step-next';
35
+ export { default as AttachIcon } from './attach';
36
+ export { default as UploadIcon } from './upload';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ const UploadIcon = () => {
3
+ return (React.createElement("svg", { width: "17", height: "18", viewBox: "0 0 17 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
4
+ React.createElement("path", { d: "M8.5 12.5V1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
5
+ React.createElement("path", { d: "M13.5 6.5L8.5 1.5L3.5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
6
+ React.createElement("path", { d: "M15.5 16.5H1.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" })));
7
+ };
8
+ export default UploadIcon;
@@ -5,14 +5,17 @@ const getCaptionText = (caption) => caption &&
5
5
  new DOMParser().parseFromString(caption, 'text/html').documentElement
6
6
  .innerText;
7
7
  const getFigureData = (element, modelMap) => {
8
- const figureId = element.containedObjectIDs.find((e) => {
9
- const model = modelMap.get(e);
10
- return model && hasObjectType(ObjectTypes.Figure)(model);
8
+ const externalFileReferences = [];
9
+ element.containedObjectIDs.map((e) => {
10
+ var _a;
11
+ const object = modelMap.get(e);
12
+ if (object && object.objectType === ObjectTypes.Figure) {
13
+ const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
14
+ if (externalFileRef) {
15
+ externalFileReferences.push(externalFileRef);
16
+ }
17
+ }
11
18
  });
12
- const { externalFileReferences } = (figureId &&
13
- modelMap.get(figureId)) || {
14
- externalFileReferences: undefined,
15
- };
16
19
  return {
17
20
  id: element._id,
18
21
  externalFileReferences,
@@ -34,25 +37,30 @@ export default (modelMap) => {
34
37
  }
35
38
  else {
36
39
  (_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
40
+ var _a;
37
41
  const element = modelMap.get(elementId);
38
42
  if (!element) {
39
43
  return;
40
44
  }
41
45
  switch (element.objectType) {
42
- case ObjectTypes.FigureElement: {
46
+ case ObjectTypes.FigureElement:
47
+ case ObjectTypes.MultiGraphicFigureElement: {
43
48
  files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: FileType.Figure }));
44
49
  break;
45
50
  }
46
51
  case ObjectTypes.TableElement: {
47
52
  const tableElement = element;
48
53
  const table = modelMap.get(tableElement.containedObjectID);
49
- files.push({
50
- id: element._id,
51
- label: `Table`,
52
- type: FileType.SheetsWorkbooks,
53
- externalFileReferences: table.externalFileReferences,
54
- caption: getCaptionText(tableElement.caption),
55
- });
54
+ const externalFileReferences = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.filter((file) => file.kind === 'dataset' && file.ref);
55
+ if (externalFileReferences && externalFileReferences.length > 0) {
56
+ files.push({
57
+ id: element._id,
58
+ label: `Table`,
59
+ type: FileType.SheetsWorkbooks,
60
+ externalFileReferences: table.externalFileReferences,
61
+ caption: getCaptionText(tableElement.caption),
62
+ });
63
+ }
56
64
  break;
57
65
  }
58
66
  }
@@ -1,15 +1,16 @@
1
- import { ExternalFile, Model } from '@manuscripts/manuscripts-json-schema';
1
+ import { Model } from '@manuscripts/manuscripts-json-schema';
2
2
  import React from 'react';
3
3
  import { Capabilities } from '../../lib/capabilities';
4
+ import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
4
5
  export declare const PermissionsContext: React.Context<Capabilities | null>;
5
6
  export declare const FileManager: React.FC<{
6
7
  submissionId: string;
7
- externalFiles: ExternalFile[];
8
+ attachments: SubmissionAttachment[];
8
9
  modelMap: Map<string, Model>;
9
10
  enableDragAndDrop: boolean;
10
11
  can: Capabilities;
11
- handleUpload: (submissionId: string, file: File, designation: string) => Promise<boolean>;
12
+ handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
12
13
  handleDownload: (url: string) => void;
13
- handleReplace: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
14
- handleChangeDesignation: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
14
+ handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<any>;
15
+ handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<any>;
15
16
  }>;
@@ -3,8 +3,9 @@ import { Action } from '../FileSectionState';
3
3
  import { Designation } from '../util';
4
4
  export declare const DesignationActions: React.FC<{
5
5
  designation?: Designation;
6
+ attachmentId: string;
6
7
  fileExtension?: string;
7
- handleChangeDesignation?: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
8
+ handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
8
9
  submissionId: string;
9
10
  fileName: string;
10
11
  dispatch?: Dispatch<Action>;
@@ -2,11 +2,12 @@ import React, { Dispatch } from 'react';
2
2
  import { Action } from '../FileSectionState';
3
3
  import { Designation } from '../util';
4
4
  export declare const DesignationActionsList: React.FC<{
5
- handleChangeDesignation?: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
5
+ handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
6
6
  designationActionsList: Array<Designation>;
7
7
  submissionId: string;
8
8
  fileName: string;
9
9
  designation?: Designation;
10
+ attachmentId: string;
10
11
  dispatch?: Dispatch<Action>;
11
12
  handleOpenConfirmationPopup: (popupHeader: string, popupMessage: string, designation: string) => void;
12
13
  }>;
@@ -5,11 +5,11 @@ export declare const FileInfo: React.FC<{
5
5
  showAttachmentName: boolean;
6
6
  showDesignationActions: boolean;
7
7
  title: string;
8
- description?: string;
9
8
  submissionAttachmentName: string;
10
9
  fileExtension: string;
11
10
  designation?: Designation;
12
- handleChangeDesignation: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
11
+ attachmentId: string;
12
+ handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
13
13
  submissionId?: string;
14
14
  dispatch?: Dispatch<Action>;
15
15
  }>;