Merge pull request #10577 from nixocio/ui_issue_9550

Display error message if schedule does not exist

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

closes: #9550

Reviewed-by: Alex Corey <Alex.swansboro@gmail.com>
Reviewed-by: Sarah Akus <sakus@redhat.com>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-07-15 15:29:34 +00:00 committed by GitHub
commit 39522a35c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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',