Skip to content

Commit

Permalink
fix(media): allow creating folders in empty folder (#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj authored Nov 24, 2023
1 parent e26abc9 commit 09f3ade
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/components/CreateMediaFolderModal/CreateMediaFolderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ interface CreateMediaFolderModalProps {

const getButtonLabel = (
originalSelectedMedia: SelectedMediaDto[],
filesCount: number,
selectedMedia: SelectedMediaDto[],
mediaLabels: MediaLabels
) => {
Expand All @@ -80,7 +81,7 @@ const getButtonLabel = (
pluralMediaLabel,
} = mediaLabels

if (originalSelectedMedia.length > 0) {
if (originalSelectedMedia.length > 0 || filesCount === 0) {
return `Create ${singularDirectoryLabel}`
}

Expand Down Expand Up @@ -229,7 +230,7 @@ export const CreateMediaFolderModal = ({
</FormErrorMessage>
</FormControl>

{originalSelectedMedia.length === 0 && (
{originalSelectedMedia.length === 0 && files.length !== 0 && (
<>
<Text as="h5" textStyle="h5" mt="2rem">
Select {pluralMediaLabel} to add to this{" "}
Expand Down Expand Up @@ -314,7 +315,7 @@ export const CreateMediaFolderModal = ({
justifyContent="flex-end"
mt="0.5rem"
>
{originalSelectedMedia.length > 0 && (
{(originalSelectedMedia.length > 0 || files.length === 0) && (
<Button
variant="clear"
colorScheme="neutral"
Expand All @@ -323,7 +324,7 @@ export const CreateMediaFolderModal = ({
Cancel
</Button>
)}
{originalSelectedMedia.length === 0 && (
{originalSelectedMedia.length === 0 && files.length !== 0 && (
<Button
variant="clear"
colorScheme="neutral"
Expand Down Expand Up @@ -359,6 +360,7 @@ export const CreateMediaFolderModal = ({
>
{getButtonLabel(
originalSelectedMedia,
files.length,
methods.getValues("selectedPages"),
mediaLabels
)}
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/Media/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,7 @@ export const Media = (): JSX.Element => {
{directoryLevel < MAX_MEDIA_LEVELS && (
<Greyscale isActive={isWriteDisabled}>
<Button
as={Link}
to={`${url}/createDirectory`}
onClick={onCreateMediaFolderModalOpen}
mt="1rem"
variant="clear"
>
Expand Down

0 comments on commit 09f3ade

Please sign in to comment.