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 2 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
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ export default {
canceled: 'canceled task',
reopened: 'reopened task',
error: 'You do not have the permission to do the requested action.',
notOpen: 'Only open task can be edited',
},
markAsDone: 'Mark as done',
markAsIncomplete: 'Mark as incomplete',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ export default {
canceled: 'tarea cancelada',
reopened: 'tarea reabrir',
error: 'No tiene permiso para realizar la acción solicitada.',
notOpen: 'Sólo se pueden editar las tareas abiertas',
},
markAsDone: 'Marcar como completada',
markAsIncomplete: 'Marcar como incompleta',
Expand Down
23 changes: 21 additions & 2 deletions src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ 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';
import withReportOrNotFound from '../home/report/withReportOrNotFound';

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

const isOpen = ReportUtils.isOpenTaskReport(props.task.report);
const canModifyTask = Task.canModifyTask(props.task.report, props.currentUserPersonalDetails.accountID);
const disableState = ReportUtils.isTaskReport(props.task.report) && (!canModifyTask || !isOpen);
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
const getSubtitleKey = () => {
if (!canModifyTask) {
return 'task.messages.error';
}
return 'task.messages.notOpen';
};

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<FullPageNotFoundView
shouldShow={disableState}
subtitleKey={getSubtitleKey()}
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
>
<HeaderWithBackButton
title={props.translate('task.assignee')}
onBackButtonPress={() => (lodashGet(props.route.params, 'reportID') ? Navigation.dismissModal() : Navigation.goBack(ROUTES.NEW_TASK))}
Expand All @@ -209,7 +226,7 @@ function TaskAssigneeSelectorModal(props) {
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
/>
</View>
</>
</FullPageNotFoundView>
)}
</ScreenWrapper>
);
Expand All @@ -221,6 +238,8 @@ TaskAssigneeSelectorModal.defaultProps = defaultProps;

export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withReportOrNotFound,
withOnyx({
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
Expand Down
82 changes: 57 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,63 @@ function TaskDescriptionPage(props) {

const inputRef = useRef(null);

const isOpen = ReportUtils.isOpenTaskReport(props.report);
const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID);
const disableState = !canModifyTask || !isOpen;
const getSubtitleKey = () => {
if (!canModifyTask) {
return 'task.messages.error';
}
return 'task.messages.notOpen';
};

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={disableState}
subtitleKey={getSubtitleKey()}
>
<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 +118,8 @@ TaskDescriptionPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withReportOrNotFound,
withOnyx({
session: {
key: ONYXKEYS.SESSION,
Expand Down
70 changes: 49 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,56 @@ function TaskTitlePage(props) {
);

const inputRef = useRef(null);
const isOpen = ReportUtils.isOpenTaskReport(props.report);
const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID);
const disableState = ReportUtils.isTaskReport(props.report) && (!canModifyTask || !isOpen);
const getSubtitleKey = () => {
if (!canModifyTask) {
return 'task.messages.error';
}
return 'task.messages.notOpen';
};

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={disableState}
subtitleKey={getSubtitleKey()}
>
<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 +122,8 @@ TaskTitlePage.defaultProps = defaultProps;

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