-
Notifications
You must be signed in to change notification settings - Fork 0
[_]: feature/attachments #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b6d9311
feat: attachments
xabg2 fcd78e2
fix: use Attachment type from SDK
xabg2 e8ca081
test: add coverage to the upload manager and the attachment custom hook
xabg2 779f75a
refactor: improve the remove task flow
xabg2 b422564
Merge branch 'feature/upload-attachment-manager' into feature/attachm…
xabg2 3f6f0c3
fix: types in custom hook
xabg2 09965d4
Merge branch 'feature/custom-hook-to-upload-attachments' into feature…
xabg2 3b0b2ca
feat: improve attachment too large notification error
xabg2 cc4bf15
Merge branch 'master' into feature/attachments
xabg2 605fed8
fix: import the correct variable
xabg2 6aac630
Merge branch 'feature/custom-hook-to-upload-attachments' into feature…
xabg2 dca2821
refactor: use compose send custom hook
xabg2 a003da7
Merge branch 'master' into feature/attachments
xabg2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/components/compose-message/components/AttachmentList.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { ArrowClockwiseIcon, PaperclipIcon, SpinnerIcon, WarningIcon, XIcon } from '@phosphor-icons/react'; | ||
| import { bytesToString } from '@/utils/bytes-to-string'; | ||
| import { useTranslationContext } from '@/i18n'; | ||
| import { type AttachmentTask } from '../hooks/useAttachments'; | ||
| import { MAX_TOTAL_ATTACHMENT_BYTES_PER_MAIL } from '@/constants'; | ||
|
|
||
| interface AttachmentListProps { | ||
| attachments: AttachmentTask[]; | ||
| totalSize: number; | ||
| onRemove: (id: string) => void; | ||
| onRetry: (id: string) => void; | ||
| } | ||
|
|
||
| export const AttachmentList = ({ attachments, totalSize, onRemove, onRetry }: AttachmentListProps) => { | ||
| const { translate } = useTranslationContext(); | ||
| if (attachments.length === 0) return null; | ||
| return ( | ||
| <div className="mt-3 flex flex-col gap-2"> | ||
| <div className="flex flex-wrap gap-2"> | ||
| {attachments.map((a) => ( | ||
| <div key={a.id} className="flex items-center gap-1.5 rounded-md bg-gray-5 px-2 py-1"> | ||
| {a.status === 'uploading' && <SpinnerIcon size={14} className="animate-spin" />} | ||
| {a.status === 'done' && <PaperclipIcon size={14} />} | ||
| {a.status === 'error' && <WarningIcon size={14} weight="fill" className="text-red" />} | ||
| <span className="text-sm font-medium text-gray-80">{a.name}</span> | ||
| <span className="text-xs text-gray-50">{bytesToString({ size: a.size })}</span> | ||
| {a.status === 'error' && ( | ||
| <ArrowClockwiseIcon className="cursor-pointer" size={14} weight="bold" onClick={() => onRetry(a.id)} /> | ||
| )} | ||
| <XIcon className="cursor-pointer" size={14} weight="bold" onClick={() => onRemove(a.id)} /> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| <p className="text-xs text-gray-50"> | ||
| {translate('modals.composeMessageDialog.attachments.totalSize', { | ||
| used: bytesToString({ size: totalSize }), | ||
| max: bytesToString({ size: MAX_TOTAL_ATTACHMENT_BYTES_PER_MAIL }), | ||
| })} | ||
| </p> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.