From 3b01ee03e77b1c5794d2f5454de670db2b39eea2 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 28 Oct 2024 15:48:38 +0530 Subject: [PATCH 1/2] Check if repo with the same name already exists --- .../projects/create/template/index.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx b/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx index 7e855240..79e62801 100644 --- a/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx +++ b/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx @@ -41,6 +41,17 @@ const CreateRepo = () => { const [gitAccounts, setGitAccounts] = useState([]); const [isLoading, setIsLoading] = useState(false); + const checkRepoExists = async (account: string, repoName: string) => { + try { + await octokit.rest.repos.get({ owner: account, repo: repoName }); + return true; + } catch (error) { + // Error handled by octokit error hook interceptor in Octokit context + console.error(error); + return; + } + }; + const submitRepoHandler: SubmitHandler = useCallback( async (data) => { assert(data.account); @@ -50,6 +61,18 @@ const CreateRepo = () => { assert(template.repoFullName, 'Template URL not provided'); const [owner, repo] = template.repoFullName.split('/'); + const repoExists = await checkRepoExists(data.account, data.repoName); + if (repoExists) { + toast({ + id: 'repo-exist-error', + title: 'Repository already exists with this name', + variant: 'warning', + onDismiss: dismiss, + }); + setIsLoading(false); + return; + } + setIsLoading(true); navigate( @@ -81,7 +104,7 @@ const CreateRepo = () => { }); } }, - [octokit], + [octokit, toast], ); useEffect(() => { -- 2.45.2 From 15db8836f1817c03f2bd4a1ce70dbd2cf766db99 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 28 Oct 2024 16:11:33 +0530 Subject: [PATCH 2/2] Remove arbitrum from supported chains --- packages/frontend/src/context/Web3Provider.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/context/Web3Provider.tsx b/packages/frontend/src/context/Web3Provider.tsx index 593b85ac..1d3b0854 100644 --- a/packages/frontend/src/context/Web3Provider.tsx +++ b/packages/frontend/src/context/Web3Provider.tsx @@ -2,7 +2,7 @@ import { ReactNode } from 'react'; import assert from 'assert'; import { SiweMessage, generateNonce } from 'siwe'; import { WagmiProvider } from 'wagmi'; -import { arbitrum, mainnet } from 'wagmi/chains'; +import { mainnet } from 'wagmi/chains'; import axios from 'axios'; import { createWeb3Modal } from '@web3modal/wagmi/react'; @@ -36,7 +36,7 @@ const metadata = { url: window.location.origin, icons: ['https://avatars.githubusercontent.com/u/37784886'], }; -const chains = [mainnet, arbitrum] as const; +const chains = [mainnet] as const; const config = defaultWagmiConfig({ chains, projectId: VITE_WALLET_CONNECT_ID, -- 2.45.2