Merge pull request #6194 from jakemcdermott/6191-fix-unnecessary-panel-reload

Fix panel loading and clean up unneeded code

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-03-06 17:14:27 +00:00 committed by GitHub
commit 1b8ff1f846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ class WorkflowJobTemplate extends Component {
const { setBreadcrumb, match } = this.props;
const { id } = match.params;
this.setState({ contentError: null, hasContentLoading: true });
this.setState({ contentError: null });
try {
const { data } = await WorkflowJobTemplatesAPI.readDetail(id);
if (data?.related?.webhook_key) {
@ -113,22 +113,17 @@ class WorkflowJobTemplate extends Component {
tab.id = n;
});
let cardHeader = hasContentLoading ? null : (
<TabbedCardHeader>
<RoutedTabs tabsArray={tabsArray} />
<CardActions>
<CardCloseButton linkTo="/templates" />
</CardActions>
</TabbedCardHeader>
);
if (location.pathname.endsWith('edit')) {
cardHeader = null;
}
if (hasContentLoading) {
return <ContentLoading />;
return (
<PageSection>
<Card>
<ContentLoading />
</Card>
</PageSection>
);
}
if (!hasContentLoading && contentError) {
if (contentError) {
return (
<PageSection>
<Card>
@ -145,10 +140,19 @@ class WorkflowJobTemplate extends Component {
);
}
const cardHeader = (
<TabbedCardHeader>
<RoutedTabs tabsArray={tabsArray} />
<CardActions>
<CardCloseButton linkTo="/templates" />
</CardActions>
</TabbedCardHeader>
);
return (
<PageSection>
<Card>
{cardHeader}
{location.pathname.endsWith('edit') ? null : cardHeader}
<Switch>
<Redirect
from="/templates/workflow_job_template/:id"
@ -201,7 +205,7 @@ class WorkflowJobTemplate extends Component {
/>
</Route>
)}
{template.id && (
{template?.id && (
<Route
path="/templates/:templateType/:id/schedules"
render={() => (
@ -215,19 +219,17 @@ class WorkflowJobTemplate extends Component {
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound>
{match.params.id && (
<Link
to={`/templates/workflow_job_template/${match.params.id}/details`}
>
{i18n._(`View Template Details`)}
</Link>
)}
</ContentError>
)
}
render={() => (
<ContentError isNotFound>
{match.params.id && (
<Link
to={`/templates/workflow_job_template/${match.params.id}/details`}
>
{i18n._(`View Template Details`)}
</Link>
)}
</ContentError>
)}
/>
</Switch>
</Card>