From 87e418bb8679619adb6f944088a1db54697a9dcc Mon Sep 17 00:00:00 2001 From: Ritik Kapoor Date: Fri, 5 Jul 2024 16:39:26 +0000 Subject: [PATCH] update: [code-2017] swagger (#2110) * 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 --- types/pipeline.go | 2 +- web/src/atoms/repoMetadata.ts | 4 +- .../BranchProtectionForm.tsx | 17 +- .../BranchProtectionHeader.tsx | 2 +- .../BranchProtectionListing.tsx | 28 +- web/src/components/CommentBox/CommentBox.tsx | 6 +- web/src/components/CommitInfo/CommitInfo.tsx | 4 +- .../CreateBranchModal/CreateBranchModal.tsx | 2 +- .../CreateTagModal/CreateTagModal.tsx | 2 +- web/src/components/Editor/Editor.tsx | 4 +- .../ExecutionPageHeader.tsx | 2 +- .../components/LatestCommit/LatestCommit.tsx | 4 +- .../MarkdownEditorWithPreview.tsx | 4 +- .../NewPipelineModal/NewPipelineModal.tsx | 8 +- .../NewRepoModalButton/NewRepoModalButton.tsx | 18 +- .../NewSecretModalButton.tsx | 2 +- .../NewSpaceModalButton.tsx | 12 +- .../NewTriggerModalButton.tsx | 2 +- .../PipelineSettingsPageHeader.tsx | 2 +- .../PipelineSettingsTab.tsx | 2 +- .../PipelineTriggersTab.tsx | 8 +- .../components/PluginsPanel/PluginsPanel.tsx | 20 +- .../RepositoryPageHeader.tsx | 2 +- .../RunPipelineModal/RunPipelineModal.tsx | 6 +- .../SpaceSelector/SpaceSelector.tsx | 20 +- .../UpdateSecretModal/UpdateSecretModal.tsx | 6 +- web/src/hooks/useGetRepositoryMetadata.ts | 4 +- web/src/layouts/menu/DefaultMenu.tsx | 4 +- web/src/pages/Compare/Compare.tsx | 4 +- .../CompareContentHeader.tsx | 2 +- web/src/pages/ExecutionList/ExecutionList.tsx | 2 +- web/src/pages/PipelineList/PipelineList.tsx | 21 +- web/src/pages/PullRequest/Checks/Checks.tsx | 6 +- .../pages/PullRequest/Checks/ChecksMenu.tsx | 28 +- .../PullRequest/Checks/ChecksOverview.tsx | 8 +- .../PullRequestActionsBox.tsx | 2 +- .../PullRequestOverviewPanel.tsx | 4 +- .../sections/ChangesSection.tsx | 4 +- .../sections/ChecksSection.tsx | 8 +- .../sections/CommentsSection.tsx | 4 +- .../PullRequestSideBar/PullRequestSideBar.tsx | 4 +- web/src/pages/PullRequest/PullRequest.tsx | 10 +- web/src/pages/PullRequests/PullRequests.tsx | 6 +- .../PullRequestsContentHeader.tsx | 2 +- .../RepositoriesListing.tsx | 18 +- .../pages/Repository/EmptyRepositoryInfo.tsx | 6 +- web/src/pages/Repository/Repository.tsx | 8 +- .../ContentHeader/ContentHeader.tsx | 4 +- .../FileContent/FileContent.tsx | 2 +- .../FileContent/GitBlame.tsx | 6 +- .../FileContent/RenameContentHistory.tsx | 8 +- .../FolderContent/Readme.tsx | 6 +- .../RepositorySummary/RepositorySummary.tsx | 6 +- .../RepositoryHeader/RepositoryHeader.tsx | 6 +- .../BranchesContent/BranchesContent.tsx | 4 +- .../RepositoryBranchesContent.tsx | 6 +- .../RepositoryFileEditHeader.tsx | 2 +- .../DeleteRepoModal/DeleteRepoModal.tsx | 10 +- .../GeneralSettingsContent.tsx | 12 +- .../SecurityScanSettings.tsx | 6 +- .../RepositoryTagsContent.tsx | 2 +- .../TagsContent/TagsContent.tsx | 4 +- web/src/pages/Search/KeywordSearchFilters.tsx | 6 +- web/src/pages/Search/Search.tsx | 4 +- web/src/pages/Secret/Secret.tsx | 2 +- web/src/pages/SecretList/SecretList.tsx | 12 +- .../SpaceSettings/ExportForm/ExportForm.tsx | 4 +- web/src/pages/SpaceSettings/SpaceSettings.tsx | 10 +- .../pages/UserProfile/NewToken/NewToken.tsx | 6 +- web/src/pages/UserProfile/UserProfile.tsx | 6 +- web/src/pages/WebhookNew/WehookForm.tsx | 8 +- web/src/pages/Webhooks/Webhooks.tsx | 16 +- .../WebhooksHeader/WebhooksHeader.tsx | 2 +- web/src/services/code/index.tsx | 1690 ++++++++++++++--- web/src/services/code/swagger.yaml | 1678 ++++++++++++++-- web/src/utils/GitUtils.ts | 8 +- 76 files changed, 3188 insertions(+), 692 deletions(-) diff --git a/types/pipeline.go b/types/pipeline.go index edd7fc075..b15a8e627 100644 --- a/types/pipeline.go +++ b/types/pipeline.go @@ -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"` diff --git a/web/src/atoms/repoMetadata.ts b/web/src/atoms/repoMetadata.ts index 02b794e67..cd975d447 100644 --- a/web/src/atoms/repoMetadata.ts +++ b/web/src/atoms/repoMetadata.ts @@ -1,4 +1,4 @@ import { atom } from 'jotai' -import type { TypesRepository } from 'services/code' +import type { RepoRepositoryOutput } from 'services/code' -export const repoMetadataAtom = atom(undefined) +export const repoMetadataAtom = atom(undefined) diff --git a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx index 1facafb0c..7949a70dc 100644 --- a/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx +++ b/web/src/components/BranchProtection/BranchProtectionForm/BranchProtectionForm.tsx @@ -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, @@ -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 }) => { @@ -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: '', @@ -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, @@ -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'] }, @@ -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', @@ -267,7 +268,7 @@ const BranchProtectionForm = (props: { delete_branch: formData.autoDelete }, status_checks: { - require_uids: formData.statusChecks + require_identifiers: formData.statusChecks } }, lifecycle: { diff --git a/web/src/components/BranchProtection/BranchProtectionHeader/BranchProtectionHeader.tsx b/web/src/components/BranchProtection/BranchProtectionHeader/BranchProtectionHeader.tsx index 0dddde82b..e00cf76f4 100644 --- a/web/src/components/BranchProtection/BranchProtectionHeader/BranchProtectionHeader.tsx +++ b/web/src/components/BranchProtection/BranchProtectionHeader/BranchProtectionHeader.tsx @@ -41,7 +41,7 @@ const BranchProtectionHeader = ({ { resource: { resourceType: 'CODE_REPOSITORY', - resourceIdentifier: repoMetadata?.uid as string + resourceIdentifier: repoMetadata?.identifier as string }, permissions: ['code_repo_edit'] }, diff --git a/web/src/components/BranchProtection/BranchProtectionListing.tsx b/web/src/components/BranchProtection/BranchProtectionListing.tsx index a0084d4ff..1900abb8b 100644 --- a/web/src/components/BranchProtection/BranchProtectionListing.tsx +++ b/web/src/components/BranchProtection/BranchProtectionListing.tsx @@ -99,12 +99,12 @@ const BranchProtectionListing = (props: { activeTab: string }) => { const { mutate } = useMutate({ 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( @@ -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'), @@ -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'] }, @@ -215,7 +215,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => { {row.original?.uid} + name: {row.original?.identifier} }} /> @@ -251,7 +251,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => { @@ -259,7 +259,7 @@ const BranchProtectionListing = (props: { activeTab: string }) => { - {row.original.uid} + {row.original.identifier} {!!row.original.description && ( @@ -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) }) ) } @@ -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({}) @@ -337,7 +337,9 @@ const BranchProtectionListing = (props: { activeTab: string }) => { <> {nonEmptyRules.map((rule: { value: string }) => { return ( - + {rule.value} ) @@ -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'] }, @@ -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) }) ) }} diff --git a/web/src/components/CommentBox/CommentBox.tsx b/web/src/components/CommentBox/CommentBox.tsx index 3a9cd66e6..40a46186d 100644 --- a/web/src/components/CommentBox/CommentBox.tsx +++ b/web/src/components/CommentBox/CommentBox.tsx @@ -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' @@ -94,7 +94,7 @@ interface CommentBoxProps { outlets?: Partial> autoFocusAndPosition?: boolean enableReplyPlaceHolder?: boolean - repoMetadata: TypesRepository | undefined + repoMetadata: RepoRepositoryOutput | undefined standalone: boolean routingId: string copyLinkToComment: (commentId: number, commentItem: CommentItem) => void @@ -310,7 +310,7 @@ interface CommentsThreadProps > { onQuote: (content: string) => void setDirty: (index: number, dirty: boolean) => void - repoMetadata: TypesRepository | undefined + repoMetadata: RepoRepositoryOutput | undefined } const CommentsThread = ({ diff --git a/web/src/components/CommitInfo/CommitInfo.tsx b/web/src/components/CommitInfo/CommitInfo.tsx index a5f9f0dda..0fa923e45 100644 --- a/web/src/components/CommitInfo/CommitInfo.tsx +++ b/web/src/components/CommitInfo/CommitInfo.tsx @@ -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' @@ -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() diff --git a/web/src/components/CreateBranchModal/CreateBranchModal.tsx b/web/src/components/CreateBranchModal/CreateBranchModal.tsx index 651ec46c0..d08d75ecd 100644 --- a/web/src/components/CreateBranchModal/CreateBranchModal.tsx +++ b/web/src/components/CreateBranchModal/CreateBranchModal.tsx @@ -262,7 +262,7 @@ export const CreateBranchModalButton: React.FC = ( { resource: { resourceType: 'CODE_REPOSITORY', - resourceIdentifier: repoMetadata?.uid as string + resourceIdentifier: repoMetadata?.identifier as string }, permissions: ['code_repo_push'] }, diff --git a/web/src/components/CreateTagModal/CreateTagModal.tsx b/web/src/components/CreateTagModal/CreateTagModal.tsx index c825e32b1..9ceb7fe1c 100644 --- a/web/src/components/CreateTagModal/CreateTagModal.tsx +++ b/web/src/components/CreateTagModal/CreateTagModal.tsx @@ -236,7 +236,7 @@ export const CreateTagModalButton: React.FC = ({ { resource: { resourceType: 'CODE_REPOSITORY', - resourceIdentifier: repoMetadata?.uid as string + resourceIdentifier: repoMetadata?.identifier as string }, permissions: ['code_repo_push'] }, diff --git a/web/src/components/Editor/Editor.tsx b/web/src/components/Editor/Editor.tsx index 8ef2b17bc..dd1b1e299 100644 --- a/web/src/components/Editor/Editor.tsx +++ b/web/src/components/Editor/Editor.tsx @@ -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' @@ -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 diff --git a/web/src/components/ExecutionPageHeader/ExecutionPageHeader.tsx b/web/src/components/ExecutionPageHeader/ExecutionPageHeader.tsx index 0c25f3c45..0a6fcb2f7 100644 --- a/web/src/components/ExecutionPageHeader/ExecutionPageHeader.tsx +++ b/web/src/components/ExecutionPageHeader/ExecutionPageHeader.tsx @@ -111,7 +111,7 @@ export function ExecutionPageHeader({ {getString('repositories')} - {repoMetadata.uid} + {repoMetadata.identifier} {extraBreadcrumbLinks.map(link => ( diff --git a/web/src/components/LatestCommit/LatestCommit.tsx b/web/src/components/LatestCommit/LatestCommit.tsx index 154c5f68e..f78dace34 100644 --- a/web/src/components/LatestCommit/LatestCommit.tsx +++ b/web/src/components/LatestCommit/LatestCommit.tsx @@ -39,7 +39,7 @@ import type { OpenapiCalculateCommitDivergenceRequest, RepoCommitDivergence, TypesCommit, - TypesRepository + RepoRepositoryOutput } from 'services/code' import { CommitActions } from 'components/CommitActions/CommitActions' import { useAppContext } from 'AppContext' @@ -60,7 +60,7 @@ interface LatestCommitProps extends Pick> - repoMetadata: TypesRepository | undefined + repoMetadata: RepoRepositoryOutput | undefined standalone: boolean routingId: string suggestionBlock?: SuggestionBlock diff --git a/web/src/components/NewPipelineModal/NewPipelineModal.tsx b/web/src/components/NewPipelineModal/NewPipelineModal.tsx index 08949c08a..ae409b6f4 100644 --- a/web/src/components/NewPipelineModal/NewPipelineModal.tsx +++ b/web/src/components/NewPipelineModal/NewPipelineModal.tsx @@ -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' @@ -53,7 +53,7 @@ const useNewPipelineModal = () => { const { getString } = useStrings() const history = useHistory() const { showError } = useToaster() - const [repo, setRepo] = useState() + const [repo, setRepo] = useState() const repoPath = useMemo(() => repo?.path || '', [repo]) const { mutate: savePipeline } = useMutate({ @@ -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(() => { @@ -167,7 +167,7 @@ const useNewPipelineModal = () => { }, [repo]) return { - openModal: ({ repoMetadata }: { repoMetadata?: TypesRepository }) => { + openModal: ({ repoMetadata }: { repoMetadata?: RepoRepositoryOutput }) => { setRepo(repoMetadata) openModal() }, diff --git a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx index cb60075f6..102949c03 100644 --- a/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx +++ b/web/src/components/NewRepoModalButton/NewRepoModalButton.tsx @@ -69,8 +69,8 @@ import { getProviderTypeMapping } from 'utils/GitUtils' import type { - TypesSpace, - TypesRepository, + SpaceSpaceOutput, + RepoRepositoryOutput, SpaceImportRepositoriesOutput, OpenapiCreateRepositoryRequest } from 'services/code' @@ -95,7 +95,7 @@ export interface NewRepoModalButtonProps extends Omit void + onSubmit: (data: RepoRepositoryOutput & SpaceImportRepositoriesOutput) => void newRepoModalOnly?: boolean notFoundRepoName?: string } @@ -114,7 +114,7 @@ export const NewRepoModalButton: React.FC = ({ const [enablePublicRepo, setEnablePublicRepo] = useState(false) const { showError } = useToaster() - const { mutate: createRepo, loading: submitLoading } = useMutate({ + const { mutate: createRepo, loading: submitLoading } = useMutate({ verb: 'POST', path: `/api/v1/repos`, queryParams: standalone @@ -123,7 +123,7 @@ export const NewRepoModalButton: React.FC = ({ space_path: space } }) - const { mutate: importRepo, loading: importRepoLoading } = useMutate({ + const { mutate: importRepo, loading: importRepoLoading } = useMutate({ verb: 'POST', path: `/api/v1/repos/import`, queryParams: standalone @@ -132,7 +132,7 @@ export const NewRepoModalButton: React.FC = ({ space_path: space } }) - const { mutate: importMultipleRepositories, loading: submitImportLoading } = useMutate({ + const { mutate: importMultipleRepositories, loading: submitImportLoading } = useMutate({ verb: 'POST', path: `/api/v1/spaces/${space}/+/import` }) @@ -179,7 +179,7 @@ export const NewRepoModalButton: React.FC = ({ git_ignore: get(formData, 'gitignore', 'none'), is_public: get(formData, 'isPublic') === RepoVisibility.PUBLIC, license: get(formData, 'license', 'none'), - uid: get(formData, 'name', '').trim(), + identifier: get(formData, 'name', '').trim(), readme: get(formData, 'addReadme', false), parent_ref: space } @@ -217,7 +217,7 @@ export const NewRepoModalButton: React.FC = ({ const importPayload = { description: formData.description || '', parent_ref: space, - uid: formData.name, + identifier: formData.name, provider, provider_repo: compact([ formData.org, @@ -261,7 +261,7 @@ export const NewRepoModalButton: React.FC = ({ const importPayload = { description: (formData.description || '').trim(), parent_ref: space, - uid: formData.name.trim(), + identifier: formData.name.trim(), provider, provider_space: compact([ formData.organization, diff --git a/web/src/components/NewSecretModalButton/NewSecretModalButton.tsx b/web/src/components/NewSecretModalButton/NewSecretModalButton.tsx index 5a1728bbd..4342bc449 100644 --- a/web/src/components/NewSecretModalButton/NewSecretModalButton.tsx +++ b/web/src/components/NewSecretModalButton/NewSecretModalButton.tsx @@ -85,7 +85,7 @@ export const NewSecretModalButton: React.FC = ({ space_ref: space, data: formData.value, description: formData.description, - uid: formData.name + identifier: formData.name } await createSecret(payload) hideModal() diff --git a/web/src/components/NewSpaceModalButton/NewSpaceModalButton.tsx b/web/src/components/NewSpaceModalButton/NewSpaceModalButton.tsx index 65cc05b61..4d750e4f8 100644 --- a/web/src/components/NewSpaceModalButton/NewSpaceModalButton.tsx +++ b/web/src/components/NewSpaceModalButton/NewSpaceModalButton.tsx @@ -40,7 +40,7 @@ import { compact, get } from 'lodash-es' import { useModalHook } from 'hooks/useModalHook' import { useStrings } from 'framework/strings' import { getErrorMessage, permissionProps, REGEX_VALID_REPO_NAME } from 'utils/Utils' -import type { TypesSpace, OpenapiCreateSpaceRequest } from 'services/code' +import type { SpaceSpaceOutput, OpenapiCreateSpaceRequest } from 'services/code' import { useAppContext } from 'AppContext' import { ImportSpaceFormData, @@ -84,7 +84,7 @@ export interface NewSpaceModalButtonProps extends Omit void handleNavigation?: (value: string) => void - onSubmit: (data: TypesSpace) => void + onSubmit: (data: SpaceSpaceOutput) => void fromSpace?: boolean } export interface OpenapiCreateSpaceRequestExtended extends OpenapiCreateSpaceRequest { @@ -107,11 +107,11 @@ export const NewSpaceModalButton: React.FC = ({ const { getString } = useStrings() const { showError } = useToaster() - const { mutate: createSpace, loading: submitLoading } = useMutate({ + const { mutate: createSpace, loading: submitLoading } = useMutate({ verb: 'POST', path: `/api/v1/spaces` }) - const { mutate: importSpace, loading: submitImportLoading } = useMutate({ + const { mutate: importSpace, loading: submitImportLoading } = useMutate({ verb: 'POST', path: `/api/v1/spaces/import` }) @@ -123,7 +123,7 @@ export const NewSpaceModalButton: React.FC = ({ const payload: OpenapiCreateSpaceRequestExtended = { description: get(formData, 'description', '').trim(), is_public: get(formData, 'isPublic') === RepoVisibility.PUBLIC, - uid: get(formData, 'name', '').trim(), + identifier: get(formData, 'name', '').trim(), parent_id: standalone ? Number(space) : 0 // TODO: Backend needs to fix parentID: accept string or number } await createSpace(payload) @@ -156,7 +156,7 @@ export const NewSpaceModalButton: React.FC = ({ try { const importPayload = { description: (formData.description || '').trim(), - uid: formData.name.trim(), + identifier: formData.name.trim(), provider, provider_space: compact([ formData.organization, diff --git a/web/src/components/NewTriggerModalButton/NewTriggerModalButton.tsx b/web/src/components/NewTriggerModalButton/NewTriggerModalButton.tsx index 57d44d057..2981aa0f8 100644 --- a/web/src/components/NewTriggerModalButton/NewTriggerModalButton.tsx +++ b/web/src/components/NewTriggerModalButton/NewTriggerModalButton.tsx @@ -82,7 +82,7 @@ export const NewTriggerModalButton: React.FC = ({ try { const payload: OpenapiCreateTriggerRequest = { actions: formData.actions, - uid: formData.name + identifier: formData.name } await createTrigger(payload) hideModal() diff --git a/web/src/components/PipelineSettingsPageHeader/PipelineSettingsPageHeader.tsx b/web/src/components/PipelineSettingsPageHeader/PipelineSettingsPageHeader.tsx index c1103f69f..0cdd64927 100644 --- a/web/src/components/PipelineSettingsPageHeader/PipelineSettingsPageHeader.tsx +++ b/web/src/components/PipelineSettingsPageHeader/PipelineSettingsPageHeader.tsx @@ -69,7 +69,7 @@ const PipelineSettingsPageHeader = ({ {getString('repositories')} - {repoMetadata.uid} + {repoMetadata.identifier} {extraBreadcrumbLinks.map(link => ( diff --git a/web/src/components/PipelineSettingsTab/PipelineSettingsTab.tsx b/web/src/components/PipelineSettingsTab/PipelineSettingsTab.tsx index 4a7effd5a..7600a47e0 100644 --- a/web/src/components/PipelineSettingsTab/PipelineSettingsTab.tsx +++ b/web/src/components/PipelineSettingsTab/PipelineSettingsTab.tsx @@ -89,7 +89,7 @@ const PipelineSettingsTab = ({ pipeline, repoPath, yamlPath }: SettingsContentPr try { const payload: OpenapiUpdatePipelineRequest = { config_path: newYamlPath, - uid: name + identifier: name } await updatePipeline(payload, { pathParams: { path: `/api/v1/repos/${repoPath}/+/pipelines/${pipeline}` } diff --git a/web/src/components/PipelineTriggersTab/PipelineTriggersTab.tsx b/web/src/components/PipelineTriggersTab/PipelineTriggersTab.tsx index c5e5db4d4..a53c9bda4 100644 --- a/web/src/components/PipelineTriggersTab/PipelineTriggersTab.tsx +++ b/web/src/components/PipelineTriggersTab/PipelineTriggersTab.tsx @@ -145,7 +145,7 @@ const TriggerDetails = ({ const handleSubmit = async (formData: TriggerFormData) => { try { const payload: OpenapiUpdateTriggerRequest = { - uid: formData.name, + identifier: formData.name, actions: formData.actions, disabled: formData.disabled } @@ -324,8 +324,8 @@ const PipelineTriggersTabs = ({ repoPath, pipeline }: PipelineTriggersTabsProps) {data?.map((trigger, index) => ( { @@ -180,7 +180,7 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { if (panelView !== PluginPanelView.Listing) return if (query) { - setPlugins(existingPlugins => existingPlugins.filter((item: TypesPlugin) => item.uid?.includes(query))) + setPlugins(existingPlugins => existingPlugins.filter((item: TypesPlugin) => item.identifier?.includes(query))) } else { fetchAllPlugins().then(response => setPlugins(response)) } @@ -215,7 +215,9 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { } else { setPluginCategory(PluginCategory.Drone) fetchAllPlugins().then(response => { - const matchingPlugin = response?.find((_plugin: TypesPlugin) => _plugin?.uid === get(formData, 'spec.name')) + const matchingPlugin = response?.find( + (_plugin: TypesPlugin) => _plugin?.identifier === get(formData, 'spec.name') + ) if (matchingPlugin) { setPlugin(matchingPlugin) setPanelView(PluginPanelView.Configuration) @@ -314,7 +316,7 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { {plugins?.map((pluginItem: TypesPlugin) => { - const { uid, description } = pluginItem + const { identifier, description } = pluginItem return ( { setPanelView(PluginPanelView.Configuration) setPlugin(pluginItem) }} - key={uid} + key={identifier} width="100%"> @@ -334,7 +336,7 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { color={Color.GREY_900} className={css.fontWeight600} font={{ variation: FontVariation.BODY2_SEMI }}> - {uid} + {identifier} {description} @@ -619,9 +621,9 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { }} className={css.arrow} /> - {plugin?.uid && ( + {plugin?.identifier && ( - {getString(isUpdate ? 'updateLabel' : 'addLabel')} {plugin.uid} {getString('plugins.stepLabel')} + {getString(isUpdate ? 'updateLabel' : 'addLabel')} {plugin.identifier} {getString('plugins.stepLabel')} )} @@ -639,7 +641,7 @@ export const PluginsPanel = (props: PluginsPanelInterface): JSX.Element => { } const updatedYAMLPayload = set({}, PluginSpecInputPath, payloadForYAMLUpdate) set(updatedYAMLPayload, 'type', pluginCategory) - set(updatedYAMLPayload, `${PluginSpecPath}.name`, plugin?.uid) + set(updatedYAMLPayload, `${PluginSpecPath}.name`, plugin?.identifier) onPluginAddUpdate({ pathToField, isUpdate, diff --git a/web/src/components/RepositoryPageHeader/RepositoryPageHeader.tsx b/web/src/components/RepositoryPageHeader/RepositoryPageHeader.tsx index ade5451d2..32619214a 100644 --- a/web/src/components/RepositoryPageHeader/RepositoryPageHeader.tsx +++ b/web/src/components/RepositoryPageHeader/RepositoryPageHeader.tsx @@ -66,7 +66,7 @@ export function RepositoryPageHeader({ {getString('repositories')} - {repoMetadata?.uid || ''} + {repoMetadata?.identifier || ''} {extraBreadcrumbLinks.map(link => ( diff --git a/web/src/components/RunPipelineModal/RunPipelineModal.tsx b/web/src/components/RunPipelineModal/RunPipelineModal.tsx index cf74a2026..277935d90 100644 --- a/web/src/components/RunPipelineModal/RunPipelineModal.tsx +++ b/web/src/components/RunPipelineModal/RunPipelineModal.tsx @@ -33,7 +33,7 @@ import { } from '@harnessio/uicore' import { useStrings } from 'framework/strings' import { useModalHook } from 'hooks/useModalHook' -import type { CreateExecutionQueryParams, TypesExecution, TypesRepository } from 'services/code' +import type { CreateExecutionQueryParams, TypesExecution, RepoRepositoryOutput } from 'services/code' import { getErrorMessage } from 'utils/Utils' import { useAppContext } from 'AppContext' import { BranchTagSelect } from 'components/BranchTagSelect/BranchTagSelect' @@ -49,7 +49,7 @@ const useRunPipelineModal = () => { const { getString } = useStrings() const { showSuccess, showError, clear: clearToaster } = useToaster() const history = useHistory() - const [repo, setRepo] = useState() + const [repo, setRepo] = useState() const [pipeline, setPipeline] = useState('') const repoPath = useMemo(() => repo?.path || '', [repo]) @@ -133,7 +133,7 @@ const useRunPipelineModal = () => { }, [repo?.default_branch, pipeline]) return { - openModal: ({ repoMetadata, pipeline: pipelineUid }: { repoMetadata: TypesRepository; pipeline: string }) => { + openModal: ({ repoMetadata, pipeline: pipelineUid }: { repoMetadata: RepoRepositoryOutput; pipeline: string }) => { setRepo(repoMetadata) setPipeline(pipelineUid) openModal() diff --git a/web/src/components/SpaceSelector/SpaceSelector.tsx b/web/src/components/SpaceSelector/SpaceSelector.tsx index ac5eb9532..6564bd9b6 100644 --- a/web/src/components/SpaceSelector/SpaceSelector.tsx +++ b/web/src/components/SpaceSelector/SpaceSelector.tsx @@ -37,7 +37,7 @@ import { Classes, Popover, Position } from '@blueprintjs/core' import { useStrings } from 'framework/strings' import { ButtonRoleProps, voidFn } from 'utils/Utils' import { useShowRequestError } from 'hooks/useShowRequestError' -import { TypesSpace, useGetSpace } from 'services/code' +import { SpaceSpaceOutput, useGetSpace } from 'services/code' import { SearchInputWithSpinner } from 'components/SearchInputWithSpinner/SearchInputWithSpinner' import { useGetSpaceParam } from 'hooks/useGetSpaceParam' import { NewSpaceModalButton } from 'components/NewSpaceModalButton/NewSpaceModalButton' @@ -45,14 +45,14 @@ import { useAppContext } from 'AppContext' import css from './SpaceSelector.module.scss' interface SpaceSelectorProps { - onSelect: (space: TypesSpace, isUserAction: boolean) => void + onSelect: (space: SpaceSpaceOutput, isUserAction: boolean) => void } export const SpaceSelector: React.FC = ({ onSelect }) => { const { routes } = useAppContext() const { getString } = useStrings() const history = useHistory() - const [selectedSpace, setSelectedSpace] = useState() + const [selectedSpace, setSelectedSpace] = useState() const space = useGetSpaceParam() const [opened, setOpened] = React.useState(false) const [searchTerm, setSearchTerm] = useState('') @@ -70,7 +70,7 @@ export const SpaceSelector: React.FC = ({ onSelect }) => { }) const selectSpace = useCallback( - (_space: TypesSpace, isUserAction: boolean) => { + (_space: SpaceSpaceOutput, isUserAction: boolean) => { setSelectedSpace(_space) onSelect(_space, isUserAction) }, @@ -98,7 +98,7 @@ export const SpaceSelector: React.FC = ({ onSelect }) => { is_public: false, parent_id: 0, path: '', - uid: getString('selectSpace'), + identifier: getString('selectSpace'), updated: 0 }, false @@ -133,12 +133,12 @@ export const SpaceSelector: React.FC = ({ onSelect }) => { /> ) - const columns: Column<{ space: TypesSpace }>[] = useMemo( + const columns: Column<{ space: SpaceSpaceOutput }>[] = useMemo( () => [ { Header: getString('spaces'), width: 'calc(100% - 180px)', - Cell: ({ row }: CellProps<{ space: TypesSpace }>) => { + Cell: ({ row }: CellProps<{ space: SpaceSpaceOutput }>) => { const record = row.original return ( @@ -193,7 +193,7 @@ export const SpaceSelector: React.FC = ({ onSelect }) => { */} - {selectedSpace ? selectedSpace.uid : getString('selectSpace')} + {selectedSpace ? selectedSpace.identifier : getString('selectSpace')} @@ -224,14 +224,14 @@ export const SpaceSelector: React.FC = ({ onSelect }) => { {!!spaces?.length && ( - + hideHeaders className={cx(css.table, css.tableContainer)} columns={columns} data={spaces || []} onRowClick={spaceData => { setOpened(false) - selectSpace({ uid: spaceData?.space?.uid, path: spaceData?.space?.path }, true) + selectSpace({ identifier: spaceData?.space?.identifier, path: spaceData?.space?.path }, true) }} getRowClassName={row => cx(css.row, !row.original.space.description && css.noDesc)} /> diff --git a/web/src/components/UpdateSecretModal/UpdateSecretModal.tsx b/web/src/components/UpdateSecretModal/UpdateSecretModal.tsx index a576db78c..b441a8c99 100644 --- a/web/src/components/UpdateSecretModal/UpdateSecretModal.tsx +++ b/web/src/components/UpdateSecretModal/UpdateSecretModal.tsx @@ -51,7 +51,7 @@ const useUpdateSecretModal = () => { const { mutate: updateSecret, loading } = useMutate({ verb: 'PATCH', - path: `/api/v1/secrets/${space}/${secret?.uid}/+` + path: `/api/v1/secrets/${space}/${secret?.identifier}/+` }) const handleSubmit = async (formData: SecretFormData) => { @@ -59,7 +59,7 @@ const useUpdateSecretModal = () => { const payload: OpenapiUpdateSecretRequest = { data: formData.value, description: formData.description, - uid: formData.name + identifier: formData.name } await updateSecret(payload) hideModal() @@ -97,7 +97,7 @@ const useUpdateSecretModal = () => { () const repoPath = useMemo(() => `${space}/${repoName}`, [space, repoName]) - const { data, error, loading, refetch, response } = useGet({ + const { data, error, loading, refetch, response } = useGet({ path: `/api/v1/repos/${repoPath}/+/`, lazy: true }) diff --git a/web/src/layouts/menu/DefaultMenu.tsx b/web/src/layouts/menu/DefaultMenu.tsx index 8698031fe..0321e1835 100644 --- a/web/src/layouts/menu/DefaultMenu.tsx +++ b/web/src/layouts/menu/DefaultMenu.tsx @@ -21,7 +21,7 @@ import { useHistory, useRouteMatch } from 'react-router-dom' import { FingerprintLockCircle, BookmarkBook, UserSquare, Settings } from 'iconoir-react' import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata' import { useStrings } from 'framework/strings' -import type { TypesSpace } from 'services/code' +import type { SpaceSpaceOutput } from 'services/code' import { SpaceSelector } from 'components/SpaceSelector/SpaceSelector' import { useAppContext } from 'AppContext' import { isGitRev } from 'utils/GitUtils' @@ -31,7 +31,7 @@ import css from './DefaultMenu.module.scss' export const DefaultMenu: React.FC = () => { const history = useHistory() const { routes, standalone } = useAppContext() - const [selectedSpace, setSelectedSpace] = useState() + const [selectedSpace, setSelectedSpace] = useState() const { repoMetadata, gitRef, commitRef } = useGetRepositoryMetadata() const { getString } = useStrings() const repoPath = useMemo(() => repoMetadata?.path || '', [repoMetadata]) diff --git a/web/src/pages/Compare/Compare.tsx b/web/src/pages/Compare/Compare.tsx index 208de0365..399075efb 100644 --- a/web/src/pages/Compare/Compare.tsx +++ b/web/src/pages/Compare/Compare.tsx @@ -50,7 +50,7 @@ import type { TypesCommit, TypesDiffStats, TypesPullReq, - TypesRepository + RepoRepositoryOutput } from 'services/code' import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner' import { TabTitleWithCount, tabContainerCSS } from 'components/TabTitleWithCount/TabTitleWithCount' @@ -365,7 +365,7 @@ export default function Compare() { ), panel: ( diff --git a/web/src/pages/Compare/CompareContentHeader/CompareContentHeader.tsx b/web/src/pages/Compare/CompareContentHeader/CompareContentHeader.tsx index 2d8a12ccc..39d312189 100644 --- a/web/src/pages/Compare/CompareContentHeader/CompareContentHeader.tsx +++ b/web/src/pages/Compare/CompareContentHeader/CompareContentHeader.tsx @@ -59,7 +59,7 @@ export function CompareContentHeader({ { resource: { resourceType: 'CODE_REPOSITORY', - resourceIdentifier: repoMetadata?.uid as string + resourceIdentifier: repoMetadata?.identifier as string }, permissions: ['code_repo_push'] }, diff --git a/web/src/pages/ExecutionList/ExecutionList.tsx b/web/src/pages/ExecutionList/ExecutionList.tsx index 9608ff65d..6fa9f47f6 100644 --- a/web/src/pages/ExecutionList/ExecutionList.tsx +++ b/web/src/pages/ExecutionList/ExecutionList.tsx @@ -92,7 +92,7 @@ const ExecutionList = () => { const onEvent = useCallback( data => { - // ideally this would include number - so we only check for executions on the page - but what if new executions are kicked off? - could check for ids that are higher than the lowest id on the page? + // ideally this would include number - so we only check for executions on the page - but what if new executions are kicked off? - could check for ids that are higher than the lowest ids on the page? if (repoMetadata?.id === data?.repo_id && pipelineData?.id === data?.pipeline_id) { //TODO - revisit full refresh - can I use the message to update the execution? executionsRefetch() diff --git a/web/src/pages/PipelineList/PipelineList.tsx b/web/src/pages/PipelineList/PipelineList.tsx index 92f611d90..3fef292c6 100644 --- a/web/src/pages/PipelineList/PipelineList.tsx +++ b/web/src/pages/PipelineList/PipelineList.tsx @@ -148,7 +148,7 @@ const PipelineList = () => { inExecution /> - {record.uid} + {record.identifier} ) @@ -243,14 +243,14 @@ const PipelineList = () => { Cell: ({ row }: CellProps) => { const [menuOpen, setMenuOpen] = useState(false) const record = row.original - const { uid } = record + const { identifier } = record const repoPath = repoMetadata?.path || '' const confirmDeletePipeline = useConfirmAct() const { showSuccess, showError } = useToaster() const { mutate: deletePipeline } = useMutate({ verb: 'DELETE', - path: `/api/v1/repos/${repoPath}/+/pipelines/${uid}` + path: `/api/v1/repos/${repoPath}/+/pipelines/${identifier}` }) return ( @@ -264,7 +264,7 @@ const PipelineList = () => {