@manuscripts/style-guide 0.30.13 → 0.30.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.
- package/dist/cjs/components/FileManager/FileManager.js +23 -12
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +10 -5
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +1 -1
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +5 -1
- package/dist/cjs/components/FileManager/FileSectionState.js +15 -0
- package/dist/cjs/components/FileManager/FilesSection.js +6 -1
- package/dist/cjs/components/FileManager/util.js +7 -10
- package/dist/cjs/lib/lw-errors-decoder.js +1 -1
- package/dist/es/components/FileManager/FileManager.js +24 -13
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +10 -5
- package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +1 -1
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +6 -2
- package/dist/es/components/FileManager/FileSectionState.js +15 -0
- package/dist/es/components/FileManager/FilesSection.js +6 -1
- package/dist/es/components/FileManager/util.js +7 -10
- package/dist/es/lib/lw-errors-decoder.js +1 -1
- package/dist/types/components/FileManager/FileManager.d.ts +0 -2
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +1 -2
- package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +1 -1
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +3 -1
- package/dist/types/components/FileManager/FileSectionState.d.ts +6 -1
- package/dist/types/components/FileManager/util.d.ts +1 -7
- package/package.json +3 -3
|
@@ -45,11 +45,21 @@ const FilesSection_1 = require("./FilesSection");
|
|
|
45
45
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
46
46
|
const util_1 = require("./util");
|
|
47
47
|
exports.PermissionsContext = react_1.createContext(null);
|
|
48
|
-
exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation,
|
|
48
|
+
exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
49
49
|
const [state, dispatch] = react_1.useReducer(FileSectionState_1.reducer, FileSectionState_1.getInitialState());
|
|
50
|
-
const handleReplaceFile = react_1.useCallback((submissionId, name, file, typeId) => {
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const handleReplaceFile = react_1.useCallback((submissionId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
52
|
+
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
|
|
53
|
+
const res = yield handleReplace(submissionId, name, file, typeId);
|
|
54
|
+
if (res) {
|
|
55
|
+
dispatch(FileSectionState_1.actions.SHOW_FILE_UPLOADED_ALERT());
|
|
56
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
60
|
+
}
|
|
61
|
+
return res;
|
|
62
|
+
}), [handleReplace]);
|
|
53
63
|
const handleUploadFile = react_1.useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
64
|
try {
|
|
55
65
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -57,19 +67,20 @@ exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, ha
|
|
|
57
67
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
58
68
|
}
|
|
59
69
|
const res = yield handleUpload(submissionId, file, designation);
|
|
60
|
-
|
|
70
|
+
if (res) {
|
|
71
|
+
dispatch(FileSectionState_1.actions.SHOW_FILE_UPLOADED_ALERT());
|
|
72
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
76
|
+
}
|
|
61
77
|
return res;
|
|
62
78
|
}
|
|
63
79
|
catch (e) {
|
|
64
80
|
console.error(e);
|
|
65
81
|
return false;
|
|
66
82
|
}
|
|
67
|
-
}), [handleUpload
|
|
68
|
-
react_1.useEffect(() => {
|
|
69
|
-
if (stopUploadProgress) {
|
|
70
|
-
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
71
|
-
}
|
|
72
|
-
}, [stopUploadProgress]);
|
|
83
|
+
}), [handleUpload]);
|
|
73
84
|
const handleChangeDesignationFile = react_1.useCallback((submissionId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
85
|
try {
|
|
75
86
|
const res = yield handleChangeDesignation(submissionId, typeId, name);
|
|
@@ -94,7 +105,7 @@ exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, ha
|
|
|
94
105
|
return (designation !== undefined &&
|
|
95
106
|
util_1.designationWithFileSectionsMap.get(designation) === fileSection);
|
|
96
107
|
});
|
|
97
|
-
const itemsDataWithTitle = util_1.
|
|
108
|
+
const itemsDataWithTitle = util_1.generateExternalFilesTitles(util_1.sortExternalFiles(itemsData), fileSection);
|
|
98
109
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
99
110
|
const itemProps = {
|
|
100
111
|
submissionId: submissionId,
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ItemContainer = exports.Item = exports.ActionsIcon = exports.FileSectionItem = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
9
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
9
|
const use_dropdown_1 = require("../../../hooks/use-dropdown");
|
|
11
10
|
const Dropdown_1 = require("../../Dropdown");
|
|
@@ -20,8 +19,15 @@ exports.FileSectionItem = ({ submissionId, externalFile, title, showAttachmentNa
|
|
|
20
19
|
const fileExtension = externalFile.filename.substring(externalFile.filename.lastIndexOf('.') + 1);
|
|
21
20
|
const designation = util_1.namesWithDesignationMap.get(externalFile.designation);
|
|
22
21
|
const isMainManuscript = designation === util_1.Designation.MainManuscript;
|
|
22
|
+
const isSelected = externalFile._id == window.location.hash.substr(1);
|
|
23
23
|
return (react_1.default.createElement(exports.Item, { ref: dragRef, className: className, style: style },
|
|
24
|
-
react_1.default.createElement(exports.ItemContainer, {
|
|
24
|
+
react_1.default.createElement(exports.ItemContainer, { onClick: () => {
|
|
25
|
+
window.location.hash =
|
|
26
|
+
isEditor && !isSelected ? `#${externalFile._id}` : '#';
|
|
27
|
+
if (isSelected) {
|
|
28
|
+
window.location.hash = `#${externalFile._id}`;
|
|
29
|
+
}
|
|
30
|
+
} },
|
|
25
31
|
react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.filename }),
|
|
26
32
|
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.filename, title: title, designation: designation, description: externalFile.description, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
|
|
27
33
|
onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
|
|
@@ -32,7 +38,7 @@ exports.FileSectionItem = ({ submissionId, externalFile, title, showAttachmentNa
|
|
|
32
38
|
handleDownload && handleReplace && submissionId && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
|
|
33
39
|
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
34
40
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
35
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen }))))));
|
|
41
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
36
42
|
};
|
|
37
43
|
const IconCloseButton = styled_components_1.default.button `
|
|
38
44
|
border: none;
|
|
@@ -82,10 +88,9 @@ exports.Item = styled_components_1.default.div `
|
|
|
82
88
|
margin-right: 8px;
|
|
83
89
|
}
|
|
84
90
|
`;
|
|
85
|
-
exports.ItemContainer = styled_components_1.default
|
|
91
|
+
exports.ItemContainer = styled_components_1.default.div `
|
|
86
92
|
display: flex;
|
|
87
93
|
min-width: calc(100% - 8px);
|
|
88
94
|
padding-right: 4px;
|
|
89
95
|
box-sizing: border-box;
|
|
90
|
-
text-decoration: none;
|
|
91
96
|
`;
|
|
@@ -14,7 +14,7 @@ exports.FileSectionUploadItem = ({ fileName, isLoading, submissionId, dragRef, c
|
|
|
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 },
|
|
17
|
-
react_1.default.createElement(exports.UploadItemContainer,
|
|
17
|
+
react_1.default.createElement(exports.UploadItemContainer, null,
|
|
18
18
|
react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: false }),
|
|
19
19
|
react_1.default.createElement(FileInfo_1.FileInfoContainer, null,
|
|
20
20
|
react_1.default.createElement(FileInfo_1.FileNameContainer, null,
|
|
@@ -23,8 +23,9 @@ exports.ItemActions = void 0;
|
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
24
|
const Dropdown_1 = require("../../Dropdown");
|
|
25
25
|
const FileManager_1 = require("../FileManager");
|
|
26
|
+
const FileSectionState_1 = require("../FileSectionState");
|
|
26
27
|
const ItemsAction_1 = require("../ItemsAction");
|
|
27
|
-
exports.ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, }) => {
|
|
28
|
+
exports.ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, dispatch, }) => {
|
|
28
29
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
29
30
|
const fileInputRef = react_1.useRef(null);
|
|
30
31
|
const [selectedFile, setSelectedFile] = react_1.useState();
|
|
@@ -33,6 +34,9 @@ exports.ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, su
|
|
|
33
34
|
if (event && event.target && event.target.files) {
|
|
34
35
|
const file = event.target.files[0];
|
|
35
36
|
setSelectedFile(file);
|
|
37
|
+
if (dispatch) {
|
|
38
|
+
dispatch(FileSectionState_1.actions.UPLOAD_FILE(file));
|
|
39
|
+
}
|
|
36
40
|
replaceAttachmentHandler(submissionId, fileName, file, attachmentDesignation);
|
|
37
41
|
hideActionList();
|
|
38
42
|
}
|
|
@@ -4,6 +4,7 @@ exports.actions = exports.reducer = exports.getInitialState = void 0;
|
|
|
4
4
|
exports.getInitialState = () => ({
|
|
5
5
|
uploadedFile: undefined,
|
|
6
6
|
isUploadFile: false,
|
|
7
|
+
isFileUploaded: false,
|
|
7
8
|
moveToOtherState: undefined,
|
|
8
9
|
successMessage: '',
|
|
9
10
|
isShowSuccessMessage: false,
|
|
@@ -19,6 +20,8 @@ var ActionTypes;
|
|
|
19
20
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
20
21
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
21
22
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
23
|
+
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
24
|
+
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
22
25
|
})(ActionTypes || (ActionTypes = {}));
|
|
23
26
|
exports.reducer = (state, action) => {
|
|
24
27
|
switch (action.type) {
|
|
@@ -44,9 +47,15 @@ exports.reducer = (state, action) => {
|
|
|
44
47
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
45
48
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
46
49
|
}
|
|
50
|
+
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
51
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
52
|
+
}
|
|
47
53
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
48
54
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
49
55
|
}
|
|
56
|
+
case ActionTypes.CLOSE_FILE_UPLOADED_ALERT: {
|
|
57
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: false });
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
return state;
|
|
52
61
|
};
|
|
@@ -75,6 +84,12 @@ exports.actions = {
|
|
|
75
84
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
76
85
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
77
86
|
}),
|
|
87
|
+
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
88
|
+
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
89
|
+
}),
|
|
90
|
+
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
91
|
+
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
92
|
+
}),
|
|
78
93
|
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
79
94
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
80
95
|
}),
|
|
@@ -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");
|
|
@@ -47,7 +48,11 @@ exports.FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fileSec
|
|
|
47
48
|
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
|
|
48
49
|
state.isUploadFile &&
|
|
49
50
|
state.uploadedFile &&
|
|
50
|
-
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile }))
|
|
51
|
+
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })),
|
|
52
|
+
state.isFileUploaded && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.info, hideCloseButton: true, dismissButton: {
|
|
53
|
+
action: () => dispatch(FileSectionState_1.actions.CLOSE_FILE_UPLOADED_ALERT()),
|
|
54
|
+
text: 'Close',
|
|
55
|
+
} }, "File uploaded successfully. It may take a few moments to show the new file in the Inspector.")))),
|
|
51
56
|
state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
52
57
|
dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
|
|
53
58
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -374,16 +374,13 @@ exports.generateExternalFilesTitles = (externalFiles, fileSectionType) => {
|
|
|
374
374
|
}));
|
|
375
375
|
return result;
|
|
376
376
|
};
|
|
377
|
-
exports.sortExternalFiles = (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
: 0);
|
|
385
|
-
return externalFilesWithTitles;
|
|
386
|
-
};
|
|
377
|
+
exports.sortExternalFiles = (externalFile) => externalFile
|
|
378
|
+
.sort((a, b) => Number(a.createdAt) - Number(b.createdAt))
|
|
379
|
+
.sort((a, b) => b.designation === 'main-manuscript'
|
|
380
|
+
? 1
|
|
381
|
+
: a.designation === 'main-manuscript'
|
|
382
|
+
? -1
|
|
383
|
+
: 0);
|
|
387
384
|
exports.getDesignationActionsList = (designation, fileExtension) => {
|
|
388
385
|
const allowedDesignationsToTransition = exports.designationWithAllowedDesignationsToTransitionMap.get(designation);
|
|
389
386
|
if (allowedDesignationsToTransition) {
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const errorsExplanations = {
|
|
19
19
|
ANY_ERR_AUTHORIZATION: {
|
|
20
20
|
title: 'Authorization issue',
|
|
21
|
-
description: "It seems you don't have access to this
|
|
21
|
+
description: "It seems you don't have access to this resource. If you think you should have access, please contact the support team.",
|
|
22
22
|
type: 'System',
|
|
23
23
|
},
|
|
24
24
|
PREVIEW_HTML_GENERATION_FAILED: {
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { createContext, useCallback,
|
|
10
|
+
import React, { createContext, useCallback, useReducer } from 'react';
|
|
11
11
|
import ReactTooltip from 'react-tooltip';
|
|
12
12
|
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
13
13
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
@@ -20,11 +20,21 @@ import { FilesSection } from './FilesSection';
|
|
|
20
20
|
import { TooltipDiv } from './TooltipDiv';
|
|
21
21
|
import { Designation, designationWithFileSectionsMap, FileSectionType, generateExternalFilesTitles, namesWithDesignationMap, sortExternalFiles, } from './util';
|
|
22
22
|
export const PermissionsContext = createContext(null);
|
|
23
|
-
export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation,
|
|
23
|
+
export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
24
24
|
const [state, dispatch] = useReducer(reducer, getInitialState());
|
|
25
|
-
const handleReplaceFile = useCallback((submissionId, name, file, typeId) => {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const handleReplaceFile = useCallback((submissionId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
27
|
+
dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
|
|
28
|
+
const res = yield handleReplace(submissionId, name, file, typeId);
|
|
29
|
+
if (res) {
|
|
30
|
+
dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
|
|
31
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
35
|
+
}
|
|
36
|
+
return res;
|
|
37
|
+
}), [handleReplace]);
|
|
28
38
|
const handleUploadFile = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
39
|
try {
|
|
30
40
|
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -32,19 +42,20 @@ export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, ca
|
|
|
32
42
|
dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
|
|
33
43
|
}
|
|
34
44
|
const res = yield handleUpload(submissionId, file, designation);
|
|
35
|
-
|
|
45
|
+
if (res) {
|
|
46
|
+
dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
|
|
47
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
51
|
+
}
|
|
36
52
|
return res;
|
|
37
53
|
}
|
|
38
54
|
catch (e) {
|
|
39
55
|
console.error(e);
|
|
40
56
|
return false;
|
|
41
57
|
}
|
|
42
|
-
}), [handleUpload
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (stopUploadProgress) {
|
|
45
|
-
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
46
|
-
}
|
|
47
|
-
}, [stopUploadProgress]);
|
|
58
|
+
}), [handleUpload]);
|
|
48
59
|
const handleChangeDesignationFile = useCallback((submissionId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
60
|
try {
|
|
50
61
|
const res = yield handleChangeDesignation(submissionId, typeId, name);
|
|
@@ -69,7 +80,7 @@ export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, ca
|
|
|
69
80
|
return (designation !== undefined &&
|
|
70
81
|
designationWithFileSectionsMap.get(designation) === fileSection);
|
|
71
82
|
});
|
|
72
|
-
const itemsDataWithTitle = sortExternalFiles(
|
|
83
|
+
const itemsDataWithTitle = generateExternalFilesTitles(sortExternalFiles(itemsData), fileSection);
|
|
73
84
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
74
85
|
const itemProps = {
|
|
75
86
|
submissionId: submissionId,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
import { useDropdown } from '../../../hooks/use-dropdown';
|
|
5
4
|
import { DropdownContainer } from '../../Dropdown';
|
|
@@ -14,8 +13,15 @@ export const FileSectionItem = ({ submissionId, externalFile, title, showAttachm
|
|
|
14
13
|
const fileExtension = externalFile.filename.substring(externalFile.filename.lastIndexOf('.') + 1);
|
|
15
14
|
const designation = namesWithDesignationMap.get(externalFile.designation);
|
|
16
15
|
const isMainManuscript = designation === Designation.MainManuscript;
|
|
16
|
+
const isSelected = externalFile._id == window.location.hash.substr(1);
|
|
17
17
|
return (React.createElement(Item, { ref: dragRef, className: className, style: style },
|
|
18
|
-
React.createElement(ItemContainer, {
|
|
18
|
+
React.createElement(ItemContainer, { onClick: () => {
|
|
19
|
+
window.location.hash =
|
|
20
|
+
isEditor && !isSelected ? `#${externalFile._id}` : '#';
|
|
21
|
+
if (isSelected) {
|
|
22
|
+
window.location.hash = `#${externalFile._id}`;
|
|
23
|
+
}
|
|
24
|
+
} },
|
|
19
25
|
React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.filename }),
|
|
20
26
|
React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.filename, title: title, designation: designation, description: externalFile.description, handleChangeDesignation: handleChangeDesignation, submissionId: submissionId, dispatch: dispatch })),
|
|
21
27
|
onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
|
|
@@ -26,7 +32,7 @@ export const FileSectionItem = ({ submissionId, externalFile, title, showAttachm
|
|
|
26
32
|
handleDownload && handleReplace && submissionId && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
27
33
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
28
34
|
React.createElement(DotsIcon, null)),
|
|
29
|
-
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen }))))));
|
|
35
|
+
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, submissionId: submissionId, fileName: externalFile.filename, designation: externalFile.designation, publicUrl: externalFile.publicUrl, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
30
36
|
};
|
|
31
37
|
const IconCloseButton = styled.button `
|
|
32
38
|
border: none;
|
|
@@ -76,10 +82,9 @@ export const Item = styled.div `
|
|
|
76
82
|
margin-right: 8px;
|
|
77
83
|
}
|
|
78
84
|
`;
|
|
79
|
-
export const ItemContainer = styled
|
|
85
|
+
export const ItemContainer = styled.div `
|
|
80
86
|
display: flex;
|
|
81
87
|
min-width: calc(100% - 8px);
|
|
82
88
|
padding-right: 4px;
|
|
83
89
|
box-sizing: border-box;
|
|
84
|
-
text-decoration: none;
|
|
85
90
|
`;
|
|
@@ -8,7 +8,7 @@ export const FileSectionUploadItem = ({ fileName, isLoading, submissionId, dragR
|
|
|
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 },
|
|
11
|
-
React.createElement(UploadItemContainer,
|
|
11
|
+
React.createElement(UploadItemContainer, null,
|
|
12
12
|
React.createElement(FileTypeIcon, { withDot: false }),
|
|
13
13
|
React.createElement(FileInfoContainer, null,
|
|
14
14
|
React.createElement(FileNameContainer, null,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useContext, useRef, useState } from 'react';
|
|
1
|
+
import React, { useContext, useRef, useState, } from 'react';
|
|
2
2
|
import { DropdownList } from '../../Dropdown';
|
|
3
3
|
import { PermissionsContext } from '../FileManager';
|
|
4
|
+
import { actions } from '../FileSectionState';
|
|
4
5
|
import { ActionsItem } from '../ItemsAction';
|
|
5
|
-
export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, }) => {
|
|
6
|
+
export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, submissionId, fileName, designation, publicUrl, hideActionList, dispatch, }) => {
|
|
6
7
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
7
8
|
const fileInputRef = useRef(null);
|
|
8
9
|
const [selectedFile, setSelectedFile] = useState();
|
|
@@ -11,6 +12,9 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
|
|
|
11
12
|
if (event && event.target && event.target.files) {
|
|
12
13
|
const file = event.target.files[0];
|
|
13
14
|
setSelectedFile(file);
|
|
15
|
+
if (dispatch) {
|
|
16
|
+
dispatch(actions.UPLOAD_FILE(file));
|
|
17
|
+
}
|
|
14
18
|
replaceAttachmentHandler(submissionId, fileName, file, attachmentDesignation);
|
|
15
19
|
hideActionList();
|
|
16
20
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const getInitialState = () => ({
|
|
2
2
|
uploadedFile: undefined,
|
|
3
3
|
isUploadFile: false,
|
|
4
|
+
isFileUploaded: false,
|
|
4
5
|
moveToOtherState: undefined,
|
|
5
6
|
successMessage: '',
|
|
6
7
|
isShowSuccessMessage: false,
|
|
@@ -16,6 +17,8 @@ var ActionTypes;
|
|
|
16
17
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
17
18
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
18
19
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
20
|
+
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
21
|
+
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
19
22
|
})(ActionTypes || (ActionTypes = {}));
|
|
20
23
|
export const reducer = (state, action) => {
|
|
21
24
|
switch (action.type) {
|
|
@@ -41,9 +44,15 @@ export const reducer = (state, action) => {
|
|
|
41
44
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
42
45
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
43
46
|
}
|
|
47
|
+
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
48
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
49
|
+
}
|
|
44
50
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
45
51
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
46
52
|
}
|
|
53
|
+
case ActionTypes.CLOSE_FILE_UPLOADED_ALERT: {
|
|
54
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: false });
|
|
55
|
+
}
|
|
47
56
|
}
|
|
48
57
|
return state;
|
|
49
58
|
};
|
|
@@ -72,6 +81,12 @@ export const actions = {
|
|
|
72
81
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
73
82
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
74
83
|
}),
|
|
84
|
+
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
85
|
+
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
86
|
+
}),
|
|
87
|
+
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
88
|
+
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
89
|
+
}),
|
|
75
90
|
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
76
91
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
77
92
|
}),
|
|
@@ -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';
|
|
@@ -25,7 +26,11 @@ export const FilesSection = ({ submissionId, enableDragAndDrop, handleUpload, fi
|
|
|
25
26
|
(isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, submissionId: submissionId, dispatch: dispatch })),
|
|
26
27
|
state.isUploadFile &&
|
|
27
28
|
state.uploadedFile &&
|
|
28
|
-
state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile }))
|
|
29
|
+
state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { submissionId: submissionId, fileName: state.uploadedFile.name, isLoading: state.isUploadFile })),
|
|
30
|
+
state.isFileUploaded && (React.createElement(AlertMessage, { type: AlertMessageType.info, hideCloseButton: true, dismissButton: {
|
|
31
|
+
action: () => dispatch(actions.CLOSE_FILE_UPLOADED_ALERT()),
|
|
32
|
+
text: 'Close',
|
|
33
|
+
} }, "File uploaded successfully. It may take a few moments to show the new file in the Inspector.")))),
|
|
29
34
|
state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
30
35
|
dispatch(actions.HANDLE_CANCEL_UPLOAD());
|
|
31
36
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -368,16 +368,13 @@ export const generateExternalFilesTitles = (externalFiles, fileSectionType) => {
|
|
|
368
368
|
}));
|
|
369
369
|
return result;
|
|
370
370
|
};
|
|
371
|
-
export const sortExternalFiles = (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
: 0);
|
|
379
|
-
return externalFilesWithTitles;
|
|
380
|
-
};
|
|
371
|
+
export const sortExternalFiles = (externalFile) => externalFile
|
|
372
|
+
.sort((a, b) => Number(a.createdAt) - Number(b.createdAt))
|
|
373
|
+
.sort((a, b) => b.designation === 'main-manuscript'
|
|
374
|
+
? 1
|
|
375
|
+
: a.designation === 'main-manuscript'
|
|
376
|
+
? -1
|
|
377
|
+
: 0);
|
|
381
378
|
export const getDesignationActionsList = (designation, fileExtension) => {
|
|
382
379
|
const allowedDesignationsToTransition = designationWithAllowedDesignationsToTransitionMap.get(designation);
|
|
383
380
|
if (allowedDesignationsToTransition) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const errorsExplanations = {
|
|
17
17
|
ANY_ERR_AUTHORIZATION: {
|
|
18
18
|
title: 'Authorization issue',
|
|
19
|
-
description: "It seems you don't have access to this
|
|
19
|
+
description: "It seems you don't have access to this resource. If you think you should have access, please contact the support team.",
|
|
20
20
|
type: 'System',
|
|
21
21
|
},
|
|
22
22
|
PREVIEW_HTML_GENERATION_FAILED: {
|
|
@@ -11,6 +11,4 @@ export declare const FileManager: React.FC<{
|
|
|
11
11
|
handleDownload: (url: string) => void;
|
|
12
12
|
handleReplace: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
13
13
|
handleChangeDesignation: (submissionId: string, typeId: string, name: string) => Promise<boolean>;
|
|
14
|
-
setNewUploadedFileName: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
15
|
-
stopUploadProgress?: boolean;
|
|
16
14
|
}>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExternalFile } from '@manuscripts/manuscripts-json-schema';
|
|
2
2
|
import React, { CSSProperties, Dispatch } from 'react';
|
|
3
3
|
import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
|
|
4
|
-
import { Link } from 'react-router-dom';
|
|
5
4
|
import { Action } from '../FileSectionState';
|
|
6
5
|
export interface FileSectionItemProps {
|
|
7
6
|
submissionId?: string;
|
|
@@ -23,4 +22,4 @@ export interface FileSectionItemProps {
|
|
|
23
22
|
export declare const FileSectionItem: React.FC<FileSectionItemProps>;
|
|
24
23
|
export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
25
24
|
export declare const Item: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
26
|
-
export declare const ItemContainer: import("styled-components").StyledComponent<
|
|
25
|
+
export declare const ItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -9,5 +9,5 @@ export interface FileSectionItemProps {
|
|
|
9
9
|
style?: CSSProperties;
|
|
10
10
|
}
|
|
11
11
|
export declare const FileSectionUploadItem: React.FC<FileSectionItemProps>;
|
|
12
|
-
export declare const UploadItemContainer: import("styled-components").StyledComponent<
|
|
12
|
+
export declare const UploadItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
13
13
|
export declare const ProgressBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Action } from '../FileSectionState';
|
|
2
3
|
export declare const ItemActions: React.FC<{
|
|
3
4
|
downloadAttachmentHandler: (url: string) => void;
|
|
4
5
|
replaceAttachmentHandler: (submissionId: string, name: string, file: File, typeId: string) => Promise<boolean>;
|
|
@@ -7,4 +8,5 @@ export declare const ItemActions: React.FC<{
|
|
|
7
8
|
designation?: string | undefined;
|
|
8
9
|
publicUrl: string | undefined;
|
|
9
10
|
hideActionList: () => void;
|
|
11
|
+
dispatch?: Dispatch<Action>;
|
|
10
12
|
}>;
|
|
@@ -3,6 +3,7 @@ export declare const getInitialState: () => State;
|
|
|
3
3
|
export interface State {
|
|
4
4
|
uploadedFile: File | undefined;
|
|
5
5
|
isUploadFile: boolean;
|
|
6
|
+
isFileUploaded: boolean;
|
|
6
7
|
moveToOtherState: {
|
|
7
8
|
submissionId: string;
|
|
8
9
|
typeId: string;
|
|
@@ -20,7 +21,9 @@ declare enum ActionTypes {
|
|
|
20
21
|
HANDLE_CANCEL_UPLOAD = "handleCancel",
|
|
21
22
|
HANDLE_UPLOAD_ACTION = "handleUpload",
|
|
22
23
|
HANDLE_FINISH_UPLOAD = "handleFinishUpload",
|
|
23
|
-
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage"
|
|
24
|
+
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage",
|
|
25
|
+
SHOW_FILE_UPLOADED_ALERT = "showFileUploadedAlert",
|
|
26
|
+
CLOSE_FILE_UPLOADED_ALERT = "closeFileUploadedAlert"
|
|
24
27
|
}
|
|
25
28
|
export declare const reducer: (state: State, action: Action) => State;
|
|
26
29
|
export interface Action {
|
|
@@ -34,6 +37,8 @@ export declare const actions: {
|
|
|
34
37
|
SELECT_DESIGNATION: (designation: Designation) => Action;
|
|
35
38
|
MOVE_FILE: (submissionId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
36
39
|
HANDLE_FINISH_UPLOAD: () => Action;
|
|
40
|
+
SHOW_FILE_UPLOADED_ALERT: () => Action;
|
|
41
|
+
CLOSE_FILE_UPLOADED_ALERT: () => Action;
|
|
37
42
|
HANDLE_SUCCESS_MESSAGE: () => Action;
|
|
38
43
|
};
|
|
39
44
|
export {};
|
|
@@ -46,13 +46,7 @@ export declare const generateExternalFilesTitles: (externalFiles: ExternalFile[]
|
|
|
46
46
|
title: string;
|
|
47
47
|
externalFile: ExternalFile;
|
|
48
48
|
}>;
|
|
49
|
-
export declare const sortExternalFiles: (
|
|
50
|
-
title: string;
|
|
51
|
-
externalFile: ExternalFile;
|
|
52
|
-
}>) => Array<{
|
|
53
|
-
title: string;
|
|
54
|
-
externalFile: ExternalFile;
|
|
55
|
-
}>;
|
|
49
|
+
export declare const sortExternalFiles: (externalFile: ExternalFile[]) => ExternalFile[];
|
|
56
50
|
export declare const getDesignationActionsList: (designation: Designation, fileExtension: string) => Array<Designation>;
|
|
57
51
|
export declare const getDesignationName: (designation: Designation) => string;
|
|
58
52
|
export declare const getDesignationByFileSection: (fileSectionType: FileSectionType) => Array<Designation>;
|
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.30.
|
|
4
|
+
"version": "0.30.17",
|
|
5
5
|
"repository": "gitlab:mpapp-public/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@manuscripts/eslint-config": "^0.4.2",
|
|
38
38
|
"@reach/tabs": "^0.11.2",
|
|
39
39
|
"@types/react-color": "^3.0.4",
|
|
40
|
-
"@types/react-router-dom": "^5.
|
|
40
|
+
"@types/react-router-dom": "^5.1.6",
|
|
41
41
|
"date-fns": "^2.16.1",
|
|
42
42
|
"lodash-es": "^4.17.15",
|
|
43
43
|
"pdfjs-dist": "^2.7.570",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-intl": "^3.12.0",
|
|
47
47
|
"react-modal": "^3.11.2",
|
|
48
48
|
"react-modern-calendar-datepicker": "^3.1.3",
|
|
49
|
-
"react-router-dom": "^5.
|
|
49
|
+
"react-router-dom": "^5.2.0",
|
|
50
50
|
"react-select": "^3.0.8",
|
|
51
51
|
"react-sizeme": "^2.6.12",
|
|
52
52
|
"react-tooltip": "^4.2.11",
|