@manuscripts/style-guide 1.1.2 → 1.1.4-LEAN-2192
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/EditorHeader/EditorHeader.js +2 -2
- package/dist/cjs/components/EditorHeader/ProceedView.js +5 -5
- package/dist/cjs/components/FileManager/FileManager.js +7 -0
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +3 -3
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +3 -3
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +6 -1
- package/dist/cjs/components/FileManager/InlineFilesSection.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/lib/capabilities.js +13 -15
- package/dist/es/components/EditorHeader/EditorHeader.js +2 -2
- package/dist/es/components/EditorHeader/ProceedView.js +5 -5
- package/dist/es/components/FileManager/FileManager.js +8 -1
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +3 -3
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +3 -3
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +7 -2
- package/dist/es/components/FileManager/InlineFilesSection.js +2 -2
- package/dist/es/index.js +1 -1
- package/dist/es/lib/capabilities.js +11 -13
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +1 -1
- package/dist/types/components/EditorHeader/ProceedView.d.ts +1 -1
- package/dist/types/components/FileManager/FileManager.d.ts +5 -5
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +1 -1
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +7 -4
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +5 -2
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -3
- package/dist/types/components/FileManager/util.d.ts +3 -3
- package/dist/types/hooks/use-files.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/capabilities.d.ts +3 -4
- package/dist/types/lib/inlineFiles.d.ts +3 -3
- package/package.json +2 -2
- /package/dist/cjs/lib/{lw-errors-decoder.js → errors-decoder.js} +0 -0
- /package/dist/es/lib/{lw-errors-decoder.js → errors-decoder.js} +0 -0
- /package/dist/types/lib/{lw-errors-decoder.d.ts → errors-decoder.d.ts} +0 -0
|
@@ -49,7 +49,7 @@ const MapUserRole = {
|
|
|
49
49
|
Viewer: { label: 'Reading...', icon: __1.ReadingIcon },
|
|
50
50
|
};
|
|
51
51
|
const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
|
|
52
|
-
var _a, _b, _c;
|
|
52
|
+
var _a, _b, _c, _d;
|
|
53
53
|
const [confirmationDialog, toggleConfirmationDialog] = (0, react_1.useState)(false);
|
|
54
54
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
55
55
|
const [noteValue, setNoteValue] = (0, react_1.useState)('');
|
|
@@ -95,7 +95,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
|
|
|
95
95
|
react_1.default.createElement("span", null, "Dashboard"))),
|
|
96
96
|
handleSnapshot &&
|
|
97
97
|
typeof hasPendingSuggestions == 'boolean' &&
|
|
98
|
-
submission.
|
|
98
|
+
submission.previousStep && (react_1.default.createElement(ProceedView_1.ProceedView, { isAnnotator: isAnnotator, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, loading: loading, showComplete: showComplete, noteValue: noteValue, currentStepTransition: currentStepTransition, error: error, currentStepType: submission.currentStep.type, previousStepType: (_d = submission.previousStep) === null || _d === void 0 ? void 0 : _d.type, confirmationDialog: confirmationDialog, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
|
|
99
99
|
status && (react_1.default.createElement(ChildWrapper, null,
|
|
100
100
|
react_1.default.createElement(__1.SaveStatus, { status: status }))),
|
|
101
101
|
react_1.default.createElement(Spacer, null),
|
|
@@ -46,7 +46,7 @@ const StepDetails = ({ icon, label, description, role }) => (react_1.default.cre
|
|
|
46
46
|
react_1.default.createElement(__1.SecondarySmallText, null,
|
|
47
47
|
"Actor: ",
|
|
48
48
|
role.label))));
|
|
49
|
-
const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog,
|
|
49
|
+
const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog, currentStepType, previousStepType, isAnnotator, hasPendingSuggestions, error, noteValue, onNoteChange, onCancelClick, continueDialogAction, message: Message, }) => {
|
|
50
50
|
const dialogMessages = (0, react_1.useMemo)(() => hasPendingSuggestions && !isAnnotator
|
|
51
51
|
? {
|
|
52
52
|
header: 'The task can not be transitioned to the next step',
|
|
@@ -62,7 +62,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
62
62
|
: showComplete
|
|
63
63
|
? {
|
|
64
64
|
header: 'Content reassigned successfully',
|
|
65
|
-
message: `to the ${
|
|
65
|
+
message: `to the ${currentStepType.label}`,
|
|
66
66
|
actions: {
|
|
67
67
|
primary: {
|
|
68
68
|
action: onCancelClick,
|
|
@@ -87,7 +87,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
87
87
|
showComplete,
|
|
88
88
|
continueDialogAction,
|
|
89
89
|
onCancelClick,
|
|
90
|
-
|
|
90
|
+
currentStepType,
|
|
91
91
|
hasPendingSuggestions,
|
|
92
92
|
isAnnotator,
|
|
93
93
|
]);
|
|
@@ -100,10 +100,10 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loadin
|
|
|
100
100
|
(loading && (react_1.default.createElement(__1.LoadingOverlay, null,
|
|
101
101
|
react_1.default.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026")))) || (react_1.default.createElement(__1.Dialog, { isOpen: confirmationDialog && !loading, category: __1.Category.confirmation, header: dialogMessages.header, message: dialogMessages.message, actions: dialogMessages.actions },
|
|
102
102
|
(showComplete && (react_1.default.createElement(Grid, null,
|
|
103
|
-
react_1.default.createElement(StepDetails, Object.assign({},
|
|
103
|
+
react_1.default.createElement(StepDetails, Object.assign({}, previousStepType, { icon: react_1.default.createElement(react_1.default.Fragment, null,
|
|
104
104
|
react_1.default.createElement(__1.TaskStepDoneIcon, null),
|
|
105
105
|
react_1.default.createElement(Line, null)) })),
|
|
106
|
-
react_1.default.createElement(StepDetails, Object.assign({},
|
|
106
|
+
react_1.default.createElement(StepDetails, Object.assign({}, currentStepType))))) ||
|
|
107
107
|
((!hasPendingSuggestions || isAnnotator) && onNoteChange && (react_1.default.createElement(TextAreaWrapper, null,
|
|
108
108
|
react_1.default.createElement(EditorHeader_1.MediumTextArea, { value: noteValue, onChange: onNoteChange, rows: 5, placeholder: 'Add any additional comment here...' })))),
|
|
109
109
|
error && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, error))))));
|
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.FileManager = exports.PermissionsContext = void 0;
|
|
39
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
39
40
|
const transform_1 = require("@manuscripts/transform");
|
|
40
41
|
const react_1 = __importStar(require("react"));
|
|
41
42
|
const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
@@ -87,6 +88,10 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
87
88
|
}
|
|
88
89
|
return response;
|
|
89
90
|
}), [upload, saveModel]);
|
|
91
|
+
const handleSupplementReplace = (0, react_1.useCallback)((attachment, oldAttachmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
const model = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
|
|
93
|
+
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
94
|
+
}), [modelMap, saveModel]);
|
|
90
95
|
const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
96
|
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
92
97
|
if (res) {
|
|
@@ -122,6 +127,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
122
127
|
const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
|
|
123
128
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
124
129
|
const itemProps = {
|
|
130
|
+
fileSection,
|
|
125
131
|
externalFile: element.externalFile,
|
|
126
132
|
title: element.title,
|
|
127
133
|
showAttachmentName: isSupplementOrOtherFilesTab,
|
|
@@ -129,6 +135,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
129
135
|
showReplaceAction: !isOtherFilesTab,
|
|
130
136
|
handleDownload,
|
|
131
137
|
handleReplace: handleReplaceFile,
|
|
138
|
+
handleSupplementReplace,
|
|
132
139
|
handleChangeDesignation: handleChangeDesignationFile,
|
|
133
140
|
dispatch: dispatch,
|
|
134
141
|
};
|
|
@@ -31,11 +31,11 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const FileManager_1 = require("../FileManager");
|
|
33
33
|
const DesignationActions_1 = require("./DesignationActions");
|
|
34
|
-
const FileInfo = ({ showAttachmentName, showDesignationActions, title,
|
|
35
|
-
const fileName =
|
|
34
|
+
const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
|
|
35
|
+
const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
|
|
36
36
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
37
37
|
return (react_1.default.createElement(exports.FileInfoContainer, null,
|
|
38
|
-
showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName:
|
|
38
|
+
showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
|
|
39
39
|
react_1.default.createElement(exports.FileNameTitleContainer, null,
|
|
40
40
|
react_1.default.createElement(exports.FileTitle, null,
|
|
41
41
|
!showAttachmentName ? fileName : title,
|
|
@@ -14,7 +14,7 @@ const util_1 = require("../util");
|
|
|
14
14
|
const FileInfo_1 = require("./FileInfo");
|
|
15
15
|
const FileTypeIcon_1 = require("./FileTypeIcon");
|
|
16
16
|
const ItemActions_1 = require("./ItemActions");
|
|
17
|
-
const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
17
|
+
const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
18
18
|
const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
|
|
19
19
|
const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
|
|
20
20
|
const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
|
|
@@ -29,7 +29,7 @@ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, show
|
|
|
29
29
|
}
|
|
30
30
|
} },
|
|
31
31
|
react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
|
|
32
|
-
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions,
|
|
32
|
+
react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
|
|
33
33
|
onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
|
|
34
34
|
e.preventDefault();
|
|
35
35
|
onClose();
|
|
@@ -38,7 +38,7 @@ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, show
|
|
|
38
38
|
handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
|
|
39
39
|
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
40
40
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
41
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
41
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
42
42
|
};
|
|
43
43
|
exports.FileSectionItem = FileSectionItem;
|
|
44
44
|
const IconCloseButton = styled_components_1.default.button `
|
|
@@ -39,7 +39,7 @@ const FileManager_1 = require("../FileManager");
|
|
|
39
39
|
const FileSectionState_1 = require("../FileSectionState");
|
|
40
40
|
const ItemsAction_1 = require("../ItemsAction");
|
|
41
41
|
const util_1 = require("../util");
|
|
42
|
-
const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
42
|
+
const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
43
43
|
const attachmentDesignation = designation == undefined ? 'undefined' : designation;
|
|
44
44
|
const attachmentDesignationName = attachmentDesignation !== 'undefined'
|
|
45
45
|
? util_1.namesWithDesignationMap.get(attachmentDesignation)
|
|
@@ -65,6 +65,11 @@ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, deta
|
|
|
65
65
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
|
|
66
66
|
}
|
|
67
67
|
const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
|
|
68
|
+
if (fileSection === util_1.FileSectionType.Supplements &&
|
|
69
|
+
typeof result === 'object' &&
|
|
70
|
+
handleSupplementReplace) {
|
|
71
|
+
handleSupplementReplace(result, attachmentId);
|
|
72
|
+
}
|
|
68
73
|
if (typeof result === 'object' && handleUpdateInline) {
|
|
69
74
|
handleUpdateInline(result);
|
|
70
75
|
}
|
|
@@ -74,7 +74,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
|
|
|
74
74
|
handleDownload && handleReplace && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
|
|
75
75
|
react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace or Detach", "aria-pressed": isOpen },
|
|
76
76
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
77
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
77
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: util_1.FileSectionType.Inline, replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
78
78
|
(attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
|
|
79
79
|
handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
|
|
80
80
|
attachment.modelId &&
|
package/dist/cjs/index.js
CHANGED
|
@@ -76,8 +76,8 @@ Object.defineProperty(exports, "useDeepCompareMemo", { enumerable: true, get: fu
|
|
|
76
76
|
Object.defineProperty(exports, "useDeepCompareCallback", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareCallback; } });
|
|
77
77
|
__exportStar(require("./lib/authors"), exports);
|
|
78
78
|
__exportStar(require("./lib/capabilities"), exports);
|
|
79
|
-
var
|
|
80
|
-
Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(
|
|
79
|
+
var errors_decoder_1 = require("./lib/errors-decoder");
|
|
80
|
+
Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(errors_decoder_1).default; } });
|
|
81
81
|
__exportStar(require("./types"), exports);
|
|
82
82
|
var SelectDialogDesignation_1 = require("./components/FileManager/SelectDialogDesignation");
|
|
83
83
|
Object.defineProperty(exports, "SelectDialogDesignation", { enumerable: true, get: function () { return SelectDialogDesignation_1.SelectDialogDesignation; } });
|
|
@@ -3,23 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CapabilitiesProvider = exports.useCalcPermission = exports.usePermissions = exports.getAllPermitted = exports.
|
|
6
|
+
exports.CapabilitiesProvider = exports.useCalcPermission = exports.usePermissions = exports.getAllPermitted = exports.getCapabilities = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
var A;
|
|
9
9
|
(function (A) {
|
|
10
|
-
A["proceed"] = "proceed";
|
|
11
10
|
A["updateAttachment"] = "update-attachment";
|
|
12
11
|
A["updateDueDate"] = "update-due-date";
|
|
13
12
|
A["addNote"] = "add-note";
|
|
14
13
|
A["setMainManuscript"] = "set-main-manuscript";
|
|
15
14
|
})(A || (A = {}));
|
|
16
|
-
const
|
|
15
|
+
const getCapabilities = (project, profile, role, actions) => {
|
|
17
16
|
const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
18
17
|
const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
19
18
|
const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
20
19
|
const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
21
20
|
const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
22
|
-
const
|
|
21
|
+
const isProdEditor = () => role == 'pe';
|
|
23
22
|
const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
|
|
24
23
|
return {
|
|
25
24
|
handleSuggestion: isOwner() || isEditor() || isWriter(),
|
|
@@ -44,12 +43,11 @@ const getLWCapabilities = (project, profile, lwRole, actions) => {
|
|
|
44
43
|
uploadFile: isOwner() || isEditor() || isWriter(),
|
|
45
44
|
handleQualityReport: isOwner() || isEditor() || isWriter(),
|
|
46
45
|
setMainManuscript: allowed(A.setMainManuscript),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
changeDueDate: isLWProdEditor() && allowed(A.updateDueDate),
|
|
46
|
+
rejectTask: isProdEditor(),
|
|
47
|
+
acceptTask: isProdEditor(),
|
|
48
|
+
resolveOnHoldTask: isProdEditor(),
|
|
49
|
+
putOnHoldTask: isProdEditor(),
|
|
50
|
+
changeDueDate: isProdEditor() && allowed(A.updateDueDate),
|
|
53
51
|
previewAccess: true,
|
|
54
52
|
editNotTracked: false,
|
|
55
53
|
accessEditor: true,
|
|
@@ -59,9 +57,9 @@ const getLWCapabilities = (project, profile, lwRole, actions) => {
|
|
|
59
57
|
shareProject: isOwner(),
|
|
60
58
|
};
|
|
61
59
|
};
|
|
62
|
-
exports.
|
|
60
|
+
exports.getCapabilities = getCapabilities;
|
|
63
61
|
const getAllPermitted = () => {
|
|
64
|
-
const capabilities = (0, exports.
|
|
62
|
+
const capabilities = (0, exports.getCapabilities)();
|
|
65
63
|
const allAllowed = Object.keys(capabilities).reduce((caps, item) => {
|
|
66
64
|
caps[item] = true;
|
|
67
65
|
return caps;
|
|
@@ -69,14 +67,14 @@ const getAllPermitted = () => {
|
|
|
69
67
|
return allAllowed;
|
|
70
68
|
};
|
|
71
69
|
exports.getAllPermitted = getAllPermitted;
|
|
72
|
-
const CapabilitiesContext = react_1.default.createContext((0, exports.
|
|
70
|
+
const CapabilitiesContext = react_1.default.createContext((0, exports.getCapabilities)());
|
|
73
71
|
CapabilitiesContext.displayName = 'CapabilitiesContext';
|
|
74
72
|
const usePermissions = () => {
|
|
75
73
|
return react_1.default.useContext(CapabilitiesContext);
|
|
76
74
|
};
|
|
77
75
|
exports.usePermissions = usePermissions;
|
|
78
|
-
const useCalcPermission = ({ project, profile,
|
|
79
|
-
return (0, exports.
|
|
76
|
+
const useCalcPermission = ({ project, profile, role, permittedActions, }) => {
|
|
77
|
+
return (0, exports.getCapabilities)(project, profile, role, permittedActions);
|
|
80
78
|
};
|
|
81
79
|
exports.useCalcPermission = useCalcPermission;
|
|
82
80
|
const CapabilitiesProvider = (props) => {
|
|
@@ -20,7 +20,7 @@ const MapUserRole = {
|
|
|
20
20
|
Viewer: { label: 'Reading...', icon: ReadingIcon },
|
|
21
21
|
};
|
|
22
22
|
export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
|
|
23
|
-
var _a, _b, _c;
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
24
|
const [confirmationDialog, toggleConfirmationDialog] = useState(false);
|
|
25
25
|
const [loading, setLoading] = useState(false);
|
|
26
26
|
const [noteValue, setNoteValue] = useState('');
|
|
@@ -66,7 +66,7 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
|
|
|
66
66
|
React.createElement("span", null, "Dashboard"))),
|
|
67
67
|
handleSnapshot &&
|
|
68
68
|
typeof hasPendingSuggestions == 'boolean' &&
|
|
69
|
-
submission.
|
|
69
|
+
submission.previousStep && (React.createElement(ProceedView, { isAnnotator: isAnnotator, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, loading: loading, showComplete: showComplete, noteValue: noteValue, currentStepTransition: currentStepTransition, error: error, currentStepType: submission.currentStep.type, previousStepType: (_d = submission.previousStep) === null || _d === void 0 ? void 0 : _d.type, confirmationDialog: confirmationDialog, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
|
|
70
70
|
status && (React.createElement(ChildWrapper, null,
|
|
71
71
|
React.createElement(SaveStatus, { status: status }))),
|
|
72
72
|
React.createElement(Spacer, null),
|
|
@@ -17,7 +17,7 @@ const StepDetails = ({ icon, label, description, role }) => (React.createElement
|
|
|
17
17
|
React.createElement(SecondarySmallText, null,
|
|
18
18
|
"Actor: ",
|
|
19
19
|
role.label))));
|
|
20
|
-
export const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog,
|
|
20
|
+
export const ProceedView = ({ currentStepTransition, onTransitionClick, disable, loading, showComplete, confirmationDialog, currentStepType, previousStepType, isAnnotator, hasPendingSuggestions, error, noteValue, onNoteChange, onCancelClick, continueDialogAction, message: Message, }) => {
|
|
21
21
|
const dialogMessages = useMemo(() => hasPendingSuggestions && !isAnnotator
|
|
22
22
|
? {
|
|
23
23
|
header: 'The task can not be transitioned to the next step',
|
|
@@ -33,7 +33,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
|
|
|
33
33
|
: showComplete
|
|
34
34
|
? {
|
|
35
35
|
header: 'Content reassigned successfully',
|
|
36
|
-
message: `to the ${
|
|
36
|
+
message: `to the ${currentStepType.label}`,
|
|
37
37
|
actions: {
|
|
38
38
|
primary: {
|
|
39
39
|
action: onCancelClick,
|
|
@@ -58,7 +58,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
|
|
|
58
58
|
showComplete,
|
|
59
59
|
continueDialogAction,
|
|
60
60
|
onCancelClick,
|
|
61
|
-
|
|
61
|
+
currentStepType,
|
|
62
62
|
hasPendingSuggestions,
|
|
63
63
|
isAnnotator,
|
|
64
64
|
]);
|
|
@@ -71,10 +71,10 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
|
|
|
71
71
|
(loading && (React.createElement(LoadingOverlay, null,
|
|
72
72
|
React.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026")))) || (React.createElement(Dialog, { isOpen: confirmationDialog && !loading, category: Category.confirmation, header: dialogMessages.header, message: dialogMessages.message, actions: dialogMessages.actions },
|
|
73
73
|
(showComplete && (React.createElement(Grid, null,
|
|
74
|
-
React.createElement(StepDetails, Object.assign({},
|
|
74
|
+
React.createElement(StepDetails, Object.assign({}, previousStepType, { icon: React.createElement(React.Fragment, null,
|
|
75
75
|
React.createElement(TaskStepDoneIcon, null),
|
|
76
76
|
React.createElement(Line, null)) })),
|
|
77
|
-
React.createElement(StepDetails, Object.assign({},
|
|
77
|
+
React.createElement(StepDetails, Object.assign({}, currentStepType))))) ||
|
|
78
78
|
((!hasPendingSuggestions || isAnnotator) && onNoteChange && (React.createElement(TextAreaWrapper, null,
|
|
79
79
|
React.createElement(MediumTextArea, { value: noteValue, onChange: onNoteChange, rows: 5, placeholder: 'Add any additional comment here...' })))),
|
|
80
80
|
error && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, error))))));
|
|
@@ -7,7 +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 {
|
|
10
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
11
|
+
import { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/transform';
|
|
11
12
|
import React, { createContext, useCallback, useReducer } from 'react';
|
|
12
13
|
import ReactTooltip from 'react-tooltip';
|
|
13
14
|
import { FileSectionType, useFiles } from '../../index';
|
|
@@ -58,6 +59,10 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
58
59
|
}
|
|
59
60
|
return response;
|
|
60
61
|
}), [upload, saveModel]);
|
|
62
|
+
const handleSupplementReplace = useCallback((attachment, oldAttachmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
const model = getModelsByType(modelMap, ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
|
|
64
|
+
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
65
|
+
}), [modelMap, saveModel]);
|
|
61
66
|
const handleChangeDesignationFile = useCallback((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
67
|
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
63
68
|
if (res) {
|
|
@@ -93,6 +98,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
93
98
|
const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
|
|
94
99
|
const filesItems = itemsDataWithTitle.map((element) => {
|
|
95
100
|
const itemProps = {
|
|
101
|
+
fileSection,
|
|
96
102
|
externalFile: element.externalFile,
|
|
97
103
|
title: element.title,
|
|
98
104
|
showAttachmentName: isSupplementOrOtherFilesTab,
|
|
@@ -100,6 +106,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
100
106
|
showReplaceAction: !isOtherFilesTab,
|
|
101
107
|
handleDownload,
|
|
102
108
|
handleReplace: handleReplaceFile,
|
|
109
|
+
handleSupplementReplace,
|
|
103
110
|
handleChangeDesignation: handleChangeDesignationFile,
|
|
104
111
|
dispatch: dispatch,
|
|
105
112
|
};
|
|
@@ -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,
|
|
6
|
-
const fileName =
|
|
5
|
+
export const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
|
|
6
|
+
const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
|
|
7
7
|
const can = useContext(PermissionsContext);
|
|
8
8
|
return (React.createElement(FileInfoContainer, null,
|
|
9
|
-
showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName:
|
|
9
|
+
showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, 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 = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
|
|
11
|
+
export const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, handleSupplementReplace, 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,7 +23,7 @@ export const FileSectionItem = ({ externalFile, title, showAttachmentName = fals
|
|
|
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,
|
|
26
|
+
React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: 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();
|
|
@@ -32,7 +32,7 @@ export const FileSectionItem = ({ externalFile, title, showAttachmentName = fals
|
|
|
32
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, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
35
|
+
isOpen && (React.createElement(ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, 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;
|
|
@@ -12,8 +12,8 @@ import { DropdownList } from '../../Dropdown';
|
|
|
12
12
|
import { PermissionsContext } from '../FileManager';
|
|
13
13
|
import { actions } from '../FileSectionState';
|
|
14
14
|
import { ActionsItem } from '../ItemsAction';
|
|
15
|
-
import { Designation, namesWithDesignationMap } from '../util';
|
|
16
|
-
export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
15
|
+
import { Designation, FileSectionType, namesWithDesignationMap } from '../util';
|
|
16
|
+
export const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, 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)
|
|
@@ -39,6 +39,11 @@ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandle
|
|
|
39
39
|
dispatch(actions.SELECT_DESIGNATION(attachmentDesignationName || Designation.Document));
|
|
40
40
|
}
|
|
41
41
|
const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
|
|
42
|
+
if (fileSection === FileSectionType.Supplements &&
|
|
43
|
+
typeof result === 'object' &&
|
|
44
|
+
handleSupplementReplace) {
|
|
45
|
+
handleSupplementReplace(result, attachmentId);
|
|
46
|
+
}
|
|
42
47
|
if (typeof result === 'object' && handleUpdateInline) {
|
|
43
48
|
handleUpdateInline(result);
|
|
44
49
|
}
|
|
@@ -5,7 +5,7 @@ import DotsIcon from '../icons/dots-icon';
|
|
|
5
5
|
import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
|
|
6
6
|
import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
|
|
7
7
|
import { ItemActions } from './FileSectionItem/ItemActions';
|
|
8
|
-
import { extensionsWithFileTypesMap, fileTypesWithIconMap, } from './util';
|
|
8
|
+
import { extensionsWithFileTypesMap, FileSectionType, fileTypesWithIconMap, } from './util';
|
|
9
9
|
const trackedJoint = ':dataTracked:';
|
|
10
10
|
export const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, handleDetachFile, inlineFiles, isEditor, dispatch, }) => {
|
|
11
11
|
const onElementClick = useCallback((e) => {
|
|
@@ -44,7 +44,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
|
|
|
44
44
|
handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
45
45
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace or Detach", "aria-pressed": isOpen },
|
|
46
46
|
React.createElement(DotsIcon, null)),
|
|
47
|
-
isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
47
|
+
isOpen && (React.createElement(ItemActions, { fileSection: FileSectionType.Inline, replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
|
|
48
48
|
(attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
|
|
49
49
|
handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
|
|
50
50
|
attachment.modelId &&
|
package/dist/es/index.js
CHANGED
|
@@ -53,7 +53,7 @@ export { useFiles } from './hooks/use-files';
|
|
|
53
53
|
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
54
54
|
export * from './lib/authors';
|
|
55
55
|
export * from './lib/capabilities';
|
|
56
|
-
export { default as errorsDecoder } from './lib/
|
|
56
|
+
export { default as errorsDecoder } from './lib/errors-decoder';
|
|
57
57
|
export * from './types';
|
|
58
58
|
export { SelectDialogDesignation } from './components/FileManager/SelectDialogDesignation';
|
|
59
59
|
export * from './components/LoadingOverlay';
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
var A;
|
|
3
3
|
(function (A) {
|
|
4
|
-
A["proceed"] = "proceed";
|
|
5
4
|
A["updateAttachment"] = "update-attachment";
|
|
6
5
|
A["updateDueDate"] = "update-due-date";
|
|
7
6
|
A["addNote"] = "add-note";
|
|
8
7
|
A["setMainManuscript"] = "set-main-manuscript";
|
|
9
8
|
})(A || (A = {}));
|
|
10
|
-
export const
|
|
9
|
+
export const getCapabilities = (project, profile, role, actions) => {
|
|
11
10
|
const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
12
11
|
const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
13
12
|
const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
14
13
|
const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
15
14
|
const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
|
|
16
|
-
const
|
|
15
|
+
const isProdEditor = () => role == 'pe';
|
|
17
16
|
const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
|
|
18
17
|
return {
|
|
19
18
|
handleSuggestion: isOwner() || isEditor() || isWriter(),
|
|
@@ -38,12 +37,11 @@ export const getLWCapabilities = (project, profile, lwRole, actions) => {
|
|
|
38
37
|
uploadFile: isOwner() || isEditor() || isWriter(),
|
|
39
38
|
handleQualityReport: isOwner() || isEditor() || isWriter(),
|
|
40
39
|
setMainManuscript: allowed(A.setMainManuscript),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
changeDueDate: isLWProdEditor() && allowed(A.updateDueDate),
|
|
40
|
+
rejectTask: isProdEditor(),
|
|
41
|
+
acceptTask: isProdEditor(),
|
|
42
|
+
resolveOnHoldTask: isProdEditor(),
|
|
43
|
+
putOnHoldTask: isProdEditor(),
|
|
44
|
+
changeDueDate: isProdEditor() && allowed(A.updateDueDate),
|
|
47
45
|
previewAccess: true,
|
|
48
46
|
editNotTracked: false,
|
|
49
47
|
accessEditor: true,
|
|
@@ -54,20 +52,20 @@ export const getLWCapabilities = (project, profile, lwRole, actions) => {
|
|
|
54
52
|
};
|
|
55
53
|
};
|
|
56
54
|
export const getAllPermitted = () => {
|
|
57
|
-
const capabilities =
|
|
55
|
+
const capabilities = getCapabilities();
|
|
58
56
|
const allAllowed = Object.keys(capabilities).reduce((caps, item) => {
|
|
59
57
|
caps[item] = true;
|
|
60
58
|
return caps;
|
|
61
59
|
}, {});
|
|
62
60
|
return allAllowed;
|
|
63
61
|
};
|
|
64
|
-
const CapabilitiesContext = React.createContext(
|
|
62
|
+
const CapabilitiesContext = React.createContext(getCapabilities());
|
|
65
63
|
CapabilitiesContext.displayName = 'CapabilitiesContext';
|
|
66
64
|
export const usePermissions = () => {
|
|
67
65
|
return React.useContext(CapabilitiesContext);
|
|
68
66
|
};
|
|
69
|
-
export const useCalcPermission = ({ project, profile,
|
|
70
|
-
return
|
|
67
|
+
export const useCalcPermission = ({ project, profile, role, permittedActions, }) => {
|
|
68
|
+
return getCapabilities(project, profile, role, permittedActions);
|
|
71
69
|
};
|
|
72
70
|
export const CapabilitiesProvider = (props) => {
|
|
73
71
|
const { can } = props;
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
export type PartialSubmission = {
|
|
4
4
|
id: string;
|
|
5
5
|
currentStep: SubmissionStep;
|
|
6
|
-
|
|
6
|
+
previousStep?: SubmissionStep | null | undefined;
|
|
7
7
|
};
|
|
8
8
|
export type SubmissionStep = {
|
|
9
9
|
type: SubmissionStepType;
|
|
@@ -11,8 +11,8 @@ export declare const ProceedView: React.FC<{
|
|
|
11
11
|
noteValue: string;
|
|
12
12
|
currentStepTransition: SubmissionStepTransition[];
|
|
13
13
|
error: string | undefined;
|
|
14
|
-
nextStepType: SubmissionStepType;
|
|
15
14
|
currentStepType: SubmissionStepType;
|
|
15
|
+
previousStepType: SubmissionStepType;
|
|
16
16
|
confirmationDialog: boolean;
|
|
17
17
|
onCancelClick: () => void;
|
|
18
18
|
continueDialogAction: () => Promise<void>;
|
|
@@ -2,12 +2,12 @@ import { Model } from '@manuscripts/json-schema';
|
|
|
2
2
|
import { Build } from '@manuscripts/transform';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Capabilities } from '../../lib/capabilities';
|
|
5
|
-
import {
|
|
6
|
-
export type Upload = (file: File, designation: string) => Promise<boolean |
|
|
7
|
-
export type Replace = (attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean |
|
|
5
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
6
|
+
export type Upload = (file: File, designation: string) => Promise<boolean | FileAttachment | undefined>;
|
|
7
|
+
export type Replace = (attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean | FileAttachment | undefined>;
|
|
8
8
|
export type ChangeDesignation = (attachmentId: string, typeId: string, name: string) => Promise<boolean>;
|
|
9
9
|
export interface FileManagement {
|
|
10
|
-
getAttachments: () =>
|
|
10
|
+
getAttachments: () => FileAttachment[];
|
|
11
11
|
upload: Upload;
|
|
12
12
|
replace: Replace;
|
|
13
13
|
changeDesignation: ChangeDesignation;
|
|
@@ -19,5 +19,5 @@ export declare const FileManager: React.FC<{
|
|
|
19
19
|
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
20
20
|
enableDragAndDrop: boolean;
|
|
21
21
|
can: Capabilities;
|
|
22
|
-
addAttachmentToState?: (a:
|
|
22
|
+
addAttachmentToState?: (a: FileAttachment) => void;
|
|
23
23
|
}>;
|
|
@@ -6,7 +6,7 @@ export declare const FileInfo: React.FC<{
|
|
|
6
6
|
showAttachmentName: boolean;
|
|
7
7
|
showDesignationActions: boolean;
|
|
8
8
|
title: string;
|
|
9
|
-
|
|
9
|
+
fileAttachmentName: string;
|
|
10
10
|
fileExtension: string;
|
|
11
11
|
designation?: Designation;
|
|
12
12
|
attachmentId: string;
|
|
@@ -3,18 +3,20 @@ import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
|
|
|
3
3
|
import { Maybe } from '../../SubmissionInspector/types';
|
|
4
4
|
import { ChangeDesignation, Replace } from '../FileManager';
|
|
5
5
|
import { Action } from '../FileSectionState';
|
|
6
|
-
|
|
6
|
+
import { FileSectionType } from '../util';
|
|
7
|
+
export type FileAttachment = {
|
|
7
8
|
id: string;
|
|
8
9
|
name: string;
|
|
9
|
-
type:
|
|
10
|
+
type: FileAttachmentType;
|
|
10
11
|
link: string;
|
|
11
12
|
};
|
|
12
|
-
export type
|
|
13
|
+
export type FileAttachmentType = {
|
|
13
14
|
id: string;
|
|
14
15
|
label?: Maybe<string> | undefined;
|
|
15
16
|
};
|
|
16
17
|
export interface FileSectionItemProps {
|
|
17
|
-
externalFile:
|
|
18
|
+
externalFile: FileAttachment;
|
|
19
|
+
fileSection: FileSectionType;
|
|
18
20
|
title: string;
|
|
19
21
|
showAttachmentName?: boolean;
|
|
20
22
|
showDesignationActions?: boolean;
|
|
@@ -22,6 +24,7 @@ export interface FileSectionItemProps {
|
|
|
22
24
|
showReplaceAction?: boolean;
|
|
23
25
|
handleDownload?: (url: string) => void;
|
|
24
26
|
handleReplace?: Replace;
|
|
27
|
+
handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
|
|
25
28
|
handleChangeDesignation: ChangeDesignation;
|
|
26
29
|
dispatch?: Dispatch<Action>;
|
|
27
30
|
dragRef?: DragElementWrapper<DragSourceOptions>;
|
|
@@ -2,12 +2,15 @@ import React, { Dispatch } from 'react';
|
|
|
2
2
|
import { Maybe } from '../../SubmissionInspector/types';
|
|
3
3
|
import { Replace } from '../FileManager';
|
|
4
4
|
import { Action } from '../FileSectionState';
|
|
5
|
-
import {
|
|
5
|
+
import { FileSectionType } from '../util';
|
|
6
|
+
import { FileAttachment } from './FileSectionItem';
|
|
6
7
|
export declare const ItemActions: React.FC<{
|
|
8
|
+
fileSection: FileSectionType;
|
|
7
9
|
downloadAttachmentHandler: (url: string) => void;
|
|
8
10
|
replaceAttachmentHandler: Replace;
|
|
9
11
|
detachAttachmnetHandler?: () => void;
|
|
10
|
-
handleUpdateInline?: (attachment:
|
|
12
|
+
handleUpdateInline?: (attachment: FileAttachment) => void;
|
|
13
|
+
handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
|
|
11
14
|
attachmentId: string;
|
|
12
15
|
fileName: string;
|
|
13
16
|
designation?: Maybe<string> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Dispatch } from 'react';
|
|
2
2
|
import { Replace } from './FileManager';
|
|
3
|
-
import {
|
|
3
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
4
4
|
import { Action } from './FileSectionState';
|
|
5
5
|
import { FileType } from './util';
|
|
6
6
|
export declare const InlineFilesSection: React.FC<{
|
|
@@ -9,11 +9,11 @@ export declare const InlineFilesSection: React.FC<{
|
|
|
9
9
|
label: string;
|
|
10
10
|
type: FileType;
|
|
11
11
|
caption?: string;
|
|
12
|
-
attachments?:
|
|
12
|
+
attachments?: FileAttachment[];
|
|
13
13
|
}[];
|
|
14
14
|
handleReplace: Replace;
|
|
15
15
|
handleDownload: (url: string) => void;
|
|
16
|
-
handleUpdateInline?: (modelId: string, attachment:
|
|
16
|
+
handleUpdateInline?: (modelId: string, attachment: FileAttachment) => void;
|
|
17
17
|
handleDetachFile?: (attachmentLink: string, modelId: string) => void;
|
|
18
18
|
isEditor: boolean;
|
|
19
19
|
dispatch: Dispatch<Action>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Capabilities } from '../../lib/capabilities';
|
|
2
2
|
import { Maybe } from '../SubmissionInspector/types';
|
|
3
|
-
import {
|
|
3
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
4
4
|
export declare enum FileSectionType {
|
|
5
5
|
Inline = 0,
|
|
6
6
|
Supplements = 1,
|
|
@@ -44,9 +44,9 @@ export declare const designationWithAllowedDesignationsToTransitionMap: Map<Desi
|
|
|
44
44
|
export declare const extensionsWithFileTypesMap: Map<string, FileType>;
|
|
45
45
|
export declare const fileTypesWithTitlesMap: Map<FileType | undefined, string>;
|
|
46
46
|
export declare const fileTypesWithIconMap: Map<FileType | undefined, JSX.Element>;
|
|
47
|
-
export declare const generateAttachmentsTitles: (externalFiles:
|
|
47
|
+
export declare const generateAttachmentsTitles: (externalFiles: FileAttachment[], fileSectionType: FileSectionType) => Array<{
|
|
48
48
|
title: string;
|
|
49
|
-
externalFile:
|
|
49
|
+
externalFile: FileAttachment;
|
|
50
50
|
}>;
|
|
51
51
|
export declare const getDesignationActionsList: (designation: Designation, fileExtension: string) => Array<Designation>;
|
|
52
52
|
export declare const getDesignationName: (designation: Designation) => string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/json-schema';
|
|
2
|
-
import {
|
|
2
|
+
import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
|
|
3
3
|
import { InlineFile } from '../lib/inlineFiles';
|
|
4
4
|
type FilePredicate = (fileName: string) => boolean;
|
|
5
|
-
export declare const useFiles: (modelMap: Map<string, Model>, attachments:
|
|
6
|
-
otherFiles:
|
|
7
|
-
supplementFiles:
|
|
5
|
+
export declare const useFiles: (modelMap: Map<string, Model>, attachments: FileAttachment[], filePredicate?: FilePredicate) => {
|
|
6
|
+
otherFiles: FileAttachment[];
|
|
7
|
+
supplementFiles: FileAttachment[];
|
|
8
8
|
inlineFiles: InlineFile[];
|
|
9
9
|
};
|
|
10
10
|
export default useFiles;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export { useFiles } from './hooks/use-files';
|
|
|
54
54
|
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
55
55
|
export * from './lib/authors';
|
|
56
56
|
export * from './lib/capabilities';
|
|
57
|
-
export { default as errorsDecoder } from './lib/
|
|
57
|
+
export { default as errorsDecoder } from './lib/errors-decoder';
|
|
58
58
|
export * from './types';
|
|
59
59
|
export { SelectDialogDesignation } from './components/FileManager/SelectDialogDesignation';
|
|
60
60
|
export * from './components/LoadingOverlay';
|
|
@@ -24,7 +24,6 @@ export type Capabilities = {
|
|
|
24
24
|
uploadFile: boolean;
|
|
25
25
|
handleQualityReport: boolean;
|
|
26
26
|
setMainManuscript: boolean;
|
|
27
|
-
completeTask: boolean;
|
|
28
27
|
rejectTask: boolean;
|
|
29
28
|
acceptTask: boolean;
|
|
30
29
|
resolveOnHoldTask: boolean;
|
|
@@ -41,14 +40,14 @@ export type Capabilities = {
|
|
|
41
40
|
export interface ProviderProps {
|
|
42
41
|
project?: Project;
|
|
43
42
|
profile?: UserProfileWithAvatar;
|
|
44
|
-
|
|
43
|
+
role?: string;
|
|
45
44
|
permittedActions?: string[];
|
|
46
45
|
children?: React.ReactNode;
|
|
47
46
|
}
|
|
48
|
-
export declare const
|
|
47
|
+
export declare const getCapabilities: (project?: Project, profile?: UserProfileWithAvatar, role?: ProviderProps['role'], actions?: string[]) => Capabilities;
|
|
49
48
|
export declare const getAllPermitted: () => Capabilities;
|
|
50
49
|
export declare const usePermissions: () => Capabilities;
|
|
51
|
-
export declare const useCalcPermission: ({ project, profile,
|
|
50
|
+
export declare const useCalcPermission: ({ project, profile, role, permittedActions, }: ProviderProps) => Capabilities;
|
|
52
51
|
export declare const CapabilitiesProvider: React.FC<{
|
|
53
52
|
can: Capabilities;
|
|
54
53
|
}>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/json-schema';
|
|
2
|
-
import {
|
|
2
|
+
import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
|
|
3
3
|
import { FileType } from '../components/FileManager/util';
|
|
4
4
|
export type InlineFile = {
|
|
5
5
|
id: string;
|
|
6
6
|
label: string;
|
|
7
7
|
type: FileType;
|
|
8
|
-
attachments?:
|
|
8
|
+
attachments?: FileAttachment[];
|
|
9
9
|
};
|
|
10
|
-
declare const _default: (modelMap: Map<string, Model>, attachments:
|
|
10
|
+
declare const _default: (modelMap: Map<string, Model>, attachments: FileAttachment[]) => InlineFile[];
|
|
11
11
|
export default _default;
|
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": "1.1.
|
|
4
|
+
"version": "1.1.4-LEAN-2192",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -144,4 +144,4 @@
|
|
|
144
144
|
"resolutions": {
|
|
145
145
|
"@types/react": "^17.0.2"
|
|
146
146
|
}
|
|
147
|
-
}
|
|
147
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|