diff --git a/templates/frontend/src/components/shared/file-browser/file-browser.jsx b/templates/frontend/src/components/shared/file-browser/file-browser.jsx
index c5387c0a..e1657e41 100644
--- a/templates/frontend/src/components/shared/file-browser/file-browser.jsx
+++ b/templates/frontend/src/components/shared/file-browser/file-browser.jsx
@@ -149,10 +149,10 @@ const FileBrowser = ({ readOnly = false, onCreateManually, className }) => {
});
};
- const handleRenameFolder = (newName, folderId) => {
+ const handleRenameItem = (newName, itemId) => {
filesDispatch({
- type: 'renameFolder',
- folderId,
+ type: 'renameItem',
+ itemId,
newName,
});
};
@@ -207,7 +207,7 @@ const FileBrowser = ({ readOnly = false, onCreateManually, className }) => {
onAddFile={!readOnly ? handleAddFile : noop}
onAddFolder={!readOnly ? handleAddFolder : noop}
onDropFile={!readOnly ? handleDropFile : noop}
- onRenameFolder={!readOnly ? handleRenameFolder : noop}
+ onRenameItem={!readOnly ? handleRenameItem : noop}
onItemDelete={!readOnly ? handleDeleteItem : noop}
onOpenFile={handleOpenFile}
onDragStart={!readOnly ? handleDragStart : noop}
diff --git a/templates/frontend/src/components/shared/file-browser/file/file.jsx b/templates/frontend/src/components/shared/file-browser/file/file.jsx
index 2f6039e8..9ad24332 100644
--- a/templates/frontend/src/components/shared/file-browser/file/file.jsx
+++ b/templates/frontend/src/components/shared/file-browser/file/file.jsx
@@ -1,8 +1,10 @@
import classNames from 'classnames/bind';
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useRef, useState, useCallback } from 'react';
+import Dropdown from 'components/shared/dropdown';
+import RenameItemModal from 'components/shared/file-browser/rename-item-modal';
import { useFiles } from 'contexts/files-provider';
-import CloseSvg from 'icons/close.inline.svg';
+import DotsIcon from 'icons/dots.inline.svg';
import { getIconByFilename } from 'utils/language';
import DeleteFileModal from '../delete-file-modal';
@@ -21,6 +23,7 @@ const File = ({
onDelete,
onDragStart,
onDragEnd,
+ onRenameItem,
level,
readOnly,
}) => {
@@ -31,6 +34,7 @@ const File = ({
} = useFiles();
const [isDeleteFileModalOpen, setIsDeleteFileModalOpen] = useState(false);
+ const [isRenameItemModalOpen, setIsRenameItemModalOpen] = useState(false);
useEffect(() => {
const fileElem = fileRef.current;
@@ -54,12 +58,6 @@ const File = ({
onDelete(file.id);
};
- const handleDeleteClick = (evt) => {
- evt.preventDefault();
- evt.stopPropagation();
- setIsDeleteFileModalOpen(true);
- };
-
const handleDragStart = (evt) => {
onOpen(null);
evt.preventDefault();
@@ -68,6 +66,20 @@ const File = ({
};
const Icon = getIconByFilename(file.data.name);
+ const menuItems = [
+ {
+ text: 'Rename',
+ onClick: () => setIsRenameItemModalOpen(true),
+ },
+ {
+ text: 'Delete',
+ onClick: () => setIsDeleteFileModalOpen(true),
+ theme: 'danger',
+ },
+ ];
+
+ const handleCloseDeleteFileModalClick = useCallback(() => setIsDeleteFileModalOpen(false), []);
+ const handleCloseRenameFileModalClick = useCallback(() => setIsRenameItemModalOpen(false), []);
return (
setIsDeleteFileModalOpen(false)}
+ onClose={handleCloseDeleteFileModalClick}
onSave={handleDelete}
/>
)}
+ {isRenameItemModalOpen && (
+
onRenameItem(newName, file.id)}
+ />
+ )}
{file.data.name}
{!readOnly && (
-
+
+
+
)}
);
diff --git a/templates/frontend/src/components/shared/file-browser/file/file.module.scss b/templates/frontend/src/components/shared/file-browser/file/file.module.scss
index ebc9784e..e6b27fb6 100644
--- a/templates/frontend/src/components/shared/file-browser/file/file.module.scss
+++ b/templates/frontend/src/components/shared/file-browser/file/file.module.scss
@@ -15,9 +15,11 @@
&:hover {
background-color: $color-secondary-black;
+ border-radius: 2px;
- & .button-delete {
+ .options {
visibility: visible;
+ opacity: 1;
}
}
@@ -72,3 +74,38 @@
}
}
}
+
+.options {
+ position: absolute;
+ top: 50%;
+ right: 5px;
+ z-index: 1;
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ height: 12px;
+ padding-top: 7px;
+ padding-right: 10px;
+ padding-bottom: 7px;
+ padding-left: 10px;
+ margin-left: auto;
+ cursor: pointer;
+ visibility: hidden;
+ opacity: 0;
+ transform: translateY(-50%);
+
+ &:hover {
+ circle {
+ fill: $color-white;
+ }
+ }
+}
+
+.options-icon {
+ height: 15px;
+ fill: $color-grey;
+}
+
+.options-menu {
+ min-width: 100px;
+}
diff --git a/templates/frontend/src/components/shared/file-browser/folder/folder.jsx b/templates/frontend/src/components/shared/file-browser/folder/folder.jsx
index 0a04e749..392a7657 100644
--- a/templates/frontend/src/components/shared/file-browser/folder/folder.jsx
+++ b/templates/frontend/src/components/shared/file-browser/folder/folder.jsx
@@ -5,7 +5,7 @@ import Dropdown from 'components/shared/dropdown';
import AddFileModal from 'components/shared/file-browser/add-file-modal';
import AddFolderModal from 'components/shared/file-browser/add-folder-modal';
import DeleteFolderModal from 'components/shared/file-browser/delete-folder-modal';
-import RenameFolderModal from 'components/shared/file-browser/rename-folder-modal';
+import RenameItemModal from 'components/shared/file-browser/rename-item-modal';
import TreeRecursive from 'components/shared/file-browser/tree-recursive';
import ArrowSvg from 'icons/arrow-down.inline.svg';
import DotsIcon from 'icons/dots.inline.svg';
@@ -21,7 +21,7 @@ const Folder = ({
onOpenFile,
onAddFile,
onAddFolder,
- onRenameFolder,
+ onRenameItem,
onDragStart,
onDragEnd,
level,
@@ -73,7 +73,7 @@ const Folder = ({
const [isAddFileModalOpen, setIsAddFileModalOpen] = useState(false);
const [isAddFolderModalOpen, setIsAddFolderModalOpen] = useState(false);
- const [isRenameFolderModalOpen, setIsRenameFolderModalOpen] = useState(false);
+ const [isRenameItemModalOpen, setIsRenameItemModalOpen] = useState(false);
const [isDeleteFolderModalOpen, setIsDeleteFolderModalOpen] = useState(false);
const menuItems = [
@@ -87,7 +87,7 @@ const Folder = ({
},
{
text: 'Rename',
- onClick: () => setIsRenameFolderModalOpen(true),
+ onClick: () => setIsRenameItemModalOpen(true),
},
{
text: 'Delete',
@@ -96,6 +96,22 @@ const Folder = ({
},
];
+ const handleCloseRenameItemModalClick = useCallback(() => {
+ setIsRenameItemModalOpen(false);
+ }, []);
+
+ const handleCloseAddFolderModalClick = useCallback(() => {
+ setIsAddFolderModalOpen(false);
+ }, []);
+
+ const handleCloseDeleteFolderModalClick = useCallback(() => {
+ setIsDeleteFolderModalOpen(false);
+ }, []);
+
+ const handleCloseAddFileModalClick = useCallback(() => {
+ setIsAddFileModalOpen(false);
+ }, []);
+
return (
setIsAddFileModalOpen(false)}
+ onClose={handleCloseAddFileModalClick}
onSave={(fileName) => onAddFile(fileName, folder.id)}
/>
)}
{isAddFolderModalOpen && (
setIsAddFolderModalOpen(false)}
+ onClose={handleCloseAddFolderModalClick}
onSave={(folderName) => onAddFolder(folderName, folder.id)}
/>
)}
- {isRenameFolderModalOpen && (
- setIsRenameFolderModalOpen(false)}
- onSave={(newName) => onRenameFolder(newName, folder.id)}
+ isOpen={isRenameItemModalOpen}
+ onClose={handleCloseRenameItemModalClick}
+ onSave={(newName) => onRenameItem(newName, folder.id)}
/>
)}
{isDeleteFolderModalOpen && (
setIsDeleteFolderModalOpen(false)}
+ onClose={handleCloseDeleteFolderModalClick}
onSave={() => onDelete(folder.id)}
/>
)}
@@ -174,7 +191,7 @@ const Folder = ({
onAddFile={onAddFile}
onAddFolder={onAddFolder}
onOpenFile={onOpenFile}
- onRenameFolder={onRenameFolder}
+ onRenameItem={onRenameItem}
onDragStart={onDragStart}
onDragEnd={onDragEnd}
/>
diff --git a/templates/frontend/src/components/shared/file-browser/rename-folder-modal/index.js b/templates/frontend/src/components/shared/file-browser/rename-folder-modal/index.js
deleted file mode 100644
index 440e8e10..00000000
--- a/templates/frontend/src/components/shared/file-browser/rename-folder-modal/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './rename-folder-modal';
diff --git a/templates/frontend/src/components/shared/file-browser/rename-item-modal/index.js b/templates/frontend/src/components/shared/file-browser/rename-item-modal/index.js
new file mode 100644
index 00000000..5cfba6a7
--- /dev/null
+++ b/templates/frontend/src/components/shared/file-browser/rename-item-modal/index.js
@@ -0,0 +1 @@
+export { default } from './rename-item-modal';
diff --git a/templates/frontend/src/components/shared/file-browser/rename-folder-modal/rename-folder-modal.jsx b/templates/frontend/src/components/shared/file-browser/rename-item-modal/rename-item-modal.jsx
similarity index 81%
rename from templates/frontend/src/components/shared/file-browser/rename-folder-modal/rename-folder-modal.jsx
rename to templates/frontend/src/components/shared/file-browser/rename-item-modal/rename-item-modal.jsx
index 09ef9541..228fcbc9 100644
--- a/templates/frontend/src/components/shared/file-browser/rename-folder-modal/rename-folder-modal.jsx
+++ b/templates/frontend/src/components/shared/file-browser/rename-item-modal/rename-item-modal.jsx
@@ -10,7 +10,7 @@ import Input from 'components/shared/input';
import Modal from 'components/shared/modal';
import ModalPortal from 'components/shared/modal-portal';
-import styles from './rename-folder-modal.module.scss';
+import styles from './rename-item-modal.module.scss';
const schema = yup.object().shape({
newName: yup
@@ -23,8 +23,8 @@ const schema = yup.object().shape({
const cx = classNames.bind(styles);
-const RenameFolderModal = (props) => {
- const { name, isOpen, onClose, onSave } = props;
+const RenameItemModal = (props) => {
+ const { name, isOpen, onClose, onSave, label } = props;
const { register, handleSubmit, clearErrors, errors } = useForm({
defaultValues: { newName: name },
@@ -40,10 +40,10 @@ const RenameFolderModal = (props) => {
return (
-
+