-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Use push to page for report settings #16910
Conversation
@rushatgabhane @neil-marcellini 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] |
Removing C+, as it is a very simple fix |
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.
It looks like the recommendation in the Slack conversation was to convert this to Push to page. I think we should do that.
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.
Hmm I'm changing my mind. I think since we already "pushed" to the settings page, if we make the "Save" button navigate back then it's effectively using push to page. It would be odd to have each settings field on its own page. For example with https://staging.new.expensify.com/settings/profile/display-name the first and last name can be updated on the same page. What do you think @shawnborton?
The changes work well for updating the room name, but let's make it navigate back when you hit the "Save" button so that it works for the notification preference.
Screen.Recording.2023-04-04.at.8.48.20.AM.mov
I think we decided that we want both the room name and the notification frequency to be push-to-page inputs. When you tap on room name, you get pushed to a new page where you are auto-focused. Saving this new page then returns back to the overview page. |
Gotcha! Refactoring this, then! WIP for now |
Ok sounds good. It might be cool to have an illustration, animation, or branding on the "pushed" pages because they feel really empty to me. |
I thought maybe the problem was the keyboard not opening. I tried forwarding a ref to the RoomNameInput and focusing it onEntryTransitionEnd, but I couldn't get the ref to work, it was always null. Here's the changes I tried on the RoomNamePage if you want to play around with it. Anyways, I want to make sure I understand the problem before I dig deeper. Forward ref focus attemptimport React, {useCallback, useRef} from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import CONST from '../../../CONST';
import ScreenWrapper from '../../../components/ScreenWrapper';
import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import Form from '../../../components/Form';
import ONYXKEYS from '../../../ONYXKEYS';
import styles from '../../../styles/styles';
import Navigation from '../../../libs/Navigation/Navigation';
import compose from '../../../libs/compose';
import * as ErrorUtils from '../../../libs/ErrorUtils';
import * as ValidationUtils from '../../../libs/ValidationUtils';
import withReportOrNotFound from '../../home/report/withReportOrNotFound';
import reportPropTypes from '../../reportPropTypes';
import ROUTES from '../../../ROUTES';
import * as Report from '../../../libs/actions/Report';
import RoomNameInput from '../../../components/RoomNameInput';
const propTypes = {
...withLocalizePropTypes,
/** The room report for which the name is being edited */
report: reportPropTypes.isRequired,
/** All reports shared with the user */
reports: PropTypes.objectOf(reportPropTypes),
};
const defaultProps = {
reports: {},
};
const RoomNamePage = (props) => {
const report = props.report;
const reports = props.reports;
const translate = props.translate;
const nameInputRef = useRef(null);
const validate = useCallback((values) => {
console.log('debug validate nameInputRef =', nameInputRef);
const errors = {};
// We should skip validation hence we return an empty errors and we skip Form submission on the onSubmit method
if (values.roomName === report.reportName) {
return errors;
}
if (!values.roomName || values.roomName === CONST.POLICY.ROOM_PREFIX) {
// We error if the user doesn't enter a room name or left blank
ErrorUtils.addErrorMessage(errors, 'roomName', translate('newRoomPage.pleaseEnterRoomName'));
} else if (!ValidationUtils.isValidRoomName(values.roomName)) {
// We error if the room name has invalid characters
ErrorUtils.addErrorMessage(errors, 'roomName', translate('newRoomPage.roomNameInvalidError'));
} else if (ValidationUtils.isReservedRoomName(values.roomName)) {
// Certain names are reserved for default rooms and should not be used for policy rooms.
ErrorUtils.addErrorMessage(errors, 'roomName', translate('newRoomPage.roomNameReservedError', {reservedName: values.roomName}));
} else if (ValidationUtils.isExistingRoomName(values.roomName, reports, report.policyID)) {
// The room name can't be set to one that already exists on the policy
ErrorUtils.addErrorMessage(errors, 'roomName', translate('newRoomPage.roomAlreadyExistsError'));
}
return errors;
}, [report, reports, translate]);
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => {
console.log('debug nameInputRef =', nameInputRef);
if (!nameInputRef.current) {
return;
}
nameInputRef.current.focus();
}}
>
<HeaderWithCloseButton
title={translate('newRoomPage.roomName')}
shouldShowBackButton
onBackButtonPress={() => Navigation.drawerGoBack(ROUTES.getReportSettingsRoute(report.reportID))}
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.ROOM_NAME_FORM}
onSubmit={values => Report.updatePolicyRoomNameAndNavigate(report, values.roomName)}
validate={validate}
submitButtonText={translate('common.save')}
enabledWhenOffline
>
<View style={styles.mb4}>
<RoomNameInput
inputID="roomName"
defaultValue={report.reportName}
ref={nameInputRef}
/>
</View>
</Form>
</ScreenWrapper>
);
};
RoomNamePage.propTypes = propTypes;
RoomNamePage.defaultProps = defaultProps;
RoomNamePage.displayName = 'RoomNamePage';
export default compose(
withLocalize,
withReportOrNotFound,
withOnyx({
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
},
}),
)(RoomNamePage); |
@neil-marcellini it's easily reproducible. Please check #admins room settings |
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.
We can fix android focus issue as a follow-up.
Please fix lint.
Ah yes, thanks for explaining! |
BUG: infinite loop when press back button after visiting room name page directly from address bar bug3.mov |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
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.
@neil-marcellini Great job on this one, there is one conflict though, can you please resolve it?
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.
Thanks @Gonals for staring, @aimane-chnaif for review and testing and @neil-marcellini getting it to the finish line.
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.16-0 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.16-7 🚀
|
2 similar comments
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.16-7 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.16-7 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.16-7 🚀
|
Details
Here we are refactoring the report settings page to use "push to page". So instead of entering the room name directly on the report settings page, there is a menu item for the report name. When you click it you are navigated to a separate page for entering the room name. When you save it you are navigated back. I implemented the same thing for the room notification preference selection, using the same pattern as on the LanguagePage. Push to page is our preferred pattern for inputs now.
I used functional components for the new pages, but left existing pages as class components since they should be refactored separately. The ReportSettings page is mostly unchanged, but it moved, so it will be easier to look at the diff between the new file path and the file on main.
Fixed Issues
$ #16768
Tests
Rename a room
Update room notification preference
Offline tests
Rename a room offline
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
I only tested on Web since the changes are platform independent.
Web
Rename a room
room-rename.mov
Update room notification preference
room-notif-pref.mov
Rename a room offline
offline-room-rename.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android