@manuscripts/style-guide 0.31.15 → 0.31.16

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.
@@ -111,6 +111,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
111
111
  const getFileSectionExternalFile = (fileSection) => {
112
112
  const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
113
113
  fileSection === util_1.FileSectionType.OtherFile;
114
+ const isOtherFilesTab = fileSection === util_1.FileSectionType.OtherFile;
114
115
  const itemsData = (fileSection === util_1.FileSectionType.Supplements && supplementFiles) ||
115
116
  attachments.filter((element) => {
116
117
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
@@ -123,6 +124,7 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
123
124
  title: element.title,
124
125
  showAttachmentName: isSupplementOrOtherFilesTab,
125
126
  showDesignationActions: isSupplementOrOtherFilesTab,
127
+ showReplaceAction: !isOtherFilesTab,
126
128
  handleDownload,
127
129
  handleReplace: handleReplaceFile,
128
130
  handleChangeDesignation: handleChangeDesignationFile,
@@ -14,7 +14,7 @@ const util_1 = require("../util");
14
14
  const FileInfo_1 = require("./FileInfo");
15
15
  const FileTypeIcon_1 = require("./FileTypeIcon");
16
16
  const ItemActions_1 = require("./ItemActions");
17
- const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
17
+ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
18
18
  const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
19
19
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
20
20
  const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
@@ -38,7 +38,7 @@ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, show
38
38
  handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
39
39
  react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
40
40
  react_1.default.createElement(dots_icon_1.default, null)),
41
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
41
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
42
42
  };
43
43
  exports.FileSectionItem = FileSectionItem;
44
44
  const IconCloseButton = styled_components_1.default.button `
@@ -35,17 +35,18 @@ const FileManager_1 = require("../FileManager");
35
35
  const FileSectionState_1 = require("../FileSectionState");
36
36
  const ItemsAction_1 = require("../ItemsAction");
37
37
  const util_1 = require("../util");
38
- const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
38
+ const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
39
39
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
40
40
  const attachmentDesignationName = attachmentDesignation !== 'undefined'
41
41
  ? util_1.namesWithDesignationMap.get(attachmentDesignation)
42
42
  : undefined;
43
- const canBeReplaced = attachmentDesignationName == undefined ||
44
- ![
45
- util_1.Designation.MainManuscript,
46
- util_1.Designation.SubmissionFile,
47
- util_1.Designation.SubmissionPdf,
48
- ].includes(attachmentDesignationName);
43
+ const canBeReplaced = (showReplaceAction == undefined || showReplaceAction) &&
44
+ (attachmentDesignationName == undefined ||
45
+ ![
46
+ util_1.Designation.MainManuscript,
47
+ util_1.Designation.SubmissionFile,
48
+ util_1.Designation.SubmissionPdf,
49
+ ].includes(attachmentDesignationName));
49
50
  const fileInputRef = (0, react_1.useRef)(null);
50
51
  const [selectedFile, setSelectedFile] = (0, react_1.useState)();
51
52
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
@@ -68,7 +68,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
68
68
  handleDownload && handleReplace && (react_1.default.createElement(DropdownContainer, { ref: wrapperRef },
69
69
  react_1.default.createElement(FileSectionItem_1.ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
70
70
  react_1.default.createElement(dots_icon_1.default, null)),
71
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
71
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
72
72
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
73
73
  handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
74
74
  };
@@ -86,6 +86,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
86
86
  const getFileSectionExternalFile = (fileSection) => {
87
87
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
88
88
  fileSection === FileSectionType.OtherFile;
89
+ const isOtherFilesTab = fileSection === FileSectionType.OtherFile;
89
90
  const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
90
91
  attachments.filter((element) => {
91
92
  const designation = namesWithDesignationMap.get(element.type.label);
@@ -98,6 +99,7 @@ export const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileM
98
99
  title: element.title,
99
100
  showAttachmentName: isSupplementOrOtherFilesTab,
100
101
  showDesignationActions: isSupplementOrOtherFilesTab,
102
+ showReplaceAction: !isOtherFilesTab,
101
103
  handleDownload,
102
104
  handleReplace: handleReplaceFile,
103
105
  handleChangeDesignation: handleChangeDesignationFile,
@@ -8,7 +8,7 @@ import { Designation, namesWithDesignationMap } from '../util';
8
8
  import { FileInfo } from './FileInfo';
9
9
  import { FileTypeIcon } from './FileTypeIcon';
10
10
  import { ItemActions } from './ItemActions';
11
- export const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
11
+ export const FileSectionItem = ({ externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, dispatch, dragRef, className, style, onClose, isEditor, }) => {
12
12
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
13
13
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
14
14
  const designation = namesWithDesignationMap.get(externalFile.type.label);
@@ -32,7 +32,7 @@ export const FileSectionItem = ({ externalFile, title, showAttachmentName = fals
32
32
  handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
33
33
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
34
34
  React.createElement(DotsIcon, null)),
35
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
35
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
36
36
  };
37
37
  const IconCloseButton = styled.button `
38
38
  border: none;
@@ -13,17 +13,18 @@ import { PermissionsContext } from '../FileManager';
13
13
  import { actions } from '../FileSectionState';
14
14
  import { ActionsItem } from '../ItemsAction';
15
15
  import { Designation, namesWithDesignationMap } from '../util';
16
- export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, }) => {
16
+ export const ItemActions = ({ downloadAttachmentHandler, replaceAttachmentHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
17
17
  const attachmentDesignation = designation == undefined ? 'undefined' : designation;
18
18
  const attachmentDesignationName = attachmentDesignation !== 'undefined'
19
19
  ? namesWithDesignationMap.get(attachmentDesignation)
20
20
  : undefined;
21
- const canBeReplaced = attachmentDesignationName == undefined ||
22
- ![
23
- Designation.MainManuscript,
24
- Designation.SubmissionFile,
25
- Designation.SubmissionPdf,
26
- ].includes(attachmentDesignationName);
21
+ const canBeReplaced = (showReplaceAction == undefined || showReplaceAction) &&
22
+ (attachmentDesignationName == undefined ||
23
+ ![
24
+ Designation.MainManuscript,
25
+ Designation.SubmissionFile,
26
+ Designation.SubmissionPdf,
27
+ ].includes(attachmentDesignationName));
27
28
  const fileInputRef = useRef(null);
28
29
  const [selectedFile, setSelectedFile] = useState();
29
30
  const can = useContext(PermissionsContext);
@@ -42,7 +42,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
42
42
  handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
43
43
  React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace", "aria-pressed": isOpen },
44
44
  React.createElement(DotsIcon, null)),
45
- isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
45
+ isOpen && (React.createElement(ItemActions, { replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
46
46
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
47
47
  handleUpdateInline(attachment.modelId, uploadAttachment), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
48
48
  };
@@ -19,6 +19,7 @@ export interface FileSectionItemProps {
19
19
  showAttachmentName?: boolean;
20
20
  showDesignationActions?: boolean;
21
21
  showActions?: boolean;
22
+ showReplaceAction?: boolean;
22
23
  handleDownload?: (url: string) => void;
23
24
  handleReplace?: Replace;
24
25
  handleChangeDesignation: ChangeDesignation;
@@ -14,4 +14,5 @@ export declare const ItemActions: React.FC<{
14
14
  hideActionList: (e?: React.MouseEvent) => void;
15
15
  dispatch?: Dispatch<Action>;
16
16
  dropDownClassName?: string;
17
+ showReplaceAction?: boolean;
17
18
  }>;
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.15",
4
+ "version": "0.31.16",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",