mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Start fixing loading state of ProjectView
This commit is contained in:
1 file changed
+72
-12
+72
-12
@@ -8,6 +8,7 @@ import { ProjectSidebar } from '@/components/ProjectSidebar';
|
|||||||
import { ProjectInfoDialog } from '@/components/ProjectInfoDialog';
|
import { ProjectInfoDialog } from '@/components/ProjectInfoDialog';
|
||||||
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
|
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { ArrowLeft, MessageSquare, Eye, Code, Menu, Columns2 } from 'lucide-react';
|
import { ArrowLeft, MessageSquare, Eye, Code, Menu, Columns2 } from 'lucide-react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { ActionsMenu } from '@/components/ActionsMenu';
|
import { ActionsMenu } from '@/components/ActionsMenu';
|
||||||
@@ -175,15 +176,7 @@ export function ProjectView() {
|
|||||||
navigate('/');
|
navigate('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (!project && !isLoading) {
|
||||||
return (
|
|
||||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!project) {
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
<div className="min-h-screen bg-background flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
@@ -210,6 +203,7 @@ export function ProjectView() {
|
|||||||
<Menu className="h-4 w-4" />
|
<Menu className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
|
{project ? (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="p-0 h-auto text-sm font-semibold truncate hover:bg-transparent hover:text-primary"
|
className="p-0 h-auto text-sm font-semibold truncate hover:bg-transparent hover:text-primary"
|
||||||
@@ -217,10 +211,15 @@ export function ProjectView() {
|
|||||||
>
|
>
|
||||||
{project.name}
|
{project.name}
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Skeleton className="h-5 w-32" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
{project ? (
|
||||||
|
<>
|
||||||
<StarButton
|
<StarButton
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
projectName={project.name}
|
projectName={project.name}
|
||||||
@@ -238,6 +237,13 @@ export function ProjectView() {
|
|||||||
onFirstInteraction={handleFirstInteraction}
|
onFirstInteraction={handleFirstInteraction}
|
||||||
onProjectDeleted={handleProjectDeleted}
|
onProjectDeleted={handleProjectDeleted}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Skeleton className="h-8 w-8 rounded" />
|
||||||
|
<Skeleton className="h-8 w-8 rounded" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -270,6 +276,7 @@ export function ProjectView() {
|
|||||||
|
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-hidden">
|
||||||
{mobileView === 'chat' && (
|
{mobileView === 'chat' && (
|
||||||
|
project ? (
|
||||||
<ChatPane
|
<ChatPane
|
||||||
ref={chatPaneRef}
|
ref={chatPaneRef}
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
@@ -282,12 +289,27 @@ export function ProjectView() {
|
|||||||
isBuildLoading={isBuildLoading}
|
isBuildLoading={isBuildLoading}
|
||||||
isDeployLoading={isDeployLoading}
|
isDeployLoading={isDeployLoading}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="h-full p-4 space-y-4">
|
||||||
|
<Skeleton className="h-12 w-full" />
|
||||||
|
<Skeleton className="h-8 w-3/4" />
|
||||||
|
<Skeleton className="h-8 w-1/2" />
|
||||||
|
<Skeleton className="h-32 w-full" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
{(mobileView === 'preview' || mobileView === 'code') && (
|
{(mobileView === 'preview' || mobileView === 'code') && (
|
||||||
|
project ? (
|
||||||
<PreviewPane
|
<PreviewPane
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
activeTab={mobileView}
|
activeTab={mobileView}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="h-full p-4 space-y-4">
|
||||||
|
<Skeleton className="h-8 w-32" />
|
||||||
|
<Skeleton className="h-full w-full" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -298,6 +320,7 @@ export function ProjectView() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setMobileView('chat')}
|
onClick={() => setMobileView('chat')}
|
||||||
className="flex-1 rounded-none"
|
className="flex-1 rounded-none"
|
||||||
|
disabled={!project}
|
||||||
>
|
>
|
||||||
<MessageSquare className="h-4 w-4 mr-1" />
|
<MessageSquare className="h-4 w-4 mr-1" />
|
||||||
Chat
|
Chat
|
||||||
@@ -307,6 +330,7 @@ export function ProjectView() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setMobileView('preview')}
|
onClick={() => setMobileView('preview')}
|
||||||
className="flex-1 rounded-none"
|
className="flex-1 rounded-none"
|
||||||
|
disabled={!project}
|
||||||
>
|
>
|
||||||
<Eye className="h-4 w-4 mr-1" />
|
<Eye className="h-4 w-4 mr-1" />
|
||||||
Preview
|
Preview
|
||||||
@@ -316,10 +340,11 @@ export function ProjectView() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setMobileView('code')}
|
onClick={() => setMobileView('code')}
|
||||||
className="flex-1 rounded-none"
|
className="flex-1 rounded-none"
|
||||||
|
disabled={!project}
|
||||||
>
|
>
|
||||||
<Code className="h-4 w-4 mr-1" />
|
<Code className="h-4 w-4 mr-1" />
|
||||||
Code
|
Code
|
||||||
{mobileView !== 'code' && (
|
{mobileView !== 'code' && project && (
|
||||||
<GitStatusIndicator projectId={project.id} className="ml-1" />
|
<GitStatusIndicator projectId={project.id} className="ml-1" />
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -327,11 +352,13 @@ export function ProjectView() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Project Info Dialog */}
|
{/* Project Info Dialog */}
|
||||||
|
{project && (
|
||||||
<ProjectInfoDialog
|
<ProjectInfoDialog
|
||||||
project={project}
|
project={project}
|
||||||
open={isProjectInfoOpen}
|
open={isProjectInfoOpen}
|
||||||
onOpenChange={setIsProjectInfoOpen}
|
onOpenChange={setIsProjectInfoOpen}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -339,7 +366,7 @@ export function ProjectView() {
|
|||||||
return (
|
return (
|
||||||
<div className="h-screen flex bg-background">
|
<div className="h-screen flex bg-background">
|
||||||
{/* Fixed Sidebar */}
|
{/* Fixed Sidebar */}
|
||||||
<div className={`w-80 border-r bg-sidebar transition-all duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
|
<div className={`w-80 border-r bg-sidebar duration-300 ${isSidebarVisible ? 'block' : 'hidden'}`}>
|
||||||
<ProjectSidebar
|
<ProjectSidebar
|
||||||
selectedProject={project}
|
selectedProject={project}
|
||||||
onSelectProject={(selectedProject) => {
|
onSelectProject={(selectedProject) => {
|
||||||
@@ -380,6 +407,7 @@ export function ProjectView() {
|
|||||||
{/* Center - Project title */}
|
{/* Center - Project title */}
|
||||||
<div className="flex-1 min-w-0 ml-2 px-4">
|
<div className="flex-1 min-w-0 ml-2 px-4">
|
||||||
<div className="flex items-center justify-center md:justify-start">
|
<div className="flex items-center justify-center md:justify-start">
|
||||||
|
{project ? (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="p-0 h-auto font-semibold text-lg truncate hover:bg-transparent hover:text-primary"
|
className="p-0 h-auto font-semibold text-lg truncate hover:bg-transparent hover:text-primary"
|
||||||
@@ -387,11 +415,16 @@ export function ProjectView() {
|
|||||||
>
|
>
|
||||||
{project.name}
|
{project.name}
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Skeleton className="h-6 w-40" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right side - Star and Actions Menu */}
|
{/* Right side - Star and Actions Menu */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
{project ? (
|
||||||
|
<>
|
||||||
<StarButton
|
<StarButton
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
projectName={project.name}
|
projectName={project.name}
|
||||||
@@ -409,12 +442,20 @@ export function ProjectView() {
|
|||||||
onFirstInteraction={handleFirstInteraction}
|
onFirstInteraction={handleFirstInteraction}
|
||||||
onProjectDeleted={handleProjectDeleted}
|
onProjectDeleted={handleProjectDeleted}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Skeleton className="h-8 w-8 rounded" />
|
||||||
|
<Skeleton className="h-8 w-8 rounded" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Chat Content */}
|
{/* Chat Content */}
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-hidden">
|
||||||
|
{project ? (
|
||||||
<ChatPane
|
<ChatPane
|
||||||
ref={chatPaneRef}
|
ref={chatPaneRef}
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
@@ -427,6 +468,14 @@ export function ProjectView() {
|
|||||||
isBuildLoading={isBuildLoading}
|
isBuildLoading={isBuildLoading}
|
||||||
isDeployLoading={isDeployLoading}
|
isDeployLoading={isDeployLoading}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="h-full p-4 space-y-4">
|
||||||
|
<Skeleton className="h-12 w-full" />
|
||||||
|
<Skeleton className="h-8 w-3/4" />
|
||||||
|
<Skeleton className="h-8 w-1/2" />
|
||||||
|
<Skeleton className="h-32 w-full" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
@@ -445,6 +494,7 @@ export function ProjectView() {
|
|||||||
variant={activeTab === 'preview' ? 'default' : 'ghost'}
|
variant={activeTab === 'preview' ? 'default' : 'ghost'}
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setActiveTab('preview')}
|
onClick={() => setActiveTab('preview')}
|
||||||
|
disabled={!project}
|
||||||
>
|
>
|
||||||
Preview
|
Preview
|
||||||
</Button>
|
</Button>
|
||||||
@@ -453,9 +503,10 @@ export function ProjectView() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setActiveTab('code')}
|
onClick={() => setActiveTab('code')}
|
||||||
className="gap-2"
|
className="gap-2"
|
||||||
|
disabled={!project}
|
||||||
>
|
>
|
||||||
Code
|
Code
|
||||||
{activeTab !== 'code' && (
|
{activeTab !== 'code' && project && (
|
||||||
<GitStatusIndicator projectId={project.id} />
|
<GitStatusIndicator projectId={project.id} />
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -465,10 +516,17 @@ export function ProjectView() {
|
|||||||
|
|
||||||
{/* Preview Content */}
|
{/* Preview Content */}
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-hidden">
|
||||||
|
{project ? (
|
||||||
<PreviewPane
|
<PreviewPane
|
||||||
projectId={project.id}
|
projectId={project.id}
|
||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="h-full p-4 space-y-4">
|
||||||
|
<Skeleton className="h-8 w-32" />
|
||||||
|
<Skeleton className="h-full w-full" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
@@ -477,11 +535,13 @@ export function ProjectView() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Project Info Dialog */}
|
{/* Project Info Dialog */}
|
||||||
|
{project && (
|
||||||
<ProjectInfoDialog
|
<ProjectInfoDialog
|
||||||
project={project}
|
project={project}
|
||||||
open={isProjectInfoOpen}
|
open={isProjectInfoOpen}
|
||||||
onOpenChange={setIsProjectInfoOpen}
|
onOpenChange={setIsProjectInfoOpen}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user