-
Notifications
You must be signed in to change notification settings - Fork 0
[PB-1972]: feat/mail actions #48
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 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
23c856a
feat: mail actions
xabg2 d8ac923
refactor: extract duplicated code
xabg2 89e15cd
fix: tests and types
xabg2 a30cac9
refactor: update constant name description
xabg2 e0c5bfa
refactor: extrct actions bar list items to custom hook
xabg2 f05aa1e
fix: filter read messages
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
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 |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| npm run check:i18n | ||
| npx lint-staged | ||
| npm run test:related |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
143 changes: 143 additions & 0 deletions
143
src/features/mail/components/mail-preview/actions-bar/index.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,143 @@ | ||
| import { useTranslationContext } from '@/i18n'; | ||
| import { | ||
| ArrowBendDoubleUpLeftIcon, | ||
| ArrowBendUpLeftIcon, | ||
| ArrowBendUpRightIcon, | ||
| EnvelopeOpenIcon, | ||
| TrashIcon, | ||
| TrayIcon, | ||
| WarningOctagonIcon, | ||
| } from '@phosphor-icons/react'; | ||
| import MoveTo from '@/assets/icons/move-to.svg?react'; | ||
| import { Dropdown, type MenuItemType } from '@internxt/ui'; | ||
| import { isCurrentPath } from '@/utils/current-path'; | ||
| import { useLocation } from 'react-router-dom'; | ||
| import { useCallback, useMemo } from 'react'; | ||
| import type { FolderType } from '@/types/mail'; | ||
|
|
||
| interface ActionsBarProps { | ||
| isRead: boolean; | ||
| optionsDisabled: boolean; | ||
| onMarkAsRead: () => void; | ||
| onMarkAsUnread: () => void; | ||
| onReply: () => void; | ||
| onReplyAll: () => void; | ||
| onForward: () => void; | ||
| onMove: (folder: FolderType) => Promise<null> | void; | ||
| onTrash: () => Promise<null> | void; | ||
|
xabg2 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| const Separator = () => <div className="h-5 w-px bg-gray-10" />; | ||
|
|
||
| const ActionsBar = ({ | ||
| isRead, | ||
| optionsDisabled, | ||
| onMarkAsRead, | ||
| onMarkAsUnread, | ||
| onTrash, | ||
| onMove, | ||
| onReply, | ||
| onReplyAll, | ||
| onForward, | ||
| }: ActionsBarProps) => { | ||
| const { translate } = useTranslationContext(); | ||
| const { pathname } = useLocation(); | ||
|
|
||
| const iconButtonClass = | ||
| 'flex items-center justify-center rounded-lg p-2 text-gray-60 transition-colors hover:bg-gray-5 hover:text-gray-80 disabled:pointer-events-none disabled:opacity-40'; | ||
|
|
||
| const isActive = useCallback((path: string) => isCurrentPath(path, pathname), [pathname]); | ||
|
|
||
| const moveToItems: MenuItemType<unknown>[] = useMemo( | ||
| () => [ | ||
| { | ||
| disabled: () => isActive('/inbox') || optionsDisabled, | ||
| name: translate('mail.inbox'), | ||
| icon: TrayIcon, | ||
| onClick: () => onMove('inbox'), | ||
| }, | ||
| { | ||
| disabled: () => isActive('/spam') || optionsDisabled, | ||
| name: translate('mail.spam'), | ||
| icon: WarningOctagonIcon, | ||
| onClick: () => onMove('spam'), | ||
| }, | ||
| { | ||
| disabled: () => isActive('/trash') || optionsDisabled, | ||
| name: translate('mail.trash'), | ||
| icon: TrashIcon, | ||
| onClick: () => onMove('trash'), | ||
| }, | ||
| ], | ||
| [optionsDisabled, isActive, onMove, translate], | ||
| ); | ||
|
xabg2 marked this conversation as resolved.
Outdated
xabg2 marked this conversation as resolved.
Outdated
|
||
|
|
||
| return ( | ||
| <div className="flex items-center z-30 gap-5 pl-4"> | ||
| <button | ||
| disabled={optionsDisabled} | ||
| type="button" | ||
| title={isRead ? translate('actions.markAsUnread') : translate('actions.markAsRead')} | ||
| className={iconButtonClass} | ||
| onClick={isRead ? onMarkAsUnread : onMarkAsRead} | ||
| > | ||
| <EnvelopeOpenIcon size={24} /> | ||
| </button> | ||
|
|
||
| <div className="flex flex-row gap-1 items-center"> | ||
| <button | ||
| disabled={optionsDisabled} | ||
| type="button" | ||
| title={translate('actions.trashEmail')} | ||
| className={iconButtonClass} | ||
| onClick={onTrash} | ||
| > | ||
| <TrashIcon size={24} /> | ||
| </button> | ||
| <Separator /> | ||
| <Dropdown | ||
| classButton={iconButtonClass} | ||
| dropdownActionsContext={moveToItems} | ||
| openDirection="left" | ||
| classMenuItems="max-w-[224px] w-screen" | ||
| > | ||
| <MoveTo /> | ||
| </Dropdown> | ||
| </div> | ||
|
|
||
| <div className="flex flex-row items-center gap-1"> | ||
| <button | ||
| disabled={optionsDisabled} | ||
| type="button" | ||
| title={translate('actions.reply')} | ||
| className={iconButtonClass} | ||
| onClick={onReply} | ||
| > | ||
| <ArrowBendUpLeftIcon size={24} /> | ||
| </button> | ||
| <Separator /> | ||
| <button | ||
| disabled={optionsDisabled} | ||
| type="button" | ||
| title={translate('actions.replyAll')} | ||
| className={iconButtonClass} | ||
| onClick={onReplyAll} | ||
| > | ||
| <ArrowBendDoubleUpLeftIcon size={24} /> | ||
| </button> | ||
| <Separator /> | ||
| <button | ||
| disabled={optionsDisabled} | ||
| type="button" | ||
| title={translate('actions.forward')} | ||
| className={iconButtonClass} | ||
| onClick={onForward} | ||
| > | ||
| <ArrowBendUpRightIcon size={24} /> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ActionsBar; | ||
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.