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

Fix: adds FullPageNotFoundView view for completed task #26634

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize
import compose from '../../libs/compose';
import personalDetailsPropType from '../personalDetailsPropType';
import reportPropTypes from '../reportPropTypes';
import * as ReportUtils from '../../libs/ReportUtils';
import ROUTES from '../../ROUTES';

import * as Task from '../../libs/actions/Task';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';

const propTypes = {
/** Beta features list */
Expand Down Expand Up @@ -188,10 +191,14 @@ function TaskAssigneeSelectorModal(props) {
}
};

const isOpen = ReportUtils.isOpenTaskReport(props.task.report);
const canModifyTask = Task.canModifyTask(props.task.report, props.currentUserPersonalDetails.accountID);
const isTaskNonEditable = report && ReportUtils.isTaskReport(props.task.report) && (!canModifyTask || !isOpen);

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<FullPageNotFoundView shouldShow={isTaskNonEditable}>
<HeaderWithBackButton
title={props.translate('task.assignee')}
onBackButtonPress={() => (lodashGet(props.route.params, 'reportID') ? Navigation.dismissModal() : Navigation.goBack(ROUTES.NEW_TASK))}
Expand All @@ -209,7 +216,7 @@ function TaskAssigneeSelectorModal(props) {
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
/>
</View>
</>
</FullPageNotFoundView>
)}
</ScreenWrapper>
);
Expand All @@ -221,6 +228,7 @@ TaskAssigneeSelectorModal.defaultProps = defaultProps;

export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withOnyx({
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
Expand Down
73 changes: 48 additions & 25 deletions src/pages/tasks/TaskDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import reportPropTypes from '../reportPropTypes';
import styles from '../../styles/styles';
import compose from '../../libs/compose';
import * as Task from '../../libs/actions/Task';
import * as ReportUtils from '../../libs/ReportUtils';
import CONST from '../../CONST';
import focusAndUpdateMultilineInputRange from '../../libs/focusAndUpdateMultilineInputRange';
import * as Browser from '../../libs/Browser';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';
import withReportOrNotFound from '../home/report/withReportOrNotFound';

const propTypes = {
/** Current user session */
Expand Down Expand Up @@ -48,37 +52,54 @@ function TaskDescriptionPage(props) {

const inputRef = useRef(null);

const isOpen = ReportUtils.isOpenTaskReport(props.report);
const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID);
const isTaskNonEditable = ReportUtils.isTaskReport(props.report) && (!canModifyTask || !isOpen);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => focusAndUpdateMultilineInputRange(inputRef.current)}
shouldEnableMaxHeight
>
<HeaderWithBackButton title={props.translate('task.task')} />
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.EDIT_TASK_FORM}
validate={validate}
onSubmit={submit}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
<View style={[styles.mb4]}>
<TextInput
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="description"
name="description"
label={props.translate('newTaskPage.descriptionOptional')}
accessibilityLabel={props.translate('newTaskPage.descriptionOptional')}
defaultValue={(props.report && props.report.description) || ''}
ref={(el) => (inputRef.current = el)}
autoGrowHeight
submitOnEnter={!Browser.isMobile()}
containerStyles={[styles.autoGrowHeightMultilineInput]}
textAlignVertical="top"
/>
</View>
</Form>
{({didScreenTransitionEnd}) => (
<FullPageNotFoundView shouldShow={isTaskNonEditable}>
<HeaderWithBackButton title={props.translate('task.task')} />
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.EDIT_TASK_FORM}
validate={validate}
onSubmit={submit}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
<View style={[styles.mb4]}>
<TextInput
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="description"
name="description"
label={props.translate('newTaskPage.descriptionOptional')}
accessibilityLabel={props.translate('newTaskPage.descriptionOptional')}
defaultValue={(props.report && props.report.description) || ''}
ref={(el) => {
// if we wrap the page with FullPageNotFoundView we need to explicitly handle focusing on text input
if (!el) {
return;
}
if (!inputRef.current && didScreenTransitionEnd) {
focusAndUpdateMultilineInputRange(el);
}
inputRef.current = el;
}}
autoGrowHeight
submitOnEnter={!Browser.isMobile()}
containerStyles={[styles.autoGrowHeightMultilineInput]}
textAlignVertical="top"
/>
</View>
</Form>
</FullPageNotFoundView>
)}
</ScreenWrapper>
);
}
Expand All @@ -88,6 +109,8 @@ TaskDescriptionPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withReportOrNotFound,
withOnyx({
session: {
key: ONYXKEYS.SESSION,
Expand Down
61 changes: 40 additions & 21 deletions src/pages/tasks/TaskTitlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import styles from '../../styles/styles';
import reportPropTypes from '../reportPropTypes';
import compose from '../../libs/compose';
import * as Task from '../../libs/actions/Task';
import * as ReportUtils from '../../libs/ReportUtils';
import CONST from '../../CONST';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';
import withReportOrNotFound from '../home/report/withReportOrNotFound';

const propTypes = {
/** The report currently being looked at */
Expand Down Expand Up @@ -59,34 +63,47 @@ function TaskTitlePage(props) {
);

const inputRef = useRef(null);
const isOpen = ReportUtils.isOpenTaskReport(props.report);
const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID);
const isTaskNonEditable = ReportUtils.isTaskReport(props.report) && (!canModifyTask || !isOpen);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => inputRef.current && inputRef.current.focus()}
shouldEnableMaxHeight
>
<HeaderWithBackButton title={props.translate('task.task')} />
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.EDIT_TASK_FORM}
validate={validate}
onSubmit={submit}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
<View style={[styles.mb4]}>
<TextInput
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="title"
name="title"
label={props.translate('task.title')}
accessibilityLabel={props.translate('task.title')}
defaultValue={(props.report && props.report.reportName) || ''}
ref={(el) => (inputRef.current = el)}
/>
</View>
</Form>
{({didScreenTransitionEnd}) => (
<FullPageNotFoundView shouldShow={isTaskNonEditable}>
<HeaderWithBackButton title={props.translate('task.task')} />
<Form
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.EDIT_TASK_FORM}
validate={validate}
onSubmit={submit}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
<View style={[styles.mb4]}>
<TextInput
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="title"
name="title"
label={props.translate('task.title')}
accessibilityLabel={props.translate('task.title')}
defaultValue={(props.report && props.report.reportName) || ''}
ref={(el) => {
if (!el) return;
if (!inputRef.current && didScreenTransitionEnd) {
inputRef.current.focus();
}
inputRef.current = el;
}}
/>
</View>
</Form>
</FullPageNotFoundView>
)}
</ScreenWrapper>
);
}
Expand All @@ -96,6 +113,8 @@ TaskTitlePage.defaultProps = defaultProps;

export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withReportOrNotFound,
withOnyx({
session: {
key: ONYXKEYS.SESSION,
Expand Down
Loading