Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/components/FileItemMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ export default function FileItemMenu({
<Download />
Download
</DropdownMenuItem>
<DropdownMenuItem onClick={() => run(onCopy)}>
<Copy />
Copy
</DropdownMenuItem>
{file.type === "file" && (
<DropdownMenuItem onClick={() => run(onCopy)}>
<Copy />
Make a Copy
</DropdownMenuItem>
)}
<DropdownMenuItem onClick={() => run(onShare)}>
<Share2 />
Share
Expand Down
19 changes: 11 additions & 8 deletions app/components/file-manager/FileManagerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,6 @@ export default function FileManagerContent() {
dispatchFileAction({ type: "download", file });
},
},
{
label: "Copy",
icon: Copy,
onClick: () => {
closeContextMenu();
dispatchFileAction({ type: "copy", file });
},
},
{
label: "Share",
icon: Share2,
Expand All @@ -360,6 +352,17 @@ export default function FileManagerContent() {
});
}

if (file.type === "file") {
actions.push({
label: "Make a Copy",
icon: Copy,
onClick: () => {
closeContextMenu();
dispatchFileAction({ type: "copy", file });
},
});
}

actions.push({
label: "Delete",
icon: Trash2,
Expand Down
9 changes: 2 additions & 7 deletions app/components/file-manager/hooks/useFileOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { AccessLevel } from "../../ShareDialog";
import {
getAuthenticatedSession,
copyFileResource,
copyFolderResource,
downloadFile,
downloadFolderAsZip,
deleteFileResource,
Expand Down Expand Up @@ -91,19 +90,15 @@ export function useFileOperations({

const copyFile = useCallback(
async (file: FileItemData) => {
if (!file) {
if (!file || file.type === "folder") {
return;
}

const result = await runWithToast(
`Copying "${file.name}"...`,
async () => {
const { fetch: fetchFn } = getAuthenticatedSession();
if (file.type === "folder") {
await copyFolderResource(file, fetchFn);
} else {
await copyFileResource(file, fetchFn);
}
await copyFileResource(file, fetchFn);
},
{
successMessage: `Copied "${file.name}"`,
Expand Down
Loading