-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Implement Invite message page #15672
Implement Invite message page #15672
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@thienlnam @mollfpr One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@abdulrahuman5196 Could you resolve the conflict? Thanks! |
Resolved the conflicts |
@abdulrahuman5196 We don't have the Screen.Recording.2023-03-13.at.09.10.36.mov |
The avatar is also not showing on the iOS Simulator.Screen.Recording.-.iPhone.13.-.2023-03-13.at.09.41.56.mp4 |
@mollfpr Could you kindly check if you are using the latest commit from the PR. Its working fine for me. I have been merging with main to resolve conflicts. |
@abdulrahuman5196 Thanks; I'll test it again with the latest commit. I might be missing something before. |
@abdulrahuman5196 Could you update the PR to make the |
@mollfpr And given this is a big PR, Can we do a full review of PR once(I am not sure if that was already done) and post the review comments alltogether, so that I can solve the comments in one shot. It will reduce the time for both of us, if not we might end up doing minor changes on every review. |
@abdulrahuman5196 I Found this regression when searching for a new user outside the list. The new user avatar is not showing. Step:
Screen.Recording.2023-03-16.at.09.51.37.movYes, you use the |
@luacmartins Hey, I need your help here! We try using Second, this PR is significant in solving the original issue. Could we use the original implementation and handle the refactor to use |
@mollfpr I agree here on the callouts. I made the new implementation with the latest features available, but I intentionally made less refractor on existing code logic unrelated to the problem like 'default message and its translation logic' to avoid any unwanted regressions. But if we want to refractor existing logics like refractoring WorkspaceInvitePage to use Form.js and other refractors we can still do, but it might not add value to solution we are trying to solve. So a confirm here would be good before I can start making those changes, if we still want to refractor existing code? |
this.state = { | ||
welcomeNote: this.getWelcomeNote(), | ||
}; |
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.
Instead of keeping this state, can we just pass the welcome message as the defaultValue
for the TextInput
, e.g.
<TextInput
...props
defaultValue={this.props.translate('workspace.inviteMessage.welcomeNote', {
workspaceName: this.props.policy.name,
})};
/>
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.
Form.js defaultValue takes the value only during first time - https://github.com/Expensify/App/blob/main/src/components/Form.js#L255
So if the language changes when we are already in this message, the default message won't be translated.
Do we want to change Form.js component in a way to support this usecase?
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.
That's a good point and IMO a bug with the TextInput itself. I think that we'd want to update the TextInput default value when the locale changes in case we have provided a defaultValue that needs to be translated. We do something similar for Picker.
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.
@luacmartins I am not sure if I understood the above response correctly. I see we did a similar fix Picker component, do we want to do a similar to fix to TextInput/Form itself as part of this PR, and update the message field in this particular page accordingly? Or can we do it as a separate improvement fix as its already working now in old way or else it Seems we would be bloating this PR.
I can even volunteer to take it up as a separate fix on TextInput/Form.js as well and modify the invite message page accordingly
But its just my opinion, but I am open to fix it either ways.
cc: @mollfpr
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.
@abdulrahuman5196 Here's some basic idea for a similar implementation of the Picker component.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import TextInput from './TextInput';
import * as Localize from '../libs/Localize';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import compose from '../libs/compose';
import withPolicy from '../pages/workspace/withPolicy';
const propTypes = {
inputID: PropTypes.string,
onInputChange: PropTypes.func.isRequired,
...withLocalizePropTypes,
};
const defaultProps = {
inputID: undefined,
};
class InviteMessageTextInput extends PureComponent {
constructor(props) {
super(props);
this.onInputChange = this.onInputChange.bind(this);
}
componentDidUpdate(prevProps) {
if (!(prevProps.preferredLocale !== this.props.preferredLocale
&& this.props.value === Localize.translate(prevProps.preferredLocale, 'workspace.inviteMessage.welcomeNote', {workspaceName: this.props.policy.name}))
) {
return;
}
this.onInputChange(this.props.translate('workspace.inviteMessage.welcomeNote', {
workspaceName: this.props.policy.name,
}));
}
onInputChange(value) {
if (!this.props.inputID) {
return;
}
this.props.onInputChange(value);
}
render() {
return (
<TextInput
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
onInputChange={this.onInputChange}
/>
);
}
}
InviteMessageTextInput.propTypes = propTypes;
InviteMessageTextInput.defaultProps = defaultProps;
export default compose(
withLocalize,
withPolicy,
)(InviteMessageTextInput);
We override the onInputChange
from the Form.js
component and pass the translated welcome message when the locale changes.
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.
Yes, any values should take precedence over the defaultValue. I mean, this.props.defaultValue will not be used this.setState({value: this.props.value || this.props.defaultValue || '' }); because we have this.props.value from the Form.js.
Got it, Its because we don't send 'defaultValue' instead just 'value' to TextInput. In that case we can solve it in Form itself. This case should be generic for component to update when default value changes
We have this PR #15772 that adds an option to force the use of defaultValue, but I'm not sure if it can solve our current concern.
It forcefully uses the defaultValue. It won't solve our case as we want to use the defaultValue only when there is no user provided input.
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.
@luacmartins @mollfpr I think we should revive this thread to think about adding support for Text inside Form to support changing defaultValue.
Another issue which might have used this support if it where available(not entirely same but just quoting)
#19460
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.
@abdulrahuman5196 maybe you can suggest that in the issue you linked? This issue is closed so it wouldn't get much attention.
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.
Ideally feel free to bring this up in Slack
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.
Started a thread to see if need this support or not
https://expensify.slack.com/archives/C01GTK53T8Q/p1685436048476259
Summarizing open questions to reviewers to make everyone's life easier. Let me know if i had missed any.
@mollfpr For other review comments you have posted, I agree on them. As all other seems minor code changes, I will sort out all of them once we get the alignment on the above 2 open items. |
Thank you @abdulrahuman5196, for the summary. I don't have any concerns with creating a new issue for the form refactor. @thienlnam @luacmartins I'll let you guys decide it. |
There is regression from this PR check here |
@abdulrahuman5196 yes, we can remove that. |
This broke changes we introduce on #16764 to optimistically add the user's Policy Expense Chats when they're invited to a workspace offline. Currently the functionality is broken on staging only but not prod luckily but this should be considered a blocker IMO. |
Who is fixing it? If it broke something can we revert it? What's the plan? |
So it looks like there's maybe two related issues with this PR: Issue 1Reported here BUG ‘Next’ button is disabled on back navigation even if there is a selected user; as a result user cannot continue to invite the selected user after navigating back Action Performed:
Expected Result: Next button shouldn’t be disabled as long as there is a selected user Issue 2Action Performed:
Expected Result: Actual Result: ??? Something else ??? |
@roryabraham For issue 2, |
For issue 2, From code walkthrough, The intersection i see between both PR which could have caused regression might be
We are not passing this.props.beta in the new flow. Let me make the change and test it. |
Created a draft PR with the fixes for issues - #18395 Working on author checklist |
@bondydaa Lets make sure to add the |
Agree with the comment above. Also, if there are multiple issues with this PR, I think that we should revert it. |
@abdulrahuman5196 does your PR address both issues with this PR? |
@luacmartins Yes. I am addressing both the issues. But I would require help testing if my fix is working for the issue 2 since it seems to be working before my new fix as well #18395 as per here - #16764 (comment) |
Hey team! not sure if this is on your radar but could you check to see if #18390 is a regression of this? |
Raised a Followup PR for the Fixes #18601 |
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.12-0 🚀
|
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.
This caused a "regression" #21412. We didn't account for deep access to this page. Deep link access was not being validated as a result we were able to click the invite button but the backend would return an error.
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.
Just to note: I wouldn't say it as a regression, but a miss during original implementation. But thank you for posting the comment. Will keep in mind for future usecases.
sendInvitation() { | ||
Policy.addMembersToWorkspace(this.props.invitedMembersDraft, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID); | ||
Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, []); | ||
Navigation.navigate(ROUTES.getWorkspaceMembersRoute(this.props.route.params.policyID)); |
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.
Hi, this PR caused a bug: #23311
See #23311 (comment) for more details on how you could have prevented it
@thienlnam @mollfpr
Details
Implementing a new Workspace members invite message page to fix the overlaying of message in the invite members page.
Fixed Issues
$ #15083
PROPOSAL: #15083 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Untitled.8.mp4
Mobile Web - Chrome
Untitled.9.mp4
Mobile Web - Safari
Untitled.10.mp4
Desktop
Untitled.11.mp4
iOS
Untitled.12.mp4
Android
Untitled.13.mp4