@manuscripts/style-guide 0.31.13 → 0.31.16

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 (39) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +37 -24
  2. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +3 -3
  3. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +3 -3
  4. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +2 -2
  5. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +5 -5
  6. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +2 -2
  7. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +11 -11
  8. package/dist/cjs/components/FileManager/FileSectionState.js +1 -3
  9. package/dist/cjs/components/FileManager/FilesSection.js +4 -4
  10. package/dist/cjs/components/FileManager/InlineFilesSection.js +6 -6
  11. package/dist/cjs/components/FileManager/UploadFileArea.js +4 -10
  12. package/dist/cjs/components/FileManager/util.js +1 -0
  13. package/dist/cjs/components/SubmissionInspector/BaseInformation.js +11 -7
  14. package/dist/es/components/FileManager/FileManager.js +37 -24
  15. package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +3 -3
  16. package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +3 -3
  17. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +2 -2
  18. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +5 -5
  19. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +2 -2
  20. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +11 -11
  21. package/dist/es/components/FileManager/FileSectionState.js +1 -3
  22. package/dist/es/components/FileManager/FilesSection.js +4 -4
  23. package/dist/es/components/FileManager/InlineFilesSection.js +6 -6
  24. package/dist/es/components/FileManager/UploadFileArea.js +4 -10
  25. package/dist/es/components/FileManager/util.js +1 -0
  26. package/dist/es/components/SubmissionInspector/BaseInformation.js +11 -7
  27. package/dist/types/components/FileManager/FileManager.d.ts +10 -7
  28. package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +2 -2
  29. package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +2 -2
  30. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +2 -2
  31. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +4 -7
  32. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -1
  33. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +3 -6
  34. package/dist/types/components/FileManager/FileSectionState.d.ts +1 -2
  35. package/dist/types/components/FileManager/FilesSection.d.ts +2 -2
  36. package/dist/types/components/FileManager/InlineFilesSection.d.ts +2 -6
  37. package/dist/types/components/FileManager/UploadFileArea.d.ts +2 -2
  38. package/dist/types/components/SubmissionInspector/types.d.ts +2 -0
  39. package/package.json +1 -1
@@ -48,42 +48,54 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
48
48
  const TooltipDiv_1 = require("./TooltipDiv");
49
49
  const util_1 = require("./util");
50
50
  exports.PermissionsContext = (0, react_1.createContext)(null);
51
- const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
51
+ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, }) => {
52
52
  const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
53
- const handleReplaceFile = (0, react_1.useCallback)((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
53
+ const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
54
54
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
55
55
  dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
56
- const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
56
+ const res = yield replace(attachmentId, name, file, typeId);
57
57
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
58
58
  return res;
59
- }), [handleReplace]);
60
- const handleUploadFile = (0, react_1.useCallback)((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
59
+ }), [replace]);
60
+ const handleUploadFile = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
61
61
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
62
62
  if (util_1.namesWithDesignationMap.get(designation) == util_1.Designation.Supplementary) {
63
63
  dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
64
64
  }
65
- const res = yield handleUpload(submissionId, file, designation);
65
+ const res = yield upload(file, designation);
66
66
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
67
67
  return res;
68
- }), [handleUpload]);
69
- const handleUploadFileWithSupplement = (0, react_1.useCallback)((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
70
- const res = (yield handleUploadFile(submissionId, file, designation));
71
- if (res && res.data) {
72
- const { id, name } = res.data.uploadAttachment;
68
+ }), [upload]);
69
+ const handleUploadFileWithSupplement = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
70
+ const response = yield upload(file, designation);
71
+ if (typeof response === 'object') {
72
+ const { id, name } = response;
73
73
  yield saveModel((0, manuscript_transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
74
74
  }
75
- return res;
76
- }), [handleUploadFile, saveModel]);
77
- const handleChangeDesignationFile = (0, react_1.useCallback)((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
78
- const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
75
+ return response;
76
+ }), [upload, saveModel]);
77
+ const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
78
+ const res = yield changeDesignation(attachmentId, typeId, name);
79
79
  if (res) {
80
80
  dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
81
81
  }
82
82
  return res;
83
- }), [handleChangeDesignation]);
84
- const handleDownloadFile = (0, react_1.useCallback)((publicUrl) => {
85
- return handleDownload(publicUrl);
86
- }, [handleDownload]);
83
+ }), [changeDesignation]);
84
+ const handleDownload = (0, react_1.useCallback)((url) => {
85
+ window.location.assign(url);
86
+ }, []);
87
+ const handleUpdateInline = (0, react_1.useCallback)((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
88
+ var _a;
89
+ const figureModel = modelMap.get(modelId);
90
+ const imageExternalFileIndex = (_a = figureModel === null || figureModel === void 0 ? void 0 : figureModel.externalFileReferences) === null || _a === void 0 ? void 0 : _a.findIndex((file) => file && file.kind === 'imageRepresentation');
91
+ if (figureModel.externalFileReferences &&
92
+ typeof imageExternalFileIndex !== 'undefined' &&
93
+ imageExternalFileIndex > -1) {
94
+ figureModel.externalFileReferences[imageExternalFileIndex].url = `attachment:${attachment.id}`;
95
+ yield saveModel(figureModel);
96
+ }
97
+ }), [modelMap, saveModel]);
98
+ const attachments = getAttachments();
87
99
  const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap.values(), attachments]);
88
100
  const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
89
101
  const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
@@ -99,6 +111,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
99
111
  const getFileSectionExternalFile = (fileSection) => {
100
112
  const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
101
113
  fileSection === util_1.FileSectionType.OtherFile;
114
+ const isOtherFilesTab = fileSection === util_1.FileSectionType.OtherFile;
102
115
  const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
103
116
  attachments.filter((element) => {
104
117
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
@@ -107,12 +120,12 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
107
120
  const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
108
121
  const filesItems = itemsDataWithTitle.map((element) => {
109
122
  const itemProps = {
110
- submissionId: submissionId,
111
123
  externalFile: element.externalFile,
112
124
  title: element.title,
113
125
  showAttachmentName: isSupplementOrOtherFilesTab,
114
126
  showDesignationActions: isSupplementOrOtherFilesTab,
115
- handleDownload: handleDownloadFile,
127
+ showReplaceAction: !isOtherFilesTab,
128
+ handleDownload,
116
129
  handleReplace: handleReplaceFile,
117
130
  handleChangeDesignation: handleChangeDesignationFile,
118
131
  dispatch: dispatch,
@@ -152,11 +165,11 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
152
165
  react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
153
166
  react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
154
167
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
155
- react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
168
+ react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
156
169
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
157
- react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
170
+ react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
158
171
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
159
- react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
172
+ react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
160
173
  state.isShowSuccessMessage &&
161
174
  state.successMessage !== '' &&
162
175
  handleSuccessMessage()));
@@ -31,7 +31,7 @@ const ConfirmationPopUp_1 = require("../ConfirmationPopUp");
31
31
  const TooltipDiv_1 = require("../TooltipDiv");
32
32
  const util_1 = require("../util");
33
33
  const DesignationActionsList_1 = require("./DesignationActionsList");
34
- const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, submissionId, fileName, can, dispatch, }) => {
34
+ const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, fileName, can, dispatch, }) => {
35
35
  const [isActionsShown, setIsActionsShown] = (0, react_1.useState)(false);
36
36
  const [confirmationPopUpData, setConfirmationPopUpData] = (0, react_1.useState)({
37
37
  isConfirmationPopUpOpen: false,
@@ -62,7 +62,7 @@ const DesignationActions = ({ designation, attachmentId, fileExtension, handleCh
62
62
  };
63
63
  const handleMoveAction = () => {
64
64
  handleChangeDesignation &&
65
- handleChangeDesignation(submissionId, attachmentId, confirmationPopUpData.selectedDesignation, fileName);
65
+ handleChangeDesignation(attachmentId, confirmationPopUpData.selectedDesignation, fileName);
66
66
  handleCloseAction();
67
67
  };
68
68
  const handleCloseAction = () => {
@@ -81,7 +81,7 @@ const DesignationActions = ({ designation, attachmentId, fileExtension, handleCh
81
81
  react_1.default.createElement(SecondaryActionsText, { "data-for": "file-designation", "data-tip": true }, util_1.designationWithReadableNamesMap.get(designation)),
82
82
  react_1.default.createElement(BottomArrowIcon_1.default, null),
83
83
  isActionsShown && (can === null || can === void 0 ? void 0 : can.changeDesignation) && (react_1.default.createElement(ActionsListContainer, null,
84
- react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
84
+ react_1.default.createElement(DesignationActionsList_1.DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
85
85
  confirmationPopUpData.isConfirmationPopUpOpen && (react_1.default.createElement(ConfirmationPopUp_1.ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
86
86
  ? confirmationPopUpData.confirmationPopUpHeader
87
87
  : '', popUpMessage: confirmationPopUpData.confirmationPopUpMessage !== undefined
@@ -8,17 +8,17 @@ const react_1 = __importDefault(require("react"));
8
8
  const FileSectionState_1 = require("../FileSectionState");
9
9
  const ItemsAction_1 = require("../ItemsAction");
10
10
  const util_1 = require("../util");
11
- const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, submissionId, fileName, designation, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
11
+ const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, fileName, designation, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
12
12
  const handleChangeOtherFilesTabDesignation = (designation, isMoveInOtherFileSection, confirmationPopupHeader, confirmationPopupMessage, successMoveMessage) => {
13
13
  if (isMoveInOtherFileSection) {
14
14
  if (dispatch) {
15
- dispatch(FileSectionState_1.actions.MOVE_FILE(submissionId, attachmentId, (0, util_1.getDesignationName)(designation), fileName, successMoveMessage));
15
+ dispatch(FileSectionState_1.actions.MOVE_FILE(attachmentId, (0, util_1.getDesignationName)(designation), fileName, successMoveMessage));
16
16
  handleOpenConfirmationPopup(confirmationPopupHeader, confirmationPopupMessage, (0, util_1.getDesignationName)(designation));
17
17
  }
18
18
  }
19
19
  else {
20
20
  handleChangeDesignation &&
21
- handleChangeDesignation(submissionId, attachmentId, (0, util_1.getDesignationName)(designation), fileName);
21
+ handleChangeDesignation(attachmentId, (0, util_1.getDesignationName)(designation), fileName);
22
22
  }
23
23
  };
24
24
  const isSupplementaryActionIncluded = designationActionsList.indexOf(util_1.Designation.Supplementary) !== -1;
@@ -27,11 +27,11 @@ const react_1 = __importStar(require("react"));
27
27
  const styled_components_1 = __importDefault(require("styled-components"));
28
28
  const FileManager_1 = require("../FileManager");
29
29
  const DesignationActions_1 = require("./DesignationActions");
30
- const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, submissionId, dispatch, }) => {
30
+ const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
31
31
  const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
32
32
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
33
33
  return (react_1.default.createElement(exports.FileInfoContainer, null,
34
- showDesignationActions && designation !== undefined && submissionId && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
34
+ showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
35
35
  react_1.default.createElement(exports.FileNameTitleContainer, null,
36
36
  react_1.default.createElement(exports.FileTitle, null,
37
37
  !showAttachmentName ? fileName : title,
@@ -14,7 +14,7 @@ const util_1 = require("../util");
14
14
  const FileInfo_1 = require("./FileInfo");
15
15
  const FileTypeIcon_1 = require("./FileTypeIcon");
16
16
  const ItemActions_1 = require("./ItemActions");
17
- const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
17
+ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
18
18
  const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
19
19
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
20
20
  const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
@@ -29,16 +29,16 @@ const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName
29
29
  }
30
30
  } },
31
31
  react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
32
- react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
32
+ react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
33
33
  onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
34
34
  e.preventDefault();
35
35
  onClose();
36
36
  } },
37
37
  react_1.default.createElement(icons_1.CloseOIcon, { color: '#6E6E6E' }))),
38
- handleDownload && handleReplace && submissionId && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
38
+ handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
39
39
  react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
40
40
  react_1.default.createElement(dots_icon_1.default, null)),
41
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
41
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
42
42
  };
43
43
  exports.FileSectionItem = FileSectionItem;
44
44
  const IconCloseButton = styled_components_1.default.button `
@@ -85,7 +85,7 @@ exports.Item = styled_components_1.default.div `
85
85
  ${Dropdown_1.DropdownContainer} {
86
86
  position: absolute;
87
87
  top: 24px;
88
- right: 0px;
88
+ right: 0;
89
89
  margin-right: 8px;
90
90
  }
91
91
  `;
@@ -10,7 +10,7 @@ const FileInfo_1 = require("./FileInfo");
10
10
  const FileSectionItem_1 = require("./FileSectionItem");
11
11
  const FileTypeIcon_1 = require("./FileTypeIcon");
12
12
  const ProgressBarUploadItem_1 = require("./ProgressBarUploadItem");
13
- const FileSectionUploadItem = ({ fileName, isLoading, submissionId, dragRef, className, style, }) => {
13
+ const FileSectionUploadItem = ({ fileName, isLoading, dragRef, className, style, }) => {
14
14
  const fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
15
15
  fileName = fileName.substring(0, fileName.lastIndexOf('.'));
16
16
  return (react_1.default.createElement(FileSectionItem_1.Item, { ref: dragRef, className: className, style: style },
@@ -31,7 +31,7 @@ exports.UploadItemContainer = (0, styled_components_1.default)(FileSectionItem_1
31
31
  exports.ProgressBar = styled_components_1.default.div `
32
32
  background: #1a9bc7;
33
33
  opacity: 0.7;
34
- border-radius: 8px 0px 0px 8px;
34
+ border-radius: 8px 0 0 8px;
35
35
  width: 20%;
36
36
  height: 100%;
37
37
  `;
@@ -35,17 +35,18 @@ const FileManager_1 = require("../FileManager");
35
35
  const FileSectionState_1 = require("../FileSectionState");
36
36
  const ItemsAction_1 = require("../ItemsAction");
37
37
  const util_1 = require("../util");
38
- const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
38
+ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
39
39
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
40
40
  const attachmentDesignationName = attachmentDesignation !== 'undefined'
41
41
  ? util_1.namesWithDesignationMap.get(attachmentDesignation)
42
42
  : undefined;
43
- const canBeReplaced = attachmentDesignationName == undefined ||
44
- ![
45
- util_1.Designation.MainManuscript,
46
- util_1.Designation.SubmissionFile,
47
- util_1.Designation.SubmissionPdf,
48
- ].includes(attachmentDesignationName);
43
+ const canBeReplaced = (showReplaceAction == undefined || showReplaceAction) &&
44
+ (attachmentDesignationName == undefined ||
45
+ ![
46
+ util_1.Designation.MainManuscript,
47
+ util_1.Designation.SubmissionFile,
48
+ util_1.Designation.SubmissionPdf,
49
+ ].includes(attachmentDesignationName));
49
50
  const fileInputRef = (0, react_1.useRef)(null);
50
51
  const [selectedFile, setSelectedFile] = (0, react_1.useState)();
51
52
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
@@ -57,10 +58,9 @@ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, hand
57
58
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
58
59
  dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
59
60
  }
60
- const result = yield replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
61
- const { uploadAttachment } = result === null || result === void 0 ? void 0 : result.data;
62
- if (uploadAttachment && handleUpdateInline) {
63
- handleUpdateInline(uploadAttachment);
61
+ const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
62
+ if (typeof result === 'object' && handleUpdateInline) {
63
+ handleUpdateInline(result);
64
64
  }
65
65
  if (dispatch) {
66
66
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
@@ -28,7 +28,6 @@ const reducer = (state, action) => {
28
28
  }
29
29
  case ActionTypes.MOVE_FILE: {
30
30
  return Object.assign(Object.assign({}, state), { moveToOtherState: {
31
- submissionId: action.submissionId,
32
31
  typeId: action.typeId,
33
32
  name: action.name,
34
33
  }, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
@@ -67,9 +66,8 @@ exports.actions = {
67
66
  type: ActionTypes.SELECT_DESIGNATION,
68
67
  designation,
69
68
  }),
70
- MOVE_FILE: (submissionId, attachmentId, typeId, name, successMoveMessage) => ({
69
+ MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
71
70
  type: ActionTypes.MOVE_FILE,
72
- submissionId,
73
71
  typeId,
74
72
  name,
75
73
  successMoveMessage,
@@ -28,7 +28,7 @@ const FileSectionState_1 = require("./FileSectionState");
28
28
  const SelectDialogDesignation_1 = require("./SelectDialogDesignation");
29
29
  const UploadFileArea_1 = require("./UploadFileArea");
30
30
  const util_1 = require("./util");
31
- const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
31
+ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
32
32
  let uploadedFileExtension = '';
33
33
  if (state.uploadedFile) {
34
34
  uploadedFileExtension = state.uploadedFile.name.substring(state.uploadedFile.name.lastIndexOf('.') + 1);
@@ -39,15 +39,15 @@ const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSecti
39
39
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
40
40
  state.uploadedFile &&
41
41
  state.selectDesignation !== undefined &&
42
- handleUpload(submissionId, state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
42
+ handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
43
43
  };
44
44
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
45
45
  return (react_1.default.createElement("div", null,
46
46
  (can === null || can === void 0 ? void 0 : can.uploadFile) && (react_1.default.createElement(react_1.default.Fragment, null,
47
- (isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
47
+ (isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
48
48
  state.isUploadFile &&
49
49
  state.uploadedFile &&
50
- state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
50
+ state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
51
51
  state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
52
52
  dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
53
53
  }, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
@@ -31,7 +31,7 @@ const FileInfo_1 = require("./FileSectionItem/FileInfo");
31
31
  const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
32
32
  const ItemActions_1 = require("./FileSectionItem/ItemActions");
33
33
  const util_1 = require("./util");
34
- const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
34
+ const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
35
35
  const onElementClick = (0, react_1.useCallback)((e) => {
36
36
  if (!isEditor) {
37
37
  return;
@@ -46,7 +46,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handl
46
46
  return (react_1.default.createElement("div", null, inlineFiles.map((file, index) => {
47
47
  var _a;
48
48
  return (react_1.default.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
49
- react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
49
+ react_1.default.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (react_1.default.createElement(FileReference, { key: attachment.id, attachment: attachment, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
50
50
  react_1.default.createElement(Element, { className: 'element' },
51
51
  util_1.fileTypesWithIconMap.get(file.type),
52
52
  react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
@@ -55,7 +55,7 @@ const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handl
55
55
  })));
56
56
  };
57
57
  exports.InlineFilesSection = InlineFilesSection;
58
- const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
58
+ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
59
59
  const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
60
60
  if (!attachment || !attachment.name) {
61
61
  return null;
@@ -65,12 +65,12 @@ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload
65
65
  react_1.default.createElement(Container, null,
66
66
  util_1.fileTypesWithIconMap.get(util_1.extensionsWithFileTypesMap.get(fileExtension)),
67
67
  react_1.default.createElement(FileReferenceName, null, attachment.name)),
68
- handleDownload && handleReplace && submissionId && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
68
+ handleDownload && handleReplace && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
69
69
  react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
70
70
  react_1.default.createElement(dots_icon_1.default, null)),
71
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
71
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
72
72
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
73
- handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
73
+ handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
74
74
  };
75
75
  const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
76
76
  display: flex;
@@ -26,7 +26,7 @@ const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
26
26
  const styled_components_1 = __importStar(require("styled-components"));
27
27
  const FileSectionState_1 = require("./FileSectionState");
28
28
  const util_1 = require("./util");
29
- const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch }) => {
29
+ const UploadFileArea = ({ handleUploadFile, fileSection, dispatch }) => {
30
30
  const [selectedFile, setSelectedFile] = (0, react_1.useState)();
31
31
  const fileInputRef = (0, react_1.useRef)(null);
32
32
  const isSupplementFilesTab = fileSection === util_1.FileSectionType.Supplements;
@@ -41,7 +41,7 @@ const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch
41
41
  setSelectedFile(file);
42
42
  dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
43
43
  if (file && isSupplementFilesTab) {
44
- handleUploadFile(submissionId, file, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
44
+ handleUploadFile(file, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
45
45
  }
46
46
  }
47
47
  };
@@ -51,16 +51,10 @@ const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch
51
51
  setSelectedFile(file);
52
52
  dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
53
53
  if (selectedFile && isSupplementFilesTab) {
54
- handleUploadFile(submissionId, selectedFile, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
54
+ handleUploadFile(selectedFile, (0, util_1.getDesignationName)(util_1.Designation.Supplementary));
55
55
  }
56
56
  }
57
- }, [
58
- dispatch,
59
- handleUploadFile,
60
- isSupplementFilesTab,
61
- selectedFile,
62
- submissionId,
63
- ]);
57
+ }, [dispatch, handleUploadFile, isSupplementFilesTab, selectedFile]);
64
58
  const [{ canDrop, isOver }, dropRef] = (0, react_dnd_1.useDrop)({
65
59
  accept: [react_dnd_html5_backend_1.NativeTypes.FILE],
66
60
  drop(item, monitor) {
@@ -281,6 +281,7 @@ exports.extensionsWithFileTypesMap = new Map([
281
281
  ['png', FileType.Image],
282
282
  ['jpg', FileType.Image],
283
283
  ['jpeg', FileType.Image],
284
+ ['jfif', FileType.Image],
284
285
  ['gif', FileType.Image],
285
286
  ['svg', FileType.Image],
286
287
  ['tif', FileType.Image],
@@ -102,9 +102,12 @@ const BaseInformation = ({ submission, handleDateChange, userRole }) => {
102
102
  types_1.SubmissionCriticality.OVERDUE && react_1.default.createElement(AttentionRed_1.default, null))),
103
103
  react_1.default.createElement(react_tooltip_1.default, { id: submission.id, place: "bottom", effect: "solid", offset: { top: 10 }, className: "tooltip", disable: userRole == 'pe' }, "No permissions to reschedule")));
104
104
  return (react_1.default.createElement(Grid, null,
105
- react_1.default.createElement(DateLabel, null, "Due date"),
106
- react_1.default.createElement(Value, null,
107
- react_1.default.createElement(CalenderDatePicker, { submission: submission, handleDateChange: handleDateChange, Button: Button })),
105
+ (!submission.isPublished && (react_1.default.createElement(react_1.default.Fragment, null,
106
+ react_1.default.createElement(DateLabel, null, "Due date"),
107
+ react_1.default.createElement(Value, null,
108
+ react_1.default.createElement(CalenderDatePicker, { submission: submission, handleDateChange: handleDateChange, Button: Button }))))) || (react_1.default.createElement(react_1.default.Fragment, null,
109
+ react_1.default.createElement(Label, null, "Published:"),
110
+ react_1.default.createElement(Value, null, (0, date_fns_1.format)(submission.publishedDate || 0, 'd MMM yyyy, EEEE')))),
108
111
  react_1.default.createElement(Label, null, "Article ID:"),
109
112
  react_1.default.createElement(Value, null, submission.id),
110
113
  react_1.default.createElement(Label, null, "DOI:"),
@@ -120,10 +123,11 @@ const BaseInformation = ({ submission, handleDateChange, userRole }) => {
120
123
  react_1.default.createElement(Value, null, submission.author.email))),
121
124
  react_1.default.createElement(Label, null, "Production Editor:"),
122
125
  react_1.default.createElement(Value, null, submission.journal.productionEditor.displayName),
123
- react_1.default.createElement(Label, null, "Publication Due:"),
124
- react_1.default.createElement(Value, null,
125
- (0, date_fns_1.format)(submission.dueDate, 'd MMM, EEEE'),
126
- submission.isAtRisk && (react_1.default.createElement(Pill, { background: criticalityPill[submission.criticality].color }, criticalityPill[submission.criticality].label)))));
126
+ !submission.isPublished && (react_1.default.createElement(react_1.default.Fragment, null,
127
+ react_1.default.createElement(Label, null, "Publication Due:"),
128
+ react_1.default.createElement(Value, null,
129
+ (0, date_fns_1.format)(submission.dueDate, 'd MMM, EEEE'),
130
+ submission.isAtRisk && (react_1.default.createElement(Pill, { background: criticalityPill[submission.criticality].color }, criticalityPill[submission.criticality].label)))))));
127
131
  };
128
132
  exports.BaseInformation = BaseInformation;
129
133
  const getDay = (date) => ({
@@ -23,42 +23,54 @@ import { InlineFilesSection } from './InlineFilesSection';
23
23
  import { TooltipDiv } from './TooltipDiv';
24
24
  import { Designation, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
25
25
  export const PermissionsContext = createContext(null);
26
- export const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
26
+ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, }) => {
27
27
  const [state, dispatch] = useReducer(reducer, getInitialState());
28
- const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const handleReplaceFile = useCallback((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
29
29
  dispatch(actions.HANDLE_UPLOAD_ACTION());
30
30
  dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
31
- const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
31
+ const res = yield replace(attachmentId, name, file, typeId);
32
32
  dispatch(actions.HANDLE_FINISH_UPLOAD());
33
33
  return res;
34
- }), [handleReplace]);
35
- const handleUploadFile = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
34
+ }), [replace]);
35
+ const handleUploadFile = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
36
36
  dispatch(actions.HANDLE_UPLOAD_ACTION());
37
37
  if (namesWithDesignationMap.get(designation) == Designation.Supplementary) {
38
38
  dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
39
39
  }
40
- const res = yield handleUpload(submissionId, file, designation);
40
+ const res = yield upload(file, designation);
41
41
  dispatch(actions.HANDLE_FINISH_UPLOAD());
42
42
  return res;
43
- }), [handleUpload]);
44
- const handleUploadFileWithSupplement = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
45
- const res = (yield handleUploadFile(submissionId, file, designation));
46
- if (res && res.data) {
47
- const { id, name } = res.data.uploadAttachment;
43
+ }), [upload]);
44
+ const handleUploadFileWithSupplement = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const response = yield upload(file, designation);
46
+ if (typeof response === 'object') {
47
+ const { id, name } = response;
48
48
  yield saveModel(buildSupplementaryMaterial(name, `attachment:${id}`));
49
49
  }
50
- return res;
51
- }), [handleUploadFile, saveModel]);
52
- const handleChangeDesignationFile = useCallback((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
53
- const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
50
+ return response;
51
+ }), [upload, saveModel]);
52
+ const handleChangeDesignationFile = useCallback((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
53
+ const res = yield changeDesignation(attachmentId, typeId, name);
54
54
  if (res) {
55
55
  dispatch(actions.HANDLE_SUCCESS_MESSAGE());
56
56
  }
57
57
  return res;
58
- }), [handleChangeDesignation]);
59
- const handleDownloadFile = useCallback((publicUrl) => {
60
- return handleDownload(publicUrl);
61
- }, [handleDownload]);
58
+ }), [changeDesignation]);
59
+ const handleDownload = useCallback((url) => {
60
+ window.location.assign(url);
61
+ }, []);
62
+ const handleUpdateInline = useCallback((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
63
+ var _a;
64
+ const figureModel = modelMap.get(modelId);
65
+ const imageExternalFileIndex = (_a = figureModel === null || figureModel === void 0 ? void 0 : figureModel.externalFileReferences) === null || _a === void 0 ? void 0 : _a.findIndex((file) => file && file.kind === 'imageRepresentation');
66
+ if (figureModel.externalFileReferences &&
67
+ typeof imageExternalFileIndex !== 'undefined' &&
68
+ imageExternalFileIndex > -1) {
69
+ figureModel.externalFileReferences[imageExternalFileIndex].url = `attachment:${attachment.id}`;
70
+ yield saveModel(figureModel);
71
+ }
72
+ }), [modelMap, saveModel]);
73
+ const attachments = getAttachments();
62
74
  const inlineFiles = useMemo(() => getInlineFiles(modelMap, attachments), [modelMap.values(), attachments]);
63
75
  const supplementFiles = useMemo(() => getSupplementFiles(modelMap, attachments), [attachments, modelMap.size]);
64
76
  const excludedAttachmentsIds = useMemo(() => {
@@ -74,6 +86,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
74
86
  const getFileSectionExternalFile = (fileSection) => {
75
87
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
76
88
  fileSection === FileSectionType.OtherFile;
89
+ const isOtherFilesTab = fileSection === FileSectionType.OtherFile;
77
90
  const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
78
91
  attachments.filter((element) => {
79
92
  const designation = namesWithDesignationMap.get(element.type.label);
@@ -82,12 +95,12 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
82
95
  const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
83
96
  const filesItems = itemsDataWithTitle.map((element) => {
84
97
  const itemProps = {
85
- submissionId: submissionId,
86
98
  externalFile: element.externalFile,
87
99
  title: element.title,
88
100
  showAttachmentName: isSupplementOrOtherFilesTab,
89
101
  showDesignationActions: isSupplementOrOtherFilesTab,
90
- handleDownload: handleDownloadFile,
102
+ showReplaceAction: !isOtherFilesTab,
103
+ handleDownload,
91
104
  handleReplace: handleReplaceFile,
92
105
  handleChangeDesignation: handleChangeDesignationFile,
93
106
  dispatch: dispatch,
@@ -127,11 +140,11 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
127
140
  React.createElement("div", null, "Files excluded from the final submission.")))),
128
141
  React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
129
142
  React.createElement(InspectorTabPanel, null,
130
- React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
143
+ React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
131
144
  React.createElement(InspectorTabPanel, null,
132
- React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
145
+ React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
133
146
  React.createElement(InspectorTabPanel, null,
134
- React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
147
+ React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
135
148
  state.isShowSuccessMessage &&
136
149
  state.successMessage !== '' &&
137
150
  handleSuccessMessage()));
@@ -6,7 +6,7 @@ import { ConfirmationPopUp } from '../ConfirmationPopUp';
6
6
  import { TooltipDiv } from '../TooltipDiv';
7
7
  import { designationWithReadableNamesMap, getDesignationActionsList, } from '../util';
8
8
  import { DesignationActionsList } from './DesignationActionsList';
9
- export const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, submissionId, fileName, can, dispatch, }) => {
9
+ export const DesignationActions = ({ designation, attachmentId, fileExtension, handleChangeDesignation, fileName, can, dispatch, }) => {
10
10
  const [isActionsShown, setIsActionsShown] = useState(false);
11
11
  const [confirmationPopUpData, setConfirmationPopUpData] = useState({
12
12
  isConfirmationPopUpOpen: false,
@@ -37,7 +37,7 @@ export const DesignationActions = ({ designation, attachmentId, fileExtension, h
37
37
  };
38
38
  const handleMoveAction = () => {
39
39
  handleChangeDesignation &&
40
- handleChangeDesignation(submissionId, attachmentId, confirmationPopUpData.selectedDesignation, fileName);
40
+ handleChangeDesignation(attachmentId, confirmationPopUpData.selectedDesignation, fileName);
41
41
  handleCloseAction();
42
42
  };
43
43
  const handleCloseAction = () => {
@@ -56,7 +56,7 @@ export const DesignationActions = ({ designation, attachmentId, fileExtension, h
56
56
  React.createElement(SecondaryActionsText, { "data-for": "file-designation", "data-tip": true }, designationWithReadableNamesMap.get(designation)),
57
57
  React.createElement(BottomArrowIcon, null),
58
58
  isActionsShown && (can === null || can === void 0 ? void 0 : can.changeDesignation) && (React.createElement(ActionsListContainer, null,
59
- React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, submissionId: submissionId, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
59
+ React.createElement(DesignationActionsList, { handleChangeDesignation: handleChangeDesignation, designationActionsList: designationActionsList, fileName: fileName, designation: designation, attachmentId: attachmentId, dispatch: dispatch, handleOpenConfirmationPopup: handleOpenConfirmationPopup })))),
60
60
  confirmationPopUpData.isConfirmationPopUpOpen && (React.createElement(ConfirmationPopUp, { popupHeader: confirmationPopUpData.confirmationPopUpHeader !== undefined
61
61
  ? confirmationPopUpData.confirmationPopUpHeader
62
62
  : '', 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, attachmentId, dispatch, handleOpenConfirmationPopup, }) => {
5
+ export const DesignationActionsList = ({ handleChangeDesignation, designationActionsList, 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, attachmentId, getDesignationName(designation), fileName, successMoveMessage));
9
+ dispatch(actions.MOVE_FILE(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, attachmentId, getDesignationName(designation), fileName);
15
+ handleChangeDesignation(attachmentId, getDesignationName(designation), fileName);
16
16
  }
17
17
  };
18
18
  const isSupplementaryActionIncluded = designationActionsList.indexOf(Designation.Supplementary) !== -1;
@@ -2,11 +2,11 @@ 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, attachmentId, handleChangeDesignation, submissionId, dispatch, }) => {
5
+ export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
6
6
  const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
7
7
  const can = useContext(PermissionsContext);
8
8
  return (React.createElement(FileInfoContainer, null,
9
- showDesignationActions && designation !== undefined && submissionId && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
9
+ showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
10
10
  React.createElement(FileNameTitleContainer, null,
11
11
  React.createElement(FileTitle, null,
12
12
  !showAttachmentName ? fileName : title,
@@ -8,7 +8,7 @@ import { Designation, namesWithDesignationMap } from '../util';
8
8
  import { FileInfo } from './FileInfo';
9
9
  import { FileTypeIcon } from './FileTypeIcon';
10
10
  import { ItemActions } from './ItemActions';
11
- export const FileSectionItem = ({ submissionId, externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
11
+ export const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
12
12
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
13
13
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
14
14
  const designation = namesWithDesignationMap.get(externalFile.type.label);
@@ -23,16 +23,16 @@ export const FileSectionItem = ({ submissionId, externalFile, title, showAttachm
23
23
  }
24
24
  } },
25
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 })),
26
+ React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
27
27
  onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
28
28
  e.preventDefault();
29
29
  onClose();
30
30
  } },
31
31
  React.createElement(CloseOIcon, { color: '#6E6E6E' }))),
32
- handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
32
+ handleDownload && handleReplace && (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, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
35
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, 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;
@@ -78,7 +78,7 @@ export const Item = styled.div `
78
78
  ${DropdownContainer} {
79
79
  position: absolute;
80
80
  top: 24px;
81
- right: 0px;
81
+ right: 0;
82
82
  margin-right: 8px;
83
83
  }
84
84
  `;
@@ -4,7 +4,7 @@ import { FileInfoContainer, FileName, FileNameContainer } from './FileInfo';
4
4
  import { Item, ItemContainer } from './FileSectionItem';
5
5
  import { FileTypeIcon } from './FileTypeIcon';
6
6
  import { ProgressBarUploadItem } from './ProgressBarUploadItem';
7
- export const FileSectionUploadItem = ({ fileName, isLoading, submissionId, dragRef, className, style, }) => {
7
+ export const FileSectionUploadItem = ({ fileName, isLoading, dragRef, className, style, }) => {
8
8
  const fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
9
9
  fileName = fileName.substring(0, fileName.lastIndexOf('.'));
10
10
  return (React.createElement(Item, { ref: dragRef, className: className, style: style },
@@ -24,7 +24,7 @@ export const UploadItemContainer = styled(ItemContainer) `
24
24
  export const ProgressBar = styled.div `
25
25
  background: #1a9bc7;
26
26
  opacity: 0.7;
27
- border-radius: 8px 0px 0px 8px;
27
+ border-radius: 8px 0 0 8px;
28
28
  width: 20%;
29
29
  height: 100%;
30
30
  `;
@@ -13,17 +13,18 @@ import { PermissionsContext } from '../FileManager';
13
13
  import { actions } from '../FileSectionState';
14
14
  import { ActionsItem } from '../ItemsAction';
15
15
  import { Designation, namesWithDesignationMap } from '../util';
16
- export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, submissionId, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
16
+ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
17
17
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
18
18
  const attachmentDesignationName = attachmentDesignation !== 'undefined'
19
19
  ? namesWithDesignationMap.get(attachmentDesignation)
20
20
  : undefined;
21
- const canBeReplaced = attachmentDesignationName == undefined ||
22
- ![
23
- Designation.MainManuscript,
24
- Designation.SubmissionFile,
25
- Designation.SubmissionPdf,
26
- ].includes(attachmentDesignationName);
21
+ const canBeReplaced = (showReplaceAction == undefined || showReplaceAction) &&
22
+ (attachmentDesignationName == undefined ||
23
+ ![
24
+ Designation.MainManuscript,
25
+ Designation.SubmissionFile,
26
+ Designation.SubmissionPdf,
27
+ ].includes(attachmentDesignationName));
27
28
  const fileInputRef = useRef(null);
28
29
  const [selectedFile, setSelectedFile] = useState();
29
30
  const can = useContext(PermissionsContext);
@@ -35,10 +36,9 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
35
36
  dispatch(actions.HANDLE_UPLOAD_ACTION());
36
37
  dispatch(actions.SELECT_DESIGNATION(attachmentDesignationName || Designation.Document));
37
38
  }
38
- const result = yield replaceAttachmentHandler(submissionId, attachmentId, fileName, file, attachmentDesignation);
39
- const { uploadAttachment } = result === null || result === void 0 ? void 0 : result.data;
40
- if (uploadAttachment && handleUpdateInline) {
41
- handleUpdateInline(uploadAttachment);
39
+ const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
40
+ if (typeof result === 'object' && handleUpdateInline) {
41
+ handleUpdateInline(result);
42
42
  }
43
43
  if (dispatch) {
44
44
  dispatch(actions.HANDLE_FINISH_UPLOAD());
@@ -24,7 +24,6 @@ export const reducer = (state, action) => {
24
24
  }
25
25
  case ActionTypes.MOVE_FILE: {
26
26
  return Object.assign(Object.assign({}, state), { moveToOtherState: {
27
- submissionId: action.submissionId,
28
27
  typeId: action.typeId,
29
28
  name: action.name,
30
29
  }, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
@@ -62,9 +61,8 @@ export const actions = {
62
61
  type: ActionTypes.SELECT_DESIGNATION,
63
62
  designation,
64
63
  }),
65
- MOVE_FILE: (submissionId, attachmentId, typeId, name, successMoveMessage) => ({
64
+ MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
66
65
  type: ActionTypes.MOVE_FILE,
67
- submissionId,
68
66
  typeId,
69
67
  name,
70
68
  successMoveMessage,
@@ -6,7 +6,7 @@ import { actions } from './FileSectionState';
6
6
  import { SelectDialogDesignation } from './SelectDialogDesignation';
7
7
  import { UploadFileArea } from './UploadFileArea';
8
8
  import { FileSectionType, getDesignationName } from './util';
9
- export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
9
+ export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
10
10
  let uploadedFileExtension = '';
11
11
  if (state.uploadedFile) {
12
12
  uploadedFileExtension = state.uploadedFile.name.substring(state.uploadedFile.name.lastIndexOf('.') + 1);
@@ -17,15 +17,15 @@ export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fi
17
17
  dispatch(actions.HANDLE_UPLOAD_ACTION());
18
18
  state.uploadedFile &&
19
19
  state.selectDesignation !== undefined &&
20
- handleUpload(submissionId, state.uploadedFile, getDesignationName(state.selectDesignation));
20
+ handleUpload(state.uploadedFile, getDesignationName(state.selectDesignation));
21
21
  };
22
22
  const can = useContext(PermissionsContext);
23
23
  return (React.createElement("div", null,
24
24
  (can === null || can === void 0 ? void 0 : can.uploadFile) && (React.createElement(React.Fragment, null,
25
- (isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
25
+ (isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
26
26
  state.isUploadFile &&
27
27
  state.uploadedFile &&
28
- state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
28
+ state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
29
29
  state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
30
30
  dispatch(actions.HANDLE_CANCEL_UPLOAD());
31
31
  }, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
@@ -6,7 +6,7 @@ import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSec
6
6
  import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
7
7
  import { ItemActions } from './FileSectionItem/ItemActions';
8
8
  import { extensionsWithFileTypesMap, fileTypesWithIconMap, } from './util';
9
- export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
9
+ export const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, inlineFiles, isEditor, dispatch, }) => {
10
10
  const onElementClick = useCallback((e) => {
11
11
  if (!isEditor) {
12
12
  return;
@@ -21,7 +21,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
21
21
  return (React.createElement("div", null, inlineFiles.map((file, index) => {
22
22
  var _a;
23
23
  return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
24
- React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(FileReference, { key: attachment.id, attachment: attachment, submissionId: submissionId, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
24
+ React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(FileReference, { key: attachment.id, attachment: attachment, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDownload: handleDownload, dispatch: dispatch })))),
25
25
  React.createElement(Element, { className: 'element' },
26
26
  fileTypesWithIconMap.get(file.type),
27
27
  React.createElement(FileInfoContainer, null,
@@ -29,7 +29,7 @@ export const InlineFilesSection = ({ submissionId, handleReplace, handleDownload
29
29
  React.createElement(FileTitle, null, file.label))))));
30
30
  })));
31
31
  };
32
- const FileReference = ({ attachment, submissionId, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
32
+ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdateInline, dispatch, }) => {
33
33
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
34
34
  if (!attachment || !attachment.name) {
35
35
  return null;
@@ -39,12 +39,12 @@ const FileReference = ({ attachment, submissionId, handleReplace, handleDownload
39
39
  React.createElement(Container, null,
40
40
  fileTypesWithIconMap.get(extensionsWithFileTypesMap.get(fileExtension)),
41
41
  React.createElement(FileReferenceName, null, attachment.name)),
42
- handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
42
+ handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
43
43
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
44
44
  React.createElement(DotsIcon, null)),
45
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
45
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
46
46
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
47
- handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, submissionId: submissionId, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
47
+ handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
48
48
  };
49
49
  const ElementItem = styled(Item) `
50
50
  display: flex;
@@ -4,7 +4,7 @@ import { NativeTypes } from 'react-dnd-html5-backend';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { actions } from './FileSectionState';
6
6
  import { Designation, FileSectionType, getDesignationName } from './util';
7
- export const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, dispatch }) => {
7
+ export const UploadFileArea = ({ handleUploadFile, fileSection, dispatch }) => {
8
8
  const [selectedFile, setSelectedFile] = useState();
9
9
  const fileInputRef = useRef(null);
10
10
  const isSupplementFilesTab = fileSection === FileSectionType.Supplements;
@@ -19,7 +19,7 @@ export const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, di
19
19
  setSelectedFile(file);
20
20
  dispatch(actions.UPLOAD_FILE(file));
21
21
  if (file && isSupplementFilesTab) {
22
- handleUploadFile(submissionId, file, getDesignationName(Designation.Supplementary));
22
+ handleUploadFile(file, getDesignationName(Designation.Supplementary));
23
23
  }
24
24
  }
25
25
  };
@@ -29,16 +29,10 @@ export const UploadFileArea = ({ handleUploadFile, fileSection, submissionId, di
29
29
  setSelectedFile(file);
30
30
  dispatch(actions.UPLOAD_FILE(file));
31
31
  if (selectedFile && isSupplementFilesTab) {
32
- handleUploadFile(submissionId, selectedFile, getDesignationName(Designation.Supplementary));
32
+ handleUploadFile(selectedFile, getDesignationName(Designation.Supplementary));
33
33
  }
34
34
  }
35
- }, [
36
- dispatch,
37
- handleUploadFile,
38
- isSupplementFilesTab,
39
- selectedFile,
40
- submissionId,
41
- ]);
35
+ }, [dispatch, handleUploadFile, isSupplementFilesTab, selectedFile]);
42
36
  const [{ canDrop, isOver }, dropRef] = useDrop({
43
37
  accept: [NativeTypes.FILE],
44
38
  drop(item, monitor) {
@@ -275,6 +275,7 @@ export const extensionsWithFileTypesMap = new Map([
275
275
  ['png', FileType.Image],
276
276
  ['jpg', FileType.Image],
277
277
  ['jpeg', FileType.Image],
278
+ ['jfif', FileType.Image],
278
279
  ['gif', FileType.Image],
279
280
  ['svg', FileType.Image],
280
281
  ['tif', FileType.Image],
@@ -77,9 +77,12 @@ export const BaseInformation = ({ submission, handleDateChange, userRole }) => {
77
77
  SubmissionCriticality.OVERDUE && React.createElement(AttentionRed, null))),
78
78
  React.createElement(ReactTooltip, { id: submission.id, place: "bottom", effect: "solid", offset: { top: 10 }, className: "tooltip", disable: userRole == 'pe' }, "No permissions to reschedule")));
79
79
  return (React.createElement(Grid, null,
80
- React.createElement(DateLabel, null, "Due date"),
81
- React.createElement(Value, null,
82
- React.createElement(CalenderDatePicker, { submission: submission, handleDateChange: handleDateChange, Button: Button })),
80
+ (!submission.isPublished && (React.createElement(React.Fragment, null,
81
+ React.createElement(DateLabel, null, "Due date"),
82
+ React.createElement(Value, null,
83
+ React.createElement(CalenderDatePicker, { submission: submission, handleDateChange: handleDateChange, Button: Button }))))) || (React.createElement(React.Fragment, null,
84
+ React.createElement(Label, null, "Published:"),
85
+ React.createElement(Value, null, format(submission.publishedDate || 0, 'd MMM yyyy, EEEE')))),
83
86
  React.createElement(Label, null, "Article ID:"),
84
87
  React.createElement(Value, null, submission.id),
85
88
  React.createElement(Label, null, "DOI:"),
@@ -95,10 +98,11 @@ export const BaseInformation = ({ submission, handleDateChange, userRole }) => {
95
98
  React.createElement(Value, null, submission.author.email))),
96
99
  React.createElement(Label, null, "Production Editor:"),
97
100
  React.createElement(Value, null, submission.journal.productionEditor.displayName),
98
- React.createElement(Label, null, "Publication Due:"),
99
- React.createElement(Value, null,
100
- format(submission.dueDate, 'd MMM, EEEE'),
101
- submission.isAtRisk && (React.createElement(Pill, { background: criticalityPill[submission.criticality].color }, criticalityPill[submission.criticality].label)))));
101
+ !submission.isPublished && (React.createElement(React.Fragment, null,
102
+ React.createElement(Label, null, "Publication Due:"),
103
+ React.createElement(Value, null,
104
+ format(submission.dueDate, 'd MMM, EEEE'),
105
+ submission.isAtRisk && (React.createElement(Pill, { background: criticalityPill[submission.criticality].color }, criticalityPill[submission.criticality].label)))))));
102
106
  };
103
107
  const getDay = (date) => ({
104
108
  year: date.getFullYear(),
@@ -3,17 +3,20 @@ import { Model, Supplement } from '@manuscripts/manuscripts-json-schema';
3
3
  import React from 'react';
4
4
  import { Capabilities } from '../../lib/capabilities';
5
5
  import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
6
+ export declare type Upload = (file: File, designation: string) => Promise<boolean | SubmissionAttachment | undefined>;
7
+ export declare type Replace = (attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean | SubmissionAttachment | undefined>;
8
+ export declare type ChangeDesignation = (attachmentId: string, typeId: string, name: string) => Promise<boolean>;
9
+ export interface FileManagement {
10
+ getAttachments: () => SubmissionAttachment[];
11
+ upload: Upload;
12
+ replace: Replace;
13
+ changeDesignation: ChangeDesignation;
14
+ }
6
15
  export declare const PermissionsContext: React.Context<Capabilities | null>;
7
16
  export declare const FileManager: React.FC<{
8
- submissionId: string;
9
- attachments: SubmissionAttachment[];
17
+ fileManagement: FileManagement;
10
18
  modelMap: Map<string, Model>;
11
19
  saveModel: (model: Build<Supplement>) => Promise<Build<Supplement>>;
12
20
  enableDragAndDrop: boolean;
13
21
  can: Capabilities;
14
- handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
15
- handleDownload: (url: string) => void;
16
- handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<any>;
17
- handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<any>;
18
- handleUpdateInline?: (modelId: string, attachment: SubmissionAttachment) => void;
19
22
  }>;
@@ -1,13 +1,13 @@
1
1
  import React, { Dispatch } from 'react';
2
2
  import { Capabilities } from '../../../lib/capabilities';
3
+ import { ChangeDesignation } from '../FileManager';
3
4
  import { Action } from '../FileSectionState';
4
5
  import { Designation } from '../util';
5
6
  export declare const DesignationActions: React.FC<{
6
7
  designation?: Designation;
7
8
  attachmentId: string;
8
9
  fileExtension?: string;
9
- handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
10
- submissionId: string;
10
+ handleChangeDesignation?: ChangeDesignation;
11
11
  fileName: string;
12
12
  can: Capabilities | null;
13
13
  dispatch?: Dispatch<Action>;
@@ -1,10 +1,10 @@
1
1
  import React, { Dispatch } from 'react';
2
+ import { ChangeDesignation } from '../FileManager';
2
3
  import { Action } from '../FileSectionState';
3
4
  import { Designation } from '../util';
4
5
  export declare const DesignationActionsList: React.FC<{
5
- handleChangeDesignation?: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
6
+ handleChangeDesignation?: ChangeDesignation;
6
7
  designationActionsList: Array<Designation>;
7
- submissionId: string;
8
8
  fileName: string;
9
9
  designation?: Designation;
10
10
  attachmentId: string;
@@ -1,4 +1,5 @@
1
1
  import React, { Dispatch } from 'react';
2
+ import { ChangeDesignation } from '../FileManager';
2
3
  import { Action } from '../FileSectionState';
3
4
  import { Designation } from '../util';
4
5
  export declare const FileInfo: React.FC<{
@@ -9,8 +10,7 @@ export declare const FileInfo: React.FC<{
9
10
  fileExtension: string;
10
11
  designation?: Designation;
11
12
  attachmentId: string;
12
- handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
13
- submissionId?: string;
13
+ handleChangeDesignation: ChangeDesignation;
14
14
  dispatch?: Dispatch<Action>;
15
15
  }>;
16
16
  export declare const FileInfoContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1,6 +1,7 @@
1
1
  import React, { CSSProperties, Dispatch } from 'react';
2
2
  import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
3
3
  import { Maybe } from '../../SubmissionInspector/types';
4
+ import { ChangeDesignation, Replace } from '../FileManager';
4
5
  import { Action } from '../FileSectionState';
5
6
  export declare type SubmissionAttachment = {
6
7
  id: string;
@@ -13,19 +14,15 @@ export declare type SubmissionAttachmentType = {
13
14
  label?: Maybe<string> | undefined;
14
15
  };
15
16
  export interface FileSectionItemProps {
16
- submissionId?: string;
17
17
  externalFile: SubmissionAttachment;
18
18
  title: string;
19
19
  showAttachmentName?: boolean;
20
20
  showDesignationActions?: boolean;
21
21
  showActions?: boolean;
22
+ showReplaceAction?: boolean;
22
23
  handleDownload?: (url: string) => void;
23
- handleReplace?: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
24
- data: {
25
- uploadAttachment: SubmissionAttachment;
26
- };
27
- }>;
28
- handleChangeDesignation: (submissionId: string, attachmentId: string, typeId: string, name: string) => Promise<boolean>;
24
+ handleReplace?: Replace;
25
+ handleChangeDesignation: ChangeDesignation;
29
26
  dispatch?: Dispatch<Action>;
30
27
  dragRef?: DragElementWrapper<DragSourceOptions>;
31
28
  className?: string;
@@ -3,7 +3,6 @@ import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
3
3
  export interface FileSectionItemProps {
4
4
  fileName: string;
5
5
  isLoading: boolean;
6
- submissionId: string;
7
6
  dragRef?: DragElementWrapper<DragSourceOptions>;
8
7
  className?: string;
9
8
  style?: CSSProperties;
@@ -1,16 +1,12 @@
1
1
  import React, { Dispatch } from 'react';
2
2
  import { Maybe } from '../../SubmissionInspector/types';
3
+ import { Replace } from '../FileManager';
3
4
  import { Action } from '../FileSectionState';
4
5
  import { SubmissionAttachment } from './FileSectionItem';
5
6
  export declare const ItemActions: React.FC<{
6
7
  downloadAttachmentHandler: (url: string) => void;
7
- replaceAttachmentHandler: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
8
- data: {
9
- uploadAttachment: SubmissionAttachment;
10
- };
11
- }>;
8
+ replaceAttachmentHandler: Replace;
12
9
  handleUpdateInline?: (attachment: SubmissionAttachment) => void;
13
- submissionId: string;
14
10
  attachmentId: string;
15
11
  fileName: string;
16
12
  designation?: Maybe<string> | undefined;
@@ -18,4 +14,5 @@ export declare const ItemActions: React.FC<{
18
14
  hideActionList: (e?: React.MouseEvent) => void;
19
15
  dispatch?: Dispatch<Action>;
20
16
  dropDownClassName?: string;
17
+ showReplaceAction?: boolean;
21
18
  }>;
@@ -4,7 +4,6 @@ export interface State {
4
4
  uploadedFile: File | undefined;
5
5
  isUploadFile: boolean;
6
6
  moveToOtherState: {
7
- submissionId: string;
8
7
  typeId: string;
9
8
  name: string;
10
9
  } | undefined;
@@ -32,7 +31,7 @@ export declare const actions: {
32
31
  HANDLE_UPLOAD_ACTION: () => Action;
33
32
  HANDLE_CANCEL_UPLOAD: () => Action;
34
33
  SELECT_DESIGNATION: (designation: Designation) => Action;
35
- MOVE_FILE: (submissionId: string, attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
34
+ MOVE_FILE: (attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
36
35
  HANDLE_FINISH_UPLOAD: () => Action;
37
36
  HANDLE_SUCCESS_MESSAGE: () => Action;
38
37
  };
@@ -1,10 +1,10 @@
1
1
  import React, { Dispatch } from 'react';
2
+ import { Upload } from './FileManager';
2
3
  import { Action, State } from './FileSectionState';
3
4
  import { FileSectionType } from './util';
4
5
  export declare const FilesSection: React.FC<{
5
- submissionId: string;
6
6
  enableDragAndDrop: boolean;
7
- handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
7
+ handleUpload: Upload;
8
8
  fileSection: FileSectionType;
9
9
  filesItem: JSX.Element[];
10
10
  dispatch: Dispatch<Action>;
@@ -1,4 +1,5 @@
1
1
  import React, { Dispatch } from 'react';
2
+ import { Replace } from './FileManager';
2
3
  import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
3
4
  import { Action } from './FileSectionState';
4
5
  import { FileType } from './util';
@@ -8,7 +9,6 @@ export interface ExternalFileRef {
8
9
  ref?: SubmissionAttachment;
9
10
  }
10
11
  export declare const InlineFilesSection: React.FC<{
11
- submissionId: string;
12
12
  inlineFiles: {
13
13
  id: string;
14
14
  label: string;
@@ -16,11 +16,7 @@ export declare const InlineFilesSection: React.FC<{
16
16
  caption?: string;
17
17
  attachments?: SubmissionAttachment[];
18
18
  }[];
19
- handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<{
20
- data: {
21
- uploadAttachment: SubmissionAttachment;
22
- };
23
- }>;
19
+ handleReplace: Replace;
24
20
  handleDownload: (url: string) => void;
25
21
  handleUpdateInline?: (modelId: string, attachment: SubmissionAttachment) => void;
26
22
  isEditor: boolean;
@@ -1,9 +1,9 @@
1
1
  import React, { Dispatch } from 'react';
2
+ import { Upload } from './FileManager';
2
3
  import { Action } from './FileSectionState';
3
4
  import { FileSectionType } from './util';
4
5
  export declare const UploadFileArea: React.FC<{
5
- handleUploadFile: (submissionId: string, file: File, designation: string) => Promise<any>;
6
+ handleUploadFile: Upload;
6
7
  fileSection: FileSectionType;
7
- submissionId: string;
8
8
  dispatch: Dispatch<Action>;
9
9
  }>;
@@ -31,6 +31,8 @@ export declare type Submission = {
31
31
  dueDate: Date;
32
32
  criticality: SubmissionCriticality;
33
33
  isAtRisk: boolean;
34
+ isPublished: boolean;
35
+ publishedDate?: Date;
34
36
  };
35
37
  export declare type Journal = {
36
38
  id: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "0.31.13",
4
+ "version": "0.31.16",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",