Fix panel reloading and clean up unneeded code

This commit is contained in:
Jake McDermott
2020-03-05 15:21:01 -05:00
parent 6c22ddf608
commit a5afac62ca

View File

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