Skip to content

Commit d53f740

Browse files
jordanvnreesscot
authored andcommitted
Copy storagemanager as fileuploader (#5744)
* chore: copy StorageManager component, renaming copy FileUploader * chore: add FileUploader to component class names * chore: renaming internal FileUploader references to use its own name * chore: adding test for default prop in FileControl * chore: rename test file to use FileUploader reference * chore: add changeset * fix: adding reference to correct component class in test * Update .changeset/small-masks-act.md Co-authored-by: Scott Rees <[email protected]> --------- Co-authored-by: Scott Rees <[email protected]>
1 parent 5d9c329 commit d53f740

File tree

4 files changed

+111
-20
lines changed

4 files changed

+111
-20
lines changed

.changeset/small-masks-act.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@aws-amplify/ui-react-storage': minor
3+
'@aws-amplify/ui': minor
4+
---
5+
6+
Adds FileUploader as new default name of StorageManager to avoid confusion with new components

packages/react-storage/src/components/FileUploader/hooks/useFileUploader/__tests__/useFileUploader.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,6 @@ describe('useUploadFiles', () => {
167167
expect(result.current.files.length).toBe(1);
168168
});
169169

170-
it('should update a target file key', () => {
171-
const { result } = renderHook(() => useStorageManager(defaultFiles));
172-
173-
const processedKey = 'processedKey';
174-
175-
expect(result.current.files[0].processedKey).toBeUndefined();
176-
177-
act(() => result.current.setProcessedKey({ id: 'file1', processedKey }));
178-
179-
expect(result.current.files[0].processedKey).toBe(processedKey);
180-
});
181-
182170
describe('defaultFiles', () => {
183171
it('should handle good defaultFiles', () => {
184172
const { result } = renderHook(() =>

packages/react-storage/src/components/FileUploader/hooks/useFileUploader/actions.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ export const queueFilesAction = (): Action => ({
2323
type: FileUploaderActionTypes.QUEUE_FILES,
2424
});
2525

26-
export const setProcessedKeyAction = (input: {
27-
id: string;
28-
processedKey: string;
29-
}): Action => ({
30-
...input,
31-
type: StorageManagerActionTypes.SET_PROCESSED_FILE_KEY,
32-
});
33-
3426
export const setUploadingFileAction = ({
3527
id,
3628
uploadTask,

packages/react-storage/src/components/StorageManager/ui/FileList/__tests__/__snapshots__/FileControl.test.tsx.snap

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,108 @@ exports[`FileControl should default to showThumbnails being true 1`] = `
355355
</div>
356356
</div>
357357
`;
358+
359+
exports[`FileControl should default to showThumbnails being true 1`] = `
360+
<div>
361+
<div
362+
class="amplify-storagemanager__file"
363+
>
364+
<div
365+
class="amplify-storagemanager__file__wrapper"
366+
>
367+
<div
368+
class="amplify-storagemanager__file__image"
369+
>
370+
<span
371+
class="amplify-icon"
372+
style="width: 1em; height: 1em;"
373+
>
374+
<svg
375+
fill="none"
376+
height="24"
377+
viewBox="0 0 24 24"
378+
width="24"
379+
xmlns="http://www.w3.org/2000/svg"
380+
>
381+
<path
382+
d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"
383+
fill="currentColor"
384+
/>
385+
</svg>
386+
</span>
387+
</div>
388+
<div
389+
class="amplify-storagemanager__file__main"
390+
>
391+
<p
392+
class="amplify-text amplify-storagemanager__file__name"
393+
>
394+
fileName
395+
</p>
396+
</div>
397+
<span
398+
class="amplify-text amplify-storagemanager__file__size"
399+
/>
400+
<svg
401+
class="amplify-loader amplify-loader--linear amplify-storagemanager__loader"
402+
role="img"
403+
>
404+
<g>
405+
<line
406+
data-testid="linear-empty"
407+
style="stroke: undefined;"
408+
x1="0"
409+
x2="100%"
410+
y1="50%"
411+
y2="50%"
412+
/>
413+
<line
414+
data-testid="linear-filled"
415+
x1="0"
416+
x2="100%"
417+
y1="50%"
418+
y2="50%"
419+
/>
420+
</g>
421+
</svg>
422+
<button
423+
class="amplify-button amplify-field-group__control amplify-button--small"
424+
data-testid="storage-manager-remove-button"
425+
type="button"
426+
>
427+
<span
428+
class="amplify-visually-hidden"
429+
>
430+
Remove file fileName
431+
</span>
432+
<span
433+
aria-hidden="true"
434+
>
435+
<span
436+
class="amplify-icon"
437+
style="width: 1em; height: 1em;"
438+
>
439+
<svg
440+
fill="none"
441+
height="24"
442+
viewBox="0 0 24 24"
443+
width="24"
444+
xmlns="http://www.w3.org/2000/svg"
445+
>
446+
<path
447+
d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z"
448+
fill="currentColor"
449+
/>
450+
</svg>
451+
</span>
452+
</span>
453+
</button>
454+
</div>
455+
<p
456+
class="amplify-text amplify-storagemanager__file__status"
457+
>
458+
Uploading
459+
</p>
460+
</div>
461+
</div>
462+
`;

0 commit comments

Comments
 (0)