11
2+
23'use client' ;
34
45import { useParams , useRouter , useSearchParams } from 'next/navigation' ;
@@ -7,7 +8,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter }
78import { Tabs , TabsContent , TabsList , TabsTrigger } from "@/components/ui/tabs" ;
89import { Avatar , AvatarFallback , AvatarImage } from '@/components/ui/avatar' ;
910import { AlertDialog , AlertDialogAction , AlertDialogCancel , AlertDialogContent , AlertDialogDescription , AlertDialogFooter , AlertDialogHeader , AlertDialogTitle , AlertDialogTrigger } from "@/components/ui/alert-dialog" ;
10- import { ArrowLeft , Edit3 , PlusCircle , Trash2 , CheckSquare , FileText , Megaphone , Users , FolderGit2 , Loader2 , Mail , UserX , Tag as TagIcon , BookOpen , Pin , PinOff , ShieldAlert , Eye as EyeIcon , Flame , AlertCircle , ListChecks , Palette , CheckCircle , ExternalLink , Info , Code2 , Github , Link2 , Settings2 , Unlink , Copy as CopyIcon , Terminal , InfoIcon , GitBranch , DownloadCloud } from 'lucide-react' ;
11+ import { ArrowLeft , Edit3 , PlusCircle , Trash2 , CheckSquare , FileText , Megaphone , Users , FolderGit2 , Loader2 , Mail , UserX , Tag as TagIcon , BookOpen , Pin , PinOff , ShieldAlert , Eye as EyeIcon , Flame , AlertCircle , ListChecks , Palette , CheckCircle , ExternalLink , Info , Code2 , Github , Link2 , Settings2 , Unlink , Copy as CopyIcon , Terminal , InfoIcon , GitBranch , DownloadCloud , MessageSquare } from 'lucide-react' ;
1112import Link from 'next/link' ;
1213import type { Project , Task , Document as ProjectDocumentType , Tag as TagType , ProjectMember , ProjectMemberRole , TaskStatus , Announcement as ProjectAnnouncementType , UserGithubOAuthToken } from '@/types' ;
1314import { Badge } from '@/components/ui/badge' ;
@@ -117,8 +118,13 @@ type ProjectAnnouncementFormValues = z.infer<typeof projectAnnouncementFormSchem
117118const linkGithubFormSchema = z . object ( {
118119 githubRepoName : z . string ( ) . optional ( ) ,
119120 useDefaultRepoName : z . boolean ( ) . default ( true ) ,
120- } ) . refine ( data => data . useDefaultRepoName || ( data . githubRepoName && data . githubRepoName . trim ( ) !== '' ) , {
121- message : "Custom repository name cannot be empty if not using default." ,
121+ } ) . refine ( data => {
122+ if ( ! data . useDefaultRepoName ) { // If custom name is chosen
123+ return data . githubRepoName && data . githubRepoName . trim ( ) !== '' ; // Then it must be non-empty
124+ }
125+ return true ; // Otherwise (default name is chosen), validation passes
126+ } , {
127+ message : "Custom repository name cannot be empty if you are not using the default name." ,
122128 path : [ "githubRepoName" ] ,
123129} ) ;
124130type LinkGithubFormValues = z . infer < typeof linkGithubFormSchema > ;
@@ -231,13 +237,13 @@ function ProjectDetailPageContent() {
231237 const oauthStatus = searchParams . get ( 'oauth_status' ) ;
232238 if ( oauthStatus === 'success' ) {
233239 toast ( { title : "GitHub Connected!" , description : "Your GitHub account has been successfully linked." } ) ;
234- loadUserGithubOAuth ( ) ;
240+ loadUserGithubOAuth ( ) ; // Reload token after successful OAuth
235241 const newUrl = new URL ( window . location . href ) ;
236242 newUrl . searchParams . delete ( 'oauth_status' ) ;
237- newUrl . searchParams . delete ( 'code' ) ;
243+ newUrl . searchParams . delete ( 'code' ) ; // Also remove code and state if they exist
238244 newUrl . searchParams . delete ( 'state' ) ;
239245 router . replace ( newUrl . toString ( ) , { scroll : false } ) ;
240- } else if ( oauthStatus === 'error' || searchParams . get ( 'error' ) ) {
246+ } else if ( oauthStatus === 'error' || searchParams . get ( 'error' ) ) { // Handle error state from OAuth
241247 toast ( { variant : "destructive" , title : "GitHub Connection Error" , description : searchParams . get ( 'message' ) || searchParams . get ( 'error_description' ) || "Failed to connect GitHub account." } ) ;
242248 const newUrl = new URL ( window . location . href ) ;
243249 newUrl . searchParams . delete ( 'oauth_status' ) ;
@@ -247,7 +253,7 @@ function ProjectDetailPageContent() {
247253 router . replace ( newUrl . toString ( ) , { scroll : false } ) ;
248254 }
249255
250- } , [ searchParams , router , toast ] ) ;
256+ } , [ searchParams , router , toast ] ) ; // toast added to dependency array
251257
252258
253259 const loadUserGithubOAuth = useCallback ( async ( ) => {
@@ -1127,10 +1133,10 @@ function ProjectDetailPageContent() {
11271133 const formData = new FormData ( ) ;
11281134 formData . append ( 'projectUuid' , project . uuid ) ;
11291135 formData . append ( 'flowUpProjectName' , project . name ) ;
1136+ formData . append ( 'useDefaultRepoName' , values . useDefaultRepoName . toString ( ) ) ;
11301137 if ( ! values . useDefaultRepoName && values . githubRepoName ) {
11311138 formData . append ( 'githubRepoName' , values . githubRepoName ) ;
11321139 }
1133- // project.isPrivate will be used by the server action
11341140 ReactStartTransition ( ( ) => {
11351141 linkProjectToGithubFormAction ( formData ) ;
11361142 } ) ;
@@ -1140,6 +1146,7 @@ function ProjectDetailPageContent() {
11401146 const handleInitiateGithubOAuth = ( ) => {
11411147 if ( ! project ) return ;
11421148 const redirectTo = `/projects/${ project . uuid } ?tab=codespace` ;
1149+ // Pass projectUuid in state for the callback to use
11431150 window . location . href = `/api/auth/github/oauth/login?redirectTo=${ encodeURIComponent ( redirectTo ) } &projectUuid=${ project . uuid } ` ;
11441151 } ;
11451152
@@ -1664,7 +1671,7 @@ function ProjectDetailPageContent() {
16641671 < CardDescription >
16651672 Provide a general overview, setup instructions, or any other important information about this project. Supports Markdown.
16661673 { project ?. githubRepoUrl && (
1667- < span className = "block text-xs mt-1 text-green-600" > This README is synced with GitHub.</ span >
1674+ < span className = "block text-xs mt-1 text-green-600" > This README is synced with GitHub. Changes saved here will be pushed. </ span >
16681675 ) }
16691676 </ CardDescription >
16701677 </ div >
@@ -1977,7 +1984,7 @@ function ProjectDetailPageContent() {
19771984 < h3 className = "text-lg font-semibold mb-1" > GitHub Account Connected!</ h3 >
19781985 < p className = "text-sm text-muted-foreground mb-4" >
19791986 Your GitHub account is linked. You can now create a repository for this FlowUp project.
1980- The repository will be { project . isPrivate ? 'private' : 'public' } by default , matching your project's visibility setting .
1987+ The repository will be { project . isPrivate ? 'private' : 'public' } , matching your project's visibility.
19811988 </ p >
19821989 < Dialog open = { isLinkGithubDialogOpen } onOpenChange = { setIsLinkGithubDialogOpen } >
19831990 < DialogTrigger asChild >
@@ -2099,8 +2106,8 @@ function ProjectDetailPageContent() {
20992106
21002107 < Card >
21012108 < CardHeader >
2102- < CardTitle className = "flex items-center" > < Code2 className = "mr-2 h-5 w-5" /> File Management (Coming Soon )</ CardTitle >
2103- < CardDescription > Soon you'll be able to browse , view, and edit your repository files directly within FlowUp.</ CardDescription >
2109+ < CardTitle className = "flex items-center" > < Code2 className = "mr-2 h-5 w-5" /> File Management (Placeholder )</ CardTitle >
2110+ < CardDescription > Future: Browse , view, and edit your repository files directly within FlowUp.</ CardDescription >
21042111 </ CardHeader >
21052112 < CardContent className = "text-center py-8 text-muted-foreground border-dashed border-2 rounded-md m-6" >
21062113 < GitBranch className = "mx-auto h-10 w-10 mb-3 opacity-50" />
@@ -2110,8 +2117,8 @@ function ProjectDetailPageContent() {
21102117 </ Card >
21112118 < Card >
21122119 < CardHeader >
2113- < CardTitle className = "flex items-center" > < Terminal className = "mr-2 h-5 w-5" /> Discord Logs (Coming Soon )</ CardTitle >
2114- < CardDescription > Integrate with Discord to send commit logs or other notifications.</ CardDescription >
2120+ < CardTitle className = "flex items-center" > < MessageSquare className = "mr-2 h-5 w-5" /> Discord Logs (Placeholder )</ CardTitle >
2121+ < CardDescription > Future: Integrate with Discord to send commit logs or other notifications.</ CardDescription >
21152122 </ CardHeader >
21162123 < CardContent className = "text-center py-8 text-muted-foreground border-dashed border-2 rounded-md m-6" >
21172124 < svg xmlns = "http://www.w3.org/2000/svg" width = "40" height = "40" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "mx-auto mb-3 opacity-50" > < path d = "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12c0 1.99.586 3.823 1.589 5.34L2.056 22l4.603-1.534A9.956 9.956 0 0 0 12 22z" > </ path > < path d = "M8 12.5c-.828 0-1.5-.895-1.5-2s.672-2 1.5-2 1.5.895 1.5 2-.672 2-1.5 2zm8 0c-.828 0-1.5-.895-1.5-2s.672-2 1.5-2 1.5.895 1.5 2-.672 2-1.5 2z" > </ path > </ svg >
@@ -2121,8 +2128,8 @@ function ProjectDetailPageContent() {
21212128 </ Card >
21222129 < Card >
21232130 < CardHeader >
2124- < CardTitle className = "flex items-center" > < DownloadCloud className = "mr-2 h-5 w-5" /> Desktop Application (Coming Soon )</ CardTitle >
2125- < CardDescription > Access FlowUp more easily with a dedicated desktop application.</ CardDescription >
2131+ < CardTitle className = "flex items-center" > < DownloadCloud className = "mr-2 h-5 w-5" /> Desktop Application (Placeholder )</ CardTitle >
2132+ < CardDescription > Future: Access FlowUp more easily with a dedicated desktop application.</ CardDescription >
21262133 </ CardHeader >
21272134 < CardContent className = "text-center py-8 text-muted-foreground border-dashed border-2 rounded-md m-6" >
21282135 < svg xmlns = "http://www.w3.org/2000/svg" width = "40" height = "40" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" className = "mx-auto mb-3 opacity-50" > < rect x = "2" y = "3" width = "20" height = "14" rx = "2" ry = "2" > </ rect > < line x1 = "8" y1 = "21" x2 = "16" y2 = "21" > </ line > < line x1 = "12" y1 = "17" x2 = "12" y2 = "21" > </ line > </ svg >
@@ -2385,3 +2392,4 @@ export default function ProjectDetailPage() {
23852392 </ Suspense >
23862393 )
23872394}
2395+
0 commit comments