@manuscripts/style-guide 0.31.16 → 0.31.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/FileManager/FileManager.js +4 -9
- package/dist/cjs/components/FileManager/FileSectionState.js +4 -3
- package/dist/cjs/components/FileManager/FilesSection.js +7 -0
- package/dist/es/components/FileManager/FileManager.js +4 -9
- package/dist/es/components/FileManager/FileSectionState.js +4 -3
- package/dist/es/components/FileManager/FilesSection.js +7 -0
- package/dist/types/components/FileManager/FileSectionState.d.ts +1 -1
- package/package.json +1 -1
|
@@ -36,7 +36,6 @@ const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
|
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const react_tooltip_1 = __importDefault(require("react-tooltip"));
|
|
38
38
|
const inlineFiles_1 = __importStar(require("../../lib/inlineFiles"));
|
|
39
|
-
const AlertMessage_1 = require("../AlertMessage");
|
|
40
39
|
const Inspector_1 = require("../Inspector");
|
|
41
40
|
const InspectorSection_1 = require("../InspectorSection");
|
|
42
41
|
const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
|
|
@@ -55,6 +54,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
55
54
|
dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
|
|
56
55
|
const res = yield replace(attachmentId, name, file, typeId);
|
|
57
56
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
57
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
58
58
|
return res;
|
|
59
59
|
}), [replace]);
|
|
60
60
|
const handleUploadFile = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -64,6 +64,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
64
64
|
}
|
|
65
65
|
const res = yield upload(file, designation);
|
|
66
66
|
dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
|
|
67
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
67
68
|
return res;
|
|
68
69
|
}), [upload]);
|
|
69
70
|
const handleUploadFileWithSupplement = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -77,7 +78,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
77
78
|
const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
79
|
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
79
80
|
if (res) {
|
|
80
|
-
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE());
|
|
81
|
+
dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(''));
|
|
81
82
|
}
|
|
82
83
|
return res;
|
|
83
84
|
}), [changeDesignation]);
|
|
@@ -139,9 +140,6 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
139
140
|
});
|
|
140
141
|
return filesItems;
|
|
141
142
|
};
|
|
142
|
-
const handleSuccessMessage = () => {
|
|
143
|
-
return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.info, hideCloseButton: false }, state.successMessage));
|
|
144
|
-
};
|
|
145
143
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
146
144
|
react_1.default.createElement(DragLayer_1.DragLayer, null),
|
|
147
145
|
react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
|
|
@@ -169,9 +167,6 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
|
|
|
169
167
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
170
168
|
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: util_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(util_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
171
169
|
react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
|
|
172
|
-
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))
|
|
173
|
-
state.isShowSuccessMessage &&
|
|
174
|
-
state.successMessage !== '' &&
|
|
175
|
-
handleSuccessMessage()));
|
|
170
|
+
react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: util_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(util_1.FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
|
|
176
171
|
};
|
|
177
172
|
exports.FileManager = FileManager;
|
|
@@ -36,7 +36,7 @@ const reducer = (state, action) => {
|
|
|
36
36
|
return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
|
|
37
37
|
}
|
|
38
38
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
39
|
-
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true });
|
|
39
|
+
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
40
40
|
}
|
|
41
41
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
42
42
|
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
|
|
@@ -45,7 +45,7 @@ const reducer = (state, action) => {
|
|
|
45
45
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
46
46
|
}
|
|
47
47
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
48
|
-
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
48
|
+
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage });
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
return state;
|
|
@@ -75,7 +75,8 @@ exports.actions = {
|
|
|
75
75
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
76
76
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
77
77
|
}),
|
|
78
|
-
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
78
|
+
HANDLE_SUCCESS_MESSAGE: (successMessage) => ({
|
|
79
79
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
80
|
+
successMessage,
|
|
80
81
|
}),
|
|
81
82
|
};
|
|
@@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.FilesSection = void 0;
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
|
+
const AlertMessage_1 = require("../AlertMessage");
|
|
24
25
|
const DragItemArea_1 = require("./DragItemArea");
|
|
25
26
|
const FileManager_1 = require("./FileManager");
|
|
26
27
|
const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
|
|
@@ -42,12 +43,18 @@ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem,
|
|
|
42
43
|
handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
|
|
43
44
|
};
|
|
44
45
|
const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
|
|
46
|
+
const handleSuccessMessage = () => {
|
|
47
|
+
return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.success, hideCloseButton: true, dismissButton: { text: 'OK' } }, state.successMessage));
|
|
48
|
+
};
|
|
45
49
|
return (react_1.default.createElement("div", null,
|
|
46
50
|
(can === null || can === void 0 ? void 0 : can.uploadFile) && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
47
51
|
(isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
|
|
48
52
|
state.isUploadFile &&
|
|
49
53
|
state.uploadedFile &&
|
|
50
54
|
state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
55
|
+
state.isShowSuccessMessage &&
|
|
56
|
+
state.successMessage !== '' &&
|
|
57
|
+
handleSuccessMessage(),
|
|
51
58
|
state.uploadedFile && isOtherFileTab && (react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
52
59
|
dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
|
|
53
60
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -11,7 +11,6 @@ import { buildSupplementaryMaterial, } from '@manuscripts/manuscript-transform';
|
|
|
11
11
|
import React, { createContext, useCallback, useMemo, useReducer } from 'react';
|
|
12
12
|
import ReactTooltip from 'react-tooltip';
|
|
13
13
|
import getInlineFiles, { getSupplementFiles } from '../../lib/inlineFiles';
|
|
14
|
-
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
15
14
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
16
15
|
import { InspectorSection } from '../InspectorSection';
|
|
17
16
|
import { DraggableFileSectionItem } from './FileSectionItem/DraggableFileSectionItem';
|
|
@@ -30,6 +29,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
30
29
|
dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
|
|
31
30
|
const res = yield replace(attachmentId, name, file, typeId);
|
|
32
31
|
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
32
|
+
dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
33
33
|
return res;
|
|
34
34
|
}), [replace]);
|
|
35
35
|
const handleUploadFile = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -39,6 +39,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
39
39
|
}
|
|
40
40
|
const res = yield upload(file, designation);
|
|
41
41
|
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
42
|
+
dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
42
43
|
return res;
|
|
43
44
|
}), [upload]);
|
|
44
45
|
const handleUploadFileWithSupplement = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -52,7 +53,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
52
53
|
const handleChangeDesignationFile = useCallback((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
54
|
const res = yield changeDesignation(attachmentId, typeId, name);
|
|
54
55
|
if (res) {
|
|
55
|
-
dispatch(actions.HANDLE_SUCCESS_MESSAGE());
|
|
56
|
+
dispatch(actions.HANDLE_SUCCESS_MESSAGE(''));
|
|
56
57
|
}
|
|
57
58
|
return res;
|
|
58
59
|
}), [changeDesignation]);
|
|
@@ -114,9 +115,6 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
114
115
|
});
|
|
115
116
|
return filesItems;
|
|
116
117
|
};
|
|
117
|
-
const handleSuccessMessage = () => {
|
|
118
|
-
return (React.createElement(AlertMessage, { type: AlertMessageType.info, hideCloseButton: false }, state.successMessage));
|
|
119
|
-
};
|
|
120
118
|
return (React.createElement(React.Fragment, null,
|
|
121
119
|
React.createElement(DragLayer, null),
|
|
122
120
|
React.createElement(PermissionsContext.Provider, { value: can },
|
|
@@ -144,8 +142,5 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
|
|
|
144
142
|
React.createElement(InspectorTabPanel, null,
|
|
145
143
|
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: FileSectionType.Supplements, filesItem: getFileSectionExternalFile(FileSectionType.Supplements), state: state, dispatch: dispatch })),
|
|
146
144
|
React.createElement(InspectorTabPanel, null,
|
|
147
|
-
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))
|
|
148
|
-
state.isShowSuccessMessage &&
|
|
149
|
-
state.successMessage !== '' &&
|
|
150
|
-
handleSuccessMessage()));
|
|
145
|
+
React.createElement(FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(FileSectionType.OtherFile), state: state, dispatch: dispatch }))))))));
|
|
151
146
|
};
|
|
@@ -32,7 +32,7 @@ export const reducer = (state, action) => {
|
|
|
32
32
|
return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
|
|
33
33
|
}
|
|
34
34
|
case ActionTypes.HANDLE_UPLOAD_ACTION: {
|
|
35
|
-
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true });
|
|
35
|
+
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
|
|
36
36
|
}
|
|
37
37
|
case ActionTypes.HANDLE_CANCEL_UPLOAD: {
|
|
38
38
|
return Object.assign(Object.assign({}, state), { isOpenSelectDesignationPopup: false });
|
|
@@ -41,7 +41,7 @@ export const reducer = (state, action) => {
|
|
|
41
41
|
return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
|
|
42
42
|
}
|
|
43
43
|
case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
|
|
44
|
-
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true });
|
|
44
|
+
return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage });
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return state;
|
|
@@ -70,7 +70,8 @@ export const actions = {
|
|
|
70
70
|
HANDLE_FINISH_UPLOAD: () => ({
|
|
71
71
|
type: ActionTypes.HANDLE_FINISH_UPLOAD,
|
|
72
72
|
}),
|
|
73
|
-
HANDLE_SUCCESS_MESSAGE: () => ({
|
|
73
|
+
HANDLE_SUCCESS_MESSAGE: (successMessage) => ({
|
|
74
74
|
type: ActionTypes.HANDLE_SUCCESS_MESSAGE,
|
|
75
|
+
successMessage,
|
|
75
76
|
}),
|
|
76
77
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
+
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
2
3
|
import { DragItemArea } from './DragItemArea';
|
|
3
4
|
import { PermissionsContext } from './FileManager';
|
|
4
5
|
import { FileSectionUploadItem } from './FileSectionItem/FileSectionUploadItem';
|
|
@@ -20,12 +21,18 @@ export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, fil
|
|
|
20
21
|
handleUpload(state.uploadedFile, getDesignationName(state.selectDesignation));
|
|
21
22
|
};
|
|
22
23
|
const can = useContext(PermissionsContext);
|
|
24
|
+
const handleSuccessMessage = () => {
|
|
25
|
+
return (React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: { text: 'OK' } }, state.successMessage));
|
|
26
|
+
};
|
|
23
27
|
return (React.createElement("div", null,
|
|
24
28
|
(can === null || can === void 0 ? void 0 : can.uploadFile) && (React.createElement(React.Fragment, null,
|
|
25
29
|
(isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
|
|
26
30
|
state.isUploadFile &&
|
|
27
31
|
state.uploadedFile &&
|
|
28
32
|
state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
|
|
33
|
+
state.isShowSuccessMessage &&
|
|
34
|
+
state.successMessage !== '' &&
|
|
35
|
+
handleSuccessMessage(),
|
|
29
36
|
state.uploadedFile && isOtherFileTab && (React.createElement(SelectDialogDesignation, { isOpen: state.isOpenSelectDesignationPopup, fileExtension: uploadedFileExtension, handleCancel: () => {
|
|
30
37
|
dispatch(actions.HANDLE_CANCEL_UPLOAD());
|
|
31
38
|
}, uploadFileHandler: () => handleUploadOtherFile(), dispatch: dispatch, fileSection: fileSection })),
|
|
@@ -33,6 +33,6 @@ export declare const actions: {
|
|
|
33
33
|
SELECT_DESIGNATION: (designation: Designation) => Action;
|
|
34
34
|
MOVE_FILE: (attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
35
35
|
HANDLE_FINISH_UPLOAD: () => Action;
|
|
36
|
-
HANDLE_SUCCESS_MESSAGE: () => Action;
|
|
36
|
+
HANDLE_SUCCESS_MESSAGE: (successMessage: string) => Action;
|
|
37
37
|
};
|
|
38
38
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.17",
|
|
5
5
|
"repository": "gitlab:atypon-opensource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|