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"
path="*"
render={() => {
return (
<ContentError> <ContentError>
{unifiedJobTemplate && ( {unifiedJobTemplate && (
<Link to={`${pathRoot}details`}> <Link to={`${pathRoot}details`}>{i18n._(t`View Details`)}</Link>
{i18n._(t`View Details`)}
</Link>
)} )}
</ContentError> </ContentError>
); </Route>
}}
/>
</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
key="details"
path={`${match.path}/:scheduleId`}
render={() => (
<Schedule <Schedule
unifiedJobTemplate={unifiedJobTemplate} unifiedJobTemplate={unifiedJobTemplate}
setBreadcrumb={setBreadcrumb} setBreadcrumb={setBreadcrumb}
/> />
)} </Route>
/> <Route key="list" path={`${match.path}`}>
<Route
key="list"
path={`${match.path}`}
render={() => {
return (
<ScheduleList <ScheduleList
loadSchedules={loadSchedules} loadSchedules={loadSchedules}
loadScheduleOptions={loadScheduleOptions} loadScheduleOptions={loadScheduleOptions}
/> />
); </Route>
}}
/>
</Switch> </Switch>
); );
} }

View File

@@ -98,33 +98,22 @@ 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"
path="/credentials/:id/access"
render={() => (
<ResourceAccessList <ResourceAccessList
resource={credential} resource={credential}
apiModel={CredentialsAPI} apiModel={CredentialsAPI}
/> />
)} </Route>
/>
), ),
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
<Link to={`/credentials/${match.params.id}/details`}> <Link to={`/credentials/${match.params.id}/details`}>
@@ -132,15 +121,11 @@ function Credential({ i18n, setBreadcrumb }) {
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>,
/>,
]} ]}
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{id && ( {id && (
<Link to={`/credentials/${id}/details`}> <Link to={`/credentials/${id}/details`}>
@@ -148,9 +133,8 @@ function Credential({ i18n, setBreadcrumb }) {
</Link> </Link>
)} )}
</ContentError> </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,11 +137,7 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) {
<InventoryGroupHosts inventoryGroup={inventoryGroup} /> <InventoryGroupHosts inventoryGroup={inventoryGroup} />
</Route>, </Route>,
]} ]}
<Route <Route key="not-found" path="*">
key="not-found"
path="*"
render={() => {
return (
<ContentError> <ContentError>
{inventory && ( {inventory && (
<Link to={`/inventories/inventory/${inventory.id}/details`}> <Link to={`/inventories/inventory/${inventory.id}/details`}>
@@ -149,9 +145,7 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) {
</Link> </Link>
)} )}
</ContentError> </ContentError>
); </Route>
}}
/>
</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"
path="/inventories/inventory/:id/groups/add"
render={() => {
return (
<InventoryGroupAdd <InventoryGroupAdd
setBreadcrumb={setBreadcrumb} setBreadcrumb={setBreadcrumb}
inventory={inventory} inventory={inventory}
/> />
); </Route>
}} <Route key="details" path="/inventories/inventory/:id/groups/:groupId/">
/>
<Route
key="details"
path="/inventories/inventory/:id/groups/:groupId/"
render={() => (
<InventoryGroup inventory={inventory} setBreadcrumb={setBreadcrumb} /> <InventoryGroup inventory={inventory} setBreadcrumb={setBreadcrumb} />
)} </Route>
/> <Route key="list" path="/inventories/inventory/:id/groups">
<Route <InventoryGroupsList />
key="list" </Route>
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,11 +154,8 @@ class SmartInventory extends Component {
}} }}
/> />
</Route>, </Route>,
<Route <Route key="not-found" path="*">
key="not-found" {!hasContentLoading && (
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
<Link <Link
@@ -174,9 +165,8 @@ class SmartInventory extends Component {
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>,
/>,
]} ]}
</Switch> </Switch>
</Card> </Card>

View File

@@ -124,43 +124,25 @@ 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"
path="/jobs/:type/:id/details"
render={() => (
<JobDetail type={match.params.type} job={job} /> <JobDetail type={match.params.type} job={job} />
)} </Route>,
/>, <Route key="output" path="/jobs/:type/:id/output">
<Route
key="output"
path="/jobs/:type/:id/output"
render={() => (
<JobOutput type={match.params.type} job={job} /> <JobOutput type={match.params.type} job={job} />
)} </Route>,
/>, <Route key="not-found" path="*">
<Route {!hasContentLoading && (
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
<Link <Link
to={`/jobs/${match.params.type}/${match.params.id}/details`} to={`/jobs/${match.params.type}/${match.params.id}/details`}
@@ -168,9 +150,8 @@ class Job extends Component {
{i18n._(`View Job Details`)} {i18n._(`View Job Details`)}
</Link> </Link>
</ContentError> </ContentError>
) )}
} </Route>,
/>,
]} ]}
</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`}
render={({ match: m }) => (
<JobTypeRedirect id={m.params.id} path={m.path} view="output" />
)}
/>
<Route
path={`${match.path}/:type/:id`}
render={() => (
<Job <Job
history={history} history={history}
location={location} location={location}
setBreadcrumb={buildBreadcrumbConfig} setBreadcrumb={buildBreadcrumbConfig}
/> />
)} </Route>
/> <Route path={`${match.path}/:id`}>
<Route <JobTypeRedirect id={id} path={match.path} />
path={`${match.path}/:id`} </Route>
render={({ match: m }) => (
<JobTypeRedirect id={m.params.id} path={m.path} />
)}
/>
</Switch> </Switch>
</> </>
); );

View File

@@ -176,51 +176,37 @@ 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"
render={() => (
<OrganizationDetail organization={organization} /> <OrganizationDetail organization={organization} />
)} </Route>
/>
)} )}
{organization && ( {organization && (
<Route <Route path="/organizations/:id/access">
path="/organizations/:id/access"
render={() => (
<ResourceAccessList <ResourceAccessList
resource={organization} resource={organization}
apiModel={OrganizationsAPI} apiModel={OrganizationsAPI}
/> />
</Route>
)} )}
/> <Route path="/organizations/:id/teams">
)} <OrganizationTeams id={Number(match.params.id)} />
<Route </Route>
path="/organizations/:id/teams"
render={() => <OrganizationTeams id={Number(match.params.id)} />}
/>
{canSeeNotificationsTab && ( {canSeeNotificationsTab && (
<Route <Route path="/organizations/:id/notifications">
path="/organizations/:id/notifications"
render={() => (
<NotificationList <NotificationList
id={Number(match.params.id)} id={Number(match.params.id)}
canToggleNotifications={canToggleNotifications} canToggleNotifications={canToggleNotifications}
apiModel={OrganizationsAPI} apiModel={OrganizationsAPI}
/> />
</Route>
)} )}
/> <Route key="not-found" path="*">
)} {!hasContentLoading && (
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
<Link to={`/organizations/${match.params.id}/details`}> <Link to={`/organizations/${match.params.id}/details`}>
@@ -228,9 +214,8 @@ class Organization extends Component {
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -55,13 +55,10 @@ 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
path={`${match.path}/:id`}
render={() => (
<Config> <Config>
{({ me }) => ( {({ me }) => (
<Organization <Organization
@@ -72,9 +69,10 @@ class Organizations extends Component {
/> />
)} )}
</Config> </Config>
)} </Route>
/> <Route path={`${match.path}`}>
<Route path={`${match.path}`} render={() => <OrganizationsList />} /> <OrganizationsList />
</Route>
</Switch> </Switch>
</Fragment> </Fragment>
); );

View File

@@ -192,50 +192,34 @@ 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"
render={() => (
<NotificationList <NotificationList
id={Number(match.params.id)} id={Number(match.params.id)}
canToggleNotifications={canToggleNotifications} canToggleNotifications={canToggleNotifications}
apiModel={ProjectsAPI} apiModel={ProjectsAPI}
/> />
</Route>
)} )}
/> <Route path="/projects/:id/job_templates">
)}
<Route
path="/projects/:id/job_templates"
render={() => (
<ProjectJobTemplatesList id={Number(match.params.id)} /> <ProjectJobTemplatesList id={Number(match.params.id)} />
)} </Route>
/>
{project?.scm_type && project.scm_type !== '' && ( {project?.scm_type && project.scm_type !== '' && (
<Route <Route path="/projects/:id/schedules">
path="/projects/:id/schedules"
render={() => (
<Schedules <Schedules
setBreadcrumb={setBreadcrumb} setBreadcrumb={setBreadcrumb}
unifiedJobTemplate={project} unifiedJobTemplate={project}
@@ -243,14 +227,10 @@ class Project extends Component {
loadSchedules={this.loadSchedules} loadSchedules={this.loadSchedules}
loadScheduleOptions={this.loadScheduleOptions} loadScheduleOptions={this.loadScheduleOptions}
/> />
</Route>
)} )}
/> <Route key="not-found" path="*">
)} {!hasContentLoading && (
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
<Link to={`/projects/${match.params.id}/details`}> <Link to={`/projects/${match.params.id}/details`}>
@@ -258,9 +238,8 @@ class Project extends Component {
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -62,10 +62,10 @@ 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
@@ -76,9 +76,10 @@ class Projects extends Component {
/> />
)} )}
</Config> </Config>
)} </Route>
/> <Route path={`${match.path}`}>
<Route path={`${match.path}`} render={() => <ProjectsList />} /> <ProjectsList />
</Route>
</Switch> </Switch>
</Fragment> </Fragment>
); );

View File

@@ -87,28 +87,22 @@ 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="*"
render={() =>
!hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{id && ( {id && (
<Link to={`/teams/${id}/details`}> <Link to={`/teams/${id}/details`}>
@@ -116,9 +110,8 @@ function Team({ i18n, setBreadcrumb }) {
</Link> </Link>
)} )}
</ContentError> </ContentError>
) )}
} </Route>
/>
</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"
render={() => (
<ResourceAccessList <ResourceAccessList
resource={template} resource={template}
apiModel={WorkflowJobTemplatesAPI} apiModel={WorkflowJobTemplatesAPI}
/> />
)} </Route>
/>
)} )}
{canSeeNotificationsTab && ( {canSeeNotificationsTab && (
<Route <Route path="/templates/workflow_job_template/:id/notifications">
path="/templates/workflow_job_template/:id/notifications"
render={() => (
<NotificationList <NotificationList
id={Number(match.params.id)} id={Number(match.params.id)}
canToggleNotifications={canToggleNotifications} canToggleNotifications={canToggleNotifications}
apiModel={WorkflowJobTemplatesAPI} 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,9 +267,7 @@ 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"
render={() => (
<Schedules <Schedules
setBreadcrumb={setBreadcrumb} setBreadcrumb={setBreadcrumb}
unifiedJobTemplate={template} unifiedJobTemplate={template}
@@ -286,18 +275,14 @@ class WorkflowJobTemplate extends Component {
loadSchedules={this.loadSchedules} loadSchedules={this.loadSchedules}
loadScheduleOptions={this.loadScheduleOptions} 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"
path="*"
render={() => (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
<Link <Link
@@ -307,8 +292,7 @@ class WorkflowJobTemplate extends Component {
</Link> </Link>
)} )}
</ContentError> </ContentError>
)} </Route>
/>
</Switch> </Switch>
</Card> </Card>
</PageSection> </PageSection>

View File

@@ -119,43 +119,33 @@ 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"
render={() => (
<span> <span>
this needs a different access list from regular resources this needs a different access list from regular resources like
like proj, inv, jt proj, inv, jt
</span> </span>
</Route>
)} )}
/> <Route path="/users/:id/tokens">
)} <UserTokens id={Number(match.params.id)} />
<Route </Route>
path="/users/:id/tokens" <Route key="not-found" path="*">
render={() => <UserTokens id={Number(match.params.id)} />}
/>
<Route
key="not-found"
path="*"
render={() =>
!hasContentLoading && ( !hasContentLoading && (
<ContentError isNotFound> <ContentError isNotFound>
{match.params.id && ( {match.params.id && (
@@ -165,8 +155,7 @@ class User extends Component {
)} )}
</ContentError> </ContentError>
) )
} </Route>
/>
, ,
</Switch> </Switch>
</Card> </Card>

View File

@@ -54,10 +54,10 @@ 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
@@ -68,9 +68,10 @@ class Users extends Component {
/> />
)} )}
</Config> </Config>
)} </Route>
/> <Route path={`${match.path}`}>
<Route path={`${match.path}`} render={() => <UsersList />} /> <UsersList />
</Route>
</Switch> </Switch>
</Fragment> </Fragment>
); );