Skip to content

Commit 29c082c

Browse files
committed
feat: Flow into Cluster creation smoothly
https://harperdb.atlassian.net/browse/STUDIO-481
1 parent 9a6f9e1 commit 29c082c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/features/clusters/ClustersList.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SubNavMenu } from '@/components/SubNavMenu';
22
import { Button } from '@/components/ui/button';
33
import { Input } from '@/components/ui/input';
44
import { ClusterCard } from '@/features/clusters/components/ClusterCard';
5+
import { UpsertCluster } from '@/features/clusters/upsert';
56
import { getOrganizationQueryOptions } from '@/features/organization/queries/getOrganizationQuery';
67
import { useOrganizationClusterPermissions } from '@/hooks/usePermissions';
78
import { Cluster } from '@/lib/api.patch';
@@ -30,6 +31,10 @@ export function ClustersList() {
3031
.filter(curryFilterByFuzzySearch<Cluster>(['id', 'name'], filterByNameValue))
3132
.sort(byClusterStatusThenName) || [], [filterByNameValue, orgInfo?.clusters]);
3233

34+
if (!clusters.length && create) {
35+
return <UpsertCluster embedded={true} />;
36+
}
37+
3338
return (
3439
<>
3540
<SubNavMenu>
@@ -70,8 +75,7 @@ export function ClustersList() {
7075
) : (
7176
<div className="flex-col space-y-5 items-center justify-center text-center">
7277
<h2 className="text-2xl text-center text-white">
73-
No clusters found.
74-
{create && ' Want to create a new cluster?'}
78+
No clusters found.{!create ? ' Talk to your org admin to create one!' : ''}
7579
</h2>
7680

7781
{create && (

src/features/clusters/upsert/ClusterForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface ClusterFormProps {
3232
clusterId?: string;
3333
defaultValues: z.infer<typeof UpsertClusterSchema>;
3434
deploymentToPerformanceToPlan: Record<string, Record<string, SchemaPlan>>;
35+
embedded: boolean | undefined;
3536
organization: Organization;
3637
organizationId: string;
3738
planTypes: SchemaPlan[];
@@ -46,6 +47,7 @@ export function ClusterForm({
4647
clusterId,
4748
defaultValues,
4849
deploymentToPerformanceToPlan,
50+
embedded,
4951
organization,
5052
organizationId,
5153
planTypes,
@@ -284,7 +286,8 @@ export function ClusterForm({
284286
}
285287

286288
void router.invalidate();
287-
void navigate({ to: creating ? '../' : '../../' });
289+
void navigate({ to: creating ? embedded ? './' : '../' : '../../' });
290+
form.reset();
288291
toast.success(creating ? 'Cluster Created' : 'Cluster Updated', {
289292
id: toastId,
290293
description: isSelfManaged

src/features/clusters/upsert/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { useParams, useRouteContext } from '@tanstack/react-router';
2020
import { useMemo } from 'react';
2121
import { z } from 'zod';
2222

23-
export function UpsertCluster() {
23+
export function UpsertCluster(params?: { embedded?: boolean }) {
2424
const { organizationId, clusterId }: { organizationId: string; clusterId?: string } = useParams({ strict: false });
2525
const { organization, cluster }: {
2626
organization: Organization;
@@ -151,6 +151,7 @@ export function UpsertCluster() {
151151
clusterId={clusterId}
152152
defaultValues={defaultValues}
153153
deploymentToPerformanceToPlan={deploymentToPerformanceToPlan}
154+
embedded={params?.embedded}
154155
organization={organization}
155156
organizationId={organizationId}
156157
planTypes={planTypes}

0 commit comments

Comments
 (0)