@manuscripts/style-guide 0.31.14 → 0.31.17

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 (37) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +40 -32
  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 +5 -6
  9. package/dist/cjs/components/FileManager/FilesSection.js +11 -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/SubmissionInspector/BaseInformation.js +11 -7
  13. package/dist/es/components/FileManager/FileManager.js +40 -32
  14. package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +3 -3
  15. package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +3 -3
  16. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +2 -2
  17. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +5 -5
  18. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +2 -2
  19. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +11 -11
  20. package/dist/es/components/FileManager/FileSectionState.js +5 -6
  21. package/dist/es/components/FileManager/FilesSection.js +11 -4
  22. package/dist/es/components/FileManager/InlineFilesSection.js +6 -6
  23. package/dist/es/components/FileManager/UploadFileArea.js +4 -10
  24. package/dist/es/components/SubmissionInspector/BaseInformation.js +11 -7
  25. package/dist/types/components/FileManager/FileManager.d.ts +10 -7
  26. package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +2 -2
  27. package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +2 -2
  28. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +2 -2
  29. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +4 -7
  30. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -1
  31. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +3 -6
  32. package/dist/types/components/FileManager/FileSectionState.d.ts +2 -3
  33. package/dist/types/components/FileManager/FilesSection.d.ts +2 -2
  34. package/dist/types/components/FileManager/InlineFilesSection.d.ts +2 -6
  35. package/dist/types/components/FileManager/UploadFileArea.d.ts +2 -2
  36. package/dist/types/components/SubmissionInspector/types.d.ts +2 -0
  37. package/package.json +1 -1
@@ -36,7 +36,6 @@ const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
36
36
  const react_1 = __importStar(require("react"));
37
37
  const react_tooltip_1 = __importDefault(require("react-tooltip"));
38
38
  const inlineFiles_1 = __importStar(require("../../lib/inlineFiles"));
39
- const AlertMessage_1 = require("../AlertMessage");
40
39
  const Inspector_1 = require("../Inspector");
41
40
  const InspectorSection_1 = require("../InspectorSection");
42
41
  const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
@@ -48,42 +47,56 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
48
47
  const TooltipDiv_1 = require("./TooltipDiv");
49
48
  const util_1 = require("./util");
50
49
  exports.PermissionsContext = (0, react_1.createContext)(null);
51
- const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
50
+ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, }) => {
52
51
  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* () {
52
+ const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
54
53
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
55
54
  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);
55
+ const res = yield replace(attachmentId, name, file, typeId);
57
56
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
57
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
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
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
67
68
  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;
69
+ }), [upload]);
70
+ const handleUploadFileWithSupplement = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
71
+ const response = yield upload(file, designation);
72
+ if (typeof response === 'object') {
73
+ const { id, name } = response;
73
74
  yield saveModel((0, manuscript_transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
74
75
  }
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);
76
+ return response;
77
+ }), [upload, saveModel]);
78
+ const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
79
+ const res = yield changeDesignation(attachmentId, typeId, name);
79
80
  if (res) {
80
- dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
81
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(''));
81
82
  }
82
83
  return res;
83
- }), [handleChangeDesignation]);
84
- const handleDownloadFile = (0, react_1.useCallback)((publicUrl) => {
85
- return handleDownload(publicUrl);
86
- }, [handleDownload]);
84
+ }), [changeDesignation]);
85
+ const handleDownload = (0, react_1.useCallback)((url) => {
86
+ window.location.assign(url);
87
+ }, []);
88
+ const handleUpdateInline = (0, react_1.useCallback)((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
89
+ var _a;
90
+ const figureModel = modelMap.get(modelId);
91
+ 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');
92
+ if (figureModel.externalFileReferences &&
93
+ typeof imageExternalFileIndex !== 'undefined' &&
94
+ imageExternalFileIndex > -1) {
95
+ figureModel.externalFileReferences[imageExternalFileIndex].url = `attachment:${attachment.id}`;
96
+ yield saveModel(figureModel);
97
+ }
98
+ }), [modelMap, saveModel]);
99
+ const attachments = getAttachments();
87
100
  const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap.values(), attachments]);
88
101
  const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
89
102
  const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
@@ -99,6 +112,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
99
112
  const getFileSectionExternalFile = (fileSection) => {
100
113
  const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
101
114
  fileSection === util_1.FileSectionType.OtherFile;
115
+ const isOtherFilesTab = fileSection === util_1.FileSectionType.OtherFile;
102
116
  const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
103
117
  attachments.filter((element) => {
104
118
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
@@ -107,12 +121,12 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
107
121
  const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
108
122
  const filesItems = itemsDataWithTitle.map((element) => {
109
123
  const itemProps = {
110
- submissionId: submissionId,
111
124
  externalFile: element.externalFile,
112
125
  title: element.title,
113
126
  showAttachmentName: isSupplementOrOtherFilesTab,
114
127
  showDesignationActions: isSupplementOrOtherFilesTab,
115
- handleDownload: handleDownloadFile,
128
+ showReplaceAction: !isOtherFilesTab,
129
+ handleDownload,
116
130
  handleReplace: handleReplaceFile,
117
131
  handleChangeDesignation: handleChangeDesignationFile,
118
132
  dispatch: dispatch,
@@ -126,9 +140,6 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
126
140
  });
127
141
  return filesItems;
128
142
  };
129
- const handleSuccessMessage = () => {
130
- return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.info, hideCloseButton: false }, state.successMessage));
131
- };
132
143
  return (react_1.default.createElement(react_1.default.Fragment, null,
133
144
  react_1.default.createElement(DragLayer_1.DragLayer, null),
134
145
  react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
@@ -152,13 +163,10 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
152
163
  react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
153
164
  react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
154
165
  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 })),
166
+ react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
156
167
  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 })),
168
+ 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
169
  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 })))))),
160
- state.isShowSuccessMessage &&
161
- state.successMessage !== '' &&
162
- handleSuccessMessage()));
170
+ 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 }))))))));
163
171
  };
164
172
  exports.FileManager = FileManager;
@@ -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 });
@@ -37,7 +36,7 @@ const reducer = (state, action) => {
37
36
  return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
38
37
  }
39
38
  case ActionTypes.HANDLE_UPLOAD_ACTION: {
40
- return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true });
39
+ return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
41
40
  }
42
41
  case ActionTypes.HANDLE_CANCEL_UPLOAD: {
43
42
  return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
@@ -46,7 +45,7 @@ const reducer = (state, action) => {
46
45
  return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
47
46
  }
48
47
  case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
49
- return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
48
+ return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage });
50
49
  }
51
50
  }
52
51
  return state;
@@ -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,
@@ -77,7 +75,8 @@ exports.actions = {
77
75
  HANDLE_FINISH_UPLOAD: () => ({
78
76
  type: ActionTypes.HANDLE_FINISH_UPLOAD,
79
77
  }),
80
- HANDLE_SUCCESS_MESSAGE: () => ({
78
+ HANDLE_SUCCESS_MESSAGE: (successMessage) => ({
81
79
  type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
80
+ successMessage,
82
81
  }),
83
82
  };
@@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.FilesSection = void 0;
23
23
  const react_1 = __importStar(require("react"));
24
+ const AlertMessage_1 = require("../AlertMessage");
24
25
  const DragItemArea_1 = require("./DragItemArea");
25
26
  const FileManager_1 = require("./FileManager");
26
27
  const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
@@ -28,7 +29,7 @@ const FileSectionState_1 = require("./FileSectionState");
28
29
  const SelectDialogDesignation_1 = require("./SelectDialogDesignation");
29
30
  const UploadFileArea_1 = require("./UploadFileArea");
30
31
  const util_1 = require("./util");
31
- const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
32
+ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
32
33
  let uploadedFileExtension = '';
33
34
  if (state.uploadedFile) {
34
35
  uploadedFileExtension = state.uploadedFile.name.substring(state.uploadedFile.name.lastIndexOf('.') + 1);
@@ -39,15 +40,21 @@ const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSecti
39
40
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
40
41
  state.uploadedFile &&
41
42
  state.selectDesignation !== undefined &&
42
- handleUpload(submissionId, state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
43
+ handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
43
44
  };
44
45
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
46
+ const handleSuccessMessage = () => {
47
+ return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.success, hideCloseButton: true, dismissButton: { text: 'OK' } }, state.successMessage));
48
+ };
45
49
  return (react_1.default.createElement("div", null,
46
50
  (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 })),
51
+ (isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
48
52
  state.isUploadFile &&
49
53
  state.uploadedFile &&
50
- state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
54
+ state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
55
+ state.isShowSuccessMessage &&
56
+ state.successMessage !== '' &&
57
+ handleSuccessMessage(),
51
58
  state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
52
59
  dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
53
60
  }, 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) {
@@ -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) => ({