@manuscripts/style-guide 0.31.4 → 0.31.8
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/Comments/CommentWrapper.js +5 -3
- package/dist/cjs/components/FileManager/FileManager.js +29 -8
- package/dist/cjs/components/icons/index.js +3 -1
- package/dist/cjs/lib/lw-errors-decoder.js +5 -0
- package/dist/es/components/Comments/CommentWrapper.js +5 -3
- package/dist/es/components/FileManager/FileManager.js +29 -8
- package/dist/es/components/icons/index.js +1 -0
- package/dist/es/lib/lw-errors-decoder.js +5 -0
- package/dist/types/components/FileManager/FileManager.d.ts +3 -1
- package/dist/types/components/icons/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -54,8 +54,10 @@ const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollabo
|
|
|
54
54
|
const [isEditing, setIsEditing] = (0, react_1.useState)();
|
|
55
55
|
const threadRef = (0, react_1.useRef)(null);
|
|
56
56
|
(0, react_1.useEffect)(() => {
|
|
57
|
-
if (isNew) {
|
|
58
|
-
|
|
57
|
+
if (isNew || isSelected) {
|
|
58
|
+
{
|
|
59
|
+
isNew && setIsEditing(true);
|
|
60
|
+
}
|
|
59
61
|
if (threadRef.current) {
|
|
60
62
|
setTimeout(() => {
|
|
61
63
|
var _a;
|
|
@@ -66,7 +68,7 @@ const CommentWrapper = ({ createKeyword, comment, can, currentUserId, getCollabo
|
|
|
66
68
|
}, 100);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
}, [isNew]);
|
|
71
|
+
}, [isNew, isSelected]);
|
|
70
72
|
const onTitleMouseDown = (0, react_1.useCallback)((e) => {
|
|
71
73
|
e.preventDefault();
|
|
72
74
|
handleRequestSelect && handleRequestSelect();
|
|
@@ -32,6 +32,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.FileManager = exports.PermissionsContext = void 0;
|
|
35
|
+
const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
36
|
+
const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
|
|
35
37
|
const react_1 = __importStar(require("react"));
|
|
36
38
|
const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
37
39
|
const inlineFiles_1 = __importDefault(require("../../lib/inlineFiles"));
|
|
@@ -47,7 +49,7 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
|
47
49
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
48
50
|
const util_1 = require("./util");
|
|
49
51
|
exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
50
|
-
const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
52
|
+
const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
51
53
|
const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
|
|
52
54
|
const handleReplaceFile = (0, react_1.useCallback)((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
55
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -65,6 +67,14 @@ const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, c
|
|
|
65
67
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
66
68
|
return res;
|
|
67
69
|
}), [handleUpload]);
|
|
70
|
+
const handleUploadFileWithSupplement = (0, react_1.useCallback)((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const res = (yield handleUploadFile(submissionId, file, designation));
|
|
72
|
+
if (res && res.data) {
|
|
73
|
+
const { id, name } = res.data.uploadAttachment;
|
|
74
|
+
yield saveModel((0, manuscript_transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
|
|
75
|
+
}
|
|
76
|
+
return res;
|
|
77
|
+
}), [handleUploadFile, saveModel]);
|
|
68
78
|
const handleChangeDesignationFile = (0, react_1.useCallback)((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
79
|
const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
|
|
70
80
|
if (res) {
|
|
@@ -85,15 +95,26 @@ const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, c
|
|
|
85
95
|
});
|
|
86
96
|
return attachmentsIDs;
|
|
87
97
|
}, [inlineFiles]);
|
|
98
|
+
const supplementFiles = (0, react_1.useMemo)(() => {
|
|
99
|
+
const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return [
|
|
102
|
+
(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
|
|
103
|
+
supplement,
|
|
104
|
+
];
|
|
105
|
+
}));
|
|
106
|
+
return attachments.filter((attachment) => supplements.has(attachment.id));
|
|
107
|
+
}, [attachments, modelMap.size]);
|
|
88
108
|
const getFileSectionExternalFile = (fileSection) => {
|
|
89
109
|
const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
|
|
90
110
|
fileSection === util_1.FileSectionType.OtherFile;
|
|
91
|
-
const itemsData =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
|
|
112
|
+
attachments.filter((element) => {
|
|
113
|
+
const designation = util_1.namesWithDesignationMap.get(element.type.label);
|
|
114
|
+
return (designation !== undefined &&
|
|
115
|
+
util_1.designationWithFileSectionsMap.get(designation) === fileSection &&
|
|
116
|
+
!inlineAttachmentsIds.has(element.id));
|
|
117
|
+
});
|
|
97
118
|
const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
|
|
98
119
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
99
120
|
const itemProps = {
|
|
@@ -144,7 +165,7 @@ const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, c
|
|
|
144
165
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
145
166
|
react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
146
167
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
147
|
-
react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload:
|
|
168
|
+
react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
148
169
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
149
170
|
react_1.default.createElement(FilesSection_1.FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
|
|
150
171
|
state.isShowSuccessMessage &&
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.MissingImage = exports.UploadIcon = exports.AttachIcon = exports.TaskStepNextIcon = exports.TaskStepDoneIcon = exports.TaskStepCurrentIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.UserIcon = exports.TickMarkIcon = exports.SearchIcon = exports.ProjectsListIcon = exports.ProjectIcon = exports.ProjectNotificationIcon = exports.OrcidIcon = exports.GoogleIcon = exports.CloseOIcon = exports.BookmarkIcon = exports.BackArrowIcon = exports.AddIconInverted = exports.AddIconActive = exports.AddAuthor = void 0;
|
|
21
|
+
exports.UnsupportedFormatFileIcon = exports.MissingImage = exports.UploadIcon = exports.AttachIcon = exports.TaskStepNextIcon = exports.TaskStepDoneIcon = exports.TaskStepCurrentIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.UserIcon = exports.TickMarkIcon = exports.SearchIcon = exports.ProjectsListIcon = exports.ProjectIcon = exports.ProjectNotificationIcon = exports.OrcidIcon = exports.GoogleIcon = exports.CloseOIcon = exports.BookmarkIcon = exports.BackArrowIcon = exports.AddIconInverted = exports.AddIconActive = exports.AddAuthor = void 0;
|
|
22
22
|
var add_author_1 = require("./add-author");
|
|
23
23
|
Object.defineProperty(exports, "AddAuthor", { enumerable: true, get: function () { return __importDefault(add_author_1).default; } });
|
|
24
24
|
var add_icon_active_1 = require("./add-icon-active");
|
|
@@ -63,3 +63,5 @@ var upload_1 = require("./upload");
|
|
|
63
63
|
Object.defineProperty(exports, "UploadIcon", { enumerable: true, get: function () { return __importDefault(upload_1).default; } });
|
|
64
64
|
var missing_image_1 = require("./missing-image");
|
|
65
65
|
Object.defineProperty(exports, "MissingImage", { enumerable: true, get: function () { return __importDefault(missing_image_1).default; } });
|
|
66
|
+
var unsupported_format_file_icon_1 = require("./unsupported-format-file-icon");
|
|
67
|
+
Object.defineProperty(exports, "UnsupportedFormatFileIcon", { enumerable: true, get: function () { return __importDefault(unsupported_format_file_icon_1).default; } });
|
|
@@ -236,6 +236,11 @@ const errorsExplanations = {
|
|
|
236
236
|
description: 'There are figures in the docment containing multiple images.',
|
|
237
237
|
type: 'Workflow',
|
|
238
238
|
},
|
|
239
|
+
CP_FILES_MERGED: {
|
|
240
|
+
title: 'Package files were merged',
|
|
241
|
+
description: 'Submission files were merged automatically before conversion. In case of errors please check the merged main manuscript to check the correct files were merged.',
|
|
242
|
+
type: 'Workflow',
|
|
243
|
+
},
|
|
239
244
|
FC_FAIL_QA_CHECKLIST: {
|
|
240
245
|
title: 'Quality report checks outstanding',
|
|
241
246
|
description: 'The Quality report still contains outstanding critical checks that have to be resolved in order to proceed.',
|
|
@@ -29,8 +29,10 @@ export const CommentWrapper = ({ createKeyword, comment, can, currentUserId, get
|
|
|
29
29
|
const [isEditing, setIsEditing] = useState();
|
|
30
30
|
const threadRef = useRef(null);
|
|
31
31
|
useEffect(() => {
|
|
32
|
-
if (isNew) {
|
|
33
|
-
|
|
32
|
+
if (isNew || isSelected) {
|
|
33
|
+
{
|
|
34
|
+
isNew && setIsEditing(true);
|
|
35
|
+
}
|
|
34
36
|
if (threadRef.current) {
|
|
35
37
|
setTimeout(() => {
|
|
36
38
|
var _a;
|
|
@@ -41,7 +43,7 @@ export const CommentWrapper = ({ createKeyword, comment, can, currentUserId, get
|
|
|
41
43
|
}, 100);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
}, [isNew]);
|
|
46
|
+
}, [isNew, isSelected]);
|
|
45
47
|
const onTitleMouseDown = useCallback((e) => {
|
|
46
48
|
e.preventDefault();
|
|
47
49
|
handleRequestSelect && handleRequestSelect();
|
|
@@ -7,6 +7,8 @@ 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 { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/manuscript-transform';
|
|
11
|
+
import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
|
|
10
12
|
import React, { createContext, useCallback, useMemo, useReducer } from 'react';
|
|
11
13
|
import ReactTooltip from 'react-tooltip';
|
|
12
14
|
import getInlineFiles from '../../lib/inlineFiles';
|
|
@@ -22,7 +24,7 @@ import { InlineFilesSection } from './InlineFilesSection';
|
|
|
22
24
|
import { TooltipDiv } from './TooltipDiv';
|
|
23
25
|
import { Designation, designationWithFileSectionsMap, FileSectionType, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
|
|
24
26
|
export const PermissionsContext = createContext(null);
|
|
25
|
-
export const FileManager = ({ submissionId, attachments, modelMap, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
27
|
+
export const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDragAndDrop, can, handleUpload, handleDownload, handleReplace, handleChangeDesignation, }) => {
|
|
26
28
|
const [state, dispatch] = useReducer(reducer, getInitialState());
|
|
27
29
|
const handleReplaceFile = useCallback((submissionId, attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
30
|
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -40,6 +42,14 @@ export const FileManager = ({ submissionId, attachments, modelMap, enableDragAnd
|
|
|
40
42
|
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
41
43
|
return res;
|
|
42
44
|
}), [handleUpload]);
|
|
45
|
+
const handleUploadFileWithSupplement = useCallback((submissionId, file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const res = (yield handleUploadFile(submissionId, file, designation));
|
|
47
|
+
if (res && res.data) {
|
|
48
|
+
const { id, name } = res.data.uploadAttachment;
|
|
49
|
+
yield saveModel(buildSupplementaryMaterial(name, `attachment:${id}`));
|
|
50
|
+
}
|
|
51
|
+
return res;
|
|
52
|
+
}), [handleUploadFile, saveModel]);
|
|
43
53
|
const handleChangeDesignationFile = useCallback((submissionId, attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
54
|
const res = yield handleChangeDesignation(submissionId, attachmentId, typeId, name);
|
|
45
55
|
if (res) {
|
|
@@ -60,15 +70,26 @@ export const FileManager = ({ submissionId, attachments, modelMap, enableDragAnd
|
|
|
60
70
|
});
|
|
61
71
|
return attachmentsIDs;
|
|
62
72
|
}, [inlineFiles]);
|
|
73
|
+
const supplementFiles = useMemo(() => {
|
|
74
|
+
const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return [
|
|
77
|
+
(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
|
|
78
|
+
supplement,
|
|
79
|
+
];
|
|
80
|
+
}));
|
|
81
|
+
return attachments.filter((attachment) => supplements.has(attachment.id));
|
|
82
|
+
}, [attachments, modelMap.size]);
|
|
63
83
|
const getFileSectionExternalFile = (fileSection) => {
|
|
64
84
|
const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
|
|
65
85
|
fileSection === FileSectionType.OtherFile;
|
|
66
|
-
const itemsData =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
|
|
87
|
+
attachments.filter((element) => {
|
|
88
|
+
const designation = namesWithDesignationMap.get(element.type.label);
|
|
89
|
+
return (designation !== undefined &&
|
|
90
|
+
designationWithFileSectionsMap.get(designation) === fileSection &&
|
|
91
|
+
!inlineAttachmentsIds.has(element.id));
|
|
92
|
+
});
|
|
72
93
|
const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
|
|
73
94
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
74
95
|
const itemProps = {
|
|
@@ -119,7 +140,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, enableDragAnd
|
|
|
119
140
|
React.createElement(InspectorTabPanel, null,
|
|
120
141
|
React.createElement(InlineFilesSection, { inlineFiles: inlineFiles, submissionId: submissionId, handleReplace: handleReplace, handleDownload: handleDownload, isEditor: enableDragAndDrop, dispatch: dispatch })),
|
|
121
142
|
React.createElement(InspectorTabPanel, null,
|
|
122
|
-
React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload:
|
|
143
|
+
React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
123
144
|
React.createElement(InspectorTabPanel, null,
|
|
124
145
|
React.createElement(FilesSection, { submissionId: submissionId, enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch })))))),
|
|
125
146
|
state.isShowSuccessMessage &&
|
|
@@ -35,3 +35,4 @@ export { default as TaskStepNextIcon } from './task-step-next';
|
|
|
35
35
|
export { default as AttachIcon } from './attach';
|
|
36
36
|
export { default as UploadIcon } from './upload';
|
|
37
37
|
export { default as MissingImage } from './missing-image';
|
|
38
|
+
export { default as UnsupportedFormatFileIcon } from './unsupported-format-file-icon';
|
|
@@ -234,6 +234,11 @@ const errorsExplanations = {
|
|
|
234
234
|
description: 'There are figures in the docment containing multiple images.',
|
|
235
235
|
type: 'Workflow',
|
|
236
236
|
},
|
|
237
|
+
CP_FILES_MERGED: {
|
|
238
|
+
title: 'Package files were merged',
|
|
239
|
+
description: 'Submission files were merged automatically before conversion. In case of errors please check the merged main manuscript to check the correct files were merged.',
|
|
240
|
+
type: 'Workflow',
|
|
241
|
+
},
|
|
237
242
|
FC_FAIL_QA_CHECKLIST: {
|
|
238
243
|
title: 'Quality report checks outstanding',
|
|
239
244
|
description: 'The Quality report still contains outstanding critical checks that have to be resolved in order to proceed.',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Build } from '@manuscripts/manuscript-transform';
|
|
2
|
+
import { Model, Supplement } from '@manuscripts/manuscripts-json-schema';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { Capabilities } from '../../lib/capabilities';
|
|
4
5
|
import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
|
|
@@ -7,6 +8,7 @@ export declare const FileManager: React.FC<{
|
|
|
7
8
|
submissionId: string;
|
|
8
9
|
attachments: SubmissionAttachment[];
|
|
9
10
|
modelMap: Map<string, Model>;
|
|
11
|
+
saveModel: (model: Build<Supplement>) => Promise<Build<Supplement>>;
|
|
10
12
|
enableDragAndDrop: boolean;
|
|
11
13
|
can: Capabilities;
|
|
12
14
|
handleUpload: (submissionId: string, file: File, designation: string) => Promise<any>;
|
|
@@ -35,3 +35,4 @@ export { default as TaskStepNextIcon } from './task-step-next';
|
|
|
35
35
|
export { default as AttachIcon } from './attach';
|
|
36
36
|
export { default as UploadIcon } from './upload';
|
|
37
37
|
export { default as MissingImage } from './missing-image';
|
|
38
|
+
export { default as UnsupportedFormatFileIcon } from './unsupported-format-file-icon';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.8",
|
|
5
5
|
"repository": "gitlab:atypon-opensource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@manuscripts/comment-editor": "^0.2.3",
|
|
64
64
|
"@manuscripts/data": "^0.1.0",
|
|
65
65
|
"@manuscripts/examples": "^0.0.7",
|
|
66
|
-
"@manuscripts/manuscript-transform": "^0.48.
|
|
66
|
+
"@manuscripts/manuscript-transform": "^0.48.19",
|
|
67
67
|
"@manuscripts/manuscripts-json-schema": "^1.49.11",
|
|
68
68
|
"@manuscripts/publish": "^0.2.2",
|
|
69
69
|
"@storybook/addon-actions": "^5.3.14",
|