@manuscripts/style-guide 1.1.8-LEAN-2457-1 → 1.1.8-LEAN-2158
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/Dropdown.js +1 -1
- package/dist/cjs/components/FileManager/ConfirmationPopUp.js +4 -73
- package/dist/cjs/components/FileManager/FileManager.js +3 -6
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +1 -1
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +3 -12
- package/dist/cjs/components/FileManager/FileSectionState.js +1 -1
- package/dist/cjs/hooks/use-files.js +13 -7
- package/dist/cjs/lib/capabilities.js +0 -1
- package/dist/es/components/Dropdown.js +1 -1
- package/dist/es/components/FileManager/ConfirmationPopUp.js +1 -49
- package/dist/es/components/FileManager/FileManager.js +3 -6
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +1 -1
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +3 -12
- package/dist/es/components/FileManager/FileSectionState.js +1 -1
- package/dist/es/hooks/use-files.js +13 -7
- package/dist/es/lib/capabilities.js +0 -1
- package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +1 -5
- package/dist/types/components/FileManager/FileManager.d.ts +0 -1
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -1
- package/dist/types/lib/capabilities.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/components/FileManager/FileManagerProvider.js +0 -44
- package/dist/es/components/FileManager/FileManagerProvider.js +0 -17
- package/dist/types/components/FileManager/FileManagerProvider.d.ts +0 -25
|
@@ -14,7 +14,7 @@ exports.DropdownList = styled_components_1.default.div `
|
|
|
14
14
|
box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
|
|
15
15
|
background: ${(props) => props.theme.colors.background.primary};
|
|
16
16
|
width: ${(props) => (props.width ? props.width + 'px' : 'auto')};
|
|
17
|
-
${(props) => props.height && `
|
|
17
|
+
${(props) => props.height && `height: ${props.height}px`};
|
|
18
18
|
${(props) => (props.direction === 'right' ? ' right: 0' : 'left : 0')};
|
|
19
19
|
top: ${(props) => props.theme.grid.unit * (props.top || 3)}px;
|
|
20
20
|
position: absolute;
|
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
4
|
};
|
|
34
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
36
|
-
const
|
|
37
|
-
const transform_1 = require("@manuscripts/transform");
|
|
38
|
-
const react_1 = __importStar(require("react"));
|
|
6
|
+
exports.ConfirmationPopUp = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
39
8
|
const Dialog_1 = require("../Dialog");
|
|
40
|
-
const FileManagerProvider_1 = require("./FileManagerProvider");
|
|
41
|
-
const FileSectionState_1 = require("./FileSectionState");
|
|
42
|
-
const util_1 = require("./util");
|
|
43
9
|
const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClose, handleMove }) => {
|
|
44
10
|
return (react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, category: Dialog_1.Category.confirmation, header: popupHeader, message: popUpMessage, actions: {
|
|
45
11
|
primary: {
|
|
@@ -53,38 +19,3 @@ const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClose, han
|
|
|
53
19
|
} }));
|
|
54
20
|
};
|
|
55
21
|
exports.ConfirmationPopUp = ConfirmationPopUp;
|
|
56
|
-
const MoveFilePopup = ({ dispatch, }) => {
|
|
57
|
-
const { moveFilePopup: { isOpen, fileSection, attachmentId }, saveModel, deleteModel, modelMap, getAttachments, setMoveFilePopupData, } = (0, react_1.useContext)(FileManagerProvider_1.FileManagerContext);
|
|
58
|
-
const isSupplement = fileSection === util_1.FileSectionType.Supplements;
|
|
59
|
-
const message = {
|
|
60
|
-
popupHeader: `Are you sure you want to move this file to “${(!isSupplement && 'Supplements') || 'Other files'}”?`,
|
|
61
|
-
popUpMessage: `The file will be removed from the “${(isSupplement && 'Supplements') || 'Other files'}” and added to “${(!isSupplement && 'Supplements') || 'Other files'}”.`,
|
|
62
|
-
};
|
|
63
|
-
const closePopup = (0, react_1.useCallback)(() => setMoveFilePopupData({
|
|
64
|
-
isOpen: false,
|
|
65
|
-
fileSection: fileSection,
|
|
66
|
-
}), [fileSection, setMoveFilePopupData]);
|
|
67
|
-
const showSuccessMessage = (0, react_1.useCallback)(() => dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(`File moved to ${(isSupplement && 'Other files') || 'Supplements'}.`, fileSection)), [dispatch, fileSection, isSupplement]);
|
|
68
|
-
const moveToSupplement = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
closePopup();
|
|
70
|
-
const attachment = getAttachments().find(({ id }) => id === attachmentId);
|
|
71
|
-
if (!attachment) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const model = (0, transform_1.buildSupplementaryMaterial)(attachment.name, `attachment:${attachment.id}`);
|
|
75
|
-
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
76
|
-
showSuccessMessage();
|
|
77
|
-
}), [getAttachments, saveModel, showSuccessMessage, closePopup, attachmentId]);
|
|
78
|
-
const moveSupplementToOtherFiles = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
closePopup();
|
|
80
|
-
const model = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === attachmentId);
|
|
81
|
-
if (!model) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
yield deleteModel(model._id);
|
|
85
|
-
showSuccessMessage();
|
|
86
|
-
}), [attachmentId, closePopup, deleteModel, modelMap, showSuccessMessage]);
|
|
87
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
88
|
-
react_1.default.createElement(exports.ConfirmationPopUp, Object.assign({ isOpen: isOpen }, message, { handleMove: () => (!isSupplement && moveToSupplement()) || moveSupplementToOtherFiles(), handleClose: closePopup }))));
|
|
89
|
-
};
|
|
90
|
-
exports.MoveFilePopup = MoveFilePopup;
|
|
@@ -43,8 +43,6 @@ const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
|
43
43
|
const index_1 = require("../../index");
|
|
44
44
|
const Inspector_1 = require("../Inspector");
|
|
45
45
|
const InspectorSection_1 = require("../InspectorSection");
|
|
46
|
-
const ConfirmationPopUp_1 = require("./ConfirmationPopUp");
|
|
47
|
-
const FileManagerProvider_1 = require("./FileManagerProvider");
|
|
48
46
|
const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
|
|
49
47
|
const DragLayer_1 = require("./FileSectionItem/DragLayer");
|
|
50
48
|
const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
|
|
@@ -54,7 +52,7 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
|
|
|
54
52
|
const TooltipDiv_1 = require("./TooltipDiv");
|
|
55
53
|
const util_1 = require("./util");
|
|
56
54
|
exports.PermissionsContext = (0, react_1.createContext)(null);
|
|
57
|
-
const FileManager = ({ modelMap, saveModel,
|
|
55
|
+
const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
|
|
58
56
|
const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
|
|
59
57
|
const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
58
|
dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -138,7 +136,7 @@ const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDrop, can,
|
|
|
138
136
|
});
|
|
139
137
|
return filesItems;
|
|
140
138
|
};
|
|
141
|
-
return (react_1.default.createElement(
|
|
139
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
142
140
|
react_1.default.createElement(DragLayer_1.DragLayer, null),
|
|
143
141
|
react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
|
|
144
142
|
react_1.default.createElement(InspectorSection_1.InspectorSection, { title: 'Files', contentStyles: { margin: '24px' } },
|
|
@@ -165,7 +163,6 @@ const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDrop, can,
|
|
|
165
163
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
166
164
|
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: index_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(index_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
167
165
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
168
|
-
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: index_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(index_1.FileSectionType.OtherFile), state: state, dispatch: dispatch })))))
|
|
169
|
-
react_1.default.createElement(ConfirmationPopUp_1.MoveFilePopup, { dispatch: dispatch }))));
|
|
166
|
+
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: index_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(index_1.FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
|
|
170
167
|
};
|
|
171
168
|
exports.FileManager = FileManager;
|
|
@@ -36,7 +36,7 @@ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName
|
|
|
36
36
|
handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
|
|
37
37
|
react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
38
38
|
react_1.default.createElement(dots_icon_1.default, null)),
|
|
39
|
-
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection,
|
|
39
|
+
isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
40
40
|
};
|
|
41
41
|
exports.FileSectionItem = FileSectionItem;
|
|
42
42
|
const IconCloseButton = styled_components_1.default.button `
|
|
@@ -36,13 +36,11 @@ exports.ItemActions = void 0;
|
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const Dropdown_1 = require("../../Dropdown");
|
|
38
38
|
const FileManager_1 = require("../FileManager");
|
|
39
|
-
const FileManagerProvider_1 = require("../FileManagerProvider");
|
|
40
39
|
const FileSectionState_1 = require("../FileSectionState");
|
|
41
40
|
const ItemsAction_1 = require("../ItemsAction");
|
|
42
41
|
const util_1 = require("../util");
|
|
43
|
-
const ItemActions = ({ fileSection,
|
|
42
|
+
const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
44
43
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
45
|
-
const { setMoveFilePopupData } = (0, react_1.useContext)(FileManagerProvider_1.FileManagerContext);
|
|
46
44
|
const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
|
|
47
45
|
const fileInputRef = (0, react_1.useRef)(null);
|
|
48
46
|
const [selectedFile, setSelectedFile] = (0, react_1.useState)();
|
|
@@ -73,20 +71,13 @@ const ItemActions = ({ fileSection, isMainManuscript, downloadAttachmentHandler,
|
|
|
73
71
|
fileInputRef.current.click();
|
|
74
72
|
}
|
|
75
73
|
};
|
|
76
|
-
return (react_1.default.createElement(Dropdown_1.DropdownList, { direction: 'right', className: dropDownClassName, width:
|
|
74
|
+
return (react_1.default.createElement(Dropdown_1.DropdownList, { direction: 'right', className: dropDownClassName, width: 125, height: 120, top: 5, onClick: hideActionList },
|
|
77
75
|
react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => {
|
|
78
76
|
publicUrl !== undefined ? downloadAttachmentHandler(publicUrl) : {};
|
|
79
77
|
} }, "Download"),
|
|
80
78
|
(can === null || can === void 0 ? void 0 : can.replaceFile) && canBeReplaced && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
81
79
|
react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: openFileDialog }, "Replace"),
|
|
82
80
|
react_1.default.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' }))),
|
|
83
|
-
(can === null || can === void 0 ? void 0 : can.editArticle) && detachAttachmnetHandler && (react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => detachAttachmnetHandler() }, "Detach"))
|
|
84
|
-
!isMainManuscript &&
|
|
85
|
-
fileSection !== util_1.FileSectionType.Inline &&
|
|
86
|
-
(can === null || can === void 0 ? void 0 : can.moveFile) && (react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => setMoveFilePopupData({ isOpen: true, attachmentId, fileSection }) },
|
|
87
|
-
"Move to",
|
|
88
|
-
' ',
|
|
89
|
-
(fileSection === util_1.FileSectionType.OtherFile && 'Supplements') ||
|
|
90
|
-
'Other files'))));
|
|
81
|
+
(can === null || can === void 0 ? void 0 : can.editArticle) && detachAttachmnetHandler && (react_1.default.createElement(ItemsAction_1.ActionsItem, { onClick: () => detachAttachmnetHandler() }, "Detach"))));
|
|
91
82
|
};
|
|
92
83
|
exports.ItemActions = ItemActions;
|
|
@@ -33,7 +33,7 @@ const reducer = (state, action) => {
|
|
|
33
33
|
}, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
|
|
34
34
|
}
|
|
35
35
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
36
|
-
return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false,
|
|
36
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
37
37
|
}
|
|
38
38
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
39
39
|
return Object.assign({}, state);
|
|
@@ -8,21 +8,27 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
8
8
|
const transform_1 = require("@manuscripts/transform");
|
|
9
9
|
const inlineFiles_1 = __importDefault(require("../lib/inlineFiles"));
|
|
10
10
|
const use_deep_compare_1 = require("./use-deep-compare");
|
|
11
|
-
const
|
|
11
|
+
const getInlineFilesIds = (inlineFiles) => {
|
|
12
|
+
return inlineFiles
|
|
13
|
+
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
14
|
+
.flat();
|
|
15
|
+
};
|
|
16
|
+
const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
|
|
12
17
|
const supplements = new Map((0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
18
|
+
const excludedAttachmentsIds = new Set(getInlineFilesIds(inlineFiles).map(({ id }) => id));
|
|
13
19
|
return attachments.filter((attachment) => {
|
|
14
20
|
if (supplements.has(attachment.id) && filePredicate) {
|
|
15
|
-
return
|
|
21
|
+
return (!excludedAttachmentsIds.has(attachment.id) &&
|
|
22
|
+
filePredicate(attachment.name));
|
|
16
23
|
}
|
|
17
24
|
else {
|
|
18
|
-
return
|
|
25
|
+
return (!excludedAttachmentsIds.has(attachment.id) &&
|
|
26
|
+
supplements.has(attachment.id));
|
|
19
27
|
}
|
|
20
28
|
});
|
|
21
29
|
};
|
|
22
30
|
const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
|
|
23
|
-
const inlineFilesAttachmentIds = inlineFiles
|
|
24
|
-
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
25
|
-
.flat();
|
|
31
|
+
const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
|
|
26
32
|
const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
|
|
27
33
|
return attachments.filter(({ id, name }) => {
|
|
28
34
|
if (!excludedAttachmentsIds.has(id) && filePredicate) {
|
|
@@ -35,7 +41,7 @@ const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate)
|
|
|
35
41
|
};
|
|
36
42
|
const useFiles = (modelMap, attachments, filePredicate) => (0, use_deep_compare_1.useDeepCompareMemo)(() => {
|
|
37
43
|
const inlineFiles = (0, inlineFiles_1.default)(modelMap, attachments);
|
|
38
|
-
const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
|
|
44
|
+
const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
|
|
39
45
|
const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
|
|
40
46
|
return {
|
|
41
47
|
otherFiles,
|
|
@@ -40,7 +40,6 @@ const getCapabilities = (project, profile, role, actions) => {
|
|
|
40
40
|
downloadFiles: true,
|
|
41
41
|
changeDesignation: (isOwner() || isEditor() || isWriter()) &&
|
|
42
42
|
allowed(Actions.updateAttachment),
|
|
43
|
-
moveFile: isOwner() || isEditor() || isWriter(),
|
|
44
43
|
replaceFile: isOwner() || isEditor() || isWriter(),
|
|
45
44
|
uploadFile: isOwner() || isEditor() || isWriter(),
|
|
46
45
|
handleQualityReport: isOwner() || isEditor() || isWriter(),
|
|
@@ -8,7 +8,7 @@ export const DropdownList = styled.div `
|
|
|
8
8
|
box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
|
|
9
9
|
background: ${(props) => props.theme.colors.background.primary};
|
|
10
10
|
width: ${(props) => (props.width ? props.width + 'px' : 'auto')};
|
|
11
|
-
${(props) => props.height && `
|
|
11
|
+
${(props) => props.height && `height: ${props.height}px`};
|
|
12
12
|
${(props) => (props.direction === 'right' ? ' right: 0' : 'left : 0')};
|
|
13
13
|
top: ${(props) => props.theme.grid.unit * (props.top || 3)}px;
|
|
14
14
|
position: absolute;
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
11
|
-
import { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/transform';
|
|
12
|
-
import React, { useCallback, useContext } from 'react';
|
|
1
|
+
import React from 'react';
|
|
13
2
|
import { Category, Dialog } from '../Dialog';
|
|
14
|
-
import { FileManagerContext } from './FileManagerProvider';
|
|
15
|
-
import { actions } from './FileSectionState';
|
|
16
|
-
import { FileSectionType } from './util';
|
|
17
3
|
export const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClose, handleMove }) => {
|
|
18
4
|
return (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: popupHeader, message: popUpMessage, actions: {
|
|
19
5
|
primary: {
|
|
@@ -26,37 +12,3 @@ export const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClo
|
|
|
26
12
|
},
|
|
27
13
|
} }));
|
|
28
14
|
};
|
|
29
|
-
export const MoveFilePopup = ({ dispatch, }) => {
|
|
30
|
-
const { moveFilePopup: { isOpen, fileSection, attachmentId }, saveModel, deleteModel, modelMap, getAttachments, setMoveFilePopupData, } = useContext(FileManagerContext);
|
|
31
|
-
const isSupplement = fileSection === FileSectionType.Supplements;
|
|
32
|
-
const message = {
|
|
33
|
-
popupHeader: `Are you sure you want to move this file to “${(!isSupplement && 'Supplements') || 'Other files'}”?`,
|
|
34
|
-
popUpMessage: `The file will be removed from the “${(isSupplement && 'Supplements') || 'Other files'}” and added to “${(!isSupplement && 'Supplements') || 'Other files'}”.`,
|
|
35
|
-
};
|
|
36
|
-
const closePopup = useCallback(() => setMoveFilePopupData({
|
|
37
|
-
isOpen: false,
|
|
38
|
-
fileSection: fileSection,
|
|
39
|
-
}), [fileSection, setMoveFilePopupData]);
|
|
40
|
-
const showSuccessMessage = useCallback(() => dispatch(actions.HANDLE_SUCCESS_MESSAGE(`File moved to ${(isSupplement && 'Other files') || 'Supplements'}.`, fileSection)), [dispatch, fileSection, isSupplement]);
|
|
41
|
-
const moveToSupplement = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
closePopup();
|
|
43
|
-
const attachment = getAttachments().find(({ id }) => id === attachmentId);
|
|
44
|
-
if (!attachment) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const model = buildSupplementaryMaterial(attachment.name, `attachment:${attachment.id}`);
|
|
48
|
-
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
49
|
-
showSuccessMessage();
|
|
50
|
-
}), [getAttachments, saveModel, showSuccessMessage, closePopup, attachmentId]);
|
|
51
|
-
const moveSupplementToOtherFiles = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
closePopup();
|
|
53
|
-
const model = getModelsByType(modelMap, ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === attachmentId);
|
|
54
|
-
if (!model) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
yield deleteModel(model._id);
|
|
58
|
-
showSuccessMessage();
|
|
59
|
-
}), [attachmentId, closePopup, deleteModel, modelMap, showSuccessMessage]);
|
|
60
|
-
return (React.createElement(React.Fragment, null,
|
|
61
|
-
React.createElement(ConfirmationPopUp, Object.assign({ isOpen: isOpen }, message, { handleMove: () => (!isSupplement && moveToSupplement()) || moveSupplementToOtherFiles(), handleClose: closePopup }))));
|
|
62
|
-
};
|
|
@@ -14,8 +14,6 @@ import ReactTooltip from 'react-tooltip';
|
|
|
14
14
|
import { FileSectionType, useFiles } from '../../index';
|
|
15
15
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
16
16
|
import { InspectorSection } from '../InspectorSection';
|
|
17
|
-
import { MoveFilePopup } from './ConfirmationPopUp';
|
|
18
|
-
import { FileManagerProvider } from './FileManagerProvider';
|
|
19
17
|
import { DraggableFileSectionItem } from './FileSectionItem/DraggableFileSectionItem';
|
|
20
18
|
import { DragLayer } from './FileSectionItem/DragLayer';
|
|
21
19
|
import { FileSectionItem, } from './FileSectionItem/FileSectionItem';
|
|
@@ -25,7 +23,7 @@ import { InlineFilesSection } from './InlineFilesSection';
|
|
|
25
23
|
import { TooltipDiv } from './TooltipDiv';
|
|
26
24
|
import { generateAttachmentsTitles } from './util';
|
|
27
25
|
export const PermissionsContext = createContext(null);
|
|
28
|
-
export const FileManager = ({ modelMap, saveModel,
|
|
26
|
+
export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
|
|
29
27
|
const [state, dispatch] = useReducer(reducer, getInitialState());
|
|
30
28
|
const handleReplaceFile = useCallback((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
29
|
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
@@ -109,7 +107,7 @@ export const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDro
|
|
|
109
107
|
});
|
|
110
108
|
return filesItems;
|
|
111
109
|
};
|
|
112
|
-
return (React.createElement(
|
|
110
|
+
return (React.createElement(React.Fragment, null,
|
|
113
111
|
React.createElement(DragLayer, null),
|
|
114
112
|
React.createElement(PermissionsContext.Provider, { value: can },
|
|
115
113
|
React.createElement(InspectorSection, { title: 'Files', contentStyles: { margin: '24px' } },
|
|
@@ -136,6 +134,5 @@ export const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDro
|
|
|
136
134
|
React.createElement(InspectorTabPanel, null,
|
|
137
135
|
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
138
136
|
React.createElement(InspectorTabPanel, null,
|
|
139
|
-
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch })))))
|
|
140
|
-
React.createElement(MoveFilePopup, { dispatch: dispatch }))));
|
|
137
|
+
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
|
|
141
138
|
};
|
|
@@ -30,7 +30,7 @@ export const FileSectionItem = ({ fileSection, externalFile, title, showAttachme
|
|
|
30
30
|
handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
|
|
31
31
|
React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
|
|
32
32
|
React.createElement(DotsIcon, null)),
|
|
33
|
-
isOpen && (React.createElement(ItemActions, { fileSection: fileSection,
|
|
33
|
+
isOpen && (React.createElement(ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
|
|
34
34
|
};
|
|
35
35
|
const IconCloseButton = styled.button `
|
|
36
36
|
border: none;
|
|
@@ -10,13 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import React, { useContext, useRef, useState, } from 'react';
|
|
11
11
|
import { DropdownList } from '../../Dropdown';
|
|
12
12
|
import { PermissionsContext } from '../FileManager';
|
|
13
|
-
import { FileManagerContext } from '../FileManagerProvider';
|
|
14
13
|
import { actions } from '../FileSectionState';
|
|
15
14
|
import { ActionsItem } from '../ItemsAction';
|
|
16
15
|
import { FileSectionType } from '../util';
|
|
17
|
-
export const ItemActions = ({ fileSection,
|
|
16
|
+
export const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
|
|
18
17
|
const can = useContext(PermissionsContext);
|
|
19
|
-
const { setMoveFilePopupData } = useContext(FileManagerContext);
|
|
20
18
|
const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
|
|
21
19
|
const fileInputRef = useRef(null);
|
|
22
20
|
const [selectedFile, setSelectedFile] = useState();
|
|
@@ -47,19 +45,12 @@ export const ItemActions = ({ fileSection, isMainManuscript, downloadAttachmentH
|
|
|
47
45
|
fileInputRef.current.click();
|
|
48
46
|
}
|
|
49
47
|
};
|
|
50
|
-
return (React.createElement(DropdownList, { direction: 'right', className: dropDownClassName, width:
|
|
48
|
+
return (React.createElement(DropdownList, { direction: 'right', className: dropDownClassName, width: 125, height: 120, top: 5, onClick: hideActionList },
|
|
51
49
|
React.createElement(ActionsItem, { onClick: () => {
|
|
52
50
|
publicUrl !== undefined ? downloadAttachmentHandler(publicUrl) : {};
|
|
53
51
|
} }, "Download"),
|
|
54
52
|
(can === null || can === void 0 ? void 0 : can.replaceFile) && canBeReplaced && (React.createElement(React.Fragment, null,
|
|
55
53
|
React.createElement(ActionsItem, { onClick: openFileDialog }, "Replace"),
|
|
56
54
|
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' }))),
|
|
57
|
-
(can === null || can === void 0 ? void 0 : can.editArticle) && detachAttachmnetHandler && (React.createElement(ActionsItem, { onClick: () => detachAttachmnetHandler() }, "Detach"))
|
|
58
|
-
!isMainManuscript &&
|
|
59
|
-
fileSection !== FileSectionType.Inline &&
|
|
60
|
-
(can === null || can === void 0 ? void 0 : can.moveFile) && (React.createElement(ActionsItem, { onClick: () => setMoveFilePopupData({ isOpen: true, attachmentId, fileSection }) },
|
|
61
|
-
"Move to",
|
|
62
|
-
' ',
|
|
63
|
-
(fileSection === FileSectionType.OtherFile && 'Supplements') ||
|
|
64
|
-
'Other files'))));
|
|
55
|
+
(can === null || can === void 0 ? void 0 : can.editArticle) && detachAttachmnetHandler && (React.createElement(ActionsItem, { onClick: () => detachAttachmnetHandler() }, "Detach"))));
|
|
65
56
|
};
|
|
@@ -29,7 +29,7 @@ export const reducer = (state, action) => {
|
|
|
29
29
|
}, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
|
|
30
30
|
}
|
|
31
31
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
32
|
-
return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false,
|
|
32
|
+
return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
33
33
|
}
|
|
34
34
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
35
35
|
return Object.assign({}, state);
|
|
@@ -2,21 +2,27 @@ import { ObjectTypes } from '@manuscripts/json-schema';
|
|
|
2
2
|
import { getModelsByType } from '@manuscripts/transform';
|
|
3
3
|
import getInlineFiles from '../lib/inlineFiles';
|
|
4
4
|
import { useDeepCompareMemo } from './use-deep-compare';
|
|
5
|
-
const
|
|
5
|
+
const getInlineFilesIds = (inlineFiles) => {
|
|
6
|
+
return inlineFiles
|
|
7
|
+
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
8
|
+
.flat();
|
|
9
|
+
};
|
|
10
|
+
const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
|
|
6
11
|
const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
|
|
12
|
+
const excludedAttachmentsIds = new Set(getInlineFilesIds(inlineFiles).map(({ id }) => id));
|
|
7
13
|
return attachments.filter((attachment) => {
|
|
8
14
|
if (supplements.has(attachment.id) && filePredicate) {
|
|
9
|
-
return
|
|
15
|
+
return (!excludedAttachmentsIds.has(attachment.id) &&
|
|
16
|
+
filePredicate(attachment.name));
|
|
10
17
|
}
|
|
11
18
|
else {
|
|
12
|
-
return
|
|
19
|
+
return (!excludedAttachmentsIds.has(attachment.id) &&
|
|
20
|
+
supplements.has(attachment.id));
|
|
13
21
|
}
|
|
14
22
|
});
|
|
15
23
|
};
|
|
16
24
|
const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
|
|
17
|
-
const inlineFilesAttachmentIds = inlineFiles
|
|
18
|
-
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
19
|
-
.flat();
|
|
25
|
+
const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
|
|
20
26
|
const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
|
|
21
27
|
return attachments.filter(({ id, name }) => {
|
|
22
28
|
if (!excludedAttachmentsIds.has(id) && filePredicate) {
|
|
@@ -29,7 +35,7 @@ const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate)
|
|
|
29
35
|
};
|
|
30
36
|
export const useFiles = (modelMap, attachments, filePredicate) => useDeepCompareMemo(() => {
|
|
31
37
|
const inlineFiles = getInlineFiles(modelMap, attachments);
|
|
32
|
-
const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
|
|
38
|
+
const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
|
|
33
39
|
const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
|
|
34
40
|
return {
|
|
35
41
|
otherFiles,
|
|
@@ -34,7 +34,6 @@ export const getCapabilities = (project, profile, role, actions) => {
|
|
|
34
34
|
downloadFiles: true,
|
|
35
35
|
changeDesignation: (isOwner() || isEditor() || isWriter()) &&
|
|
36
36
|
allowed(Actions.updateAttachment),
|
|
37
|
-
moveFile: isOwner() || isEditor() || isWriter(),
|
|
38
37
|
replaceFile: isOwner() || isEditor() || isWriter(),
|
|
39
38
|
uploadFile: isOwner() || isEditor() || isWriter(),
|
|
40
39
|
handleQualityReport: isOwner() || isEditor() || isWriter(),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { Action } from './FileSectionState';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
export declare const ConfirmationPopUp: React.FC<{
|
|
4
3
|
popupHeader: string;
|
|
5
4
|
popUpMessage: string;
|
|
@@ -7,6 +6,3 @@ export declare const ConfirmationPopUp: React.FC<{
|
|
|
7
6
|
handleClose: () => void;
|
|
8
7
|
handleMove: () => void;
|
|
9
8
|
}>;
|
|
10
|
-
export declare const MoveFilePopup: React.FC<{
|
|
11
|
-
dispatch: Dispatch<Action>;
|
|
12
|
-
}>;
|
|
@@ -15,7 +15,6 @@ export declare const FileManager: React.FC<{
|
|
|
15
15
|
fileManagement: FileManagement;
|
|
16
16
|
modelMap: Map<string, Model>;
|
|
17
17
|
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
18
|
-
deleteModel: (id: string) => Promise<string>;
|
|
19
18
|
enableDragAndDrop: boolean;
|
|
20
19
|
can: Capabilities;
|
|
21
20
|
addAttachmentToState?: (a: FileAttachment) => void;
|
|
@@ -5,7 +5,6 @@ import { FileSectionType } from '../util';
|
|
|
5
5
|
import { FileAttachment } from './FileSectionItem';
|
|
6
6
|
export declare const ItemActions: React.FC<{
|
|
7
7
|
fileSection: FileSectionType;
|
|
8
|
-
isMainManuscript?: boolean;
|
|
9
8
|
downloadAttachmentHandler: (url: string) => void;
|
|
10
9
|
replaceAttachmentHandler: Replace;
|
|
11
10
|
detachAttachmnetHandler?: () => void;
|
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.8-LEAN-
|
|
4
|
+
"version": "1.1.8-LEAN-2158",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FileManagerProvider = exports.FileManagerContext = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
exports.FileManagerContext = (0, react_1.createContext)({
|
|
29
|
-
saveModel: () => '',
|
|
30
|
-
moveFilePopup: { isOpen: false },
|
|
31
|
-
setMoveFilePopupData: () => '',
|
|
32
|
-
});
|
|
33
|
-
const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, getAttachments }) => {
|
|
34
|
-
const [moveFilePopup, setMoveFilePopupData] = (0, react_1.useState)({ isOpen: false });
|
|
35
|
-
return (react_1.default.createElement(exports.FileManagerContext.Provider, { value: {
|
|
36
|
-
saveModel,
|
|
37
|
-
deleteModel,
|
|
38
|
-
modelMap,
|
|
39
|
-
getAttachments,
|
|
40
|
-
moveFilePopup,
|
|
41
|
-
setMoveFilePopupData,
|
|
42
|
-
} }, children));
|
|
43
|
-
};
|
|
44
|
-
exports.FileManagerProvider = FileManagerProvider;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useState } from 'react';
|
|
2
|
-
export const FileManagerContext = createContext({
|
|
3
|
-
saveModel: () => '',
|
|
4
|
-
moveFilePopup: { isOpen: false },
|
|
5
|
-
setMoveFilePopupData: () => '',
|
|
6
|
-
});
|
|
7
|
-
export const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, getAttachments }) => {
|
|
8
|
-
const [moveFilePopup, setMoveFilePopupData] = useState({ isOpen: false });
|
|
9
|
-
return (React.createElement(FileManagerContext.Provider, { value: {
|
|
10
|
-
saveModel,
|
|
11
|
-
deleteModel,
|
|
12
|
-
modelMap,
|
|
13
|
-
getAttachments,
|
|
14
|
-
moveFilePopup,
|
|
15
|
-
setMoveFilePopupData,
|
|
16
|
-
} }, children));
|
|
17
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Model } from '@manuscripts/json-schema';
|
|
2
|
-
import { Build } from '@manuscripts/transform';
|
|
3
|
-
import React, { Dispatch, SetStateAction } from 'react';
|
|
4
|
-
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
5
|
-
import { FileSectionType } from './util';
|
|
6
|
-
type MoveFilePopup = {
|
|
7
|
-
isOpen: boolean;
|
|
8
|
-
fileSection?: FileSectionType;
|
|
9
|
-
attachmentId?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const FileManagerContext: React.Context<{
|
|
12
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
13
|
-
deleteModel: (id: string) => Promise<string>;
|
|
14
|
-
modelMap: Map<string, Model>;
|
|
15
|
-
getAttachments: () => FileAttachment[];
|
|
16
|
-
moveFilePopup: MoveFilePopup;
|
|
17
|
-
setMoveFilePopupData: Dispatch<SetStateAction<MoveFilePopup>>;
|
|
18
|
-
}>;
|
|
19
|
-
export declare const FileManagerProvider: React.FC<{
|
|
20
|
-
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
21
|
-
deleteModel: (id: string) => Promise<string>;
|
|
22
|
-
modelMap: Map<string, Model>;
|
|
23
|
-
getAttachments: () => FileAttachment[];
|
|
24
|
-
}>;
|
|
25
|
-
export {};
|