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

PLU-337: Allow attachments in postman #821

Open
wants to merge 29 commits into
base: develop-v2
Choose a base branch
from

Conversation

kevinkim-ogp
Copy link
Contributor

@kevinkim-ogp kevinkim-ogp commented Dec 16, 2024

Problem

Users want to upload a fixed file when sending email via Postman.

Solution

Allow uploads at Postman step for users to send a fixed file with every email.
Note: attachments are available for use in all Postman steps of the same Pipe

Features:

  • Upload fixed file when sending email via Postman

Improvements:

  • Improve attachment selector to be consistent with other variable selectors
  • Improve toPrettyDateString function to convert iso and ms inputs to date strings
  • Improve FileUpload component to show as an IconButton or with text

Before & After Screenshots

BEFORE:
Screenshot 2024-12-16 at 1 43 29 PM

AFTER:
Screenshot 2024-12-16 at 2 23 28 PM
Screenshot 2024-12-16 at 2 23 49 PM

Tests

  • Existing Pipes with variable attachments are populated and checked correctly
  • Existing Pipes can handle uploaded attachments and send emails correctly with existing variable attachments
  • New Pipes can handle both FormSG, LetterSG and uploaded attachments
  • When deleting a file in a Pipe, file should be deleted from all Steps in the Pipe (ensures that Pipe does not fail)
  • When deleting a Pipe, files uploaded to the Pipe should be deleted from S3

Deploy Notes

  • Note: infra updates required to add permissions for Malware Protection and GetObjectTagging

New scripts:

  • packages/backend/src/graphql/__tests__/mutations/delete-from-s3.itest.ts : tests for functions to delete from s3
  • packages/backend/src/graphql/__tests__/mutations/flow.mock.ts : mocks to create mock flow and step
  • packages/backend/src/graphql/__tests__/mutations/generate-presigned-url.itest.ts : tests for function to generate pre-signed URL to upload files to S3
  • packages/backend/src/graphql/mutations/delete-from-s3.ts: function to delete files from S3 and corresponding steps
  • packages/backend/src/graphql/mutations/generate-presigned-url.ts: function to generate pre-signed URL for uploading file to S3
  • packages/frontend/src/components/AttachmentSuggestions/components/Checkbox.tsx: component to display attachments as checkboxes
  • packages/frontend/src/components/AttachmentSuggestions/components/Suggestions.tsx: component to display attachments in same format as variables
  • packages/frontend/src/components/AttachmentSuggestions/components/TagList.tsx: component to display selected files as a Tag, with close button to remove
  • packages/frontend/src/components/AttachmentSuggestions/hooks/useAttachmentSelection.ts: hook to manage attachment selection
  • packages/frontend/src/components/AttachmentSuggestions/index.tsx: component for suggesting attachment variables or upload fixed attachments
  • packages/frontend/src/components/AttachmentSuggestions/style.ts: to manage styles for AttachmentSuggestions
    -packages/frontend/src/components/AttachmentSuggestions/utils.ts: helpers for attachments including file type and size validation, formatters to file size display, reformatting files to correct format for saving
  • packages/frontend/src/components/SuggestionsWrapper/index.tsx: generic wrapper for suggestions panel
  • packages/frontend/src/graphql/mutations/delete-from-s3.ts: to invoke DeleteFromS3
  • packages/frontend/src/graphql/mutations/generate-presigned-url.ts: to call
  • packages/frontend/src/hooks/useS3Operations.ts: hook to perform upload and delete from S3
  • packages/frontend/src/theme/components/Checkbox.ts: set style for Checkbox

New dependencies:

  • @aws-sdk/s3-request-presigner : to generate pre-signed URL for uploading attachments to S3

Copy link

linear bot commented Dec 16, 2024

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Dec 16, 2024

Datadog Report

Branch report: feat/postman-upload-attachment
Commit report: 116db38
Test service: plumber

✅ 0 Failed, 745 Passed, 0 Skipped, 2m 8.84s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.52%)

🔻 Code Coverage Decreases vs Default Branch (1)

@kevinkim-ogp kevinkim-ogp marked this pull request as ready for review December 17, 2024 02:41
@kevinkim-ogp kevinkim-ogp requested a review from a team as a code owner December 17, 2024 02:41
@kevinkim-ogp kevinkim-ogp force-pushed the feat/postman-upload-attachment branch from dd3a98f to 116db38 Compare December 19, 2024 15:34
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.

1 participant