Skip to content

Commit 099ab6b

Browse files
authored
Merge pull request supabase#17216 from supabase/chore/better-no-org-state
Add better empty state if no org
2 parents 1acbe05 + a5cdac7 commit 099ab6b

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

studio/components/interfaces/Home/ProjectList/ProjectList.tsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ProjectListProps {
2424
}
2525

2626
const ProjectList = ({ rewriteHref }: ProjectListProps) => {
27-
const { data: organizations } = useOrganizationsQuery()
27+
const { data: organizations, isSuccess } = useOrganizationsQuery()
2828
const {
2929
data: allProjects,
3030
isLoading: isLoadingProjects,
@@ -40,7 +40,7 @@ const ProjectList = ({ rewriteHref }: ProjectListProps) => {
4040
const projectsByOrg = groupBy(allProjects, 'organization_id')
4141
const isLoadingPermissions = IS_PLATFORM ? _isLoadingPermissions : false
4242

43-
return (
43+
return isSuccess && organizations && organizations?.length > 0 ? (
4444
<>
4545
{organizations?.map((organization) => {
4646
return (
@@ -62,6 +62,8 @@ const ProjectList = ({ rewriteHref }: ProjectListProps) => {
6262
)
6363
})}
6464
</>
65+
) : (
66+
<NoProjectsState slug={''} />
6567
)
6668
}
6769

@@ -132,19 +134,7 @@ const OrganizationProjects = ({
132134
/>
133135
</div>
134136
) : isEmpty ? (
135-
<div className="col-span-4 space-y-4 rounded-lg border-2 border-dashed border-gray-300 p-6 text-center">
136-
<div className="space-y-1">
137-
<p>No projects</p>
138-
<p className="text-sm text-scale-1100">Get started by creating a new project.</p>
139-
</div>
140-
<div>
141-
<Link href={`/new/${slug}`}>
142-
<a>
143-
<Button icon={<IconPlus />}>New Project</Button>
144-
</a>
145-
</Link>
146-
</div>
147-
</div>
137+
<NoProjectsState slug={slug} />
148138
) : (
149139
projects?.map((project) => (
150140
<ProjectCard
@@ -159,3 +149,21 @@ const OrganizationProjects = ({
159149
</div>
160150
)
161151
}
152+
153+
const NoProjectsState = ({ slug }: { slug: string }) => {
154+
return (
155+
<div className="col-span-4 space-y-4 rounded-lg border-2 border-dashed border-gray-300 p-6 text-center">
156+
<div className="space-y-1">
157+
<p>No projects</p>
158+
<p className="text-sm text-scale-1100">Get started by creating a new project.</p>
159+
</div>
160+
<div>
161+
<Link href={`/new/${slug}`}>
162+
<a>
163+
<Button icon={<IconPlus />}>New Project</Button>
164+
</a>
165+
</Link>
166+
</div>
167+
</div>
168+
)
169+
}

studio/pages/projects.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const ProjectsPage: NextPageWithLayout = () => {
5858

5959
{!navLayoutV2 && isSuccess && (
6060
<div className="py-4 px-5">
61-
{IS_PLATFORM && (
61+
{IS_PLATFORM && organizations.length !== 0 && (
6262
<div className="my-2">
6363
<div className="flex">
6464
<div className="">

0 commit comments

Comments
 (0)