@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
@@ -11,7 +11,6 @@ import { buildSupplementaryMaterial, } from '@manuscripts/manuscript-transform';
11
11
  import React, { createContext, useCallback, useMemo, useReducer } from 'react';
12
12
  import ReactTooltip from 'react-tooltip';
13
13
  import getInlineFiles, { getSupplementFiles } from '../../lib/inlineFiles';
14
- import { AlertMessage, AlertMessageType } from '../AlertMessage';
15
14
  import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
16
15
  import { InspectorSection } from '../InspectorSection';
17
16
  import { DraggableFileSectionItem } from './FileSectionItem/DraggableFileSectionItem';
@@ -23,42 +22,56 @@ import { InlineFilesSection } from './InlineFilesSection';
23
22
  import { TooltipDiv } from './TooltipDiv';
24
23
  import { Designation, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
25
24
  export const PermissionsContext = createContext(null);
26
- export const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, handleUpdateInline, }) => {
25
+ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, }) => {
27
26
  const [state, dispatch] = useReducer(reducer, getInitialState());
28
- const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const handleReplaceFile = useCallback((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
29
28
  dispatch(actions.HANDLE_UPLOAD_ACTION());
30
29
  dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
31
- const res = yield handleReplace(submissionId, attachmentId, name, file, typeId);
30
+ const res = yield replace(attachmentId, name, file, typeId);
32
31
  dispatch(actions.HANDLE_FINISH_UPLOAD());
32
+ dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
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
+ dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
42
43
  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;
44
+ }), [upload]);
45
+ const handleUploadFileWithSupplement = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const response = yield upload(file, designation);
47
+ if (typeof response === 'object') {
48
+ const { id, name } = response;
48
49
  yield saveModel(buildSupplementaryMaterial(name, `attachment:${id}`));
49
50
  }
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);
51
+ return response;
52
+ }), [upload, saveModel]);
53
+ const handleChangeDesignationFile = useCallback((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
54
+ const res = yield changeDesignation(attachmentId, typeId, name);
54
55
  if (res) {
55
- dispatch(actions.HANDLE_SUCCESS_MESSAGE());
56
+ dispatch(actions.HANDLE_SUCCESS_MESSAGE(''));
56
57
  }
57
58
  return res;
58
- }), [handleChangeDesignation]);
59
- const handleDownloadFile = useCallback((publicUrl) => {
60
- return handleDownload(publicUrl);
61
- }, [handleDownload]);
59
+ }), [changeDesignation]);
60
+ const handleDownload = useCallback((url) => {
61
+ window.location.assign(url);
62
+ }, []);
63
+ const handleUpdateInline = useCallback((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
64
+ var _a;
65
+ const figureModel = modelMap.get(modelId);
66
+ 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');
67
+ if (figureModel.externalFileReferences &&
68
+ typeof imageExternalFileIndex !== 'undefined' &&
69
+ imageExternalFileIndex > -1) {
70
+ figureModel.externalFileReferences[imageExternalFileIndex].url = `attachment:${attachment.id}`;
71
+ yield saveModel(figureModel);
72
+ }
73
+ }), [modelMap, saveModel]);
74
+ const attachments = getAttachments();
62
75
  const inlineFiles = useMemo(() => getInlineFiles(modelMap, attachments), [modelMap.values(), attachments]);
63
76
  const supplementFiles = useMemo(() => getSupplementFiles(modelMap, attachments), [attachments, modelMap.size]);
64
77
  const excludedAttachmentsIds = useMemo(() => {
@@ -74,6 +87,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
74
87
  const getFileSectionExternalFile = (fileSection) => {
75
88
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
76
89
  fileSection === FileSectionType.OtherFile;
90
+ const isOtherFilesTab = fileSection === FileSectionType.OtherFile;
77
91
  const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
78
92
  attachments.filter((element) => {
79
93
  const designation = namesWithDesignationMap.get(element.type.label);
@@ -82,12 +96,12 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
82
96
  const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
83
97
  const filesItems = itemsDataWithTitle.map((element) => {
84
98
  const itemProps = {
85
- submissionId: submissionId,
86
99
  externalFile: element.externalFile,
87
100
  title: element.title,
88
101
  showAttachmentName: isSupplementOrOtherFilesTab,
89
102
  showDesignationActions: isSupplementOrOtherFilesTab,
90
- handleDownload: handleDownloadFile,
103
+ showReplaceAction: !isOtherFilesTab,
104
+ handleDownload,
91
105
  handleReplace: handleReplaceFile,
92
106
  handleChangeDesignation: handleChangeDesignationFile,
93
107
  dispatch: dispatch,
@@ -101,9 +115,6 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
101
115
  });
102
116
  return filesItems;
103
117
  };
104
- const handleSuccessMessage = () => {
105
- return (React.createElement(AlertMessage, { type: AlertMessageType.info, hideCloseButton: false }, state.successMessage));
106
- };
107
118
  return (React.createElement(React.Fragment, null,
108
119
  React.createElement(DragLayer, null),
109
120
  React.createElement(PermissionsContext.Provider, { value: can },
@@ -127,12 +138,9 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
127
138
  React.createElement("div", null, "Files excluded from the final submission.")))),
128
139
  React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
129
140
  React.createElement(InspectorTabPanel, null,
130
- React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
141
+ React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, isEditor: enableDragAndDrop, dispatch: dispatch })),
131
142
  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 })),
143
+ React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
133
144
  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 })))))),
135
- state.isShowSuccessMessage &&
136
- state.successMessage !== '' &&
137
- handleSuccessMessage()));
145
+ React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
138
146
  };
@@ -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 });
@@ -33,7 +32,7 @@ export const reducer = (state, action) => {
33
32
  return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
34
33
  }
35
34
  case ActionTypes.HANDLE_UPLOAD_ACTION: {
36
- return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true });
35
+ return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
37
36
  }
38
37
  case ActionTypes.HANDLE_CANCEL_UPLOAD: {
39
38
  return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
@@ -42,7 +41,7 @@ export const reducer = (state, action) => {
42
41
  return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
43
42
  }
44
43
  case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
45
- return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
44
+ return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage });
46
45
  }
47
46
  }
48
47
  return state;
@@ -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,
@@ -72,7 +70,8 @@ export const actions = {
72
70
  HANDLE_FINISH_UPLOAD: () => ({
73
71
  type: ActionTypes.HANDLE_FINISH_UPLOAD,
74
72
  }),
75
- HANDLE_SUCCESS_MESSAGE: () => ({
73
+ HANDLE_SUCCESS_MESSAGE: (successMessage) => ({
76
74
  type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
75
+ successMessage,
77
76
  }),
78
77
  };
@@ -1,4 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
+ import { AlertMessage, AlertMessageType } from '../AlertMessage';
2
3
  import { DragItemArea } from './DragItemArea';
3
4
  import { PermissionsContext } from './FileManager';
4
5
  import { FileSectionUploadItem } from './FileSectionItem/FileSectionUploadItem';
@@ -6,7 +7,7 @@ import { actions } from './FileSectionState';
6
7
  import { SelectDialogDesignation } from './SelectDialogDesignation';
7
8
  import { UploadFileArea } from './UploadFileArea';
8
9
  import { FileSectionType, getDesignationName } from './util';
9
- export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
10
+ export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
10
11
  let uploadedFileExtension = '';
11
12
  if (state.uploadedFile) {
12
13
  uploadedFileExtension = state.uploadedFile.name.substring(state.uploadedFile.name.lastIndexOf('.') + 1);
@@ -17,15 +18,21 @@ export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fi
17
18
  dispatch(actions.HANDLE_UPLOAD_ACTION());
18
19
  state.uploadedFile &&
19
20
  state.selectDesignation !== undefined &&
20
- handleUpload(submissionId, state.uploadedFile, getDesignationName(state.selectDesignation));
21
+ handleUpload(state.uploadedFile, getDesignationName(state.selectDesignation));
21
22
  };
22
23
  const can = useContext(PermissionsContext);
24
+ const handleSuccessMessage = () => {
25
+ return (React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: { text: 'OK' } }, state.successMessage));
26
+ };
23
27
  return (React.createElement("div", null,
24
28
  (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 })),
29
+ (isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
26
30
  state.isUploadFile &&
27
31
  state.uploadedFile &&
28
- state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
32
+ state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
33
+ state.isShowSuccessMessage &&
34
+ state.successMessage !== '' &&
35
+ handleSuccessMessage(),
29
36
  state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
30
37
  dispatch(actions.HANDLE_CANCEL_UPLOAD());
31
38
  }, 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) {
@@ -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;