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
33 changes: 26 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/(dashboard)/dashboard/files/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ async function FilesPage() {
}

export default withPermissions(FilesPage, {
requiredPermissions: ["files.index"],
requiredPermissions: ["files.index", "self.files.index"],
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import {revalidatePath} from "next/cache";
import {APP_PATHS} from "@/lib/app-paths";
import {deleteFile} from "@/dal/private/files";
import {addNewFile, deleteFile} from "@/dal/private/files";

export async function addFileAction(formData: FormData): Promise<any> {
await addNewFile(formData);
}

export async function deleteFileAction(formData: FormData) {
const fileId = formData.get("id")?.toString();
Expand All @@ -12,3 +16,4 @@ export async function deleteFileAction(formData: FormData) {
await deleteFile(fileId);
revalidatePath(APP_PATHS.dashboard.files);
}

2 changes: 1 addition & 1 deletion src/components/files-explorer/add-file-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {useState, useRef, useId} from "react";
import {Tooltip, ActionIcon, Loader} from "@mantine/core";
import {IconPlus} from "@tabler/icons-react";
import {addFileAction} from "@/features/files/actions";
import {addFileAction} from "./actions";

type Props = {
onAdd: () => void;
Expand Down
29 changes: 16 additions & 13 deletions src/components/files-explorer/file-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "@mantine/core";
import {IconEye, IconTrash, IconCheck} from "@tabler/icons-react";
import {FILES_PUBLIC_URL} from "@/constants/envs";
import {deleteFileAction} from "@/features/files/actions";
import {deleteFileAction} from "./actions";
import {mimeToIcon, defaultIcon} from "./mimetype-mapping";
import classes from "./file-card.module.css";

Expand All @@ -30,7 +30,7 @@ type File = {
type Props = {
file: File;
isSelected?: boolean;
onDelete: (id: string) => void;
onDelete?: (id: string) => void;
onSelect?: (id: string) => void;
};

Expand All @@ -39,7 +39,7 @@ export function FileCard({file, isSelected, onDelete, onSelect}: Props) {
mutationKey: ["file-delete"],
mutationFn: deleteFileAction,
onSuccess: () => {
onDelete(file.uuid);
onDelete?.(file.uuid);
handleClose();
},
});
Expand All @@ -58,6 +58,7 @@ export function FileCard({file, isSelected, onDelete, onSelect}: Props) {
};

const handleDelete = async () => {
if (!onDelete) return;
const fd = new FormData();
fd.set("id", file.uuid);
mutate(fd);
Expand Down Expand Up @@ -128,16 +129,18 @@ export function FileCard({file, isSelected, onDelete, onSelect}: Props) {
>
<IconEye />
</ActionIcon>
<ActionIcon
size={"lg"}
color="red"
onClick={(e) => {
e.stopPropagation();
setShowDeleteConfirm(true);
}}
>
<IconTrash />
</ActionIcon>
{onDelete !== undefined && (
<ActionIcon
size={"lg"}
color="red"
onClick={(e) => {
e.stopPropagation();
setShowDeleteConfirm(true);
}}
>
<IconTrash />
</ActionIcon>
)}
</ActionIconGroup>
</Box>
</Overlay>
Expand Down
Loading
Loading