Converts most of our route render prop usage to children

This commit is contained in:
mabashian
2020-04-07 15:22:35 -04:00
parent a26c0dfb8a
commit 193ec21149
20 changed files with 401 additions and 576 deletions

View File

@@ -111,26 +111,17 @@ function Schedule({ i18n, setBreadcrumb, unifiedJobTemplate }) {
<Route <Route
key="details" key="details"
path={`${pathRoot}schedules/:scheduleId/details`} path={`${pathRoot}schedules/:scheduleId/details`}
render={() => { >
return <ScheduleDetail schedule={schedule} />; <ScheduleDetail schedule={schedule} />
}} </Route>,
/>,
]} ]}
<Route <Route key="not-found" path="*">
key="not-found" <ContentError>
path="*" {unifiedJobTemplate && (
render={() => { <Link to={`${pathRoot}details`}>{i18n._(t`View Details`)}</Link>
return ( )}
<ContentError> </ContentError>
{unifiedJobTemplate && ( </Route>
<Link to={`${pathRoot}details`}>
{i18n._(t`View Details`)}
</Link>
)}
</ContentError>
);
}}
/>
</Switch> </Switch>
</> </>
); );

View File

@@ -14,32 +14,21 @@ function Schedules({
return ( return (
<Switch> <Switch>
<Route <Route path={`${match.path}/add`}>
path={`${match.path}/add`} <ScheduleAdd createSchedule={createSchedule} />
render={() => <ScheduleAdd createSchedule={createSchedule} />} </Route>
/> <Route key="details" path={`${match.path}/:scheduleId`}>
<Route <Schedule
key="details" unifiedJobTemplate={unifiedJobTemplate}
path={`${match.path}/:scheduleId`} setBreadcrumb={setBreadcrumb}
render={() => ( />
<Schedule </Route>
unifiedJobTemplate={unifiedJobTemplate} <Route key="list" path={`${match.path}`}>
setBreadcrumb={setBreadcrumb} <ScheduleList
/> loadSchedules={loadSchedules}
)} loadScheduleOptions={loadScheduleOptions}
/> />
<Route </Route>
key="list"
path={`${match.path}`}
render={() => {
return (
<ScheduleList
loadSchedules={loadSchedules}
loadScheduleOptions={loadScheduleOptions}
/>
);
}}
/>
</Switch> </Switch>
); );
} }

View File

@@ -98,59 +98,43 @@ function Credential({ i18n, setBreadcrumb }) {
exact exact
/> />
{credential && [ {credential && [
<Route <Route key="details" path="/credentials/:id/details">
key="details" <CredentialDetail credential={credential} />
path="/credentials/:id/details" </Route>,
render={() => <CredentialDetail credential={credential} />} <Route key="edit" path="/credentials/:id/edit">
/>, <CredentialEdit credential={credential} />
<Route </Route>,
key="edit"
path="/credentials/:id/edit"
render={() => <CredentialEdit credential={credential} />}
/>,
credential.organization && ( credential.organization && (
<Route <Route key="access" path="/credentials/:id/access">
key="access" <ResourceAccessList
path="/credentials/:id/access" resource={credential}
render={() => ( apiModel={CredentialsAPI}
<ResourceAccessList />
resource={credential} </Route>
apiModel={CredentialsAPI}
/>
)}
/>
), ),
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound>
{match.params.id && (
<Link to={`/credentials/${match.params.id}/details`}>
{i18n._(`View Credential Details`)}
</Link>
)}
</ContentError>
)
}
/>,
]}
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{id && ( {match.params.id && (
<Link to={`/credentials/${id}/details`}> <Link to={`/credentials/${match.params.id}/details`}>
{i18n._(`View Credential Details`)} {i18n._(`View Credential Details`)}
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>,
/> ]}
<Route key="not-found" path="*">
{!hasContentLoading && (
<ContentError isNotFound>
{id && (
<Link to={`/credentials/${id}/details`}>
{i18n._(`View Credential Details`)}
</Link>
)}
</ContentError>
)}
</Route>
</Switch> </Switch>
</Card> </Card>
</PageSection> </PageSection>

View File

@@ -1,20 +1,14 @@
import React from 'react'; import React from 'react';
import { withI18n } from '@lingui/react'; import { withI18n } from '@lingui/react';
import { Switch, Route } from 'react-router-dom'; import { Switch, Route } from 'react-router-dom';
import HostGroupsList from './HostGroupsList'; import HostGroupsList from './HostGroupsList';
function HostGroups({ host }) { function HostGroups({ host }) {
return ( return (
<Switch> <Switch>
<Route <Route key="list" path="/hosts/:id/groups">
key="list" <HostGroupsList host={host} />
path="/hosts/:id/groups" </Route>
render={() => {
return <HostGroupsList host={host} />;
}}
/>
</Switch> </Switch>
); );
} }

View File

@@ -85,14 +85,12 @@ class Inventories extends Component {
<> <>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
<Switch> <Switch>
<Route <Route path={`${match.path}/inventory/add`}>
path={`${match.path}/inventory/add`} <InventoryAdd />
render={() => <InventoryAdd />} </Route>
/> <Route path={`${match.path}/smart_inventory/add`}>
<Route <SmartInventoryAdd />
path={`${match.path}/smart_inventory/add`} </Route>
render={() => <SmartInventoryAdd />}
/>
<Route path={`${match.path}/inventory/:id`}> <Route path={`${match.path}/inventory/:id`}>
<Config> <Config>
{({ me }) => ( {({ me }) => (
@@ -119,7 +117,9 @@ class Inventories extends Component {
</Config> </Config>
)} )}
/> />
<Route path={`${match.path}`} render={() => <InventoryList />} /> <Route path={`${match.path}`}>
<InventoryList />
</Route>
</Switch> </Switch>
</> </>
); );

View File

@@ -137,21 +137,15 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) {
<InventoryGroupHosts inventoryGroup={inventoryGroup} /> <InventoryGroupHosts inventoryGroup={inventoryGroup} />
</Route>, </Route>,
]} ]}
<Route <Route key="not-found" path="*">
key="not-found" <ContentError>
path="*" {inventory && (
render={() => { <Link to={`/inventories/inventory/${inventory.id}/details`}>
return ( {i18n._(t`View Inventory Details`)}
<ContentError> </Link>
{inventory && ( )}
<Link to={`/inventories/inventory/${inventory.id}/details`}> </ContentError>
{i18n._(t`View Inventory Details`)} </Route>
</Link>
)}
</ContentError>
);
}}
/>
</Switch> </Switch>
</> </>
); );

View File

@@ -11,32 +11,18 @@ import InventoryGroupsList from './InventoryGroupsList';
function InventoryGroups({ setBreadcrumb, inventory }) { function InventoryGroups({ setBreadcrumb, inventory }) {
return ( return (
<Switch> <Switch>
<Route <Route key="add" path="/inventories/inventory/:id/groups/add">
key="add" <InventoryGroupAdd
path="/inventories/inventory/:id/groups/add" setBreadcrumb={setBreadcrumb}
render={() => { inventory={inventory}
return ( />
<InventoryGroupAdd </Route>
setBreadcrumb={setBreadcrumb} <Route key="details" path="/inventories/inventory/:id/groups/:groupId/">
inventory={inventory} <InventoryGroup inventory={inventory} setBreadcrumb={setBreadcrumb} />
/> </Route>
); <Route key="list" path="/inventories/inventory/:id/groups">
}} <InventoryGroupsList />
/> </Route>
<Route
key="details"
path="/inventories/inventory/:id/groups/:groupId/"
render={() => (
<InventoryGroup inventory={inventory} setBreadcrumb={setBreadcrumb} />
)}
/>
<Route
key="list"
path="/inventories/inventory/:id/groups"
render={() => {
return <InventoryGroupsList />;
}}
/>
</Switch> </Switch>
); );
} }

View File

@@ -8,13 +8,9 @@ import InventoryHostGroupsList from './InventoryHostGroupsList';
function InventoryHostGroups() { function InventoryHostGroups() {
return ( return (
<Switch> <Switch>
<Route <Route key="list" path="/inventories/inventory/:id/hosts/:hostId/groups">
key="list" <InventoryHostGroupsList />
path="/inventories/inventory/:id/hosts/:hostId/groups" </Route>
render={() => {
return <InventoryHostGroupsList />;
}}
/>
</Switch> </Switch>
); );
} }

View File

@@ -119,33 +119,27 @@ class SmartInventory extends Component {
<Route <Route
key="details" key="details"
path="/inventories/smart_inventory/:id/details" path="/inventories/smart_inventory/:id/details"
render={() => ( >
<SmartInventoryDetail <SmartInventoryDetail
hasSmartInventoryLoading={hasContentLoading} hasSmartInventoryLoading={hasContentLoading}
inventory={inventory} inventory={inventory}
/> />
)} </Route>,
/>, <Route key="edit" path="/inventories/smart_inventory/:id/edit">
<Route <SmartInventoryEdit inventory={inventory} />
key="edit" </Route>,
path="/inventories/smart_inventory/:id/edit"
render={() => <SmartInventoryEdit inventory={inventory} />}
/>,
<Route <Route
key="access" key="access"
path="/inventories/smart_inventory/:id/access" path="/inventories/smart_inventory/:id/access"
render={() => ( >
<ResourceAccessList <ResourceAccessList
resource={inventory} resource={inventory}
apiModel={InventoriesAPI} apiModel={InventoriesAPI}
/> />
)} </Route>,
/>, <Route key="hosts" path="/inventories/smart_inventory/:id/hosts">
<Route <SmartInventoryHosts inventory={inventory} />
key="hosts" </Route>,
path="/inventories/smart_inventory/:id/hosts"
render={() => <SmartInventoryHosts inventory={inventory} />}
/>,
<Route <Route
key="completed_jobs" key="completed_jobs"
path="/inventories/smart_inventory/:id/completed_jobs" path="/inventories/smart_inventory/:id/completed_jobs"
@@ -160,23 +154,19 @@ class SmartInventory extends Component {
}} }}
/> />
</Route>, </Route>,
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*" <ContentError isNotFound>
render={() => {match.params.id && (
!hasContentLoading && ( <Link
<ContentError isNotFound> to={`/inventories/smart_inventory/${match.params.id}/details`}
{match.params.id && ( >
<Link {i18n._(`View Inventory Details`)}
to={`/inventories/smart_inventory/${match.params.id}/details`} </Link>
> )}
{i18n._(`View Inventory Details`)} </ContentError>
</Link> )}
)} </Route>,
</ContentError>
)
}
/>,
]} ]}
</Switch> </Switch>
</Card> </Card>

View File

@@ -124,53 +124,34 @@ class Job extends Component {
to="/jobs/:type/:id/output" to="/jobs/:type/:id/output"
exact exact
/> />
<Route {job &&
key="workflow-details" job.type === 'workflow_job' && [
path="/jobs/workflow/:id/details" <Route key="workflow-details" path="/jobs/workflow/:id/details">
render={() => <WorkflowDetail job={job} />
job && </Route>,
job.type === 'workflow_job' && <WorkflowDetail job={job} /> <Route key="workflow-output" path="/jobs/workflow/:id/output">
} <WorkflowOutput job={job} />
/> </Route>,
<Route ]}
key="workflow-output"
path="/jobs/workflow/:id/output"
render={() =>
job &&
job.type === 'workflow_job' && <WorkflowOutput job={job} />
}
/>
{job && {job &&
job.type !== 'workflow_job' && [ job.type !== 'workflow_job' && [
<Route <Route key="details" path="/jobs/:type/:id/details">
key="details" <JobDetail type={match.params.type} job={job} />
path="/jobs/:type/:id/details" </Route>,
render={() => ( <Route key="output" path="/jobs/:type/:id/output">
<JobDetail type={match.params.type} job={job} /> <JobOutput type={match.params.type} job={job} />
</Route>,
<Route key="not-found" path="*">
{!hasContentLoading && (
<ContentError isNotFound>
<Link
to={`/jobs/${match.params.type}/${match.params.id}/details`}
>
{i18n._(`View Job Details`)}
</Link>
</ContentError>
)} )}
/>, </Route>,
<Route
key="output"
path="/jobs/:type/:id/output"
render={() => (
<JobOutput type={match.params.type} job={job} />
)}
/>,
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound>
<Link
to={`/jobs/${match.params.type}/${match.params.id}/details`}
>
{i18n._(`View Job Details`)}
</Link>
</ContentError>
)
}
/>,
]} ]}
</Switch> </Switch>
</Card> </Card>

View File

@@ -4,6 +4,7 @@ import {
Switch, Switch,
useHistory, useHistory,
useLocation, useLocation,
useParams,
useRouteMatch, useRouteMatch,
} from 'react-router-dom'; } from 'react-router-dom';
import { withI18n } from '@lingui/react'; import { withI18n } from '@lingui/react';
@@ -18,6 +19,7 @@ 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`),
@@ -52,34 +54,22 @@ function Jobs({ i18n }) {
/> />
</PageSection> </PageSection>
</Route> </Route>
<Route <Route path={`${match.path}/:id/details`}>
path={`${match.path}/:id/details`} <JobTypeRedirect id={id} path={match.path} view="details" />
render={({ match: m }) => ( </Route>
<JobTypeRedirect id={m.params.id} path={m.path} view="details" /> <Route path={`${match.path}/:id/output`}>
)} <JobTypeRedirect id={id} path={match.path} view="output" />
/> </Route>
<Route <Route path={`${match.path}/:type/:id`}>
path={`${match.path}/:id/output`} <Job
render={({ match: m }) => ( history={history}
<JobTypeRedirect id={m.params.id} path={m.path} view="output" /> location={location}
)} setBreadcrumb={buildBreadcrumbConfig}
/> />
<Route </Route>
path={`${match.path}/:type/:id`} <Route path={`${match.path}/:id`}>
render={() => ( <JobTypeRedirect id={id} path={match.path} />
<Job </Route>
history={history}
location={location}
setBreadcrumb={buildBreadcrumbConfig}
/>
)}
/>
<Route
path={`${match.path}/:id`}
render={({ match: m }) => (
<JobTypeRedirect id={m.params.id} path={m.path} />
)}
/>
</Switch> </Switch>
</> </>
); );

View File

@@ -176,61 +176,46 @@ class Organization extends Component {
exact exact
/> />
{organization && ( {organization && (
<Route <Route path="/organizations/:id/edit">
path="/organizations/:id/edit" <OrganizationEdit organization={organization} />
render={() => <OrganizationEdit organization={organization} />} </Route>
/>
)} )}
{organization && ( {organization && (
<Route <Route path="/organizations/:id/details">
path="/organizations/:id/details" <OrganizationDetail organization={organization} />
render={() => ( </Route>
<OrganizationDetail organization={organization} />
)}
/>
)} )}
{organization && ( {organization && (
<Route <Route path="/organizations/:id/access">
path="/organizations/:id/access" <ResourceAccessList
render={() => ( resource={organization}
<ResourceAccessList apiModel={OrganizationsAPI}
resource={organization} />
apiModel={OrganizationsAPI} </Route>
/>
)}
/>
)} )}
<Route <Route path="/organizations/:id/teams">
path="/organizations/:id/teams" <OrganizationTeams id={Number(match.params.id)} />
render={() => <OrganizationTeams id={Number(match.params.id)} />} </Route>
/>
{canSeeNotificationsTab && ( {canSeeNotificationsTab && (
<Route <Route path="/organizations/:id/notifications">
path="/organizations/:id/notifications" <NotificationList
render={() => ( id={Number(match.params.id)}
<NotificationList canToggleNotifications={canToggleNotifications}
id={Number(match.params.id)} apiModel={OrganizationsAPI}
canToggleNotifications={canToggleNotifications} />
apiModel={OrganizationsAPI} </Route>
/>
)}
/>
)} )}
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*" <ContentError isNotFound>
render={() => {match.params.id && (
!hasContentLoading && ( <Link to={`/organizations/${match.params.id}/details`}>
<ContentError isNotFound> {i18n._(`View Organization Details`)}
{match.params.id && ( </Link>
<Link to={`/organizations/${match.params.id}/details`}> )}
{i18n._(`View Organization Details`)} </ContentError>
</Link> )}
)} </Route>
</ContentError>
)
}
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -55,26 +55,24 @@ class Organizations extends Component {
<Fragment> <Fragment>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
<Switch> <Switch>
<Route <Route path={`${match.path}/add`}>
path={`${match.path}/add`} <OrganizationAdd />
render={() => <OrganizationAdd />} </Route>
/> <Route path={`${match.path}/:id`}>
<Route <Config>
path={`${match.path}/:id`} {({ me }) => (
render={() => ( <Organization
<Config> history={history}
{({ me }) => ( location={location}
<Organization setBreadcrumb={this.setBreadcrumbConfig}
history={history} me={me || {}}
location={location} />
setBreadcrumb={this.setBreadcrumbConfig} )}
me={me || {}} </Config>
/> </Route>
)} <Route path={`${match.path}`}>
</Config> <OrganizationsList />
)} </Route>
/>
<Route path={`${match.path}`} render={() => <OrganizationsList />} />
</Switch> </Switch>
</Fragment> </Fragment>
); );

View File

@@ -192,75 +192,54 @@ class Project extends Component {
<Switch> <Switch>
<Redirect from="/projects/:id" to="/projects/:id/details" exact /> <Redirect from="/projects/:id" to="/projects/:id/details" exact />
{project && ( {project && (
<Route <Route path="/projects/:id/edit">
path="/projects/:id/edit" <ProjectEdit project={project} />
render={() => <ProjectEdit project={project} />} </Route>
/>
)} )}
{project && ( {project && (
<Route <Route path="/projects/:id/details">
path="/projects/:id/details" <ProjectDetail project={project} />
render={() => <ProjectDetail project={project} />} </Route>
/>
)} )}
{project && ( {project && (
<Route <Route path="/projects/:id/access">
path="/projects/:id/access" <ResourceAccessList resource={project} apiModel={ProjectsAPI} />
render={() => ( </Route>
<ResourceAccessList
resource={project}
apiModel={ProjectsAPI}
/>
)}
/>
)} )}
{canSeeNotificationsTab && ( {canSeeNotificationsTab && (
<Route <Route path="/projects/:id/notifications">
path="/projects/:id/notifications" <NotificationList
render={() => ( id={Number(match.params.id)}
<NotificationList canToggleNotifications={canToggleNotifications}
id={Number(match.params.id)} apiModel={ProjectsAPI}
canToggleNotifications={canToggleNotifications} />
apiModel={ProjectsAPI} </Route>
/>
)}
/>
)} )}
<Route <Route path="/projects/:id/job_templates">
path="/projects/:id/job_templates" <ProjectJobTemplatesList id={Number(match.params.id)} />
render={() => ( </Route>
<ProjectJobTemplatesList id={Number(match.params.id)} />
)}
/>
{project?.scm_type && project.scm_type !== '' && ( {project?.scm_type && project.scm_type !== '' && (
<Route <Route path="/projects/:id/schedules">
path="/projects/:id/schedules" <Schedules
render={() => ( setBreadcrumb={setBreadcrumb}
<Schedules unifiedJobTemplate={project}
setBreadcrumb={setBreadcrumb} createSchedule={this.createSchedule}
unifiedJobTemplate={project} loadSchedules={this.loadSchedules}
createSchedule={this.createSchedule} loadScheduleOptions={this.loadScheduleOptions}
loadSchedules={this.loadSchedules} />
loadScheduleOptions={this.loadScheduleOptions} </Route>
/>
)}
/>
)} )}
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*" <ContentError isNotFound>
render={() => {match.params.id && (
!hasContentLoading && ( <Link to={`/projects/${match.params.id}/details`}>
<ContentError isNotFound> {i18n._(`View Project Details`)}
{match.params.id && ( </Link>
<Link to={`/projects/${match.params.id}/details`}> )}
{i18n._(`View Project Details`)} </ContentError>
</Link> )}
)} </Route>
</ContentError>
)
}
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -62,23 +62,24 @@ class Projects extends Component {
<Fragment> <Fragment>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
<Switch> <Switch>
<Route path={`${match.path}/add`} render={() => <ProjectAdd />} /> <Route path={`${match.path}/add`}>
<Route <ProjectAdd />
path={`${match.path}/:id`} </Route>
render={() => ( <Route path={`${match.path}/:id`}>
<Config> <Config>
{({ me }) => ( {({ me }) => (
<Project <Project
history={history} history={history}
location={location} location={location}
setBreadcrumb={this.setBreadcrumbConfig} setBreadcrumb={this.setBreadcrumbConfig}
me={me || {}} me={me || {}}
/> />
)} )}
</Config> </Config>
)} </Route>
/> <Route path={`${match.path}`}>
<Route path={`${match.path}`} render={() => <ProjectsList />} /> <ProjectsList />
</Route>
</Switch> </Switch>
</Fragment> </Fragment>
); );

View File

@@ -87,38 +87,31 @@ function Team({ i18n, setBreadcrumb }) {
</Route> </Route>
)} )}
{team && ( {team && (
<Route <Route path="/teams/:id/edit">
path="/teams/:id/edit" <TeamEdit team={team} />
render={() => <TeamEdit team={team} />} </Route>
/>
)} )}
{team && ( {team && (
<Route <Route path="/teams/:id/users">
path="/teams/:id/users" <span>Coming soon :)</span>
render={() => <span>Coming soon :)</span>} </Route>
/>
)} )}
{team && ( {team && (
<Route <Route path="/teams/:id/access">
path="/teams/:id/access" <span>Coming soon :)</span>
render={() => <span>Coming soon :)</span>} </Route>
/>
)} )}
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*" <ContentError isNotFound>
render={() => {id && (
!hasContentLoading && ( <Link to={`/teams/${id}/details`}>
<ContentError isNotFound> {i18n._(`View Team Details`)}
{id && ( </Link>
<Link to={`/teams/${id}/details`}> )}
{i18n._(`View Team Details`)} </ContentError>
</Link> )}
)} </Route>
</ContentError>
)
}
/>
</Switch> </Switch>
</Card> </Card>
</PageSection> </PageSection>

View File

@@ -80,14 +80,12 @@ class Templates extends Component {
<> <>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
<Switch> <Switch>
<Route <Route path={`${match.path}/job_template/add`}>
path={`${match.path}/job_template/add`} <JobTemplateAdd />
render={() => <JobTemplateAdd />} </Route>
/> <Route path={`${match.path}/workflow_job_template/add`}>
<Route <WorkflowJobTemplateAdd />
path={`${match.path}/workflow_job_template/add`} </Route>
render={() => <WorkflowJobTemplateAdd />}
/>
<Route <Route
path={`${match.path}/job_template/:id`} path={`${match.path}/job_template/:id`}
render={({ match: newRouteMatch }) => ( render={({ match: newRouteMatch }) => (
@@ -119,7 +117,9 @@ class Templates extends Component {
</Config> </Config>
)} )}
/> />
<Route path={`${match.path}`} render={() => <TemplateList />} /> <Route path={`${match.path}`}>
<TemplateList />
</Route>
</Switch> </Switch>
</> </>
); );

View File

@@ -210,61 +210,52 @@ class WorkflowJobTemplate extends Component {
<Route <Route
key="wfjt-details" key="wfjt-details"
path="/templates/workflow_job_template/:id/details" path="/templates/workflow_job_template/:id/details"
render={() => ( >
<WorkflowJobTemplateDetail <WorkflowJobTemplateDetail
template={template} template={template}
webhook_key={webhook_key} webhook_key={webhook_key}
/> />
)} </Route>
/>
)} )}
{template && ( {template && (
<Route <Route path="/templates/workflow_job_template/:id/access">
path="/templates/workflow_job_template/:id/access" <ResourceAccessList
render={() => ( resource={template}
<ResourceAccessList apiModel={WorkflowJobTemplatesAPI}
resource={template} />
apiModel={WorkflowJobTemplatesAPI} </Route>
/>
)}
/>
)} )}
{canSeeNotificationsTab && ( {canSeeNotificationsTab && (
<Route <Route path="/templates/workflow_job_template/:id/notifications">
path="/templates/workflow_job_template/:id/notifications" <NotificationList
render={() => ( id={Number(match.params.id)}
<NotificationList canToggleNotifications={canToggleNotifications}
id={Number(match.params.id)} apiModel={WorkflowJobTemplatesAPI}
canToggleNotifications={canToggleNotifications} />
apiModel={WorkflowJobTemplatesAPI} </Route>
/>
)}
/>
)} )}
{template && ( {template && (
<Route <Route
key="wfjt-edit" key="wfjt-edit"
path="/templates/workflow_job_template/:id/edit" path="/templates/workflow_job_template/:id/edit"
render={() => ( >
<WorkflowJobTemplateEdit <WorkflowJobTemplateEdit
template={template} template={template}
webhook_key={webhook_key} webhook_key={webhook_key}
/> />
)} </Route>
/>
)} )}
{template && ( {template && (
<Route <Route
key="wfjt-visualizer" key="wfjt-visualizer"
path="/templates/workflow_job_template/:id/visualizer" path="/templates/workflow_job_template/:id/visualizer"
render={() => ( >
<AppendBody> <AppendBody>
<FullPage> <FullPage>
<Visualizer template={template} /> <Visualizer template={template} />
</FullPage> </FullPage>
</AppendBody> </AppendBody>
)} </Route>
/>
)} )}
{template?.id && ( {template?.id && (
<Route path="/templates/workflow_job_template/:id/completed_jobs"> <Route path="/templates/workflow_job_template/:id/completed_jobs">
@@ -276,39 +267,32 @@ class WorkflowJobTemplate extends Component {
</Route> </Route>
)} )}
{template?.id && ( {template?.id && (
<Route <Route path="/templates/workflow_job_template/:id/schedules">
path="/templates/workflow_job_template/:id/schedules" <Schedules
render={() => ( setBreadcrumb={setBreadcrumb}
<Schedules unifiedJobTemplate={template}
setBreadcrumb={setBreadcrumb} createSchedule={this.createSchedule}
unifiedJobTemplate={template} loadSchedules={this.loadSchedules}
createSchedule={this.createSchedule} loadScheduleOptions={this.loadScheduleOptions}
loadSchedules={this.loadSchedules} />
loadScheduleOptions={this.loadScheduleOptions} </Route>
/>
)}
/>
)} )}
{template && ( {template && (
<Route path="/templates/:templateType/:id/survey"> <Route path="/templates/:templateType/:id/survey">
<TemplateSurvey template={template} /> <TemplateSurvey template={template} />
</Route> </Route>
)} )}
<Route <Route key="not-found" path="*">
key="not-found" <ContentError isNotFound>
path="*" {match.params.id && (
render={() => ( <Link
<ContentError isNotFound> to={`/templates/workflow_job_template/${match.params.id}/details`}
{match.params.id && ( >
<Link {i18n._(`View Template Details`)}
to={`/templates/workflow_job_template/${match.params.id}/details`} </Link>
> )}
{i18n._(`View Template Details`)} </ContentError>
</Link> </Route>
)}
</ContentError>
)}
/>
</Switch> </Switch>
</Card> </Card>
</PageSection> </PageSection>

View File

@@ -119,54 +119,43 @@ class User extends Component {
<Switch> <Switch>
<Redirect from="/users/:id" to="/users/:id/details" exact /> <Redirect from="/users/:id" to="/users/:id/details" exact />
{user && ( {user && (
<Route <Route path="/users/:id/edit">
path="/users/:id/edit" <UserEdit user={user} />
render={() => <UserEdit user={user} />} </Route>
/>
)} )}
{user && ( {user && (
<Route <Route path="/users/:id/details">
path="/users/:id/details" <UserDetail user={user} />
render={() => <UserDetail user={user} />} </Route>
/>
)} )}
<Route path="/users/:id/organizations"> <Route path="/users/:id/organizations">
<UserOrganizations id={Number(match.params.id)} /> <UserOrganizations id={Number(match.params.id)} />
</Route> </Route>
<Route <Route path="/users/:id/teams">
path="/users/:id/teams" <UserTeams id={Number(match.params.id)} />
render={() => <UserTeams id={Number(match.params.id)} />} </Route>
/>
{user && ( {user && (
<Route <Route path="/users/:id/access">
path="/users/:id/access" <span>
render={() => ( this needs a different access list from regular resources like
<span> proj, inv, jt
this needs a different access list from regular resources </span>
like proj, inv, jt </Route>
</span>
)}
/>
)} )}
<Route <Route path="/users/:id/tokens">
path="/users/:id/tokens" <UserTokens id={Number(match.params.id)} />
render={() => <UserTokens id={Number(match.params.id)} />} </Route>
/> <Route key="not-found" path="*">
<Route !hasContentLoading && (
key="not-found" <ContentError isNotFound>
path="*" {match.params.id && (
render={() => <Link to={`/users/${match.params.id}/details`}>
!hasContentLoading && ( {i18n._(`View User Details`)}
<ContentError isNotFound> </Link>
{match.params.id && ( )}
<Link to={`/users/${match.params.id}/details`}> </ContentError>
{i18n._(`View User Details`)} )
</Link> </Route>
)}
</ContentError>
)
}
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -54,23 +54,24 @@ class Users extends Component {
<Fragment> <Fragment>
<Breadcrumbs breadcrumbConfig={breadcrumbConfig} /> <Breadcrumbs breadcrumbConfig={breadcrumbConfig} />
<Switch> <Switch>
<Route path={`${match.path}/add`} render={() => <UserAdd />} /> <Route path={`${match.path}/add`}>
<Route <UserAdd />
path={`${match.path}/:id`} </Route>
render={() => ( <Route path={`${match.path}/:id`}>
<Config> <Config>
{({ me }) => ( {({ me }) => (
<User <User
history={history} history={history}
location={location} location={location}
setBreadcrumb={this.setBreadcrumbConfig} setBreadcrumb={this.setBreadcrumbConfig}
me={me || {}} me={me || {}}
/> />
)} )}
</Config> </Config>
)} </Route>
/> <Route path={`${match.path}`}>
<Route path={`${match.path}`} render={() => <UsersList />} /> <UsersList />
</Route>
</Switch> </Switch>
</Fragment> </Fragment>
); );