@@ -4,11 +4,13 @@ import type { Auth0SessionData } from "@/app/services/auth0/getCurrentSession";
44import type { GithubSourceRepo } from "@/app/services/github/types" ;
55import Card from "@/components/ui/card" ;
66import { useLocalBranches } from "@/hooks/useLocalBranches" ;
7+ import { useLocalBranchesForSite } from "@/hooks/useLocalBranchesForSite" ;
78import type { DocsUrl } from "@/utils/types" ;
89import { BranchList } from "../BranchList" ;
910import { GoToEditorButton } from "../GoToEditorButton" ;
1011import { VisualEditorEmptyCard } from "./VisualEditorEmptyCard" ;
1112import { VisualEditorHeader } from "./VisualEditorHeader" ;
13+ import { VisualEditorLoadingCard } from "./VisualEditorLoadingCard" ;
1214
1315export function VisualEditorSectionClient ( {
1416 maybeCriticalUpdateWarning,
@@ -21,28 +23,36 @@ export function VisualEditorSectionClient({
2123 docsUrl : DocsUrl ;
2224 sourceRepo ?: GithubSourceRepo ;
2325} ) {
24- const { userHasCreatedAnyBranch, loading } = useLocalBranches ( ) ;
26+ const { loading } = useLocalBranches ( ) ;
27+ const { filteredBranches } = useLocalBranchesForSite ( docsUrl ) ;
2528
26- if ( ! userHasCreatedAnyBranch && ! loading ) {
27- return (
28- < VisualEditorEmptyCard >
29+ return (
30+ < >
31+ { loading ? (
32+ < VisualEditorLoadingCard />
33+ ) : (
2934 < >
30- { maybeCriticalUpdateWarning }
31- < div className = "flex flex-col gap-2 sm:flex-row" >
32- < GoToEditorButton docsUrl = { docsUrl } session = { session } />
33- </ div >
35+ { filteredBranches . length === 0 ? (
36+ < VisualEditorEmptyCard >
37+ < >
38+ { maybeCriticalUpdateWarning }
39+ < div className = "flex flex-col gap-2 sm:flex-row" >
40+ < GoToEditorButton docsUrl = { docsUrl } session = { session } />
41+ </ div >
42+ </ >
43+ </ VisualEditorEmptyCard >
44+ ) : (
45+ < Card className = "flex flex-col" >
46+ { maybeCriticalUpdateWarning }
47+ < div className = "flex items-center justify-between" >
48+ < VisualEditorHeader />
49+ < GoToEditorButton docsUrl = { docsUrl } session = { session } />
50+ </ div >
51+ < BranchList docsUrl = { docsUrl } sourceRepo = { sourceRepo } />
52+ </ Card >
53+ ) }
3454 </ >
35- </ VisualEditorEmptyCard >
36- ) ;
37- }
38- return (
39- < Card className = "flex flex-col" >
40- { maybeCriticalUpdateWarning }
41- < div className = "flex items-center justify-between" >
42- < VisualEditorHeader />
43- < GoToEditorButton docsUrl = { docsUrl } session = { session } />
44- </ div >
45- < BranchList docsUrl = { docsUrl } sourceRepo = { sourceRepo } />
46- </ Card >
55+ ) }
56+ </ >
4757 ) ;
4858}
0 commit comments