Display error message if schedule does not exist

Display error message if schedule does not exist when redirecting to
details page.

See: https://github.com/ansible/awx/issues/9550
This commit is contained in:
nixocio 2021-06-29 12:58:07 -04:00
parent 64631fca56
commit f422677145
2 changed files with 15 additions and 1 deletions

View File

@ -69,6 +69,19 @@ function Schedule({
},
];
if (!isLoading && error) {
return (
<ContentError isNotFound error={error}>
{error.response && error.response.status === 404 && (
<span>
{t`Schedule not found.`}{' '}
<Link to={`${pathRoot}schedules`}>{t`View Schedules`}</Link>
</span>
)}
</ContentError>
);
}
if (isLoading || !schedule?.summary_fields?.unified_job_template?.id) {
return <ContentLoading />;
}

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Switch, Route, useRouteMatch } from 'react-router-dom';
import Schedule from './Schedule';
import ScheduleAdd from './ScheduleAdd';
import ScheduleList from './ScheduleList';
@ -19,6 +19,7 @@ function Schedules({
// For some management jobs that delete data, we want to provide an additional
// field on the scheduler for configuring the number of days to retain.
const hasDaysToKeepField = [
'cleanup_activitystream',
'cleanup_jobs',