Skip to content

Commit

Permalink
Adjust types in FileSelect actions to be exactly what is realistica…
Browse files Browse the repository at this point in the history
…lly possible (#2354)
  • Loading branch information
jamesricky authored Jul 29, 2024
1 parent 949356e commit 5480dc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/admin/admin/src/form/file/FileSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Alert } from "../../alert/Alert";
import { createComponentSlot } from "../../helpers/createComponentSlot";
import { ThemedComponentBaseProps } from "../../helpers/ThemedComponentBaseProps";
import { FileDropzone } from "./FileDropzone";
import { FileSelectItem, ValidFileSelectItem } from "./fileSelectItemTypes";
import { ErrorFileSelectItem, FileSelectItem, ValidFileSelectItem } from "./fileSelectItemTypes";
import { FileSelectListItem } from "./FileSelectListItem";
import { getFilesInfoText } from "./getFilesInfoText";

Expand Down Expand Up @@ -45,8 +45,8 @@ type OwnerState = {
export type FileSelectProps<AdditionalValidFileValues = Record<string, unknown>> = {
files: FileSelectItem<AdditionalValidFileValues>[];
onDrop?: DropzoneOptions["onDrop"];
onRemove?: (file: FileSelectItem<AdditionalValidFileValues>) => void;
onDownload?: (file: FileSelectItem<AdditionalValidFileValues>) => void;
onRemove?: (file: ValidFileSelectItem<AdditionalValidFileValues> | ErrorFileSelectItem) => void;
onDownload?: (file: ValidFileSelectItem<AdditionalValidFileValues>) => void;
getDownloadUrl?: (file: ValidFileSelectItem<AdditionalValidFileValues>) => string;
disabled?: boolean;
readOnly?: boolean;
Expand Down Expand Up @@ -148,7 +148,7 @@ export const FileSelect = <AdditionalValidFileValues = Record<string, unknown>,>
: undefined
}
downloadUrl={isValidFile && getDownloadUrl ? getDownloadUrl(file) : undefined}
onClickDelete={readOnly || !onRemove ? undefined : () => onRemove(file)}
onClickDelete={readOnly || !onRemove || "loading" in file ? undefined : () => onRemove(file)}
filePreview={layout === "grid"}
{...slotProps?.fileListItem}
/>
Expand Down

0 comments on commit 5480dc5

Please sign in to comment.