Skip to content

Commit

Permalink
update: [code-2017] swagger (harness#2110)
Browse files Browse the repository at this point in the history
* update: [code-2017] id and display_name to identifier
* fix: [code-2017] comment update
* fix: [code-2017] replace identifier with id in pipelines
* fix: [code-2017] prettier
* update: [code-2017] swagger
  • Loading branch information
rkapoor10 authored and Harness committed Jul 5, 2024
1 parent d46516b commit 87e418b
Show file tree
Hide file tree
Showing 76 changed files with 3,241 additions and 745 deletions.
2 changes: 1 addition & 1 deletion types/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package types
import "encoding/json"

type Pipeline struct {
ID int64 `db:"pipeline_id" json:"-"`
ID int64 `db:"pipeline_id" json:"id"`
Description string `db:"pipeline_description" json:"description"`
Identifier string `db:"pipeline_uid" json:"identifier"`
Disabled bool `db:"pipeline_disabled" json:"disabled"`
Expand Down
4 changes: 2 additions & 2 deletions web/src/atoms/repoMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { atom } from 'jotai'
import type { TypesRepository } from 'services/code'
import type { RepoRepositoryOutput } from 'services/code'

export const repoMetadataAtom = atom<TypesRepository | undefined>(undefined)
export const repoMetadataAtom = atom<RepoRepositoryOutput | undefined>(undefined)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { BranchTargetType, SettingTypeMode, SettingsTab, branchTargetOptions } f
import { useStrings } from 'framework/strings'
import { REGEX_VALID_REPO_NAME, getErrorMessage, permissionProps, rulesFormInitialPayload } from 'utils/Utils'
import type {
TypesRepository,
RepoRepositoryOutput,
OpenapiRule,
TypesPrincipalInfo,
EnumMergeMethod,
Expand All @@ -58,7 +58,7 @@ import css from './BranchProtectionForm.module.scss'
const BranchProtectionForm = (props: {
ruleUid: string
editMode: boolean
repoMetadata?: TypesRepository | undefined
repoMetadata?: RepoRepositoryOutput | undefined
refetchRules: () => void
settingSectionMode: SettingTypeMode
}) => {
Expand Down Expand Up @@ -172,7 +172,7 @@ const BranchProtectionForm = (props: {
userArrayState.length > 0 ? userArrayState : usersArray?.map(user => `${user.id} ${user.display_name}`)

return {
name: rule?.uid,
name: rule?.identifier,
desc: rule.description,
enable: rule.state !== 'disabled',
target: '',
Expand All @@ -188,8 +188,9 @@ const BranchProtectionForm = (props: {
requireNewChanges: (rule.definition as ProtectionBranch)?.pullreq?.approvals?.require_latest_commit,
reqResOfChanges: (rule.definition as ProtectionBranch)?.pullreq?.approvals?.require_no_change_request,
requireCommentResolution: (rule.definition as ProtectionBranch)?.pullreq?.comments?.require_resolve_all, // eslint-disable-next-line @typescript-eslint/no-explicit-any
requireStatusChecks: (rule.definition as any)?.pullreq?.status_checks?.require_uids?.length > 0,
statusChecks: (rule.definition as ProtectionBranch)?.pullreq?.status_checks?.require_uids || ([] as string[]),
requireStatusChecks: (rule.definition as any)?.pullreq?.status_checks?.require_identifiers?.length > 0,
statusChecks:
(rule.definition as ProtectionBranch)?.pullreq?.status_checks?.require_identifiers || ([] as string[]),
limitMergeStrategies: !!(rule.definition as ProtectionBranch)?.pullreq?.merge?.strategies_allowed,
mergeCommit: isMergePresent,
squashMerge: isSquashPresent,
Expand All @@ -210,7 +211,7 @@ const BranchProtectionForm = (props: {
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_edit']
},
Expand Down Expand Up @@ -238,7 +239,7 @@ const BranchProtectionForm = (props: {

const bypassList = formData?.bypassList?.map(item => parseInt(item.split(' ')[0]))
const payload: OpenapiRule = {
uid: formData.name,
identifier: formData.name,
type: 'branch',
description: formData.desc,
state: formData.enable === true ? 'active' : 'disabled',
Expand Down Expand Up @@ -267,7 +268,7 @@ const BranchProtectionForm = (props: {
delete_branch: formData.autoDelete
},
status_checks: {
require_uids: formData.statusChecks
require_identifiers: formData.statusChecks
}
},
lifecycle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const BranchProtectionHeader = ({
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_edit']
},
Expand Down
28 changes: 15 additions & 13 deletions web/src/components/BranchProtection/BranchProtectionListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ const BranchProtectionListing = (props: { activeTab: string }) => {

const { mutate } = useMutate<OpenapiRule>({
verb: 'PATCH',
path: `/api/v1/repos/${repoMetadata?.path}/+/rules/${row.original?.uid}`
path: `/api/v1/repos/${repoMetadata?.path}/+/rules/${row.original?.identifier}`
})
const [popoverDialogOpen, setPopoverDialogOpen] = useState(false)
const { mutate: deleteRule } = useMutate({
verb: 'DELETE',
path: `/api/v1/repos/${repoMetadata?.path}/+/rules/${row.original.uid}`
path: `/api/v1/repos/${repoMetadata?.path}/+/rules/${row.original.identifier}`
})
const confirmDelete = useConfirmAct()
const includeElements = (row.original?.pattern as ProtectionPattern)?.include?.map(
Expand Down Expand Up @@ -149,7 +149,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
'pullreq.approvals.require_latest_commit': getString('branchProtection.reqNewChangesTitle'),
'pullreq.comments.require_resolve_all': getString('branchProtection.reqCommentResolutionTitle'),
'pullreq.status_checks.all_must_succeed': getString('branchProtection.reqStatusChecksTitle'),
'pullreq.status_checks.require_uids': getString('branchProtection.reqStatusChecksTitle'),
'pullreq.status_checks.require_identifiers': getString('branchProtection.reqStatusChecksTitle'),
'pullreq.merge.strategies_allowed': getString('branchProtection.limitMergeStrategies'),
'pullreq.merge.delete_branch': getString('branchProtection.autoDeleteTitle'),
'lifecycle.create_forbidden': getString('branchProtection.blockBranchCreation'),
Expand Down Expand Up @@ -187,7 +187,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_edit']
},
Expand Down Expand Up @@ -215,7 +215,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
<StringSubstitute
str={checked ? getString('disableWebhookContent') : getString('enableWebhookContent')}
vars={{
name: <strong>{row.original?.uid}</strong>
name: <strong>{row.original?.identifier}</strong>
}}
/>
</Text>
Expand Down Expand Up @@ -251,15 +251,15 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
<Toggle
{...permissionProps(permPushResult, standalone)}
padding={{ top: 'xsmall' }}
key={`${row.original.uid}-toggle`}
key={`${row.original.identifier}-toggle`}
// className={cx(css.toggle, checked ? css.toggleEnable : css.toggleDisable)}
checked={checked}></Toggle>
</Popover>
</Container>
<Container padding={{ left: 'small' }} style={{ flexGrow: 1 }}>
<Layout.Horizontal spacing="small">
<Text padding={{ right: 'small', top: 'xsmall' }} lineClamp={1} width={150} className={css.title}>
{row.original.uid}
{row.original.identifier}
</Text>

{!!row.original.description && (
Expand All @@ -284,7 +284,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
repoPath: repoMetadata?.path as string,
settingSection: settingSection,
settingSectionMode: SettingTypeMode.EDIT,
ruleId: String(row.original.uid)
ruleId: String(row.original.identifier)
})
)
}
Expand All @@ -297,7 +297,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
confirmDelete({
className: css.hideButtonIcon,
title: getString('branchProtection.deleteProtectionRule'),
message: getString('branchProtection.deleteText', { rule: row.original.uid }),
message: getString('branchProtection.deleteText', { rule: row.original.identifier }),
action: async () => {
try {
await deleteRule({})
Expand Down Expand Up @@ -337,7 +337,9 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
<>
{nonEmptyRules.map((rule: { value: string }) => {
return (
<Text key={`${row.original.uid}-${rule}`} className={css.appliedRulesTextContainer}>
<Text
key={`${row.original.identifier}-${rule}`}
className={css.appliedRulesTextContainer}>
{rule.value}
</Text>
)
Expand Down Expand Up @@ -368,7 +370,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_edit']
},
Expand Down Expand Up @@ -405,13 +407,13 @@ const BranchProtectionListing = (props: { activeTab: string }) => {
data={rules}
getRowClassName={() => css.row}
onRowClick={row => {
setCurRuleName(row.uid as string)
setCurRuleName(row.identifier as string)
history.push(
routes.toCODESettings({
repoPath: repoMetadata?.path as string,
settingSection: settingSection,
settingSectionMode: SettingTypeMode.EDIT,
ruleId: String(row.uid)
ruleId: String(row.identifier)
})
)
}}
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/CommentBox/CommentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useStrings } from 'framework/strings'
import { ThreadSection } from 'components/ThreadSection/ThreadSection'
import { PipeSeparator } from 'components/PipeSeparator/PipeSeparator'
import { useAppContext } from 'AppContext'
import type { TypesRepository } from 'services/code'
import type { RepoRepositoryOutput } from 'services/code'
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
import { MarkdownEditorWithPreview } from 'components/MarkdownEditorWithPreview/MarkdownEditorWithPreview'
import { MarkdownViewer } from 'components/MarkdownViewer/MarkdownViewer'
Expand Down Expand Up @@ -94,7 +94,7 @@ interface CommentBoxProps<T> {
outlets?: Partial<Record<CommentBoxOutletPosition, React.ReactNode>>
autoFocusAndPosition?: boolean
enableReplyPlaceHolder?: boolean
repoMetadata: TypesRepository | undefined
repoMetadata: RepoRepositoryOutput | undefined
standalone: boolean
routingId: string
copyLinkToComment: (commentId: number, commentItem: CommentItem<T>) => void
Expand Down Expand Up @@ -310,7 +310,7 @@ interface CommentsThreadProps<T>
> {
onQuote: (content: string) => void
setDirty: (index: number, dirty: boolean) => void
repoMetadata: TypesRepository | undefined
repoMetadata: RepoRepositoryOutput | undefined
}

const CommentsThread = <T = unknown,>({
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/CommitInfo/CommitInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { useGet } from 'restful-react'
import { defaultTo } from 'lodash-es'
import { useAppContext } from 'AppContext'
import { useStrings } from 'framework/strings'
import type { TypesCommit, TypesRepository } from 'services/code'
import type { TypesCommit, RepoRepositoryOutput } from 'services/code'
import type { GitInfoProps } from 'utils/GitUtils'
import type { CODERoutes } from 'RouteDefinitions'
import { CommitActions } from 'components/CommitActions/CommitActions'
Expand All @@ -41,7 +41,7 @@ import { TimePopoverWithLocal } from 'utils/timePopoverLocal/TimePopoverWithLoca
import { useDocumentTitle } from 'hooks/useDocumentTitle'
import css from './CommitInfo.module.scss'

const CommitInfo = (props: { repoMetadata: TypesRepository; commitRef: string }) => {
const CommitInfo = (props: { repoMetadata: RepoRepositoryOutput; commitRef: string }) => {
const { repoMetadata, commitRef } = props
const history = useHistory()
const { getString } = useStrings()
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/CreateBranchModal/CreateBranchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export const CreateBranchModalButton: React.FC<CreateBranchModalButtonProps> = (
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_push']
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/CreateTagModal/CreateTagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const CreateTagModalButton: React.FC<CreateTagModalButtonProps> = ({
{
resource: {
resourceType: 'CODE_REPOSITORY',
resourceIdentifier: repoMetadata?.uid as string
resourceIdentifier: repoMetadata?.identifier as string
},
permissions: ['code_repo_push']
},
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Compartment, EditorState, Extension } from '@codemirror/state'
import { color } from '@uiw/codemirror-extensions-color'
import { hyperLink } from '@uiw/codemirror-extensions-hyper-link'
import { githubLight, githubDark } from '@uiw/codemirror-themes-all'
import type { TypesRepository } from 'services/code'
import type { RepoRepositoryOutput } from 'services/code'
import { useStrings } from 'framework/strings'
import { handleUpload } from 'utils/GitUtils'
import { handleFileDrop, handlePaste } from 'utils/Utils'
Expand All @@ -50,7 +50,7 @@ export interface EditorProps {
onChange?: (doc: Text, viewUpdate: ViewUpdate, isDirty: boolean) => void
onViewUpdate?: (viewUpdate: ViewUpdate) => void
darkTheme?: boolean
repoMetadata: TypesRepository | undefined
repoMetadata: RepoRepositoryOutput | undefined
inGitBlame?: boolean
standalone: boolean
routingId?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function ExecutionPageHeader({
<Link to={routes.toCODERepositories({ space })}>{getString('repositories')}</Link>
<Icon name="main-chevron-right" size={8} color={Color.GREY_500} />
<Link to={routes.toCODERepository({ repoPath: repoMetadata.path as string, gitRef })}>
{repoMetadata.uid}
{repoMetadata.identifier}
</Link>
{extraBreadcrumbLinks.map(link => (
<Fragment key={link.url}>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/LatestCommit/LatestCommit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import type {
OpenapiCalculateCommitDivergenceRequest,
RepoCommitDivergence,
TypesCommit,
TypesRepository
RepoRepositoryOutput
} from 'services/code'
import { CommitActions } from 'components/CommitActions/CommitActions'
import { useAppContext } from 'AppContext'
Expand All @@ -60,7 +60,7 @@ interface LatestCommitProps extends Pick<GitInfoProps, 'repoMetadata' | 'gitRef'

interface DivergenceInfoProps {
commitDivergence: RepoCommitDivergence
metadata: TypesRepository
metadata: RepoRepositoryOutput
currentGitRef: string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
import { decodeGitContent, handleUpload, normalizeGitRef } from 'utils/GitUtils'
import { defaultUsefulOrNot } from 'components/DefaultUsefulOrNot/UsefulOrNot'
import { AidaClient } from 'utils/types'
import type { TypesRepository } from 'services/code'
import type { RepoRepositoryOutput } from 'services/code'
import { useEventListener } from 'hooks/useEventListener'
import type { SuggestionBlock } from 'components/SuggestionBlock/SuggestionBlock'
import css from './MarkdownEditorWithPreview.module.scss'
Expand Down Expand Up @@ -134,7 +134,7 @@ interface MarkdownEditorWithPreviewProps {
sourceGitRef?: string
targetGitRef?: string
setFlag?: React.Dispatch<React.SetStateAction<boolean>>
repoMetadata: TypesRepository | undefined
repoMetadata: RepoRepositoryOutput | undefined
standalone: boolean
routingId: string
suggestionBlock?: SuggestionBlock
Expand Down
8 changes: 4 additions & 4 deletions web/src/components/NewPipelineModal/NewPipelineModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from '@harnessio/uicore'
import { FontVariation } from '@harnessio/design-system'
import { useModalHook } from 'hooks/useModalHook'
import type { OpenapiCreatePipelineRequest, TypesPipeline, TypesRepository } from 'services/code'
import type { OpenapiCreatePipelineRequest, TypesPipeline, RepoRepositoryOutput } from 'services/code'
import { useStrings } from 'framework/strings'
import { BranchTagSelect } from 'components/BranchTagSelect/BranchTagSelect'
import { useAppContext } from 'AppContext'
Expand All @@ -53,7 +53,7 @@ const useNewPipelineModal = () => {
const { getString } = useStrings()
const history = useHistory()
const { showError } = useToaster()
const [repo, setRepo] = useState<TypesRepository | undefined>()
const [repo, setRepo] = useState<RepoRepositoryOutput | undefined>()
const repoPath = useMemo(() => repo?.path || '', [repo])

const { mutate: savePipeline } = useMutate<TypesPipeline>({
Expand All @@ -67,7 +67,7 @@ const useNewPipelineModal = () => {
const payload: OpenapiCreatePipelineRequest = {
config_path: yamlPath,
default_branch: branch,
uid: name
identifier: name
}
savePipeline(payload, { pathParams: { path: `/api/v1/repos/${repoPath}/+/pipelines` } })
.then(() => {
Expand Down Expand Up @@ -167,7 +167,7 @@ const useNewPipelineModal = () => {
}, [repo])

return {
openModal: ({ repoMetadata }: { repoMetadata?: TypesRepository }) => {
openModal: ({ repoMetadata }: { repoMetadata?: RepoRepositoryOutput }) => {
setRepo(repoMetadata)
openModal()
},
Expand Down
Loading

0 comments on commit 87e418b

Please sign in to comment.