-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[NoQA] refactor: Split ReportActionCompose into more compositional components to allow for separate EditOnlyReportActionCompose
#90915
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
mountiny
merged 9 commits into
Expensify:main
from
margelo:@chrispader/refactor/compositional-edit-only-report-action-compose
May 26, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4e9f65d
refactor: `ReportActionCompose` changes compositional approach
chrispader 0d80e6c
refactor: split compositional components into separate files
chrispader 6a1f6f2
Merge branch 'main' into @chrispader/refactor/compositional-edit-only…
chrispader 4d7818b
Merge branch 'main' into @chrispader/refactor/compositional-edit-only…
chrispader ea220b5
refactor: extract action button component
chrispader a24eb9e
refactor: component and file renaming
chrispader c8fb311
refactor: remove prop-drilling of `reportID`
chrispader 0eafc2a
refactor: remove redundant extra component
chrispader b4bdb34
fix: TS errors
chrispader 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
14 changes: 14 additions & 0 deletions
14
src/pages/inbox/report/ReportActionCompose/ComposerActionButton.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,14 @@ | ||
| import ComposerActionMenu from './ComposerActionMenu'; | ||
| import {useComposerEditState} from './ComposerContext'; | ||
| import ComposerEditingButtons from './ComposerEditingButtons'; | ||
|
|
||
| function ComposerActionButton() { | ||
| const {isEditingInComposer} = useComposerEditState(); | ||
|
|
||
| if (isEditingInComposer) { | ||
| return <ComposerEditingButtons />; | ||
| } | ||
| return <ComposerActionMenu />; | ||
| } | ||
|
|
||
| export default ComposerActionButton; | ||
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
29 changes: 29 additions & 0 deletions
29
src/pages/inbox/report/ReportActionCompose/ComposerContainer.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,29 @@ | ||
| import React from 'react'; | ||
| import type {PropsWithChildren} from 'react'; | ||
| import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getReportOfflinePendingActionAndErrors} from '@libs/ReportUtils'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import {useComposerState} from './ComposerContext'; | ||
|
|
||
| function ComposerContainer({children}: PropsWithChildren) { | ||
| const {reportID} = useComposerState(); | ||
| const styles = useThemeStyles(); | ||
| const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); | ||
| const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`); | ||
| const {reportPendingAction: pendingAction} = getReportOfflinePendingActionAndErrors(report); | ||
|
|
||
| return ( | ||
| <OfflineWithFeedback | ||
| shouldDisableOpacity | ||
| pendingAction={pendingAction} | ||
| style={isComposerFullSize ? styles.chatItemFullComposeRow : {}} | ||
| contentContainerStyle={isComposerFullSize ? styles.flex1 : {}} | ||
| > | ||
| {children} | ||
| </OfflineWithFeedback> | ||
| ); | ||
| } | ||
|
|
||
| export default ComposerContainer; |
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
22 changes: 22 additions & 0 deletions
22
src/pages/inbox/report/ReportActionCompose/ComposerDefaultFooter.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,22 @@ | ||
| import React from 'react'; | ||
| import OfflineIndicator from '@components/OfflineIndicator'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import ComposerExceededLength from './ComposerExceededLength'; | ||
| import ComposerFooter from './ComposerFooter'; | ||
| import ComposerTypingIndicator from './ComposerTypingIndicator'; | ||
|
|
||
| function ComposerDefaultFooter() { | ||
| const styles = useThemeStyles(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
|
|
||
| return ( | ||
| <ComposerFooter> | ||
| {!shouldUseNarrowLayout && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />} | ||
| <ComposerTypingIndicator /> | ||
| <ComposerExceededLength /> | ||
| </ComposerFooter> | ||
| ); | ||
| } | ||
|
|
||
| export default ComposerDefaultFooter; |
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
7 changes: 2 additions & 5 deletions
7
src/pages/inbox/report/ReportActionCompose/ComposerFooter.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
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
46 changes: 46 additions & 0 deletions
46
src/pages/inbox/report/ReportActionCompose/ComposerInputArea.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,46 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ComposerActionButton from './ComposerActionButton'; | ||
| import ComposerBox from './ComposerBox'; | ||
| import ComposerContainer from './ComposerContainer'; | ||
| import {useComposerState} from './ComposerContext'; | ||
| import ComposerDropZone from './ComposerDropZone'; | ||
| import ComposerEmojiPicker from './ComposerEmojiPicker'; | ||
| import ComposerImportedState from './ComposerImportedState'; | ||
| import ComposerInput from './ComposerInput'; | ||
| import ComposerLocalTime from './ComposerLocalTime'; | ||
| import ComposerSendButton from './ComposerSendButton'; | ||
|
|
||
| function ComposerInputArea() { | ||
| const {reportID} = useComposerState(); | ||
| const styles = useThemeStyles(); | ||
| const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`); | ||
|
|
||
| return ( | ||
| <View | ||
| testID={CONST.COMPOSER.TEST_ID.REPORT_ACTION_COMPOSE} | ||
| style={[isComposerFullSize && styles.chatItemFullComposeRow]} | ||
| > | ||
| <ComposerLocalTime /> | ||
| <View style={isComposerFullSize ? styles.flex1 : {}}> | ||
| <ComposerContainer> | ||
| <ComposerDropZone> | ||
| <ComposerBox> | ||
| <ComposerActionButton /> | ||
| <ComposerInput /> | ||
| <ComposerEmojiPicker /> | ||
| <ComposerSendButton /> | ||
| </ComposerBox> | ||
| </ComposerDropZone> | ||
| </ComposerContainer> | ||
| <ComposerImportedState /> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default ComposerInputArea; |
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
6 changes: 4 additions & 2 deletions
6
...Compose/AgentZeroAwareTypingIndicator.tsx → ...ActionCompose/ComposerTypingIndicator.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 |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| import React from 'react'; | ||
| import useShouldSuppressConciergeIndicators from '@hooks/useShouldSuppressConciergeIndicators'; | ||
| import ReportTypingIndicator from '@pages/inbox/report/ReportTypingIndicator'; | ||
| import {useComposerState} from './ComposerContext'; | ||
|
|
||
| function AgentZeroAwareTypingIndicator({reportID}: {reportID: string}) { | ||
| function ComposerTypingIndicator() { | ||
| const {reportID} = useComposerState(); | ||
| const shouldSuppress = useShouldSuppressConciergeIndicators(reportID); | ||
| if (shouldSuppress) { | ||
| return null; | ||
| } | ||
| return <ReportTypingIndicator reportID={reportID} />; | ||
| } | ||
|
|
||
| export default AgentZeroAwareTypingIndicator; | ||
| export default ComposerTypingIndicator; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
App crashes immediately on start.
import React from 'react';is missing on this file.