mirror of
https://github.com/harness/drone.git
synced 2025-05-12 15:10:09 +08:00
Revert "feat: [code-566]: fix routing for commit list and diff page (#177)"
This reverts commit 8cddf04706
.
This commit is contained in:
parent
f8092fe117
commit
cd5fe7c418
@ -28,10 +28,9 @@ module.exports = {
|
||||
'./Repository': './src/pages/Repository/Repository.tsx',
|
||||
'./FileEdit': './src/pages/RepositoryFileEdit/RepositoryFileEdit.tsx',
|
||||
'./Commits': './src/pages/RepositoryCommits/RepositoryCommits.tsx',
|
||||
'./Commit': './src/pages/RepositoryCommit/RepositoryCommit.tsx',
|
||||
'./Branches': './src/pages/RepositoryBranches/RepositoryBranches.tsx',
|
||||
'./PullRequests': './src/pages/PullRequests/PullRequests.tsx',
|
||||
'./Tags': './src/pages/RepositoryTags/RepositoryTags.tsx',
|
||||
'./Tags':'./src/pages/RepositoryTags/RepositoryTags.tsx',
|
||||
'./PullRequest': './src/pages/PullRequest/PullRequest.tsx',
|
||||
'./Compare': './src/pages/Compare/Compare.tsx',
|
||||
'./Settings': './src/pages/RepositorySettings/RepositorySettings.tsx',
|
||||
|
@ -36,7 +36,6 @@ export interface CODERoutes {
|
||||
toCODERepository: (args: RequiredField<Pick<CODEProps, 'repoPath' | 'gitRef' | 'resourcePath'>, 'repoPath'>) => string
|
||||
toCODEFileEdit: (args: Required<Pick<CODEProps, 'repoPath' | 'gitRef' | 'resourcePath'>>) => string
|
||||
toCODECommits: (args: Required<Pick<CODEProps, 'repoPath' | 'commitRef'>>) => string
|
||||
toCODECommit: (args: Required<Pick<CODEProps, 'repoPath' | 'commitRef'>>) => string
|
||||
toCODEPullRequests: (args: Required<Pick<CODEProps, 'repoPath'>>) => string
|
||||
toCODEPullRequest: (
|
||||
args: RequiredField<
|
||||
@ -62,7 +61,6 @@ export const routes: CODERoutes = {
|
||||
`/${repoPath}/${gitRef ? '/' + gitRef : ''}${resourcePath ? '/~/' + resourcePath : ''}`,
|
||||
toCODEFileEdit: ({ repoPath, gitRef, resourcePath }) => `/${repoPath}/edit/${gitRef}/~/${resourcePath}`,
|
||||
toCODECommits: ({ repoPath, commitRef }) => `/${repoPath}/commits/${commitRef}`,
|
||||
toCODECommit: ({ repoPath, commitRef }) => `/${repoPath}/commit/${commitRef}`,
|
||||
toCODEPullRequests: ({ repoPath }) => `/${repoPath}/pulls`,
|
||||
toCODEPullRequest: ({ repoPath, pullRequestId, pullRequestSection }) =>
|
||||
`/${repoPath}/pulls/${pullRequestId}${pullRequestSection ? '/' + pullRequestSection : ''}`,
|
||||
|
@ -13,7 +13,7 @@ interface CodeCommentStatusSelectProps extends Pick<GitInfoProps, 'repoMetadata'
|
||||
commentItems: CommentItem<TypesPullReqActivity>[]
|
||||
onCommentUpdate: () => void
|
||||
|
||||
refetchActivities?: () => void
|
||||
refetchActivities: () => void
|
||||
}
|
||||
|
||||
export const CodeCommentStatusSelect: React.FC<CodeCommentStatusSelectProps> = ({
|
||||
@ -77,9 +77,7 @@ export const CodeCommentStatusSelect: React.FC<CodeCommentStatusSelectProps> = (
|
||||
commentItems[0].payload.resolved = Date.now()
|
||||
}
|
||||
}
|
||||
if (refetchActivities) {
|
||||
refetchActivities()
|
||||
}
|
||||
refetchActivities()
|
||||
})
|
||||
.catch(_exception => {
|
||||
showError(getErrorMessage(_exception), 0, getString('pr.failedToUpdateCommentStatus'))
|
||||
|
@ -87,7 +87,7 @@ export function CommitsView({
|
||||
return (
|
||||
<CommitActions
|
||||
sha={row.original.sha as string}
|
||||
href={routes.toCODECommit({
|
||||
href={routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: row.original.sha as string
|
||||
})}
|
||||
|
@ -20,7 +20,7 @@ interface LatestCommitProps extends Pick<GitInfoProps, 'repoMetadata'> {
|
||||
|
||||
export function LatestCommitForFolder({ repoMetadata, latestCommit, standaloneStyle }: LatestCommitProps) {
|
||||
const { routes } = useAppContext()
|
||||
const commitURL = routes.toCODECommit({
|
||||
const commitURL = routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: latestCommit?.sha as string
|
||||
})
|
||||
@ -49,7 +49,7 @@ export function LatestCommitForFolder({ repoMetadata, latestCommit, standaloneSt
|
||||
|
||||
export function LatestCommitForFile({ repoMetadata, latestCommit, standaloneStyle, size }: LatestCommitProps) {
|
||||
const { routes } = useAppContext()
|
||||
const commitURL = routes.toCODECommit({
|
||||
const commitURL = routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: latestCommit?.sha as string
|
||||
})
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { noop } from 'lodash-es'
|
||||
import React from 'react'
|
||||
import {
|
||||
Container,
|
||||
@ -11,8 +12,8 @@ import {
|
||||
IconName,
|
||||
useToaster
|
||||
} from '@harness/uicore'
|
||||
import { useMutate } from 'restful-react'
|
||||
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||
import { useMutate } from 'restful-react'
|
||||
import { useStrings } from 'framework/strings'
|
||||
import type { TypesPullReq, TypesRepository } from 'services/code'
|
||||
import { getErrorMessage } from 'utils/Utils'
|
||||
|
@ -50,7 +50,7 @@ export function FolderContent({
|
||||
className={css.rowText}
|
||||
onClick={() => {
|
||||
history.push(
|
||||
routes.toCODECommit({
|
||||
routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: row.original.latest_commit?.sha as string
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState } from 'react'
|
||||
import { Container, Layout, FlexExpander, ButtonVariation } from '@harness/uicore'
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import { Container, Layout, FlexExpander, DropDown, ButtonVariation } from '@harness/uicore'
|
||||
import { useStrings } from 'framework/strings'
|
||||
import { GitBranchType, CodeIcon, GitInfoProps } from 'utils/GitUtils'
|
||||
import { SearchInputWithSpinner } from 'components/SearchInputWithSpinner/SearchInputWithSpinner'
|
||||
|
@ -1,18 +0,0 @@
|
||||
.main {
|
||||
min-height: var(--page-min-height, 100%);
|
||||
background-color: var(--primary-bg) !important;
|
||||
}
|
||||
|
||||
.resourceContent {
|
||||
background-color: var(--primary-bg);
|
||||
}
|
||||
|
||||
.contentHeader {
|
||||
> div {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.changesContainer {
|
||||
padding: 0 0 var(--spacing-xlarge) 0 !important;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// this is an auto-generated file
|
||||
declare const styles: {
|
||||
readonly main: string
|
||||
readonly resourceContent: string
|
||||
readonly contentHeader: string
|
||||
readonly changesContainer: string
|
||||
}
|
||||
export default styles
|
@ -1,87 +0,0 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import { Container, FlexExpander, Layout, PageBody } from '@harness/uicore'
|
||||
import { useGet } from 'restful-react'
|
||||
import { noop } from 'lodash-es'
|
||||
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
|
||||
import { useAppContext } from 'AppContext'
|
||||
import type { TypesCommit } from 'services/code'
|
||||
import { voidFn, getErrorMessage, LIST_FETCHING_LIMIT } from 'utils/Utils'
|
||||
import { useStrings } from 'framework/strings'
|
||||
import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader'
|
||||
import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner'
|
||||
import { Changes } from 'components/Changes/Changes'
|
||||
import CommitInfo from 'components/CommitInfo/CommitInfo'
|
||||
import css from './RepositoryCommit.module.scss'
|
||||
|
||||
export default function RepositoryCommits() {
|
||||
const { repoMetadata, error, loading, commitRef, refetch } = useGetRepositoryMetadata()
|
||||
const { routes } = useAppContext()
|
||||
const { getString } = useStrings()
|
||||
|
||||
const {
|
||||
data: commits,
|
||||
error: errorCommits,
|
||||
loading: loadingCommits
|
||||
} = useGet<{ commits: TypesCommit[] }>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
queryParams: {
|
||||
limit: LIST_FETCHING_LIMIT,
|
||||
git_ref: commitRef || repoMetadata?.default_branch
|
||||
},
|
||||
lazy: !repoMetadata
|
||||
})
|
||||
|
||||
const ChangesTab = useMemo(() => {
|
||||
if (repoMetadata) {
|
||||
return (
|
||||
<Container className={css.changesContainer}>
|
||||
<Changes
|
||||
readOnly
|
||||
repoMetadata={repoMetadata}
|
||||
targetBranch={`${commitRef}~1`}
|
||||
sourceBranch={commitRef}
|
||||
emptyTitle={getString('noChanges')}
|
||||
emptyMessage={getString('noChangesCompare')}
|
||||
onCommentUpdate={noop}
|
||||
/>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
}, [repoMetadata, commitRef, getString])
|
||||
|
||||
return (
|
||||
<Container className={css.main}>
|
||||
<RepositoryPageHeader
|
||||
repoMetadata={repoMetadata}
|
||||
title={getString('commits')}
|
||||
dataTooltipId="repositoryCommits"
|
||||
extraBreadcrumbLinks={
|
||||
commitRef && repoMetadata
|
||||
? [
|
||||
{
|
||||
label: getString('commits'),
|
||||
url: routes.toCODECommits({ repoPath: repoMetadata.path as string, commitRef: '' })
|
||||
}
|
||||
]
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
<PageBody error={getErrorMessage(error || errorCommits)} retryOnError={voidFn(refetch)}>
|
||||
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits && loadingCommits} />
|
||||
{(repoMetadata && commitRef && !!commits?.commits?.length && (
|
||||
<Container padding="xlarge" className={css.resourceContent}>
|
||||
<Container className={css.contentHeader}>
|
||||
<Layout.Horizontal>
|
||||
<CommitInfo repoMetadata={repoMetadata} commitRef={commitRef} />
|
||||
<FlexExpander />
|
||||
</Layout.Horizontal>
|
||||
</Container>
|
||||
{ChangesTab}
|
||||
</Container>
|
||||
)) ||
|
||||
null}
|
||||
</PageBody>
|
||||
</Container>
|
||||
)
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import React, { useEffect, useMemo } from 'react'
|
||||
import { Container, FlexExpander, Layout, PageBody } from '@harness/uicore'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
import { useGet } from 'restful-react'
|
||||
import { noop } from 'lodash-es'
|
||||
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
|
||||
import { useAppContext } from 'AppContext'
|
||||
import { usePageIndex } from 'hooks/usePageIndex'
|
||||
@ -15,6 +16,8 @@ import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner'
|
||||
import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination'
|
||||
import { BranchTagSelect } from 'components/BranchTagSelect/BranchTagSelect'
|
||||
import { CommitsView } from 'components/CommitsView/CommitsView'
|
||||
import { Changes } from 'components/Changes/Changes'
|
||||
import CommitInfo from 'components/CommitInfo/CommitInfo'
|
||||
import css from './RepositoryCommits.module.scss'
|
||||
|
||||
export default function RepositoryCommits() {
|
||||
@ -49,6 +52,24 @@ export default function RepositoryCommits() {
|
||||
}
|
||||
}, [setPage]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const ChangesTab = useMemo(() => {
|
||||
if (repoMetadata) {
|
||||
return (
|
||||
<Container className={css.changesContainer}>
|
||||
<Changes
|
||||
readOnly
|
||||
repoMetadata={repoMetadata}
|
||||
targetBranch={`${commitRef}~1`}
|
||||
sourceBranch={commitRef}
|
||||
emptyTitle={getString('noChanges')}
|
||||
emptyMessage={getString('noChangesCompare')}
|
||||
onCommentUpdate={noop}
|
||||
/>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
}, [repoMetadata, commitRef, getString, response])
|
||||
|
||||
return (
|
||||
<Container className={css.main}>
|
||||
<RepositoryPageHeader
|
||||
@ -69,8 +90,19 @@ export default function RepositoryCommits() {
|
||||
|
||||
<PageBody error={getErrorMessage(error || errorCommits)} retryOnError={voidFn(refetch)}>
|
||||
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits && loadingCommits} />
|
||||
|
||||
{(repoMetadata && !!commits?.commits?.length && (
|
||||
{(repoMetadata && commitRef && !pageBrowser.page && !!commits?.commits?.length && (
|
||||
<Container padding="xlarge" className={css.resourceContent}>
|
||||
<Container className={css.contentHeader}>
|
||||
<Layout.Horizontal>
|
||||
<CommitInfo repoMetadata={repoMetadata} commitRef={commitRef} />
|
||||
<FlexExpander />
|
||||
</Layout.Horizontal>
|
||||
</Container>
|
||||
{ChangesTab}
|
||||
</Container>
|
||||
)) ||
|
||||
null}
|
||||
{(repoMetadata && (!commitRef || pageBrowser.page) && !!commits?.commits?.length && (
|
||||
<Container padding="xlarge" className={css.resourceContent}>
|
||||
<Container className={css.contentHeader}>
|
||||
<Layout.Horizontal spacing="medium">
|
||||
@ -84,7 +116,7 @@ export default function RepositoryCommits() {
|
||||
history.push(
|
||||
routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: `${ref}`
|
||||
commitRef: `${ref}?page=1`
|
||||
})
|
||||
)
|
||||
}}
|
||||
|
@ -78,7 +78,7 @@ export function TagsContent({ repoMetadata, searchTerm = '', branches, onDeleteS
|
||||
return (
|
||||
<CommitActions
|
||||
sha={row.original.commit?.sha as string}
|
||||
href={routes.toCODECommit({
|
||||
href={routes.toCODECommits({
|
||||
repoPath: repoMetadata.path as string,
|
||||
commitRef: row.original.commit?.sha as string
|
||||
})}
|
||||
|
Loading…
Reference in New Issue
Block a user