diff --git a/frontend/src/pages/resource_details_page.tsx b/frontend/src/pages/resource_details_page.tsx index 78e1d9c..5de4763 100644 --- a/frontend/src/pages/resource_details_page.tsx +++ b/frontend/src/pages/resource_details_page.tsx @@ -23,6 +23,7 @@ import showPopup, {useClosePopup} from "../components/popup.tsx"; import {Turnstile} from "@marsidev/react-turnstile"; import Button from "../components/button.tsx"; import Badge, {BadgeAccent} from "../components/badge.tsx"; +import Input from "../components/input.tsx"; export default function ResourcePage() { const params = useParams() @@ -264,6 +265,7 @@ function FileTile({file}: { file: RFile }) { + @@ -495,6 +497,61 @@ function CreateFileDialog({resourceId}: { resourceId: number }) { } +function UpdateFileInfoDialog({file}: { file: RFile }) { + const [isLoading, setLoading] = useState(false) + + const [filename, setFilename] = useState(file.filename) + + const [description, setDescription] = useState(file.description) + + const {t} = useTranslation() + + const reload = useContext(context) + + const handleUpdate = async () => { + if (isLoading) { + return + } + setLoading(true) + const res = await network.updateFile(file.id, filename, description); + const dialog = document.getElementById(`update_file_info_dialog_${file.id}`) as HTMLDialogElement + dialog.close() + if (res.success){ + showToast({message: t("File info updated successfully"), type: "success"}) + reload() + } else { + showToast({message: res.message, type: "error"}) + } + setLoading(false) + } + + if (!app.isAdmin() && app.user?.id !== file.user_id) { + return <> + } + + return <> + + +
+

{t("Update File Info")}

+ setFilename(e.target.value)}/> + setDescription(e.target.value)}/> +
+
+ +
+ +
+
+
+ +} + function Comments({resourceId}: { resourceId: number }) { const [page, setPage] = useState(1);