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 ability to download unsupported attachments #333

Merged
merged 7 commits into from
Jul 13, 2023

Conversation

davidjgoss
Copy link
Contributor

@davidjgoss davidjgoss commented Jul 12, 2023

🤔 What's changed?

For attachments that aren't a video, image or text, we previously rendered an error message about the attachment being unsupported.

This PR changes the behaviour so we instead render a button to download the attachment as a file. It:

  • Works with Base64 or text as the body
  • Honours the user-specified fileName from the message if present, generates a filename with the correct extension for the media type if not
  • Uses the URL.createObjectURL API, only creating the URL when first requested and cleaning up again when the component is unmounted - so we are doing this in a standards-compliant way without having to externalise a file or crash the browser

image

It also includes some slight rework in the Gherkin document accordion, so a panel is only rendered when it's expanded - previously this was just hidden by way of display: none. This means we don't render components unless the user is going to see them, and also that any generated download URLs are cleaned up when a panel is closed.

⚡️ What's your motivation?

Fixes #80.

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, documentation etc. without changing behaviour)
  • ⚡ New feature (non-breaking change which adds new behaviour)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@davidjgoss davidjgoss marked this pull request as ready for review July 12, 2023 13:51
Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

I read the changes commit by commit, and they are very clear and step-by-step. Thanks for doing it that way!

Minor: some console.log statements are perhaps builder's dust? If you think so, sweep it away, otherwise keep it.

Let's get this merged!

@davidjgoss davidjgoss merged commit 48148d4 into main Jul 13, 2023
1 check passed
@davidjgoss davidjgoss deleted the feat/80-download-attachments branch July 13, 2023 12:27
badeball added a commit to badeball/cypress-cucumber-preprocessor that referenced this pull request Jul 17, 2023
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.

react: Allow attachments with unsupported file types to be downloaded
2 participants