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

Format whispers/welcome messages in the report action list of each chat #17527

Merged
merged 20 commits into from
Apr 20, 2023

Conversation

pecanoro
Copy link
Contributor

@pecanoro pecanoro commented Apr 17, 2023

This PR gives style to whispers:

Welcome message:
Monosnap (9) New Expensify 2023-04-19 15-10-57

Whispers:

Monosnap (9) New Expensify 2023-04-18 16-44-31

Monosnap (9) New Expensify 2023-04-18 17-35-57

Monosnap (9) New Expensify 2023-04-18 14-41-03

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/276393

Tests

  1. Run CQ to add a welcome message to an announce room:
INSERT INTO reportNameValuePairs (reportID, name, value) VALUES (<reportID>, 'welcomeMessage', JSON('{"html":"Welcome to my public room!"}'));
  1. Send yourself via DM the link to the public room and click on it.
  2. As soon as you join the room, you should get the custom welcome message added via CQ.
  3. Message should be coming from the policy owner.
  4. Run CQ to make welcome message come from Concierge:
INSERT INTO reportNameValuePairs (reportID, name, value) VALUES (<reportID>, 'isWelcomeMessageFromConcierge', "true");
  1. Repeat steps 2-3 with a different account. However, this time the message should be coming from Concierge
  2. Make sure you can’t see the welcome message sent to the user from step 1-4 while being logged into another second account.
  • Verify that no errors appear in the JS console

Offline tests

Can't join a chat room offline.

QA

  1. Send yourself via DM the link to this public room and click on it: https://new.expensify.com/r/2660055103772983
  2. As soon as you join the room, you should get the custom welcome message like this:
  3. Message should be coming from Concierge.
  4. Leave a couple of messages.
  5. Log in as another user and join the announce room as well.
  6. As soon as you join the room, you should get the custom welcome message as well.
  7. However, you shouldn't see the welcome message sent to the first user and only the latest one sent to you.
  8. Log out and log in as our previous user, you can still the welcome message that was sent originally to you but not the second message sent to the user that just joined.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

image

Mobile Web - Chrome

image

Mobile Web - Safari

image

Desktop

image

iOS

image

Android

image

@pecanoro pecanoro self-assigned this Apr 17, 2023
@pecanoro
Copy link
Contributor Author

pecanoro commented Apr 18, 2023

@shawnborton I tried to style it but I am terrible with CSS and didn't manage to make it work, can I get some help 🤗

Monosnap (9) New Expensify 2023-04-17 21-12-06

This is the block: https://github.com/Expensify/App/pull/17527/files#diff-e6bee90bf18ae0cad1bb445ed9a9c0d989476874f1005810c0f8e93f1f39b99cR290-R307

@pecanoro
Copy link
Contributor Author

pecanoro commented Apr 18, 2023

@shawnborton Hmm btw, you need to run the query with one of the comments you sent to someone else so the header in the comment is visible, but you need to pull this PR as well: https://github.com/Expensify/Web-Expensify/pull/37069

UPDATE reportActions SET JSON_SET(message, '$.whisperedTo', JSON('[<recipientAccountID>]')) WHERE reportActionID=<reportActionID>;

Or maybe you know how to mimic it without it.

@grgia
Copy link
Contributor

grgia commented Apr 18, 2023

@pecanoro I'm happy to help with the styling!

@shawnborton
Copy link
Contributor

Amazing, thank you @grgia

I think I see you in the Figma file already, but here is a closer look at alignment:
image

@grgia

This comment was marked as outdated.

@shawnborton
Copy link
Contributor

Nice! I think we always want whisper rows to have the highlight bg color too:
image

And then we just need to tighten up the spacing a bit.

@grgia
Copy link
Contributor

grgia commented Apr 18, 2023

Looking at those now!

@grgia
Copy link
Contributor

grgia commented Apr 18, 2023

djisojdaoidjo


diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js
index 2c4414b424..6aa9d60534 100644
--- a/src/pages/home/report/ReportActionItem.js
+++ b/src/pages/home/report/ReportActionItem.js
@@ -268,6 +268,7 @@ class ReportActionItem extends Component {
                             <View
                                 style={StyleUtils.getReportActionItemStyle(
                                     hovered
+                                    || isWhisper
                                     || this.state.isContextMenuActive
                                     || this.props.draftMessage,
                                     (this.props.network.isOffline && this.props.action.isLoading) || this.props.action.error,
@@ -287,9 +288,9 @@ class ReportActionItem extends Component {
                                     needsOffscreenAlphaCompositing={this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU}
                                 >
                                     {isWhisper && (
-                                        <View style={[styles.chatItem]}>
-                                            <View style={[styles.chatItemRight, styles.mr3]}>
-                                                <Icon src={Expensicons.Eye} />
+                                        <View style={[styles.flexRow, styles.pl5, styles.pt2]}>
+                                            <View style={[styles.pl6, styles.mr3]}>
+                                                <Icon src={Expensicons.Eye} small />
                                             </View>
                                             <Text style={[styles.chatItemMessageHeaderTimestamp]}>
                                                 {this.props.translate('reportActionContextMenu.onlyVisible')}
@@ -307,12 +308,16 @@ class ReportActionItem extends Component {
                                     )}
                                     {!this.props.displayAsGroup
                                         ? (
-                                            <ReportActionItemSingle action={this.props.action} showHeader={!this.props.draftMessage}>
+                                            <ReportActionItemSingle
+                                                action={this.props.action}
+                                                showHeader={!this.props.draftMessage}
+                                                wrapperStyles={[styles.chatItem, isWhisper && styles.pt1]}
+                                            >
                                                 {this.renderItemContent(hovered || this.state.isContextMenuActive)}
                                             </ReportActionItemSingle>
                                         )
                                         : (
-                                            <ReportActionItemGrouped>
+                                            <ReportActionItemGrouped wrapperStyles={[styles.chatItem, isWhisper && styles.pt1]}>
                                                 {this.renderItemContent(hovered || this.state.isContextMenuActive)}
                                             </ReportActionItemGrouped>
                                         )}
diff --git a/src/pages/home/report/ReportActionItemGrouped.js b/src/pages/home/report/ReportActionItemGrouped.js
index e811144cca..9c65afd9b6 100644
--- a/src/pages/home/report/ReportActionItemGrouped.js
+++ b/src/pages/home/report/ReportActionItemGrouped.js
@@ -6,10 +6,18 @@ import styles from '../../../styles/styles';
 const propTypes = {
     /** Children view component for this action item */
     children: PropTypes.node.isRequired,
+
+    /** Styles for the outermost View */
+    // eslint-disable-next-line react/forbid-prop-types
+    wrapperStyles: PropTypes.arrayOf(PropTypes.object),
+};
+
+const defaultProps = {
+    wrapperStyles: [styles.chatItem],
 };

 const ReportActionItemGrouped = props => (
-    <View style={[styles.chatItem]}>
+    <View style={props.wrapperStyles}>
         <View style={[styles.chatItemRightGrouped]}>
             {props.children}
         </View>
@@ -17,5 +25,6 @@ const ReportActionItemGrouped = props => (
 );

 ReportActionItemGrouped.propTypes = propTypes;
+ReportActionItemGrouped.defaultProps = defaultProps;
 ReportActionItemGrouped.displayName = 'ReportActionItemGrouped';
 export default ReportActionItemGrouped;
diff --git a/src/styles/utilities/spacing.js b/src/styles/utilities/spacing.js
index 9244552312..d56344c74b 100644
--- a/src/styles/utilities/spacing.js
+++ b/src/styles/utilities/spacing.js
@@ -370,6 +370,10 @@ export default {
         paddingLeft: 20,
     },

+    pl6: {
+        paddingLeft: 24,
+    },
+
     pl10: {
         paddingLeft: 40,
     },

@grgia
Copy link
Contributor

grgia commented Apr 18, 2023

@pecanoro
Copy link
Contributor Author

Amazing, it looks awesome! @grgia It's ok to push to this branch if you want to!

@grgia
Copy link
Contributor

grgia commented Apr 18, 2023

just to writeitdown, I had to modify the query slightly for testing:

UPDATE reportActions SET message = JSON_SET(message, '$.whisperedTo', JSON('[<recipientAccountID>]')) WHERE reportActionID='<reportActionID>';

Copy link
Contributor

@0xmiros 0xmiros left a comment

Choose a reason for hiding this comment

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

Code looks good. Some minor feedback:

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

@pecanoro does this feature work on all public rooms or limited rooms for now? Asking because it doesn't work on my public rooms. Only works with your link - https://new.expensify.com/r/2660055103772983

@pecanoro
Copy link
Contributor Author

I replied in the chat, but basically, this will only work right now in public rooms where I set the message in the back end. I only set the message to the testing one. The functionality will get expanded in the future for all rooms to have it, but it's not a thing right now.

@pecanoro
Copy link
Contributor Author

@0xmiroslav don't forget to fill out the checklist 🙏

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

BUG: "Only visible to you" text isn't translated into Spanish

bug.mov

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

@pecanoro please add this condition to shouldComponentUpdate in ReportActionItem

|| this.props.translate !== nextProps.translate

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web web
Mobile Web - Chrome mchrome
Mobile Web - Safari msafari
Desktop desktop
iOS
ios.mov
Android android

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

@pecanoro please add this condition to shouldComponentUpdate in ReportActionItem

|| this.props.translate !== nextProps.translate

Once this is fixed, I will approve.

@pecanoro pecanoro dismissed stale reviews from tgolen and jasperhuangg via 64e5b04 April 20, 2023 17:07
@pecanoro
Copy link
Contributor Author

PR updated and I retested! Can you make sure I did not break it with my last commits? 😄

@0xmiros
Copy link
Contributor

0xmiros commented Apr 20, 2023

PR updated and I retested! Can you make sure I did not break it with my last commits? 😄

Confirmed and tested not breaking

Copy link
Contributor

@0xmiros 0xmiros left a comment

Choose a reason for hiding this comment

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

MVP looks good so far. Thanks for great work!

@MelvinBot
Copy link

🎯 @0xmiroslav, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #17726.

@jasperhuangg jasperhuangg merged commit 236761a into main Apr 20, 2023
@jasperhuangg jasperhuangg deleted the rocio-OnlyVisible branch April 20, 2023 17:34
@pecanoro
Copy link
Contributor Author

Thank you everyone!

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/jasperhuangg in version: 1.3.3-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.3.3-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@@ -258,6 +280,7 @@ class ReportActionItem extends Component {
<View
style={StyleUtils.getReportActionItemStyle(
hovered
|| isWhisper
Copy link
Member

Choose a reason for hiding this comment

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

Hi, this is out of scope of this PR but we caused this issue - #20451 (comment)

On native, the "New" message maker is hidden behind the whisper message because it's not transparent.

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.

9 participants