From 3cc8be9c22c4a2ab83475e0b26e5b10141fb360c Mon Sep 17 00:00:00 2001 From: Purvesh Date: Sun, 17 Nov 2024 10:41:11 +1300 Subject: [PATCH] minor asset improvements --- react-admin/src/pages/asset/AssetTable.tsx | 15 ++-- .../src/pages/asset/CreateFolderModal.tsx | 7 +- react-admin/src/pages/asset/DisplayAsset.tsx | 84 +++++++++---------- ...meFolderModal.tsx => RenameAssetModal.tsx} | 8 +- .../src/pages/asset/hooks/useCreateFolder.ts | 4 + .../src/types/asset/CreateFolderType.ts | 3 +- .../asset/rename_asset_api_handler.rs | 5 +- .../handlers/asset/store_asset_api_handler.rs | 4 +- src/providers/avored_template_provider.rs | 2 - 9 files changed, 65 insertions(+), 67 deletions(-) rename react-admin/src/pages/asset/{RenameFolderModal.tsx => RenameAssetModal.tsx} (95%) diff --git a/react-admin/src/pages/asset/AssetTable.tsx b/react-admin/src/pages/asset/AssetTable.tsx index a6b5da8..1123679 100644 --- a/react-admin/src/pages/asset/AssetTable.tsx +++ b/react-admin/src/pages/asset/AssetTable.tsx @@ -91,15 +91,16 @@ function AssetTable() {
diff --git a/react-admin/src/pages/asset/CreateFolderModal.tsx b/react-admin/src/pages/asset/CreateFolderModal.tsx index c2d54c8..38a9b30 100644 --- a/react-admin/src/pages/asset/CreateFolderModal.tsx +++ b/react-admin/src/pages/asset/CreateFolderModal.tsx @@ -12,11 +12,13 @@ import {useCreateFolder} from "./hooks/useCreateFolder"; type CreateFolderModalProps = { isOpen: any, onCloseModal: any, + parent_id?: string, } export const CreateFolderModal = (({ - isOpen, - onCloseModal, + isOpen, + onCloseModal, + parent_id }: CreateFolderModalProps) => { const [t] = useTranslation("global"); const { mutate } = useCreateFolder() @@ -24,6 +26,7 @@ export const CreateFolderModal = (({ const submitHandler: SubmitHandler = ((data: CreateFolderType) => { onCloseModal() + data.parent_id = parent_id mutate(data) }) diff --git a/react-admin/src/pages/asset/DisplayAsset.tsx b/react-admin/src/pages/asset/DisplayAsset.tsx index 53a9d76..37870ad 100644 --- a/react-admin/src/pages/asset/DisplayAsset.tsx +++ b/react-admin/src/pages/asset/DisplayAsset.tsx @@ -5,9 +5,10 @@ import { FolderPlusIcon, } from "@heroicons/react/24/outline"; import { useDeleteFolder } from "./hooks/useDeleteFolder"; -import { RenameFolderModal } from "./RenameFolderModal"; +import { RenameAssetModal } from "./RenameAssetModal"; import { useTranslation } from "react-i18next"; import {Link} from "react-router-dom"; +import {Menu, MenuButton, MenuItem, MenuItems} from "@headlessui/react"; type DisplayAssetProp = { asset: IAssetModel; @@ -42,48 +43,42 @@ export const DisplayAsset = ({ asset, openFolder }: DisplayAssetProp) => { <>
- - + + + onRemoveAssetOnClick(e, asset.asset_type, asset.id) + } + href="#" + > + {t("remove")} + + + + + {t("rename")} + + + +
{asset.asset_type === "FOLDER" ? ( @@ -93,7 +88,7 @@ export const DisplayAsset = ({ asset, openFolder }: DisplayAssetProp) => { ) : ( <> {asset.name} @@ -105,19 +100,18 @@ export const DisplayAsset = ({ asset, openFolder }: DisplayAssetProp) => { {asset.asset_type === "FOLDER" ? ( <> ) : ( <>
- - {/** ADD COPY ICON AND Allow them to copy the file name **/} - {asset.name} + {/** ADD COPY ICON AND Allow them to copy the file name **/} + {asset.name}
)} diff --git a/react-admin/src/pages/asset/RenameFolderModal.tsx b/react-admin/src/pages/asset/RenameAssetModal.tsx similarity index 95% rename from react-admin/src/pages/asset/RenameFolderModal.tsx rename to react-admin/src/pages/asset/RenameAssetModal.tsx index efd2072..6e447dc 100644 --- a/react-admin/src/pages/asset/RenameFolderModal.tsx +++ b/react-admin/src/pages/asset/RenameAssetModal.tsx @@ -10,17 +10,17 @@ import IAssetModel from "../../types/asset/IAssetModel"; import {RenameFolderType} from "../../types/asset/RenameFolderType"; import {useRenameFolder} from "./hooks/useRenameFolder"; -type RenameFolderModalProps = { +type RenameAssetModalProps = { isOpen: any, onCloseModal: any, asset: IAssetModel } -export const RenameFolderModal = (({ +export const RenameAssetModal = (({ isOpen, onCloseModal, asset - }: RenameFolderModalProps) => { + }: RenameAssetModalProps) => { const [t] = useTranslation("global"); const { mutate } = useRenameFolder() @@ -70,7 +70,7 @@ export const RenameFolderModal = (({ duration-150 ease-linear bg-primary-600 border border-primary-600 rounded-lg hover:bg-red-500" > - {t("create")} + {t("rename")}