Skip to content

Commit

Permalink
fix(fileUploader): Rename maxFiles to maxFilesCount (#3377)
Browse files Browse the repository at this point in the history
* Renamed maxFiles to maxFileCount

* Added changeset

---------

Co-authored-by: Erik Hanchett <ehhanche@amazon.com>
  • Loading branch information
ErikCH and Erik Hanchett authored Feb 2, 2023
1 parent 5138f67 commit 6daf2e6
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-rabbits-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/ui-react': patch
---

Renamed the maxFiles prop to maxFilesCount
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const FileUploaderThemeExample = () => {
accessLevel="public"
hasMultipleFiles={true}
maxSize={100000000}
maxFiles={3}
maxFileCount={3}
provider="fast" // IGNORE
/>
</ThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FileUploader } from '@aws-amplify/ui-react';
export const MaxFilesExample = () => {
return (
<FileUploader
maxFiles={3}
maxFileCount={3}
variation="drop"
acceptedFileTypes={['image/*']}
accessLevel="public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ The following props set limits on what the File Uploader will accept.

### Max Number of Files

The `maxFiles` prop accepts how many files at one time you can select to upload. The default is unlimited.
The `maxFileCount` prop accepts how many files at one time you can select to upload. The default is unlimited.

<Example>
<MaxFilesExample />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function FileUploaderEmail() {
accessLevel="public"
hasMultipleFiles={true}
maxSize={100000000}
maxFiles={3}
maxFileCount={3}
isResumable={true}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function FileUploader({
acceptedFileTypes,
shouldAutoProceed = false,
isPreviewerVisible,
maxFiles,
maxFileCount,
maxSize,
hasMultipleFiles = true,
onError,
Expand Down Expand Up @@ -76,7 +76,8 @@ export function FileUploader({
// Displays if over max files

const hasMaxFilesError =
fileStatuses.filter((file) => file.percentage !== 100).length > maxFiles;
fileStatuses.filter((file) => file.percentage !== 100).length >
maxFileCount;

useEffect(() => {
// Loading ends when all files are at 100%
Expand Down Expand Up @@ -379,7 +380,7 @@ export function FileUploader({
isLoading={isLoading}
isSuccessful={isSuccessful}
hasMaxFilesError={hasMaxFilesError}
maxFiles={maxFiles}
maxFileCount={maxFileCount}
onClear={onClear}
onFileClick={onFileClick}
aggregatePercentage={aggregatePercentage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const commonProps = {
isLoading: false,
isSuccessful: false,
hasMaxFilesError: false,
maxFiles: 10,
maxFileCount: 10,
onClear: () => null,
onFileClick: () => null,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export function UploadPreviewer({
isLoading,
isSuccessful,
hasMaxFilesError,
maxFiles,
maxFileCount,
onClear,
onFileClick,
}: PreviewerProps): JSX.Element {
const headingMaxFiles = `${translate('Cannot choose more than')} ${maxFiles}`;
const headingMaxFiles = `${translate(
'Cannot choose more than'
)} ${maxFileCount}`;
const getUploadedFilesLength = () =>
fileStatuses.filter((file) => file?.fileState === 'success').length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ describe('File Uploader', () => {
...mockReturnUseFileUploader,
});

render(<FileUploader {...commonProps} maxFiles={1} isPreviewerVisible />);
render(
<FileUploader {...commonProps} maxFileCount={1} isPreviewerVisible />
);

const uploadFilesText = await screen.findByText(/Upload 1 file/);

Expand All @@ -600,7 +602,9 @@ describe('File Uploader', () => {
...mockReturnUseFileUploader,
});

render(<FileUploader {...commonProps} maxFiles={1} isPreviewerVisible />);
render(
<FileUploader {...commonProps} maxFileCount={1} isPreviewerVisible />
);

const errorText = await screen.findByText(/Cannot choose more than 1/);

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Storage/FileUploader/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface FileUploaderProps {
isPreviewerVisible?: boolean;
isResumable?: boolean;
accessLevel: StorageAccessLevel;
maxFiles?: number;
maxFileCount?: number;
maxSize?: number;
onError?: (error: string) => void;
onSuccess?: (event: { key: string }) => void;
Expand All @@ -39,7 +39,7 @@ export interface PreviewerProps {
isLoading: boolean;
isSuccessful: boolean;
hasMaxFilesError: boolean;
maxFiles: number;
maxFileCount: number;
onClear: () => void;
onFileClick: () => void;
}
Expand Down

0 comments on commit 6daf2e6

Please sign in to comment.