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

Add file input component #2469

Merged
merged 14 commits into from
Jun 14, 2024
Merged

Add file input component #2469

merged 14 commits into from
Jun 14, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Jun 7, 2024

This adds a new component FileInput which can be used to upload files to the Snap. It can be used in forms, and the files are sent to the Snap using a new FileUploadEvent, as well as a new files property in FormSubmitEvent.

<Field label="Upload file">
  <FileInput name="file" accept={['image/*']} compact />
</Field>
@Mrtenz Mrtenz force-pushed the mrtenz/file-input-component branch 2 times, most recently from 789eea2 to 72299e3 Compare June 13, 2024 11:24
Copy link

socket-security bot commented Jun 13, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/file-upload-example-snap@0.0.0-use.local None 0 0 B

View full report↗︎

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.35%. Comparing base (151e6c5) to head (41426c5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2469   +/-   ##
=======================================
  Coverage   94.34%   94.35%           
=======================================
  Files         439      440    +1     
  Lines        9054     9070   +16     
  Branches     1391     1398    +7     
=======================================
+ Hits         8542     8558   +16     
  Misses        512      512           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mrtenz Mrtenz marked this pull request as ready for review June 13, 2024 11:42
@Mrtenz Mrtenz requested a review from a team as a code owner June 13, 2024 11:42
event.type === UserInputEventType.FileUploadEvent &&
event.file !== null
) {
const { files } = (await snap.request({
Copy link
Member

Choose a reason for hiding this comment

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

Good argument for letting context be updatable, but context currently has a quite small limit so you wouldn't be able to store large files there anyway

@Mrtenz Mrtenz force-pushed the mrtenz/file-input-component branch from 9376e09 to 41426c5 Compare June 14, 2024 11:24
@Mrtenz Mrtenz merged commit b68a7c0 into main Jun 14, 2024
156 checks passed
@Mrtenz Mrtenz deleted the mrtenz/file-input-component branch June 14, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants