mirror of
https://github.com/harness/drone.git
synced 2025-05-09 03:52:00 +08:00
feat: [code-288]: fix endpoint and payloads
This commit is contained in:
parent
4b4d1c9a08
commit
d65d01b3d0
@ -49,7 +49,9 @@ export default function Compare() {
|
||||
error: commitsError,
|
||||
refetch,
|
||||
response
|
||||
} = useGet<TypesCommit[]>({
|
||||
} = useGet<{
|
||||
commits: TypesCommit[]
|
||||
}>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
queryParams: {
|
||||
limit,
|
||||
@ -162,10 +164,10 @@ export default function Compare() {
|
||||
}, [repoMetadata, sourceGitRef, targetGitRef, getString])
|
||||
|
||||
useEffect(() => {
|
||||
if (commits?.length) {
|
||||
setTitle(commits[0].title as string)
|
||||
if (commits?.commits?.length) {
|
||||
setTitle(commits.commits[0].title as string)
|
||||
}
|
||||
}, [commits])
|
||||
}, [commits?.commits])
|
||||
|
||||
return (
|
||||
<Container className={css.main}>
|
||||
@ -268,14 +270,14 @@ export default function Compare() {
|
||||
<TabTitleWithCount
|
||||
icon={CodeIcon.Commit}
|
||||
title={getString('commits')}
|
||||
count={commits?.length || 0}
|
||||
count={commits?.commits?.length || 0}
|
||||
padding={{ left: 'medium' }}
|
||||
/>
|
||||
),
|
||||
panel: (
|
||||
<Container padding="xlarge">
|
||||
<CommitsView
|
||||
commits={commits || []}
|
||||
commits={commits?.commits || []}
|
||||
repoMetadata={repoMetadata}
|
||||
emptyTitle={getString('compareEmptyDiffTitle')}
|
||||
emptyMessage={getString('compareEmptyDiffMessage')}
|
||||
|
@ -110,7 +110,7 @@ export function FileContent({
|
||||
|
||||
const [page, setPage] = usePageIndex()
|
||||
const { data: commits, response } = useGet<{ commits: TypesCommit[]; rename_details: RenameDetails[] }>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
queryParams: {
|
||||
limit: LIST_FETCHING_LIMIT,
|
||||
page,
|
||||
|
@ -29,7 +29,7 @@ const SingleFileRenameHistory = (props: {
|
||||
commits: TypesCommit[]
|
||||
rename_details: RenameDetails[]
|
||||
}>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
lazy: true
|
||||
})
|
||||
|
||||
@ -121,7 +121,7 @@ const AllFilesRenameHistory = (props: {
|
||||
const { rename_details, repoMetadata, fileVisibility, setFileVisibility, setActiveTab } = props
|
||||
const [page, setPage] = usePageIndex()
|
||||
const { response } = useGet<{ commits: TypesCommit[]; rename_details: RenameDetails[] }>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
lazy: true
|
||||
})
|
||||
|
||||
|
@ -32,7 +32,7 @@ export default function RepositoryCommits() {
|
||||
response,
|
||||
error: errorCommits,
|
||||
loading: loadingCommits
|
||||
} = useGet<TypesCommit[]>({
|
||||
} = useGet<{ commits: TypesCommit[]}>({
|
||||
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
|
||||
queryParams: {
|
||||
limit: LIST_FETCHING_LIMIT,
|
||||
@ -55,9 +55,9 @@ export default function RepositoryCommits() {
|
||||
/>
|
||||
|
||||
<PageBody error={getErrorMessage(error || errorCommits)} retryOnError={voidFn(refetch)}>
|
||||
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits && loadingCommits} />
|
||||
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits?.commits && loadingCommits} />
|
||||
|
||||
{(repoMetadata && !!commits?.length && (
|
||||
{(repoMetadata && !!commits?.commits?.length && (
|
||||
<Container padding="xlarge" className={css.resourceContent}>
|
||||
<Container className={css.contentHeader}>
|
||||
<Layout.Horizontal spacing="medium">
|
||||
@ -81,7 +81,7 @@ export default function RepositoryCommits() {
|
||||
</Container>
|
||||
|
||||
<CommitsView
|
||||
commits={commits}
|
||||
commits={commits?.commits}
|
||||
repoMetadata={repoMetadata}
|
||||
emptyTitle={getString('noCommits')}
|
||||
emptyMessage={getString('noCommitsMessage')}
|
||||
|
Loading…
Reference in New Issue
Block a user