Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Check if we have access to newly created repo
Vasek Mlejnsky389f35e8ead2
diff --git a/components/AlertError.tsx b/components/AlertError.tsxindex bbe0b3036..217040450 100644--- a/components/AlertError.tsx+++ b/components/AlertError.tsx@@ -10,8 +10,8 @@ function AlertError({infoItems,}: Props) {return (- <div className="rounded-md bg-red-50 p-4">- <div className="flex">+ <div className="rounded-md bg-red-50 p-4 max-w-full">+ <div className="flex overflow-auto"><div className="shrink-0"><XCircle className="text-red-400" size={16} aria-hidden="true" /></div>diff --git a/components/SelectRepository/NewRepository/index.tsx b/components/SelectRepository/NewRepository/index.tsxindex 3bae945a3..e4d74ffca 100644--- a/components/SelectRepository/NewRepository/index.tsx+++ b/components/SelectRepository/NewRepository/index.tsx@@ -10,6 +10,7 @@ import { configureGitHubApp } from 'utils/github'import { useGitHubClient } from 'hooks/useGitHubClient'import SpinnerIcon from 'components/Spinner'import { createRepo } from 'github/repo'+import { fetchRepos } from 'hooks/useRepositories'import RepoAccountSelect, { GitHubAccount } from './RepoAccountSelect'import RepoNameInput from './RepoNameInput'@@ -37,19 +38,27 @@ function NewRepository({if (isLoading) returntry {- // TODO: Create a repository+ // Create a repositorysetError('')setIsLoading(true)- const data = await createRepo({+ const { id: newRepoID } = await createRepo({client: ghClient,org: selectedAccount.isOrg ? selectedAccount.name : undefined,name,})- console.log('new repo data', data)- // TODO: Check if we have permissions to the new repository,+ // Check if we have permissions to the new repository,// if not - present UI that asks user for a permission to the new repository// if we do - select the new repo+ const repos = await fetchRepos(ghClient)+ const newRepo = repos.find(r => r.id === newRepoID)+ if (newRepo) {+ console.log('HAS ACCESS TO REPO')+ //onRepoSelection(newRepo)+ } else {+ // TODO+ console.log('DO NOT HAVE ACCESS TO REPO')+ }} catch (err: any) {console.error('Error creating repository', err)setError(err.message)@@ -95,7 +104,7 @@ function NewRepository({/><button- className="w-8 min-w-[64px] flex items-center justify-center rounded bg-white/10 px-2 py-1 text-sm text-white font-medium hover:bg-white/20"+ className="w-8 min-w-[64px] h-[24px] min-h-[24px] flex items-center justify-center rounded bg-white/10 px-2 py-1 text-sm text-white font-medium hover:bg-white/20"onClick={handleCreateClick}>{isLoading ? (diff --git a/components/SelectRepository/index.tsx b/components/SelectRepository/index.tsxindex 30ced39ee..10a6b111f 100644--- a/components/SelectRepository/index.tsx+++ b/components/SelectRepository/index.tsx@@ -90,9 +90,9 @@ function SelectRepository({{selected === 'new' && (<NewRepositoryaccounts={githubAccounts}- // onRepoSelection={onRepoSelection}accessToken={accessToken}onConfigureGitHubAppClick={configureGitHubApp}+ // onRepoSelection={onRepoSelection}/>)}<buttondiff --git a/hooks/useRepositories.ts b/hooks/useRepositories.tsindex 8d90467ad..0d0f4384e 100644--- a/hooks/useRepositories.ts+++ b/hooks/useRepositories.ts@@ -1,7 +1,7 @@import { useEffect, useReducer, useState } from 'react'import { GitHubClient } from 'github/client'-async function fetchRepos(client: GitHubClient) {+export async function fetchRepos(client: GitHubClient) {const installations = await client.apps.listInstallationsForAuthenticatedUser()const repos = await Promise.all(installations.data.installations.map(async i => {