From 09f3ade49a9a71498e8dc7248e78d3fb1c7b824c Mon Sep 17 00:00:00 2001 From: Hsu Zhong Jun <27919917+dcshzj@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:29:56 +0800 Subject: [PATCH 1/4] fix(media): allow creating folders in empty folder (#1702) --- .../CreateMediaFolderModal/CreateMediaFolderModal.tsx | 10 ++++++---- src/layouts/Media/Media.tsx | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/CreateMediaFolderModal/CreateMediaFolderModal.tsx b/src/components/CreateMediaFolderModal/CreateMediaFolderModal.tsx index 8e756ce3b..c1f9ac527 100644 --- a/src/components/CreateMediaFolderModal/CreateMediaFolderModal.tsx +++ b/src/components/CreateMediaFolderModal/CreateMediaFolderModal.tsx @@ -71,6 +71,7 @@ interface CreateMediaFolderModalProps { const getButtonLabel = ( originalSelectedMedia: SelectedMediaDto[], + filesCount: number, selectedMedia: SelectedMediaDto[], mediaLabels: MediaLabels ) => { @@ -80,7 +81,7 @@ const getButtonLabel = ( pluralMediaLabel, } = mediaLabels - if (originalSelectedMedia.length > 0) { + if (originalSelectedMedia.length > 0 || filesCount === 0) { return `Create ${singularDirectoryLabel}` } @@ -229,7 +230,7 @@ export const CreateMediaFolderModal = ({ - {originalSelectedMedia.length === 0 && ( + {originalSelectedMedia.length === 0 && files.length !== 0 && ( <> Select {pluralMediaLabel} to add to this{" "} @@ -314,7 +315,7 @@ export const CreateMediaFolderModal = ({ justifyContent="flex-end" mt="0.5rem" > - {originalSelectedMedia.length > 0 && ( + {(originalSelectedMedia.length > 0 || files.length === 0) && (