Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSTEAM1-994 - Adds custom file upload html and state handling #11608

Merged
merged 37 commits into from
May 22, 2024

Conversation

HarveyPeachey
Copy link
Contributor

@HarveyPeachey HarveyPeachey commented May 9, 2024

Resolves JIRA WSTEAM1-994

Overall changes

Adds a custom file upload display, which allows management of adding and removing multiple files adding previews for images and icons for other file types.

Code changes

  • Adds a custom file uploader button that invokes the hidden file input
  • Changes state storage for files, to store them as an array of Files, instead of the input value
  • Adjusts submission logic for files for state storage change
  • Adds an ID for field labels, so aria-describedby can target labels
  • Adds SVG icons for Upload, Delete
  • Adds SVG icons as dataURI strings for Video, Audio and Documents
  • Adds adds state and logic for removal of files
  • Adds state and file reader logic for displaying thumbnails for images
  • Adds styling for file component
  • Adds unit tests

Testing

  1. cd into ws-nextjs-app
  2. Run yarn
  3. Run yarn dev
  4. Visit http://localhost:7081/somali/send/u130092370?renderer_env=test

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@HarveyPeachey HarveyPeachey changed the title adds custom file upload html and state handling WSTEAM1-994 - Adds custom file upload html and state handling May 15, 2024
).toBeInTheDocument();
});

it('should call the function to update state when a file is added', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a little brittle, as it's not testing anything in the UI, due to state management being handled in the the context, only the arguments within the handleChange function are being tested here

]);
});

it('should remove a file from the list when the remove button is clicked', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous brittle comment

@HarveyPeachey HarveyPeachey marked this pull request as ready for review May 15, 2024 14:32
@amoore108
Copy link
Contributor

Looks really great. Huge piece of a work here, so great job tackling this 👏

Is it worth adding a Storybook story for this component too? Think its maybe the only input type that doesn't have a story.

@HarveyPeachey
Copy link
Contributor Author

Looks really great. Huge piece of a work here, so great job tackling this 👏

Is it worth adding a Storybook story for this component too? Think its maybe the only input type that doesn't have a story.

Thank ya, I've added a story and the data for the somali page I've been testing on

@HarveyPeachey HarveyPeachey self-assigned this May 20, 2024
@HarveyPeachey HarveyPeachey merged commit d138d0b into latest May 22, 2024
11 checks passed
@HarveyPeachey HarveyPeachey deleted the WSTEAM1-994-file-upload-ui branch May 22, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants