mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-05 12:35:53 +00:00
Merge pull request #597 from thecodacus/add-loading-on-git-import-from-url
feat:Added backdrop and loading screen in Git clone from Url
This commit is contained in:
commit
0a4ef117ae
@ -1 +1 @@
|
|||||||
{ "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }
|
{ "commit": "43e1f436f57fc4adb43b5481b403967803d4786d" , "version": "0.0.1" }
|
@ -8,6 +8,8 @@ import { Chat } from '~/components/chat/Chat.client';
|
|||||||
import { useGit } from '~/lib/hooks/useGit';
|
import { useGit } from '~/lib/hooks/useGit';
|
||||||
import { useChatHistory } from '~/lib/persistence';
|
import { useChatHistory } from '~/lib/persistence';
|
||||||
import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
|
import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
|
||||||
|
import { LoadingOverlay } from '~/components/ui/LoadingOverlay';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
const IGNORE_PATTERNS = [
|
const IGNORE_PATTERNS = [
|
||||||
'node_modules/**',
|
'node_modules/**',
|
||||||
@ -38,6 +40,7 @@ export function GitUrlImport() {
|
|||||||
const { ready: historyReady, importChat } = useChatHistory();
|
const { ready: historyReady, importChat } = useChatHistory();
|
||||||
const { ready: gitReady, gitClone } = useGit();
|
const { ready: gitReady, gitClone } = useGit();
|
||||||
const [imported, setImported] = useState(false);
|
const [imported, setImported] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const importRepo = async (repoUrl?: string) => {
|
const importRepo = async (repoUrl?: string) => {
|
||||||
if (!gitReady && !historyReady) {
|
if (!gitReady && !historyReady) {
|
||||||
@ -109,9 +112,23 @@ ${file.content}
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
importRepo(url);
|
importRepo(url).catch((error) => {
|
||||||
|
console.error('Error importing repo:', error);
|
||||||
|
toast.error('Failed to import repository');
|
||||||
|
setLoading(false);
|
||||||
|
window.location.href = '/';
|
||||||
|
});
|
||||||
setImported(true);
|
setImported(true);
|
||||||
}, [searchParams, historyReady, gitReady, imported]);
|
}, [searchParams, historyReady, gitReady, imported]);
|
||||||
|
|
||||||
return <ClientOnly fallback={<BaseChat />}>{() => <Chat />}</ClientOnly>;
|
return (
|
||||||
|
<ClientOnly fallback={<BaseChat />}>
|
||||||
|
{() => (
|
||||||
|
<>
|
||||||
|
<Chat />
|
||||||
|
{loading && <LoadingOverlay message="Please wait while we clone the repository..." />}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ClientOnly>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
14
app/components/ui/LoadingOverlay.tsx
Normal file
14
app/components/ui/LoadingOverlay.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export const LoadingOverlay = ({ message = 'Loading...' }) => {
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 flex items-center justify-center bg-black/80 z-50 backdrop-blur-sm">
|
||||||
|
{/* Loading content */}
|
||||||
|
<div className="relative flex flex-col items-center gap-4 p-8 rounded-lg bg-bolt-elements-background-depth-2 shadow-lg">
|
||||||
|
<div
|
||||||
|
className={'i-svg-spinners:90-ring-with-bg text-bolt-elements-loader-progress'}
|
||||||
|
style={{ fontSize: '2rem' }}
|
||||||
|
></div>
|
||||||
|
<p className="text-lg text-bolt-elements-textTertiary">{message}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -4,6 +4,7 @@ import { ClientOnly } from 'remix-utils/client-only';
|
|||||||
import { BaseChat } from '~/components/chat/BaseChat';
|
import { BaseChat } from '~/components/chat/BaseChat';
|
||||||
import { GitUrlImport } from '~/components/git/GitUrlImport.client';
|
import { GitUrlImport } from '~/components/git/GitUrlImport.client';
|
||||||
import { Header } from '~/components/header/Header';
|
import { Header } from '~/components/header/Header';
|
||||||
|
import BackgroundRays from '~/components/ui/BackgroundRays';
|
||||||
|
|
||||||
export const meta: MetaFunction = () => {
|
export const meta: MetaFunction = () => {
|
||||||
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
|
return [{ title: 'Bolt' }, { name: 'description', content: 'Talk with Bolt, an AI assistant from StackBlitz' }];
|
||||||
@ -15,7 +16,8 @@ export async function loader(args: LoaderFunctionArgs) {
|
|||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full w-full">
|
<div className="flex flex-col h-full w-full bg-bolt-elements-background-depth-1">
|
||||||
|
<BackgroundRays />
|
||||||
<Header />
|
<Header />
|
||||||
<ClientOnly fallback={<BaseChat />}>{() => <GitUrlImport />}</ClientOnly>
|
<ClientOnly fallback={<BaseChat />}>{() => <GitUrlImport />}</ClientOnly>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user