work in progress poc git import

This commit is contained in:
Anirban Kar
2024-11-25 19:53:54 +05:30
parent 7fc8e40c03
commit e6ed210d0d
5 changed files with 406 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ import Cookies from 'js-cookie';
import styles from './BaseChat.module.scss';
import type { ProviderInfo } from '~/utils/types';
import GitCloneButton from './GitCloneButton';
import * as Separator from '@radix-ui/react-separator';
const EXAMPLE_PROMPTS = [
{ text: 'Build a todo app in React using Tailwind' },
@@ -208,6 +210,9 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
},
)}
>
<GitCloneButton />
<Separator.Root className="my-[15px] bg-gray6 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px"/>
<div className="flex items-center gap-3"></div>
<ModelSelector
key={provider?.name + ':' + modelList.length}
model={model}

View File

@@ -0,0 +1,24 @@
import { IconButton } from '../ui/IconButton'
import git from 'isomorphic-git'
import http from 'isomorphic-git/http/web'
import { useGit } from '~/lib/hooks/useGit'
export default function GitCloneButton() {
const {ready,gitClone} = useGit()
const onClick= async(e:any)=>{
if (!ready) return
let repoUrl=prompt("Enter the Git url")
if (repoUrl) {
await gitClone(repoUrl)
}
}
return (
<IconButton onClick={e=>{
onClick(e)
}} className="w-full justify-center" title="Clone A Git Repo">
<span className="mr-2 text-xs lg:text-sm">Clone A Git Repo</span>
<div className='i-ph:git-branch' />
</IconButton>
)
}