fix: [CODE-2628]: replaced TypesRepository with RepoRepositoryOutput from swagger (#2882)

* fixed other types too
* fix: [CODE-2628]: replaced TypesRepository with RepoRepositoryOutput from swagger
devcontainer-setup
Karan Saraswat 2024-10-28 17:21:39 +00:00 committed by Harness
parent aabc684606
commit ff00a8ba7a
15 changed files with 1990 additions and 312 deletions

View File

@ -17,6 +17,7 @@ package openapi
import (
"net/http"
"github.com/harness/gitness/app/api/controller/repo"
"github.com/harness/gitness/app/api/controller/space"
"github.com/harness/gitness/app/api/request"
"github.com/harness/gitness/app/api/usererror"
@ -319,7 +320,7 @@ func spaceOperations(reflector *openapi3.Reflector) {
opRepos.WithParameters(queryParameterQueryRepo, queryParameterSortRepo, queryParameterOrder,
QueryParameterPage, QueryParameterLimit)
_ = reflector.SetRequest(&opRepos, new(spaceRequest), http.MethodGet)
_ = reflector.SetJSONResponse(&opRepos, []types.Repository{}, http.StatusOK)
_ = reflector.SetJSONResponse(&opRepos, []repo.RepositoryOutput{}, http.StatusOK)
_ = reflector.SetJSONResponse(&opRepos, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&opRepos, new(usererror.Error), http.StatusUnauthorized)
_ = reflector.SetJSONResponse(&opRepos, new(usererror.Error), http.StatusForbidden)

View File

@ -22,7 +22,7 @@ import { Color } from '@harnessio/design-system'
import { Icon } from '@harnessio/icons'
import { Repository } from 'iconoir-react'
import { useFormikContext } from 'formik'
import type { TypesRepository } from 'services/code'
import type { RepoRepositoryOutput } from 'services/code'
import { useGetSpaceParam } from 'hooks/useGetSpaceParam'
import { String, useStrings } from 'framework/strings'
import { LIST_FETCHING_LIMIT } from 'utils/Utils'
@ -41,7 +41,7 @@ const RepositoryText = ({
value,
isCDE
}: {
repoList: TypesRepository[] | null
repoList: RepoRepositoryOutput[] | null
value?: string
isCDE?: boolean
}) => {
@ -105,7 +105,7 @@ export const GitnessRepoImportForm = ({ isCDE }: { isCDE?: boolean }) => {
data: repositories,
loading,
refetch: refetchRepos
} = useGet<TypesRepository[]>({
} = useGet<RepoRepositoryOutput[]>({
path: `/api/v1/spaces/${space}/+/repos`,
queryParams: { query: repoSearch },
debounce: 500

View File

@ -43,7 +43,7 @@ import { useStrings } from 'framework/strings'
import { getErrorMessage, permissionProps } from 'utils/Utils'
import { GitInfoProps, normalizeGitRef, isGitBranchNameValid } from 'utils/GitUtils'
import { BranchTagSelect } from 'components/BranchTagSelect/BranchTagSelect'
import type { TypesBranch } from 'services/code'
import type { TypesBranchExtended } from 'services/code'
import { useGetSpaceParam } from 'hooks/useGetSpaceParam'
import { useRuleViolationCheck } from 'hooks/useRuleViolationCheck'
import { useAppContext } from 'AppContext'
@ -57,14 +57,14 @@ interface FormData {
interface UseCreateBranchModalProps extends Pick<GitInfoProps, 'repoMetadata'> {
suggestedBranchName?: string
suggestedSourceBranch?: string
onSuccess: (data: TypesBranch) => void
onSuccess: (data: TypesBranchExtended) => void
showSuccessMessage?: boolean
showBranchTag?: boolean
refIsATag?: boolean
}
interface CreateBranchModalButtonProps extends Omit<ButtonProps, 'onClick'>, UseCreateBranchModalProps {
onSuccess: (data: TypesBranch) => void
onSuccess: (data: TypesBranchExtended) => void
showSuccessMessage?: boolean
}
@ -83,7 +83,7 @@ export function useCreateBranchModal({
const [sourceBranch, setSourceBranch] = useState(suggestedSourceBranch || (repoMetadata.default_branch as string))
const { showError, showSuccess } = useToaster()
const { violation, bypassable, bypassed, setAllStates } = useRuleViolationCheck()
const { mutate: createBranch, loading } = useMutate<TypesBranch>({
const { mutate: createBranch, loading } = useMutate<TypesBranchExtended>({
verb: 'POST',
path: `/api/v1/repos/${repoMetadata.path}/+/branches`
})

View File

@ -41,7 +41,7 @@ import { useStrings } from 'framework/strings'
import { getErrorMessage, permissionProps } from 'utils/Utils'
import { GitInfoProps, normalizeGitRef, isGitBranchNameValid } from 'utils/GitUtils'
import { BranchTagSelect } from 'components/BranchTagSelect/BranchTagSelect'
import type { TypesBranch } from 'services/code'
import type { TypesBranchExtended } from 'services/code'
import { useGetSpaceParam } from 'hooks/useGetSpaceParam'
import { useAppContext } from 'AppContext'
import css from './CreateTagModal.module.scss'
@ -55,12 +55,12 @@ interface FormData {
interface UseCreateTagModalProps extends Pick<GitInfoProps, 'repoMetadata'> {
suggestedBranchName?: string
suggestedSourceBranch?: string
onSuccess: (data: TypesBranch) => void
onSuccess: (data: TypesBranchExtended) => void
showSuccessMessage?: boolean
}
interface CreateTagModalButtonProps extends Omit<ButtonProps, 'onClick'>, UseCreateTagModalProps {
onSuccess: (data: TypesBranch) => void
onSuccess: (data: TypesBranchExtended) => void
showSuccessMessage?: boolean
}
@ -76,7 +76,7 @@ export function useCreateTagModal({
const { getString } = useStrings()
const [sourceBranch, setSourceBranch] = useState(suggestedSourceBranch || (repoMetadata.default_branch as string))
const { showError, showSuccess } = useToaster()
const { mutate: createTag, loading } = useMutate<TypesBranch>({
const { mutate: createTag, loading } = useMutate<TypesBranchExtended>({
verb: 'POST',
path: `/api/v1/repos/${repoMetadata.path}/+/tags`
})

View File

@ -37,7 +37,7 @@ import { Icon } from '@harnessio/icons'
import { useMutate } from 'restful-react'
import type {
OpenapiCalculateCommitDivergenceRequest,
RepoCommitDivergence,
TypesCommitDivergence,
TypesCommit,
RepoRepositoryOutput
} from 'services/code'
@ -59,7 +59,7 @@ interface LatestCommitProps extends Pick<GitInfoProps, 'repoMetadata' | 'gitRef'
}
interface DivergenceInfoProps {
commitDivergence: RepoCommitDivergence
commitDivergence: TypesCommitDivergence
metadata: RepoRepositoryOutput
currentGitRef: string
}
@ -75,7 +75,7 @@ export function LatestCommitForFolder({
const { routes } = useAppContext()
const { getString } = useStrings()
const { showError } = useToaster()
const [divergence, setDivergence] = useState<RepoCommitDivergence>({})
const [divergence, setDivergence] = useState<TypesCommitDivergence>({})
const commitURL = routes.toCODECommit({
repoPath: repoMetadata.path as string,
@ -111,7 +111,7 @@ export function LatestCommitForFolder({
if (isMounted.current && branchDivergenceRequestBody.requests?.length && gitRef !== repoMetadata.default_branch) {
setDivergence({})
getBranchDivergence(branchDivergenceRequestBody)
.then(([response]: RepoCommitDivergence[]) => {
.then(([response]: TypesCommitDivergence[]) => {
if (isMounted.current) {
setDivergence(response)
}

View File

@ -75,7 +75,6 @@ import type {
OpenapiCreateRepositoryRequest
} from 'services/code'
import { useAppContext } from 'AppContext'
import type { TypesRepository } from 'cde-gitness/services'
import { usePublicResourceConfig } from 'hooks/usePublicResourceConfig'
import ImportForm from './ImportForm/ImportForm'
import ImportReposForm from './ImportReposForm/ImportReposForm'
@ -97,7 +96,7 @@ export interface NewRepoModalButtonProps extends Omit<ButtonProps, 'onClick' | '
modalTitle: string
submitButtonTitle?: string
cancelButtonTitle?: string
onSubmit: (data: TypesRepository & RepoRepositoryOutput & SpaceImportRepositoriesOutput) => void
onSubmit: (data: RepoRepositoryOutput & SpaceImportRepositoriesOutput) => void
repoCreationType?: RepoCreationType
customRenderer?: (onChange: (event: any) => void) => React.ReactNode
}

View File

@ -16,13 +16,13 @@
import { useGet } from 'restful-react'
import { useAtomValue } from 'jotai'
import type { TypesBranch } from 'services/code'
import type { TypesBranchExtended } from 'services/code'
import { LIST_FETCHING_LIMIT } from 'utils/Utils'
import { repoMetadataAtom } from 'atoms/repoMetadata'
export function useFindGitBranch(branchName?: string, includeCommit = false) {
const repoMetadata = useAtomValue(repoMetadataAtom)
const { data } = useGet<TypesBranch[]>({
const { data } = useGet<TypesBranchExtended[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/branches`,
queryParams: {
limit: LIST_FETCHING_LIMIT,

View File

@ -27,7 +27,7 @@ import type {
TypesPullReqReviewer,
RepoRepositoryOutput,
TypesRuleViolations,
TypesBranch
TypesBranchExtended
} from 'services/code'
import {
PRMergeOption,
@ -125,7 +125,7 @@ const PullRequestOverviewPanel = (props: PullRequestOverviewPanelProps) => {
data: sourceBranch,
error,
refetch: refetchBranch
} = useGet<TypesBranch>({
} = useGet<TypesBranchExtended>({
path: `/api/v1/repos/${repoMetadata?.path}/+/branches/${pullReqMetadata?.source_branch}`,
queryParams: {
repo_ref: repoMetadata.path || '',

View File

@ -39,8 +39,8 @@ import { String, useStrings } from 'framework/strings'
import { useAppContext } from 'AppContext'
import type {
OpenapiCalculateCommitDivergenceRequest,
TypesBranch,
RepoCommitDivergence,
TypesBranchExtended,
TypesCommitDivergence,
RepoRepositoryOutput
} from 'services/code'
import { CommitActions } from 'components/CommitActions/CommitActions'
@ -55,7 +55,7 @@ import css from './BranchesContent.module.scss'
interface BranchesContentProps {
searchTerm?: string
repoMetadata: RepoRepositoryOutput
branches: TypesBranch[]
branches: TypesBranchExtended[]
onDeleteSuccess: () => void
}
@ -67,7 +67,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
verb: 'POST',
path: `/api/v1/repos/${repoMetadata.path}/+/commits/calculate-divergence`
})
const [divergence, setDivergence] = useState<RepoCommitDivergence[]>([])
const [divergence, setDivergence] = useState<TypesCommitDivergence[]>([])
const branchDivergenceRequestBody: OpenapiCalculateCommitDivergenceRequest = useMemo(() => {
return {
maxCount: 0,
@ -80,7 +80,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
if (isMounted.current && branchDivergenceRequestBody.requests?.length) {
setDivergence([])
getBranchDivergence(branchDivergenceRequestBody)
.then((response: RepoCommitDivergence[]) => {
.then((response: TypesCommitDivergence[]) => {
if (isMounted.current) {
setDivergence(response)
}
@ -89,12 +89,12 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
}
}, [getBranchDivergence, branchDivergenceRequestBody, isMounted])
const columns: Column<TypesBranch>[] = useMemo(
const columns: Column<TypesBranchExtended>[] = useMemo(
() => [
{
Header: getString('branch'),
width: '30%',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
return (
<Text
lineClamp={1}
@ -119,7 +119,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
Header: getString('status'),
Id: 'status',
width: 'calc(70% - 230px)',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
if (row.original?.name === repoMetadata.default_branch) {
return (
<Container flex={{ align: 'center-center' }} width={150}>
@ -141,7 +141,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
Header: getString('commit'),
Id: 'commit',
width: '15%',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
return (
<CommitActions
sha={row.original.commit?.sha as string}
@ -157,7 +157,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
{
Header: getString('updated'),
width: '200px',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
return (
<Text lineClamp={1} className={css.rowText} color={Color.BLACK} tag="div">
<Avatar hoverCard={false} size="small" name={row.original.commit?.author?.identity?.name || ''} />
@ -170,7 +170,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
{
id: 'action',
width: '30px',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
const { violation, bypassable, bypassed, setAllStates } = useRuleViolationCheck()
const [persistModal, setPersistModal] = useState(true)
const { mutate: deleteBranch } = useMutate({
@ -277,7 +277,7 @@ export function BranchesContent({ repoMetadata, searchTerm = '', branches, onDel
return (
<Container className={css.container}>
<Table<TypesBranch>
<Table<TypesBranchExtended>
className={css.table}
columns={columns}
data={branches || []}

View File

@ -19,7 +19,7 @@ import { Container } from '@harnessio/uicore'
import { useGet } from 'restful-react'
import { Render } from 'react-jsx-match'
import { useHistory } from 'react-router-dom'
import type { TypesBranch, RepoRepositoryOutput } from 'services/code'
import type { TypesBranchExtended, RepoRepositoryOutput } from 'services/code'
import { usePageIndex } from 'hooks/usePageIndex'
import { LIST_FETCHING_LIMIT, PageBrowserProps } from 'utils/Utils'
import { useAppContext } from 'AppContext'
@ -48,7 +48,7 @@ export function RepositoryBranchesContent({ repoMetadata }: Partial<Pick<GitInfo
error,
loading,
refetch
} = useGet<TypesBranch[]>({
} = useGet<TypesBranchExtended[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/branches`,
queryParams: {
limit: LIST_FETCHING_LIMIT,

View File

@ -26,7 +26,7 @@ import { noop } from 'lodash-es'
import { String, useStrings } from 'framework/strings'
import { useAppContext } from 'AppContext'
import type { TypesBranch, RepoCommitTag, RepoRepositoryOutput } from 'services/code'
import type { TypesBranchExtended, RepoCommitTag, RepoRepositoryOutput } from 'services/code'
import { formatDate, getErrorMessage, voidFn } from 'utils/Utils'
import { useConfirmAction } from 'hooks/useConfirmAction'
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
@ -38,7 +38,7 @@ import css from './TagsContent.module.scss'
interface TagsContentProps {
searchTerm?: string
repoMetadata: RepoRepositoryOutput
branches: TypesBranch[]
branches: TypesBranchExtended[]
onDeleteSuccess: () => void
}
@ -49,7 +49,7 @@ export function TagsContent({ repoMetadata, searchTerm = '', branches, onDeleteS
const onSuccess = voidFn(noop)
const columns: Column<TypesBranch>[] = useMemo(
const columns: Column<TypesBranchExtended>[] = useMemo(
() => [
{
Header: getString('tag'),
@ -139,7 +139,7 @@ export function TagsContent({ repoMetadata, searchTerm = '', branches, onDeleteS
{
id: 'action',
width: '30px',
Cell: ({ row }: CellProps<TypesBranch>) => {
Cell: ({ row }: CellProps<TypesBranchExtended>) => {
const { mutate: deleteBranch } = useMutate({
verb: 'DELETE',
path: `/api/v1/repos/${repoMetadata.path}/+/tags/${row.original.name}`
@ -235,7 +235,7 @@ export function TagsContent({ repoMetadata, searchTerm = '', branches, onDeleteS
return (
<Container className={css.container}>
<Table<TypesBranch>
<Table<TypesBranchExtended>
className={css.table}
columns={columns}
data={branches || []}

View File

@ -37,7 +37,7 @@ import { Else, Match, Render, Truthy } from 'react-jsx-match'
import { omit } from 'lodash-es'
import { useModalHook } from 'hooks/useModalHook'
import { useStrings } from 'framework/strings'
import type { OpenapiCreateTokenRequest } from 'services/code'
import type { UserCreateTokenInput } from 'services/code'
import { REGEX_VALID_REPO_NAME, getErrorMessage } from 'utils/Utils'
import { CodeIcon } from 'utils/GitUtils'
import { CopyButton } from 'components/CopyButton/CopyButton'
@ -73,7 +73,7 @@ const useNewToken = ({ onClose }: { onClose: () => void }) => {
const [openModal, hideModal] = useModalHook(() => {
return (
<Dialog isOpen enforceFocus={false} onClose={onModalClose} title={getString('createNewToken')}>
<Formik<OpenapiCreateTokenRequest>
<Formik<UserCreateTokenInput>
initialValues={{
identifier: ''
}}

View File

@ -32,7 +32,7 @@ import { FormGroup } from '@blueprintjs/core'
import { useHistory } from 'react-router-dom'
import * as yup from 'yup'
import React from 'react'
import type { OpenapiUpdateWebhookRequest, EnumWebhookTrigger, OpenapiWebhookType } from 'services/code'
import type { OpenapiUpdateRepoWebhookRequest, EnumWebhookTrigger, OpenapiWebhookType } from 'services/code'
import { getErrorMessage, permissionProps } from 'utils/Utils'
import { useStrings } from 'framework/strings'
import { WebhookIndividualEvent, type GitInfoProps, WebhookEventType } from 'utils/GitUtils'
@ -177,7 +177,7 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
const secret = (formData.secret || '').trim()
const data: OpenapiUpdateWebhookRequest = {
const data: OpenapiUpdateRepoWebhookRequest = {
identifier: formData.name,
description: formData.description,
url: formData.url,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff