mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Make project title open the menu instead of the extra menu button
This commit is contained in:
4 files changed
+230
-75
No files matched your search
@@ -0,0 +1,115 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
GitBranch,
|
||||
MessageSquarePlus,
|
||||
History,
|
||||
Folder,
|
||||
Rocket,
|
||||
Copy,
|
||||
ChevronDown,
|
||||
} from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface ProjectTitleMenuProps {
|
||||
projectName: string;
|
||||
onNewChat: () => void;
|
||||
onGitHistory: () => void;
|
||||
onGitDialog: () => void;
|
||||
onDeploy: () => void;
|
||||
onDuplicate: () => void;
|
||||
onProjectDetails: () => void;
|
||||
isAILoading: boolean;
|
||||
isAnyLoading: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ProjectTitleMenu({
|
||||
projectName,
|
||||
onNewChat,
|
||||
onGitHistory,
|
||||
onGitDialog,
|
||||
onDeploy,
|
||||
onDuplicate,
|
||||
onProjectDetails,
|
||||
isAILoading,
|
||||
isAnyLoading,
|
||||
className = '',
|
||||
}: ProjectTitleMenuProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className={cn("p-0 h-auto font-semibold truncate hover:bg-transparent hover:text-muted-foreground flex items-center gap-1", className)}
|
||||
>
|
||||
<span className="truncate">{projectName}</span>
|
||||
<ChevronDown className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" className="w-48">
|
||||
<DropdownMenuItem
|
||||
onClick={onNewChat}
|
||||
disabled={isAILoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<MessageSquarePlus className="h-4 w-4" />
|
||||
New Chat
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
onClick={onGitHistory}
|
||||
disabled={isAnyLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<History className="h-4 w-4" />
|
||||
Rollback
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
onClick={onGitDialog}
|
||||
disabled={isAnyLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<GitBranch className="h-4 w-4" />
|
||||
Repository
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
onClick={onDeploy}
|
||||
disabled={isAnyLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<Rocket className="h-4 w-4" />
|
||||
Deploy
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
onClick={onDuplicate}
|
||||
disabled={isAnyLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<Copy className="h-4 w-4" />
|
||||
{t('duplicateProject')}
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
onClick={onProjectDetails}
|
||||
disabled={isAnyLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<Folder className="h-4 w-4" />
|
||||
Project Details
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ const CommandItem = React.forwardRef<
|
||||
<CommandPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-muted data-[disabled=true]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -25,7 +25,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
||||
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-muted data-[state=open]:bg-muted",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
@@ -81,7 +81,7 @@ const DropdownMenuItem = React.forwardRef<
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
@@ -97,7 +97,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
checked={checked}
|
||||
@@ -121,7 +121,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
+110
-70
@@ -12,8 +12,12 @@ import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { ArrowLeft, MessageSquare, Eye, Code, Menu } from 'lucide-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ActionsMenu } from '@/components/ActionsMenu';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { ProjectTitleMenu } from '@/components/ProjectTitleMenu';
|
||||
import { GitHistoryDialog } from '@/components/ai/GitHistoryDialog';
|
||||
import { GitDialog } from '@/components/GitDialog';
|
||||
import { DeployDialog } from '@/components/DeployDialog';
|
||||
import { DuplicateProjectDialog } from '@/components/DuplicateProjectDialog';
|
||||
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
||||
import { StarButton } from '@/components/StarButton';
|
||||
import { useBuildProject } from '@/hooks/useBuildProject';
|
||||
@@ -30,6 +34,10 @@ export function ProjectView() {
|
||||
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('chat');
|
||||
const [isAILoading, setIsAILoading] = useState(false);
|
||||
const [isProjectDetailsOpen, setIsProjectDetailsOpen] = useState(false);
|
||||
const [gitHistoryOpen, setGitHistoryOpen] = useState(false);
|
||||
const [gitDialogOpen, setGitDialogOpen] = useState(false);
|
||||
const [deployDialogOpen, setDeployDialogOpen] = useState(false);
|
||||
const [duplicateDialogOpen, setDuplicateDialogOpen] = useState(false);
|
||||
|
||||
// Use console error state from provider
|
||||
const { consoleError, dismissConsoleError, clearErrors } = useConsoleError();
|
||||
@@ -120,6 +128,8 @@ export function ProjectView() {
|
||||
navigate('/');
|
||||
};
|
||||
|
||||
const isAnyLoading = isAILoading || build.isPending;
|
||||
|
||||
if (!project && !isLoading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
||||
@@ -149,13 +159,18 @@ export function ProjectView() {
|
||||
</Button>
|
||||
<div className="flex min-w-0 flex-1">
|
||||
{project ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="block p-0 h-auto text-sm font-semibold truncate hover:bg-transparent hover:text-primary"
|
||||
onClick={() => setIsProjectDetailsOpen(true)}
|
||||
>
|
||||
{project.name}
|
||||
</Button>
|
||||
<ProjectTitleMenu
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onGitHistory={() => setGitHistoryOpen(true)}
|
||||
onGitDialog={() => setGitDialogOpen(true)}
|
||||
onDeploy={() => setDeployDialogOpen(true)}
|
||||
onDuplicate={() => setDuplicateDialogOpen(true)}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isAILoading={isAILoading}
|
||||
isAnyLoading={isAnyLoading}
|
||||
className="text-sm"
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="h-5 w-32" />
|
||||
)}
|
||||
@@ -164,27 +179,13 @@ export function ProjectView() {
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{project ? (
|
||||
<>
|
||||
<StarButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
<ActionsMenu
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
/>
|
||||
</>
|
||||
<StarButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
</>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -298,14 +299,38 @@ export function ProjectView() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Project Details Dialog */}
|
||||
{/* Dialogs */}
|
||||
{project && (
|
||||
<ProjectDetailsDialog
|
||||
project={project}
|
||||
open={isProjectDetailsOpen}
|
||||
onOpenChange={setIsProjectDetailsOpen}
|
||||
onProjectDeleted={handleProjectDeleted}
|
||||
/>
|
||||
<>
|
||||
<ProjectDetailsDialog
|
||||
project={project}
|
||||
open={isProjectDetailsOpen}
|
||||
onOpenChange={setIsProjectDetailsOpen}
|
||||
onProjectDeleted={handleProjectDeleted}
|
||||
/>
|
||||
<GitDialog
|
||||
projectId={project.id}
|
||||
open={gitDialogOpen}
|
||||
onOpenChange={setGitDialogOpen}
|
||||
/>
|
||||
<GitHistoryDialog
|
||||
projectId={project.id}
|
||||
open={gitHistoryOpen}
|
||||
onOpenChange={setGitHistoryOpen}
|
||||
/>
|
||||
<DeployDialog
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
open={deployDialogOpen}
|
||||
onOpenChange={setDeployDialogOpen}
|
||||
/>
|
||||
<DuplicateProjectDialog
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
open={duplicateDialogOpen}
|
||||
onOpenChange={setDuplicateDialogOpen}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -357,43 +382,34 @@ export function ProjectView() {
|
||||
{/* Project title */}
|
||||
<div className="flex flex-1 min-w-0 truncate">
|
||||
{project ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="block p-0 h-auto font-semibold text-lg truncate hover:bg-transparent hover:text-primary"
|
||||
onClick={() => setIsProjectDetailsOpen(true)}
|
||||
>
|
||||
{project.name}
|
||||
</Button>
|
||||
<ProjectTitleMenu
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onGitHistory={() => setGitHistoryOpen(true)}
|
||||
onGitDialog={() => setGitDialogOpen(true)}
|
||||
onDeploy={() => setDeployDialogOpen(true)}
|
||||
onDuplicate={() => setDuplicateDialogOpen(true)}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isAILoading={isAILoading}
|
||||
isAnyLoading={isAnyLoading}
|
||||
className="text-lg"
|
||||
/>
|
||||
) : (
|
||||
<Skeleton className="h-6 w-40" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right side - Star and Actions Menu */}
|
||||
{/* Right side - Star button only */}
|
||||
<div className="flex items-center gap-2">
|
||||
{project ? (
|
||||
<>
|
||||
<StarButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
<ActionsMenu
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
onNewChat={handleNewChat}
|
||||
onProjectDetails={() => setIsProjectDetailsOpen(true)}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
/>
|
||||
</>
|
||||
<StarButton
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
className="h-8 w-8"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
</>
|
||||
<Skeleton className="h-8 w-8 rounded" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -452,14 +468,38 @@ export function ProjectView() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Project Details Dialog */}
|
||||
{/* Dialogs */}
|
||||
{project && (
|
||||
<ProjectDetailsDialog
|
||||
project={project}
|
||||
open={isProjectDetailsOpen}
|
||||
onOpenChange={setIsProjectDetailsOpen}
|
||||
onProjectDeleted={handleProjectDeleted}
|
||||
/>
|
||||
<>
|
||||
<ProjectDetailsDialog
|
||||
project={project}
|
||||
open={isProjectDetailsOpen}
|
||||
onOpenChange={setIsProjectDetailsOpen}
|
||||
onProjectDeleted={handleProjectDeleted}
|
||||
/>
|
||||
<GitDialog
|
||||
projectId={project.id}
|
||||
open={gitDialogOpen}
|
||||
onOpenChange={setGitDialogOpen}
|
||||
/>
|
||||
<GitHistoryDialog
|
||||
projectId={project.id}
|
||||
open={gitHistoryOpen}
|
||||
onOpenChange={setGitHistoryOpen}
|
||||
/>
|
||||
<DeployDialog
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
open={deployDialogOpen}
|
||||
onOpenChange={setDeployDialogOpen}
|
||||
/>
|
||||
<DuplicateProjectDialog
|
||||
projectId={project.id}
|
||||
projectName={project.name}
|
||||
open={duplicateDialogOpen}
|
||||
onOpenChange={setDuplicateDialogOpen}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user