@manuscripts/style-guide 1.1.4 → 1.1.5-LEAN-2192-v2

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.
Files changed (43) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +8 -20
  2. package/dist/cjs/components/FileManager/FileSectionItem/DragLayer.js +1 -1
  3. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +1 -3
  4. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
  5. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +3 -16
  6. package/dist/cjs/components/FileManager/FileSectionState.js +5 -14
  7. package/dist/cjs/components/FileManager/FilesSection.js +7 -20
  8. package/dist/cjs/components/FileManager/InlineFilesSection.js +1 -1
  9. package/dist/cjs/components/FileManager/util.js +1 -323
  10. package/dist/cjs/index.js +1 -3
  11. package/dist/cjs/lib/capabilities.js +0 -1
  12. package/dist/es/components/FileManager/FileManager.js +9 -21
  13. package/dist/es/components/FileManager/FileSectionItem/DragLayer.js +1 -1
  14. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +1 -3
  15. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
  16. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +4 -17
  17. package/dist/es/components/FileManager/FileSectionState.js +5 -14
  18. package/dist/es/components/FileManager/FilesSection.js +9 -22
  19. package/dist/es/components/FileManager/InlineFilesSection.js +1 -1
  20. package/dist/es/components/FileManager/util.js +0 -318
  21. package/dist/es/index.js +0 -1
  22. package/dist/es/lib/capabilities.js +0 -1
  23. package/dist/types/components/FileManager/FileManager.d.ts +2 -4
  24. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -5
  25. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +1 -3
  26. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -2
  27. package/dist/types/components/FileManager/FileSectionState.d.ts +2 -5
  28. package/dist/types/components/FileManager/util.d.ts +0 -30
  29. package/dist/types/index.d.ts +0 -1
  30. package/dist/types/lib/capabilities.d.ts +0 -1
  31. package/package.json +1 -1
  32. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +0 -131
  33. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -54
  34. package/dist/cjs/components/FileManager/SelectDesignationActions.js +0 -74
  35. package/dist/cjs/components/FileManager/SelectDialogDesignation.js +0 -33
  36. package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +0 -101
  37. package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -47
  38. package/dist/es/components/FileManager/SelectDesignationActions.js +0 -44
  39. package/dist/es/components/FileManager/SelectDialogDesignation.js +0 -26
  40. package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +0 -14
  41. package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +0 -13
  42. package/dist/types/components/FileManager/SelectDesignationActions.d.ts +0 -12
  43. package/dist/types/components/FileManager/SelectDialogDesignation.d.ts +0 -11
@@ -38,7 +38,6 @@ const getCapabilities = (project, profile, role, actions) => {
38
38
  viewHistory: false,
39
39
  restoreVersion: isOwner() || isEditor() || isWriter(),
40
40
  downloadFiles: true,
41
- changeDesignation: (isOwner() || isEditor() || isWriter()) && allowed(A.updateAttachment),
42
41
  replaceFile: isOwner() || isEditor() || isWriter(),
43
42
  uploadFile: isOwner() || isEditor() || isWriter(),
44
43
  handleQualityReport: isOwner() || isEditor() || isWriter(),
@@ -21,34 +21,31 @@ import { actions, getInitialState, reducer } from './FileSectionState';
21
21
  import { FilesSection } from './FilesSection';
22
22
  import { InlineFilesSection } from './InlineFilesSection';
23
23
  import { TooltipDiv } from './TooltipDiv';
24
- import { Designation, generateAttachmentsTitles, namesWithDesignationMap, } from './util';
24
+ import { generateAttachmentsTitles } from './util';
25
25
  export const PermissionsContext = createContext(null);
26
- export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, addAttachmentToState, }) => {
26
+ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
27
27
  const [state, dispatch] = useReducer(reducer, getInitialState());
28
- const handleReplaceFile = useCallback((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const handleReplaceFile = useCallback((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
29
29
  dispatch(actions.HANDLE_UPLOAD_ACTION());
30
- dispatch(actions.SELECT_DESIGNATION(namesWithDesignationMap.get(typeId) || Designation.Document));
31
- const res = yield replace(attachmentId, name, file, typeId);
30
+ const res = yield replace(attachmentId, name, file);
32
31
  dispatch(actions.HANDLE_FINISH_UPLOAD());
33
32
  if (res) {
34
33
  dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
35
34
  }
36
35
  return res;
37
36
  }), [replace]);
38
- const handleUploadFile = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
37
+ const handleUploadFile = useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
39
38
  dispatch(actions.HANDLE_UPLOAD_ACTION());
40
- if (namesWithDesignationMap.get(designation) == Designation.Supplementary) {
41
- dispatch(actions.SELECT_DESIGNATION(Designation.Supplementary));
42
- }
43
- const res = yield upload(file, designation);
39
+ const res = yield upload(file);
44
40
  dispatch(actions.HANDLE_FINISH_UPLOAD());
45
41
  if (res) {
46
42
  dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', FileSectionType.OtherFile));
47
43
  }
48
44
  return res;
49
45
  }), [upload]);
50
- const handleUploadFileWithSupplement = useCallback((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
51
- const response = yield upload(file, designation);
46
+ const handleUploadFileWithSupplement = useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
47
+ dispatch(actions.HANDLE_UPLOAD_ACTION());
48
+ const response = yield upload(file);
52
49
  if (typeof response === 'object') {
53
50
  const { id, name } = response;
54
51
  yield saveModel(buildSupplementaryMaterial(name, `attachment:${id}`));
@@ -63,13 +60,6 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
63
60
  const model = getModelsByType(modelMap, ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
64
61
  yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
65
62
  }), [modelMap, saveModel]);
66
- const handleChangeDesignationFile = useCallback((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
67
- const res = yield changeDesignation(attachmentId, typeId, name);
68
- if (res) {
69
- dispatch(actions.HANDLE_SUCCESS_MESSAGE(''));
70
- }
71
- return res;
72
- }), [changeDesignation]);
73
63
  const handleDownload = useCallback((url) => {
74
64
  window.location.assign(url);
75
65
  }, []);
@@ -102,12 +92,10 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
102
92
  externalFile: element.externalFile,
103
93
  title: element.title,
104
94
  showAttachmentName: isSupplementOrOtherFilesTab,
105
- showDesignationActions: isSupplementOrOtherFilesTab,
106
95
  showReplaceAction: !isOtherFilesTab,
107
96
  handleDownload,
108
97
  handleReplace: handleReplaceFile,
109
98
  handleSupplementReplace,
110
- handleChangeDesignation: handleChangeDesignationFile,
111
99
  dispatch: dispatch,
112
100
  };
113
101
  if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
@@ -26,7 +26,7 @@ export const DragLayer = () => {
26
26
  const renderItem = useCallback(() => {
27
27
  switch (itemType) {
28
28
  case 'FileSectionItem':
29
- return (React.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false, showDesignationActions: false, style: { width: item.width } }));
29
+ return (React.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false, style: { width: item.width } }));
30
30
  default:
31
31
  return null;
32
32
  }
@@ -1,12 +1,10 @@
1
1
  import React, { useContext } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { PermissionsContext } from '../FileManager';
4
- import { DesignationActions } from './DesignationActions';
5
- export const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
4
+ export const FileInfo = ({ showAttachmentName, title, fileAttachmentName, fileExtension, attachmentId, dispatch, }) => {
6
5
  const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
7
6
  const can = useContext(PermissionsContext);
8
7
  return (React.createElement(FileInfoContainer, null,
9
- showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
10
8
  React.createElement(FileNameTitleContainer, null,
11
9
  React.createElement(FileTitle, null,
12
10
  !showAttachmentName ? fileName : title,
@@ -4,15 +4,13 @@ import { useDropdown } from '../../../hooks/use-dropdown';
4
4
  import { DropdownContainer } from '../../Dropdown';
5
5
  import { CloseOIcon } from '../../icons/';
6
6
  import DotsIcon from '../../icons/dots-icon';
7
- import { Designation, namesWithDesignationMap } from '../util';
8
7
  import { FileInfo } from './FileInfo';
9
8
  import { FileTypeIcon } from './FileTypeIcon';
10
9
  import { ItemActions } from './ItemActions';
11
- export const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
10
+ export const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showReplaceAction = true, handleDownload, handleReplace, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
12
11
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
13
12
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
14
- const designation = namesWithDesignationMap.get(externalFile.type.label);
15
- const isMainManuscript = designation === Designation.MainManuscript;
13
+ const isMainManuscript = externalFile.type.label === 'main-manuscript';
16
14
  const isSelected = externalFile.id == window.location.hash.substr(1);
17
15
  return (React.createElement(Item, { ref: dragRef, className: className, style: style },
18
16
  React.createElement(ItemContainer, { onClick: () => {
@@ -23,7 +21,7 @@ export const FileSectionItem = ({ fileSection, externalFile, title, showAttachme
23
21
  }
24
22
  } },
25
23
  React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
26
- React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
24
+ React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, fileAttachmentName: externalFile.name, title: title, attachmentId: externalFile.id, dispatch: dispatch })),
27
25
  onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
28
26
  e.preventDefault();
29
27
  onClose();
@@ -32,7 +30,7 @@ export const FileSectionItem = ({ fileSection, externalFile, title, showAttachme
32
30
  handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
33
31
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
34
32
  React.createElement(DotsIcon, null)),
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 }))))));
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 }))))));
36
34
  };
37
35
  const IconCloseButton = styled.button `
38
36
  border: none;
@@ -12,22 +12,10 @@ 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, FileSectionType, namesWithDesignationMap } from '../util';
16
- export const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
17
- const attachmentDesignation = designation == undefined ? 'undefined' : designation;
18
- const attachmentDesignationName = attachmentDesignation !== 'undefined'
19
- ? namesWithDesignationMap.get(attachmentDesignation)
20
- : undefined;
15
+ import { FileSectionType } from '../util';
16
+ export const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
21
17
  const can = useContext(PermissionsContext);
22
- const canBeReplaced = ((showReplaceAction == undefined || showReplaceAction) &&
23
- (attachmentDesignationName == undefined ||
24
- ![
25
- Designation.MainManuscript,
26
- Designation.SubmissionFile,
27
- Designation.SubmissionPdf,
28
- ].includes(attachmentDesignationName))) ||
29
- (attachmentDesignationName == Designation.MainManuscript &&
30
- (can === null || can === void 0 ? void 0 : can.setMainManuscript));
18
+ const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
31
19
  const fileInputRef = useRef(null);
32
20
  const [selectedFile, setSelectedFile] = useState();
33
21
  const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
@@ -36,9 +24,8 @@ export const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAtt
36
24
  setSelectedFile(file);
37
25
  if (dispatch) {
38
26
  dispatch(actions.HANDLE_UPLOAD_ACTION());
39
- dispatch(actions.SELECT_DESIGNATION(attachmentDesignationName || Designation.Document));
40
27
  }
41
- const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
28
+ const result = yield replaceAttachmentHandler(attachmentId, fileName, file);
42
29
  if (fileSection === FileSectionType.Supplements &&
43
30
  typeof result === 'object' &&
44
31
  handleSupplementReplace) {
@@ -5,14 +5,12 @@ export const getInitialState = () => ({
5
5
  fileUploadedSuccessfullySection: undefined,
6
6
  successMessage: '',
7
7
  isShowSuccessMessage: false,
8
- selectDesignation: undefined,
9
- showDesignationPopup: undefined,
8
+ currentSection: undefined,
10
9
  });
11
10
  var ActionTypes;
12
11
  (function (ActionTypes) {
13
12
  ActionTypes["UPLOAD_FILE"] = "UploadFile";
14
13
  ActionTypes["MOVE_FILE"] = "moveFile";
15
- ActionTypes["SELECT_DESIGNATION"] = "selectDesignation";
16
14
  ActionTypes["HANDLE_CANCEL_UPLOAD"] = "handleCancel";
17
15
  ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
18
16
  ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
@@ -22,7 +20,7 @@ var ActionTypes;
22
20
  export const reducer = (state, action) => {
23
21
  switch (action.type) {
24
22
  case ActionTypes.UPLOAD_FILE: {
25
- return Object.assign(Object.assign({}, state), { showDesignationPopup: action.sectionType, uploadedFile: action.uploadFile, selectDesignation: undefined });
23
+ return Object.assign(Object.assign({}, state), { uploadedFile: action.uploadFile, currentSection: action.sectionType });
26
24
  }
27
25
  case ActionTypes.MOVE_FILE: {
28
26
  return Object.assign(Object.assign({}, state), { moveToOtherState: {
@@ -30,17 +28,14 @@ export const reducer = (state, action) => {
30
28
  name: action.name,
31
29
  }, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
32
30
  }
33
- case ActionTypes.SELECT_DESIGNATION: {
34
- return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
35
- }
36
31
  case ActionTypes.HANDLE_UPLOAD_ACTION: {
37
- return Object.assign(Object.assign({}, state), { showDesignationPopup: undefined, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
32
+ return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
38
33
  }
39
34
  case ActionTypes.HANDLE_CANCEL_UPLOAD: {
40
- return Object.assign(Object.assign({}, state), { showDesignationPopup: undefined });
35
+ return Object.assign({}, state);
41
36
  }
42
37
  case ActionTypes.HANDLE_FINISH_UPLOAD: {
43
- return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
38
+ return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined });
44
39
  }
45
40
  case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
46
41
  return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage, fileUploadedSuccessfullySection: action.sectionType });
@@ -63,10 +58,6 @@ export const actions = {
63
58
  HANDLE_CANCEL_UPLOAD: () => ({
64
59
  type: ActionTypes.HANDLE_CANCEL_UPLOAD,
65
60
  }),
66
- SELECT_DESIGNATION: (designation) => ({
67
- type: ActionTypes.SELECT_DESIGNATION,
68
- designation,
69
- }),
70
61
  MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
71
62
  type: ActionTypes.MOVE_FILE,
72
63
  typeId,
@@ -1,12 +1,10 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useEffect } from 'react';
2
2
  import { AlertMessage, AlertMessageType } from '../AlertMessage';
3
- import { DragItemArea } from './DragItemArea';
4
3
  import { PermissionsContext } from './FileManager';
5
4
  import { FileSectionUploadItem } from './FileSectionItem/FileSectionUploadItem';
6
5
  import { actions } from './FileSectionState';
7
- import { SelectDialogDesignation } from './SelectDialogDesignation';
8
6
  import { UploadFileArea } from './UploadFileArea';
9
- import { FileSectionType, getDesignationName } from './util';
7
+ import { FileSectionType } from './util';
10
8
  export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
11
9
  let uploadedFileExtension = '';
12
10
  if (state.uploadedFile) {
@@ -14,13 +12,12 @@ export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, fil
14
12
  }
15
13
  const isSupplementFilesTab = fileSection === FileSectionType.Supplements;
16
14
  const isOtherFileTab = fileSection === FileSectionType.OtherFile;
17
- const handleUploadOtherFile = () => {
18
- dispatch(actions.HANDLE_UPLOAD_ACTION());
19
- state.uploadedFile &&
20
- state.selectDesignation !== undefined &&
21
- handleUpload(state.uploadedFile, getDesignationName(state.selectDesignation));
22
- };
23
15
  const can = useContext(PermissionsContext);
16
+ useEffect(() => {
17
+ state.uploadedFile &&
18
+ fileSection === state.currentSection &&
19
+ handleUpload(state.uploadedFile);
20
+ }, [state.uploadedFile]);
24
21
  const handleSuccessMessage = () => {
25
22
  return (React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
26
23
  text: 'OK',
@@ -30,18 +27,8 @@ export const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, fil
30
27
  return (React.createElement("div", null,
31
28
  (can === null || can === void 0 ? void 0 : can.uploadFile) && (React.createElement(React.Fragment, null,
32
29
  (isOtherFileTab || isSupplementFilesTab) && (React.createElement(UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
33
- state.isUploadFile &&
34
- state.uploadedFile &&
35
- state.selectDesignation !== undefined && (React.createElement(FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
30
+ state.isUploadFile && state.uploadedFile && (React.createElement(FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
36
31
  state.fileUploadedSuccessfullySection === fileSection &&
37
32
  handleSuccessMessage(),
38
- React.createElement(SelectDialogDesignation, { isOpen: state.showDesignationPopup === fileSection, fileExtension: uploadedFileExtension, handleCancel: () => {
39
- dispatch(actions.HANDLE_CANCEL_UPLOAD());
40
- }, uploadFileHandler: handleUploadOtherFile, dispatch: dispatch, fileSection: fileSection }),
41
- filesItem,
42
- (can === null || can === void 0 ? void 0 : can.changeDesignation) &&
43
- enableDragAndDrop &&
44
- (isSupplementFilesTab || isOtherFileTab) && (React.createElement(DragItemArea, { text: isSupplementFilesTab
45
- ? 'Drag the items to place them in the text'
46
- : 'Drag the items to place in the Supplements section or in the text' }))));
33
+ filesItem));
47
34
  };
@@ -48,7 +48,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
48
48
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
49
49
  handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
50
50
  attachment.modelId &&
51
- handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
51
+ handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
52
52
  };
53
53
  const ElementItem = styled(Item) `
54
54
  display: flex;
@@ -32,245 +32,6 @@ export var FileType;
32
32
  FileType[FileType["Figure"] = 10] = "Figure";
33
33
  FileType[FileType["GraphicalAbstract"] = 11] = "GraphicalAbstract";
34
34
  })(FileType || (FileType = {}));
35
- export var Designation;
36
- (function (Designation) {
37
- Designation[Designation["Figure"] = 0] = "Figure";
38
- Designation[Designation["Table"] = 1] = "Table";
39
- Designation[Designation["Supplementary"] = 2] = "Supplementary";
40
- Designation[Designation["ConflictOfInterest"] = 3] = "ConflictOfInterest";
41
- Designation[Designation["Document"] = 4] = "Document";
42
- Designation[Designation["GraphicalAbstract"] = 5] = "GraphicalAbstract";
43
- Designation[Designation["GraphicalAbstractImage"] = 6] = "GraphicalAbstractImage";
44
- Designation[Designation["GraphicalAbstractText"] = 7] = "GraphicalAbstractText";
45
- Designation[Designation["Metadata"] = 8] = "Metadata";
46
- Designation[Designation["SubmissionFile"] = 9] = "SubmissionFile";
47
- Designation[Designation["SubmissionPdf"] = 10] = "SubmissionPdf";
48
- Designation[Designation["TitlePage"] = 11] = "TitlePage";
49
- Designation[Designation["Dataset"] = 12] = "Dataset";
50
- Designation[Designation["MainManuscript"] = 13] = "MainManuscript";
51
- })(Designation || (Designation = {}));
52
- export const designationWithFileSectionsMap = new Map([
53
- [Designation.Figure, FileSectionType.OtherFile],
54
- [Designation.Table, FileSectionType.OtherFile],
55
- [Designation.Supplementary, FileSectionType.Supplements],
56
- [Designation.ConflictOfInterest, FileSectionType.OtherFile],
57
- [Designation.Document, FileSectionType.OtherFile],
58
- [Designation.GraphicalAbstract, FileSectionType.OtherFile],
59
- [Designation.GraphicalAbstractImage, FileSectionType.OtherFile],
60
- [Designation.GraphicalAbstractText, FileSectionType.OtherFile],
61
- [Designation.Metadata, FileSectionType.OtherFile],
62
- [Designation.SubmissionFile, FileSectionType.OtherFile],
63
- [Designation.SubmissionPdf, FileSectionType.OtherFile],
64
- [Designation.TitlePage, FileSectionType.OtherFile],
65
- [Designation.Dataset, FileSectionType.OtherFile],
66
- [Designation.MainManuscript, FileSectionType.OtherFile],
67
- ]);
68
- export const namesWithDesignationMap = new Map([
69
- ['figure', Designation.Figure],
70
- ['table', Designation.Table],
71
- ['supplementary', Designation.Supplementary],
72
- ['conflict-of-interest', Designation.ConflictOfInterest],
73
- ['document', Designation.Document],
74
- ['graphical-abstract', Designation.GraphicalAbstract],
75
- ['graphical-abstract-image', Designation.GraphicalAbstractImage],
76
- ['graphical-abstract-text', Designation.GraphicalAbstractText],
77
- ['metadata', Designation.Metadata],
78
- ['submission-file', Designation.SubmissionFile],
79
- ['submission-pdf', Designation.SubmissionPdf],
80
- ['title-page', Designation.TitlePage],
81
- ['dataset', Designation.Dataset],
82
- ['main-manuscript', Designation.MainManuscript],
83
- ]);
84
- export const designationWithReadableNamesMap = new Map([
85
- [Designation.Figure, 'Figure'],
86
- [Designation.Table, 'Table'],
87
- [Designation.Supplementary, 'Supplementary'],
88
- [Designation.ConflictOfInterest, 'Conflict Of Interest'],
89
- [Designation.Document, 'Document'],
90
- [Designation.GraphicalAbstract, 'Graphical Abstract'],
91
- [Designation.GraphicalAbstractImage, 'Graphical Abstract Image'],
92
- [Designation.GraphicalAbstractText, 'Graphical Abstract Text'],
93
- [Designation.Metadata, 'Metadata'],
94
- [Designation.SubmissionFile, 'Submission File'],
95
- [Designation.SubmissionPdf, 'Submission PDF'],
96
- [Designation.TitlePage, 'Title Page'],
97
- [Designation.Dataset, 'Dataset'],
98
- [Designation.MainManuscript, 'Main Manuscript'],
99
- ]);
100
- export const designationWithAllowedMediaTypesMap = new Map([
101
- [Designation.Figure, ['jpeg', 'png', 'tiff', 'pdf', 'svg', 'ai']],
102
- [
103
- Designation.Table,
104
- ['xls', 'csv', 'tsv', 'tex', 'html', 'jpeg', 'jpg', 'png', 'gif', 'tiff'],
105
- ],
106
- [Designation.Supplementary, []],
107
- [Designation.ConflictOfInterest, ['doc', 'docx', 'pdf', 'tex', 'txt']],
108
- [Designation.Document, ['doc', 'docx', 'pdf', 'tex']],
109
- [Designation.GraphicalAbstract, ['doc', 'docx', 'pdf', 'tex', 'txt']],
110
- [
111
- Designation.GraphicalAbstractImage,
112
- ['jpeg', 'png', 'tiff', 'gif', 'pdf', 'eps'],
113
- ],
114
- [Designation.GraphicalAbstractText, ['doc', 'docx', 'pdf', 'tex', 'txt']],
115
- [Designation.Metadata, ['xml']],
116
- [Designation.SubmissionFile, []],
117
- [Designation.SubmissionPdf, ['pdf']],
118
- [Designation.TitlePage, ['doc', 'docx', 'pdf', 'tex', 'txt']],
119
- [Designation.Dataset, []],
120
- [Designation.MainManuscript, ['manuproj', 'docx']],
121
- ]);
122
- export const designationWithAllowedDesignationsToTransitionMap = new Map([
123
- [
124
- Designation.Figure,
125
- [
126
- Designation.SubmissionFile,
127
- Designation.Supplementary,
128
- Designation.GraphicalAbstractImage,
129
- Designation.Dataset,
130
- ],
131
- ],
132
- [
133
- Designation.Table,
134
- [
135
- Designation.Supplementary,
136
- Designation.SubmissionFile,
137
- Designation.Dataset,
138
- ],
139
- ],
140
- [
141
- Designation.Supplementary,
142
- [
143
- Designation.Supplementary,
144
- Designation.SubmissionFile,
145
- Designation.Document,
146
- Designation.Figure,
147
- Designation.GraphicalAbstractImage,
148
- Designation.ConflictOfInterest,
149
- Designation.SubmissionPdf,
150
- Designation.Metadata,
151
- Designation.GraphicalAbstractText,
152
- Designation.GraphicalAbstract,
153
- Designation.TitlePage,
154
- Designation.Table,
155
- Designation.Dataset,
156
- ],
157
- ],
158
- [
159
- Designation.ConflictOfInterest,
160
- [
161
- Designation.ConflictOfInterest,
162
- Designation.Document,
163
- Designation.GraphicalAbstract,
164
- Designation.GraphicalAbstractImage,
165
- Designation.GraphicalAbstractText,
166
- Designation.Metadata,
167
- Designation.SubmissionFile,
168
- Designation.SubmissionPdf,
169
- Designation.Dataset,
170
- ],
171
- ],
172
- [
173
- Designation.Document,
174
- [
175
- Designation.ConflictOfInterest,
176
- Designation.Document,
177
- Designation.GraphicalAbstract,
178
- Designation.GraphicalAbstractImage,
179
- Designation.GraphicalAbstractText,
180
- Designation.Metadata,
181
- Designation.SubmissionFile,
182
- Designation.SubmissionPdf,
183
- Designation.MainManuscript,
184
- Designation.Dataset,
185
- ],
186
- ],
187
- [
188
- Designation.GraphicalAbstract,
189
- [
190
- Designation.Document,
191
- Designation.SubmissionFile,
192
- Designation.Supplementary,
193
- Designation.Dataset,
194
- ],
195
- ],
196
- [
197
- Designation.GraphicalAbstractImage,
198
- [
199
- Designation.Figure,
200
- Designation.SubmissionFile,
201
- Designation.Supplementary,
202
- Designation.Dataset,
203
- ],
204
- ],
205
- [
206
- Designation.GraphicalAbstractText,
207
- [
208
- Designation.Document,
209
- Designation.SubmissionFile,
210
- Designation.Supplementary,
211
- Designation.Dataset,
212
- ],
213
- ],
214
- [Designation.Metadata, [Designation.SubmissionFile, Designation.Dataset]],
215
- [
216
- Designation.SubmissionFile,
217
- [
218
- Designation.Supplementary,
219
- Designation.SubmissionFile,
220
- Designation.Document,
221
- Designation.Figure,
222
- Designation.GraphicalAbstractImage,
223
- Designation.ConflictOfInterest,
224
- Designation.SubmissionPdf,
225
- Designation.Metadata,
226
- Designation.GraphicalAbstractText,
227
- Designation.GraphicalAbstract,
228
- Designation.TitlePage,
229
- Designation.Table,
230
- Designation.Dataset,
231
- ],
232
- ],
233
- [
234
- Designation.SubmissionPdf,
235
- [
236
- Designation.ConflictOfInterest,
237
- Designation.Document,
238
- Designation.GraphicalAbstract,
239
- Designation.GraphicalAbstractImage,
240
- Designation.GraphicalAbstractText,
241
- Designation.Metadata,
242
- Designation.SubmissionFile,
243
- Designation.SubmissionPdf,
244
- Designation.Dataset,
245
- ],
246
- ],
247
- [
248
- Designation.TitlePage,
249
- [
250
- Designation.Document,
251
- Designation.SubmissionFile,
252
- Designation.Supplementary,
253
- Designation.Dataset,
254
- ],
255
- ],
256
- [
257
- Designation.Dataset,
258
- [
259
- Designation.Supplementary,
260
- Designation.SubmissionFile,
261
- Designation.Document,
262
- Designation.Figure,
263
- Designation.GraphicalAbstractImage,
264
- Designation.ConflictOfInterest,
265
- Designation.SubmissionPdf,
266
- Designation.Metadata,
267
- Designation.GraphicalAbstractText,
268
- Designation.GraphicalAbstract,
269
- Designation.TitlePage,
270
- Designation.Table,
271
- ],
272
- ],
273
- ]);
274
35
  export const extensionsWithFileTypesMap = new Map([
275
36
  ['png', FileType.Image],
276
37
  ['jpg', FileType.Image],
@@ -378,85 +139,6 @@ export const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
378
139
  }));
379
140
  return result;
380
141
  };
381
- export const getDesignationActionsList = (designation, fileExtension) => {
382
- const allowedDesignationsToTransition = designationWithAllowedDesignationsToTransitionMap.get(designation);
383
- if (allowedDesignationsToTransition) {
384
- if (designation === Designation.Supplementary ||
385
- designation === Designation.SubmissionFile) {
386
- return allowedDesignationsToTransition;
387
- }
388
- else {
389
- allowedDesignationsToTransition.filter((value) => {
390
- const allowedMediaTypes = designationWithAllowedMediaTypesMap.get(value);
391
- if (allowedMediaTypes) {
392
- return allowedMediaTypes.indexOf(fileExtension) !== -1;
393
- }
394
- else {
395
- return false;
396
- }
397
- });
398
- return allowedDesignationsToTransition;
399
- }
400
- }
401
- else {
402
- return [];
403
- }
404
- };
405
- export const getDesignationName = (designation) => {
406
- let result = undefined;
407
- namesWithDesignationMap.forEach((value, key, map) => {
408
- if (value === designation) {
409
- result = key;
410
- }
411
- });
412
- if (result == undefined) {
413
- result = '';
414
- }
415
- return result;
416
- };
417
- export const getDesignationByFileSection = (fileSectionType) => {
418
- const result = new Array();
419
- designationWithFileSectionsMap.forEach((value, key, map) => {
420
- if (value === fileSectionType) {
421
- result.push(key);
422
- }
423
- });
424
- return result;
425
- };
426
- export const getUploadFileDesignationList = (fileExtension, fileSectionType, can) => {
427
- const result = new Array();
428
- const checkDesignation = (value) => {
429
- if (value === Designation.MainManuscript && !(can === null || can === void 0 ? void 0 : can.setMainManuscript)) {
430
- return;
431
- }
432
- const allowedExtension = designationWithAllowedMediaTypesMap.get(value);
433
- const isAllowed = allowedExtension === null || allowedExtension === void 0 ? void 0 : allowedExtension.includes(fileExtension);
434
- if (isAllowed ||
435
- value === Designation.Supplementary ||
436
- value === Designation.SubmissionFile ||
437
- value === Designation.Dataset) {
438
- const label = designationWithReadableNamesMap.get(value);
439
- if (label) {
440
- result.push({
441
- value: value,
442
- label: label,
443
- });
444
- }
445
- }
446
- };
447
- if (typeof fileSectionType === 'number') {
448
- const allowedDesignationByFileSection = getDesignationByFileSection(fileSectionType);
449
- allowedDesignationByFileSection.forEach(checkDesignation);
450
- }
451
- else if (Array.isArray(fileSectionType)) {
452
- designationWithFileSectionsMap.forEach((value, key) => {
453
- if (fileSectionType.includes(key)) {
454
- checkDesignation(key);
455
- }
456
- });
457
- }
458
- return result;
459
- };
460
142
  export const droppableSections = [
461
143
  FileSectionType.Supplements,
462
144
  FileSectionType.OtherFile,
package/dist/es/index.js CHANGED
@@ -55,6 +55,5 @@ export * from './lib/authors';
55
55
  export * from './lib/capabilities';
56
56
  export { default as errorsDecoder } from './lib/errors-decoder';
57
57
  export * from './types';
58
- export { SelectDialogDesignation } from './components/FileManager/SelectDialogDesignation';
59
58
  export * from './components/LoadingOverlay';
60
59
  export * from './components/EditorHeader/EditorHeader';
@@ -32,7 +32,6 @@ export const getCapabilities = (project, profile, role, actions) => {
32
32
  viewHistory: false,
33
33
  restoreVersion: isOwner() || isEditor() || isWriter(),
34
34
  downloadFiles: true,
35
- changeDesignation: (isOwner() || isEditor() || isWriter()) && allowed(A.updateAttachment),
36
35
  replaceFile: isOwner() || isEditor() || isWriter(),
37
36
  uploadFile: isOwner() || isEditor() || isWriter(),
38
37
  handleQualityReport: isOwner() || isEditor() || isWriter(),