Skip to content

Commit c0a3362

Browse files
committed
fix: add region names
1 parent 0d3936e commit c0a3362

File tree

11 files changed

+103
-55
lines changed

11 files changed

+103
-55
lines changed

frontend/src/app/dialogs/connect-railway-frame.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const stepper = defineStepper(
4848
{
4949
id: "step-3",
5050
title: "Wait for the Runner to connect",
51-
assist: false,
51+
assist: true,
5252
schema: z.object({
5353
success: z.boolean().refine((v) => v === true, {
5454
message: "Runner must be connected to proceed",
@@ -74,6 +74,8 @@ export default function ConnectRailwayFrameContent({
7474
const prefferedRegionForRailway =
7575
data.find((region) => region.name.toLowerCase().includes("us-west"))
7676
?.id ||
77+
data.find((region) => region.name.toLowerCase().includes("us-east"))
78+
?.id ||
7779
data.find((region) => region.name.toLowerCase().includes("ore"))?.id ||
7880
"auto";
7981

frontend/src/app/dialogs/connect-vercel-frame.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ export default function CreateProjectFrameContent({
4747
Add <Icon icon={faVercel} className="ml-0.5" />
4848
Vercel
4949
</div>
50-
<HelpDropdown>
51-
<Button variant="ghost" size="icon">
52-
<Icon icon={faQuestionCircle} />
53-
</Button>
54-
</HelpDropdown>
5550
</Frame.Title>
5651
</Frame.Header>
5752
<Frame.Content>

frontend/src/app/forms/connect-railway-form.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as ConnectVercelForm from "@/app/forms/connect-vercel-form";
1010
import {
1111
cn,
1212
FormControl,
13+
FormDescription,
1314
FormField,
1415
FormItem,
1516
FormLabel,
@@ -30,10 +31,15 @@ export const Datacenter = function Datacenter() {
3031
<FormLabel>Datacenter</FormLabel>
3132
<FormControl>
3233
<RegionSelect
34+
showAuto={false}
3335
onValueChange={field.onChange}
3436
value={field.value}
3537
/>
3638
</FormControl>
39+
<FormDescription>
40+
You can find the region your Railway runners are running
41+
in under <i>Settings &gt; Deploy</i>
42+
</FormDescription>
3743
<FormMessage />
3844
</FormItem>
3945
)}

frontend/src/app/forms/connect-vercel-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const stepper = defineStepper(
8181
{
8282
id: "step-3",
8383
title: "Deploy to Vercel",
84-
assist: false,
84+
assist: true,
8585
next: "Done",
8686
schema: z.object({
8787
success: z.boolean().refine((val) => val, "Connection failed"),

frontend/src/app/runner-config-table.tsx

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { faRailway, faVercel, Icon } from "@rivet-gg/icons";
12
import type { Rivet } from "@rivetkit/engine-api-full";
2-
import { formatRelative } from "date-fns";
33
import {
44
Button,
55
DiscreteCopyButton,
@@ -11,15 +11,14 @@ import {
1111
TableHeader,
1212
TableRow,
1313
Text,
14-
WithTooltip,
1514
} from "@/components";
1615

1716
interface RunnerConfigsTableProps {
1817
isLoading?: boolean;
1918
isError?: boolean;
2019
hasNextPage?: boolean;
2120
fetchNextPage?: () => void;
22-
configs: Rivet.RunnerConfig[];
21+
configs: [string, Rivet.RunnerConfig][];
2322
}
2423

2524
export function RunnerConfigsTable({
@@ -70,8 +69,8 @@ export function RunnerConfigsTable({
7069
<RowSkeleton />
7170
</>
7271
) : null}
73-
{configs?.map((config) => (
74-
<Row {...config} key={config.metadata} />
72+
{configs?.map(([id, config]) => (
73+
<Row name={id} {...config} key={id} />
7574
))}
7675

7776
{!isLoading && hasNextPage ? (
@@ -112,34 +111,43 @@ function RowSkeleton() {
112111
);
113112
}
114113

115-
function Row(config: Rivet.RunnerConfig) {
114+
function Row({ name, ...config }: { name: string } & Rivet.RunnerConfig) {
116115
return (
117-
<TableRow key={runner.runnerId}>
116+
<TableRow>
118117
<TableCell>
119-
<WithTooltip
120-
content={config}
121-
trigger={
122-
<DiscreteCopyButton value={runner.runnerId}>
123-
{runner.runnerId.slice(0, 8)}
124-
</DiscreteCopyButton>
125-
}
126-
/>
118+
<DiscreteCopyButton value={name}>{name}</DiscreteCopyButton>
127119
</TableCell>
128120
<TableCell>
129-
{config.metadata &&
130-
typeof config.metadata === "object" &&
131-
"provider" in config.metadata
132-
? (config.metadata.provider as string)
133-
: "unknown"}
121+
<Provider metadata={config.metadata} />
134122
</TableCell>
135123
<TableCell>-</TableCell>
136-
<TableCell>{runner.datacenter}</TableCell>
137-
138-
<TableCell>
139-
{runner.remainingSlots}/{runner.totalSlots}
140-
</TableCell>
124+
<TableCell>{config.serverless?.url}</TableCell>
141125

142-
<TableCell>{formatRelative(runner.createTs, new Date())}</TableCell>
126+
<TableCell></TableCell>
143127
</TableRow>
144128
);
145129
}
130+
131+
function Provider({ metadata }: { metadata: unknown }) {
132+
if (!metadata || typeof metadata !== "object") {
133+
return <span>Unknown</span>;
134+
}
135+
if ("provider" in metadata && typeof metadata.provider === "string") {
136+
if (metadata.provider === "vercel") {
137+
return (
138+
<>
139+
<Icon icon={faVercel} className="mr-1" /> Vercel
140+
</>
141+
);
142+
}
143+
if (metadata.provider === "railway") {
144+
return (
145+
<>
146+
<Icon icon={faRailway} className="mr-1" /> Railway
147+
</>
148+
);
149+
}
150+
return <span>{metadata.provider || "-"}</span>;
151+
}
152+
return <span>Unknown</span>;
153+
}

frontend/src/components/actors/region-select.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ import { useDataProvider } from "./data-provider";
66
interface RegionSelectProps {
77
onValueChange: (value: string) => void;
88
value: string;
9+
showAuto?: boolean;
910
}
1011

11-
export function RegionSelect({ onValueChange, value }: RegionSelectProps) {
12+
export function RegionSelect({
13+
onValueChange,
14+
value,
15+
showAuto = true,
16+
}: RegionSelectProps) {
1217
const {
1318
data = [],
1419
fetchNextPage,
@@ -17,11 +22,15 @@ export function RegionSelect({ onValueChange, value }: RegionSelectProps) {
1722
} = useInfiniteQuery(useDataProvider().regionsQueryOptions());
1823

1924
const regions = [
20-
{
21-
label: <span>Automatic (Recommended)</span>,
22-
value: "auto",
23-
region: { id: "auto", name: "Automatic" },
24-
},
25+
...(showAuto
26+
? [
27+
{
28+
label: <span>Automatic (Recommended)</span>,
29+
value: "auto",
30+
region: { id: "auto", name: "Automatic" },
31+
},
32+
]
33+
: []),
2534
...data.map((region) => {
2635
return {
2736
label:

frontend/src/components/matchmaker/lobby-region.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export const REGION_ICON: Record<string, string | IconProp> = {
4848
gru: "🇧🇷", // Sao Paulo
4949
bom: "🇮🇳", // Mumbai
5050
sin: "🇸🇬", // Singapore
51+
"eu-central-1": "🇩🇪", // Frankfurt
52+
"us-east-1": "🇺🇸", // Northern Virginia
53+
"us-west-1": "🇺🇸", // Oregon
54+
"ap-southeast-1": "🇸🇬", // Singapore
5155
};
5256

5357
export const REGION_LABEL: Record<string, string> = {
@@ -96,6 +100,10 @@ export const REGION_LABEL: Record<string, string> = {
96100
gru: "Sao Paulo",
97101
bom: "Mumbai, India",
98102
sin: "Singapore",
103+
"eu-central-1": "Frankfurt, Germany",
104+
"us-east-1": "Northern Virginia, USA",
105+
"us-west-1": "Oregon, USA",
106+
"ap-southeast-1": "Singapore",
99107
};
100108

101109
export function getRegionKey(regionNameId: string | undefined) {

frontend/src/lib/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const redirectToOrganization = async (clerk: Clerk) => {
2020
const { data: orgs } = await clerk.user.getOrganizationMemberships();
2121

2222
if (orgs.length > 0) {
23+
await clerk.setActive({ organization: orgs[0].organization.id });
2324
throw redirect({
2425
to: "/orgs/$organization",
2526
params: { organization: orgs[0].organization.id },

frontend/src/routes/_context/_cloud/orgs.$organization.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ import { createOrganizationContext } from "@/app/data-providers/cloud-data-provi
44

55
export const Route = createFileRoute("/_context/_cloud/orgs/$organization")({
66
component: RouteComponent,
7-
beforeLoad: ({ context, params }) => {
8-
return match(context)
9-
.with({ __type: "cloud" }, (context) => ({
10-
dataProvider: {
11-
...context.dataProvider,
12-
...createOrganizationContext({
7+
beforeLoad: async ({ context, params }) => {
8+
return await match(context)
9+
.with({ __type: "cloud" }, async (context) => {
10+
await context.clerk.setActive({
11+
organization: params.organization,
12+
});
13+
return {
14+
dataProvider: {
1315
...context.dataProvider,
14-
organization: params.organization,
15-
}),
16-
},
17-
}))
16+
...createOrganizationContext({
17+
...context.dataProvider,
18+
organization: params.organization,
19+
}),
20+
},
21+
};
22+
})
1823
.otherwise(() => {
1924
throw new Error("Invalid context type for this route");
2025
});

frontend/src/routes/_context/_cloud/orgs.$organization/projects.$project/ns.$namespace/connect.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export const Route = createFileRoute(
4242
});
4343

4444
export function RouteComponent() {
45-
const { data: runnerNamesCount, isLoading } = useInfiniteQuery({
46-
...useEngineCompatDataProvider().runnerNamesQueryOptions(),
47-
select: (data) => data.pages[0].names?.length,
45+
const { data: runnerConfigsCount, isLoading } = useInfiniteQuery({
46+
...useEngineCompatDataProvider().runnerConfigsQueryOptions(),
47+
select: (data) => Object.values(data.pages[0].runnerConfigs).length,
4848
refetchInterval: 5000,
4949
});
5050

@@ -81,7 +81,7 @@ export function RouteComponent() {
8181
<Skeleton className="min-w-48 h-auto min-h-28 rounded-md" />
8282
</div>
8383
</div>
84-
) : runnerNamesCount === 0 ? (
84+
) : runnerConfigsCount === 0 ? (
8585
<div className="p-4 px-6 max-w-5xl">
8686
<H3>Add Provider</H3>
8787
<div className="grid grid-cols-3 gap-2 my-4">

0 commit comments

Comments
 (0)