@manuscripts/style-guide 0.30.14 → 0.30.18
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 +14 -4
- 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 +8 -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 +14 -4
- 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 +8 -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/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 +2 -0
- package/dist/types/components/FileManager/util.d.ts +1 -7
- package/package.json +1 -1
|
@@ -47,9 +47,16 @@ const util_1 = require("./util");
|
|
|
47
47
|
exports.PermissionsContext = react_1.createContext(null);
|
|
48
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
|
+
}
|
|
57
|
+
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
58
|
+
return res;
|
|
59
|
+
}), [handleReplace]);
|
|
53
60
|
const handleUploadFile = react_1.useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
61
|
try {
|
|
55
62
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -57,6 +64,9 @@ exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, ha
|
|
|
57
64
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
|
|
58
65
|
}
|
|
59
66
|
const res = yield handleUpload(submissionId, file, designation);
|
|
67
|
+
if (res) {
|
|
68
|
+
dispatch(FileSectionState_1.actions.SHOW_FILE_UPLOADED_ALERT());
|
|
69
|
+
}
|
|
60
70
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
61
71
|
return res;
|
|
62
72
|
}
|
|
@@ -89,7 +99,7 @@ exports.FileManager = ({ submissionId, externalFiles, enableDragAndDrop, can, ha
|
|
|
89
99
|
return (designation !== undefined &&
|
|
90
100
|
util_1.designationWithFileSectionsMap.get(designation) === fileSection);
|
|
91
101
|
});
|
|
92
|
-
const itemsDataWithTitle = util_1.
|
|
102
|
+
const itemsDataWithTitle = util_1.generateExternalFilesTitles(util_1.sortExternalFiles(itemsData), fileSection);
|
|
93
103
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
94
104
|
const itemProps = {
|
|
95
105
|
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
|
}
|
|
@@ -20,6 +20,7 @@ var ActionTypes;
|
|
|
20
20
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
21
21
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
22
22
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
23
|
+
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
23
24
|
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
24
25
|
})(ActionTypes || (ActionTypes = {}));
|
|
25
26
|
exports.reducer = (state, action) => {
|
|
@@ -44,7 +45,10 @@ exports.reducer = (state, action) => {
|
|
|
44
45
|
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
|
|
45
46
|
}
|
|
46
47
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
47
|
-
return Object.assign(Object.assign({}, state), { isUploadFile: false,
|
|
48
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
49
|
+
}
|
|
50
|
+
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
51
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
48
52
|
}
|
|
49
53
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
50
54
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
@@ -80,6 +84,9 @@ exports.actions = {
|
|
|
80
84
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
81
85
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
82
86
|
}),
|
|
87
|
+
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
88
|
+
type: ActionTypes.SHOW_FILE_UPLOADED_ALERT,
|
|
89
|
+
}),
|
|
83
90
|
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
84
91
|
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
85
92
|
}),
|
|
@@ -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: {
|
|
@@ -22,9 +22,16 @@ import { Designation, designationWithFileSectionsMap, FileSectionType, generateE
|
|
|
22
22
|
export const PermissionsContext = createContext(null);
|
|
23
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
|
+
}
|
|
32
|
+
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
33
|
+
return res;
|
|
34
|
+
}), [handleReplace]);
|
|
28
35
|
const handleUploadFile = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
36
|
try {
|
|
30
37
|
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -32,6 +39,9 @@ export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, ca
|
|
|
32
39
|
dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
|
|
33
40
|
}
|
|
34
41
|
const res = yield handleUpload(submissionId, file, designation);
|
|
42
|
+
if (res) {
|
|
43
|
+
dispatch(actions.SHOW_FILE_UPLOADED_ALERT());
|
|
44
|
+
}
|
|
35
45
|
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
36
46
|
return res;
|
|
37
47
|
}
|
|
@@ -64,7 +74,7 @@ export const FileManager = ({ submissionId, externalFiles, enableDragAndDrop, ca
|
|
|
64
74
|
return (designation !== undefined &&
|
|
65
75
|
designationWithFileSectionsMap.get(designation) === fileSection);
|
|
66
76
|
});
|
|
67
|
-
const itemsDataWithTitle = sortExternalFiles(
|
|
77
|
+
const itemsDataWithTitle = generateExternalFilesTitles(sortExternalFiles(itemsData), fileSection);
|
|
68
78
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
69
79
|
const itemProps = {
|
|
70
80
|
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
|
}
|
|
@@ -17,6 +17,7 @@ var ActionTypes;
|
|
|
17
17
|
ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
|
|
18
18
|
ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
|
|
19
19
|
ActionTypes["HANDLE_SUCCESS_MESSAGE"] = "handleSuccessMessage";
|
|
20
|
+
ActionTypes["SHOW_FILE_UPLOADED_ALERT"] = "showFileUploadedAlert";
|
|
20
21
|
ActionTypes["CLOSE_FILE_UPLOADED_ALERT"] = "closeFileUploadedAlert";
|
|
21
22
|
})(ActionTypes || (ActionTypes = {}));
|
|
22
23
|
export const reducer = (state, action) => {
|
|
@@ -41,7 +42,10 @@ export const reducer = (state, action) => {
|
|
|
41
42
|
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
|
|
42
43
|
}
|
|
43
44
|
case ActionTypes.HANDLE_FINISH_UPLOAD: {
|
|
44
|
-
return Object.assign(Object.assign({}, state), { isUploadFile: false,
|
|
45
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
46
|
+
}
|
|
47
|
+
case ActionTypes.SHOW_FILE_UPLOADED_ALERT: {
|
|
48
|
+
return Object.assign(Object.assign({}, state), { isFileUploaded: true });
|
|
45
49
|
}
|
|
46
50
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
47
51
|
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
@@ -77,6 +81,9 @@ export const actions = {
|
|
|
77
81
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
78
82
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
79
83
|
}),
|
|
84
|
+
SHOW_FILE_UPLOADED_ALERT: () => ({
|
|
85
|
+
type: ActionTypes.SHOW_FILE_UPLOADED_ALERT,
|
|
86
|
+
}),
|
|
80
87
|
CLOSE_FILE_UPLOADED_ALERT: () => ({
|
|
81
88
|
type: ActionTypes.CLOSE_FILE_UPLOADED_ALERT,
|
|
82
89
|
}),
|
|
@@ -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: {
|
|
@@ -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
|
}>;
|
|
@@ -22,6 +22,7 @@ declare enum ActionTypes {
|
|
|
22
22
|
HANDLE_UPLOAD_ACTION = "handleUpload",
|
|
23
23
|
HANDLE_FINISH_UPLOAD = "handleFinishUpload",
|
|
24
24
|
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage",
|
|
25
|
+
SHOW_FILE_UPLOADED_ALERT = "showFileUploadedAlert",
|
|
25
26
|
CLOSE_FILE_UPLOADED_ALERT = "closeFileUploadedAlert"
|
|
26
27
|
}
|
|
27
28
|
export declare const reducer: (state: State, action: Action) => State;
|
|
@@ -36,6 +37,7 @@ export declare const actions: {
|
|
|
36
37
|
SELECT_DESIGNATION: (designation: Designation) => Action;
|
|
37
38
|
MOVE_FILE: (submissionId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
38
39
|
HANDLE_FINISH_UPLOAD: () => Action;
|
|
40
|
+
SHOW_FILE_UPLOADED_ALERT: () => Action;
|
|
39
41
|
CLOSE_FILE_UPLOADED_ALERT: () => Action;
|
|
40
42
|
HANDLE_SUCCESS_MESSAGE: () => Action;
|
|
41
43
|
};
|
|
@@ -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.18",
|
|
5
5
|
"repository": "gitlab:mpapp-public/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|