Merge pull request #6658 from mabashian/6655-job-redirect

Fixes issue where job type redirects weren't firing correctly

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2020-04-09 19:47:20 +00:00
committed by GitHub

View File

@@ -19,7 +19,6 @@ import { JOB_TYPE_URL_SEGMENTS } from '@constants';
function Jobs({ i18n }) { function Jobs({ i18n }) {
const history = useHistory(); const history = useHistory();
const location = useLocation(); const location = useLocation();
const { id } = useParams();
const match = useRouteMatch(); const match = useRouteMatch();
const [breadcrumbConfig, setBreadcrumbConfig] = useState({ const [breadcrumbConfig, setBreadcrumbConfig] = useState({
'/jobs': i18n._(t`Jobs`), '/jobs': i18n._(t`Jobs`),
@@ -42,6 +41,12 @@ function Jobs({ i18n }) {
[i18n] [i18n]
); );
function TypeRedirect({ view }) {
const { id } = useParams();
const { path } = useRouteMatch();
return <JobTypeRedirect id={id} path={path} view={view} />;
}
return ( return (
<> <>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
@@ -55,10 +60,10 @@ function Jobs({ i18n }) {
</PageSection> </PageSection>
</Route> </Route>
<Route path={`${match.path}/:id/details`}> <Route path={`${match.path}/:id/details`}>
<JobTypeRedirect id={id} path={match.path} view="details" /> <TypeRedirect view="details" />
</Route> </Route>
<Route path={`${match.path}/:id/output`}> <Route path={`${match.path}/:id/output`}>
<JobTypeRedirect id={id} path={match.path} view="output" /> <TypeRedirect view="output" />
</Route> </Route>
<Route path={`${match.path}/:type/:id`}> <Route path={`${match.path}/:type/:id`}>
<Job <Job
@@ -68,7 +73,7 @@ function Jobs({ i18n }) {
/> />
</Route> </Route>
<Route path={`${match.path}/:id`}> <Route path={`${match.path}/:id`}>
<JobTypeRedirect id={id} path={match.path} /> <TypeRedirect />
</Route> </Route>
</Switch> </Switch>
</> </>