fix routing reversion discussed with Tan

This commit is contained in:
Dan Wilson 2023-08-03 21:14:27 +01:00
parent 23923f9653
commit 74532bbd1b
2 changed files with 14 additions and 10 deletions

View File

@ -12,15 +12,19 @@ export interface CODEProps {
pullRequestSection?: string pullRequestSection?: string
webhookId?: string webhookId?: string
pipeline?: string pipeline?: string
pipelinePath?: string
execution?: string execution?: string
executionPath?: string
} }
export interface CODEQueryProps { export interface CODEQueryProps {
query?: string query?: string
} }
export const pathProps: Readonly<Omit<Required<CODEProps>, 'repoPath' | 'branch' | 'tags' | 'pipelinePath'>> = { export const pathProps: Readonly<
space: ':space', Omit<Required<CODEProps>, 'repoPath' | 'branch' | 'tags' | 'pipelinePath' | 'executionPath'>
> = {
space: ':space*',
repoName: ':repoName', repoName: ':repoName',
gitRef: ':gitRef*', gitRef: ':gitRef*',
resourcePath: ':resourcePath*', resourcePath: ':resourcePath*',
@ -69,8 +73,8 @@ export interface CODERoutes {
toCODEWebhookDetails: (args: Required<Pick<CODEProps, 'repoPath' | 'webhookId'>>) => string toCODEWebhookDetails: (args: Required<Pick<CODEProps, 'repoPath' | 'webhookId'>>) => string
toCODESettings: (args: Required<Pick<CODEProps, 'repoPath'>>) => string toCODESettings: (args: Required<Pick<CODEProps, 'repoPath'>>) => string
toCODEExecutions: (args: Required<Pick<CODEProps, 'space' | 'pipeline'>>) => string toCODEExecutions: (args: Required<Pick<CODEProps, 'pipelinePath'>>) => string
toCODEExecution: (args: Required<Pick<CODEProps, 'space' | 'pipeline' | 'execution'>>) => string toCODEExecution: (args: Required<Pick<CODEProps, 'executionPath'>>) => string
} }
export const routes: CODERoutes = { export const routes: CODERoutes = {
@ -112,6 +116,6 @@ export const routes: CODERoutes = {
toCODEWebhookNew: ({ repoPath }) => `/${repoPath}/webhooks/new`, toCODEWebhookNew: ({ repoPath }) => `/${repoPath}/webhooks/new`,
toCODEWebhookDetails: ({ repoPath, webhookId }) => `/${repoPath}/webhook/${webhookId}`, toCODEWebhookDetails: ({ repoPath, webhookId }) => `/${repoPath}/webhook/${webhookId}`,
toCODEExecutions: ({ space, pipeline }) => `/pipelines/${space}/${pipeline}`, toCODEExecutions: ({ pipelinePath }) => `/pipelines/${pipelinePath}`,
toCODEExecution: ({ space, pipeline, execution }) => `/pipelines/${space}/${pipeline}/${execution}` toCODEExecution: ({ executionPath }) => `/pipelines/${executionPath}`
} }

View File

@ -34,6 +34,8 @@ import Execution from 'pages/Execution/Execution'
export const RouteDestinations: React.FC = React.memo(function RouteDestinations() { export const RouteDestinations: React.FC = React.memo(function RouteDestinations() {
const { getString } = useStrings() const { getString } = useStrings()
const repoPath = `${pathProps.space}/${pathProps.repoName}` const repoPath = `${pathProps.space}/${pathProps.repoName}`
const pipelinePath = `${pathProps.space}/${pathProps.pipeline}`
const executionPath = `${pathProps.space}/${pathProps.pipeline}/${pathProps.execution}`
const { OPEN_SOURCE_PIPELINES, OPEN_SOURCE_SECRETS } = useFeatureFlag() const { OPEN_SOURCE_PIPELINES, OPEN_SOURCE_SECRETS } = useFeatureFlag()
@ -165,7 +167,7 @@ export const RouteDestinations: React.FC = React.memo(function RouteDestinations
)} )}
{OPEN_SOURCE_PIPELINES && ( {OPEN_SOURCE_PIPELINES && (
<Route path={routes.toCODEExecutions({ space: pathProps.space, pipeline: pathProps.pipeline })} exact> <Route path={routes.toCODEExecutions({ pipelinePath })} exact>
<LayoutWithSideNav title={getString('pageTitle.executions')}> <LayoutWithSideNav title={getString('pageTitle.executions')}>
<ExecutionList /> <ExecutionList />
</LayoutWithSideNav> </LayoutWithSideNav>
@ -175,9 +177,7 @@ export const RouteDestinations: React.FC = React.memo(function RouteDestinations
{OPEN_SOURCE_PIPELINES && ( {OPEN_SOURCE_PIPELINES && (
<Route <Route
path={routes.toCODEExecution({ path={routes.toCODEExecution({
space: pathProps.space, executionPath
pipeline: pathProps.pipeline,
execution: pathProps.execution
})} })}
exact> exact>
<LayoutWithSideNav title={getString('pageTitle.executions')}> <LayoutWithSideNav title={getString('pageTitle.executions')}>