export interface CODEProps { space?: string repoName?: string repoPath?: string gitRef?: string resourcePath?: string commitRef?: string branch?: string tags?: string diffRefs?: string pullRequestId?: string pullRequestSection?: string webhookId?: string pipeline?: string execution?: string commitSHA?: string secret?: string } export interface CODEQueryProps { query?: string } export const pathProps: Readonly, 'repoPath' | 'branch' | 'tags'>> = { space: ':space*', repoName: ':repoName', gitRef: ':gitRef*', resourcePath: ':resourcePath*', commitRef: ':commitRef*', diffRefs: ':diffRefs*', pullRequestId: ':pullRequestId', pullRequestSection: ':pullRequestSection', webhookId: ':webhookId', pipeline: ':pipeline', execution: ':execution', commitSHA: ':commitSHA', secret: ':secret' } export interface CODERoutes { toSignIn: () => string toRegister: () => string toCODEHome: () => string toCODESpaceAccessControl: (args: Required>) => string toCODESpaceSettings: (args: Required>) => string toCODEPipelines: (args: Required>) => string toCODEPipelinesNew: (args: Required>) => string toCODESecrets: (args: Required>) => string toCODEGlobalSettings: () => string toCODEUsers: () => string toCODEUserProfile: () => string toCODEUserChangePassword: () => string toCODERepositories: (args: Required>) => string toCODERepository: (args: RequiredField, 'repoPath'>) => string toCODEFileEdit: (args: Required>) => string toCODECommits: (args: Required>) => string toCODECommit: (args: Required>) => string toCODEPullRequests: (args: Required>) => string toCODEPullRequest: ( args: RequiredField< Pick, 'repoPath' | 'pullRequestId' > ) => string toCODECompare: (args: Required>) => string toCODEBranches: (args: Required>) => string toCODETags: (args: Required>) => string toCODEWebhooks: (args: Required>) => string toCODEWebhookNew: (args: Required>) => string toCODEWebhookDetails: (args: Required>) => string toCODESettings: (args: Required>) => string toCODEExecutions: (args: Required>) => string toCODEExecution: (args: Required>) => string toCODESecret: (args: Required>) => string } /** * NOTE: NEVER IMPORT AND USE THIS ROUTES EXPORT DIRECTLY IN CODE. * * routes is used to created URLs in standalone version. Instead, use * the `routes` from AppContext which is mapped to this export in standalone * version or Harness Platform routes which is passed from Harness Platform UI. * * Correct usage: const { routes } = useAppContext() */ export const routes: CODERoutes = { toSignIn: (): string => '/signin', toRegister: (): string => '/register', toCODEHome: () => `/`, toCODESpaceAccessControl: ({ space }) => `/access-control/${space}`, toCODESpaceSettings: ({ space }) => `/settings/${space}`, toCODEPipelines: ({ repoPath }) => `/${repoPath}/pipelines`, toCODEPipelinesNew: ({ space }) => `/pipelines/${space}/new`, toCODESecrets: ({ space }) => `/secrets/${space}`, toCODEGlobalSettings: () => '/settings', toCODEUsers: () => '/users', toCODEUserProfile: () => '/profile', toCODEUserChangePassword: () => '/change-password', toCODERepositories: ({ space }) => `/spaces/${space}`, toCODERepository: ({ repoPath, gitRef, resourcePath }) => `/${repoPath}${gitRef ? '/files/' + gitRef : ''}${resourcePath ? '/~/' + resourcePath : ''}`, toCODEFileEdit: ({ repoPath, gitRef, resourcePath }: RequiredField, 'repoPath' | 'gitRef'>) => `/${repoPath}/edit/${gitRef}/~/${resourcePath || ''}`, toCODECommits: ({ repoPath, commitRef }) => `/${repoPath}/commits/${commitRef}`, toCODECommit: ({ repoPath, commitRef }) => `/${repoPath}/commit/${commitRef}`, toCODEPullRequests: ({ repoPath }) => `/${repoPath}/pulls`, toCODEPullRequest: ({ repoPath, pullRequestId, pullRequestSection, commitSHA }) => `/${repoPath}/pulls/${pullRequestId}${pullRequestSection ? '/' + pullRequestSection : ''}${ commitSHA ? '/' + commitSHA : '' }`, toCODECompare: ({ repoPath, diffRefs }) => `/${repoPath}/pulls/compare/${diffRefs}`, toCODEBranches: ({ repoPath }) => `/${repoPath}/branches`, toCODETags: ({ repoPath }) => `/${repoPath}/tags`, toCODESettings: ({ repoPath }) => `/${repoPath}/settings`, toCODEWebhooks: ({ repoPath }) => `/${repoPath}/webhooks`, toCODEWebhookNew: ({ repoPath }) => `/${repoPath}/webhooks/new`, toCODEWebhookDetails: ({ repoPath, webhookId }) => `/${repoPath}/webhook/${webhookId}`, toCODEExecutions: ({ repoPath, pipeline }) => `/${repoPath}/pipelines/${pipeline}`, toCODEExecution: ({ repoPath, pipeline, execution }) => `/${repoPath}/pipelines/${pipeline}/execution/${execution}`, toCODESecret: ({ space, secret }) => `/secrets/${space}/secret/${secret}` }