diff --git a/apps/fabro-web/app/components/automation-form.tsx b/apps/fabro-web/app/components/automation-form.tsx index b1a23149a..2a744d394 100644 --- a/apps/fabro-web/app/components/automation-form.tsx +++ b/apps/fabro-web/app/components/automation-form.tsx @@ -16,9 +16,9 @@ import { gitTarget, type GitRunTarget, } from "../lib/automation"; -import { isCloneBasedEnvironment, providerLabel } from "./environment-form"; import { Panel, Row } from "./settings-panel"; import { INPUT_CLASS } from "./ui"; +import { isCloneBasedEnvironment, providerLabel } from "../lib/environment-providers"; import { sandboxRuntime } from "../lib/run-sandbox-lifecycle"; export interface AutomationFormValues { diff --git a/apps/fabro-web/app/components/environment-form.tsx b/apps/fabro-web/app/components/environment-form.tsx index d61a2c035..bcb71baf5 100644 --- a/apps/fabro-web/app/components/environment-form.tsx +++ b/apps/fabro-web/app/components/environment-form.tsx @@ -15,6 +15,7 @@ import type { ReplaceEnvironmentRequest, } from "@qltysh/fabro-api-client"; +import { CREATABLE_PROVIDERS } from "../lib/environment-providers"; import { Label, Panel, Row } from "./settings-panel"; import { INPUT_CLASS } from "./ui"; import { @@ -24,24 +25,6 @@ import { type KeyValueEntry, } from "./key-value-editor"; -// Providers a managed environment can be created with. `local` is a reserved, -// in-memory environment, never a managed-environment provider, so it is never -// offered. The provider is fixed at creation time and cannot be changed. -export const CREATABLE_PROVIDERS = [ - EnvironmentProvider.DOCKER, - EnvironmentProvider.DAYTONA, -] as const; - -// Whether a server-managed environment can back Git-targeted work such as -// automations: only the clone-based (creatable) providers qualify. -export function isCloneBasedEnvironment(environment: Environment): boolean { - return (CREATABLE_PROVIDERS as readonly string[]).includes(environment.provider); -} - -export function providerLabel(provider: string): string { - return provider.charAt(0).toUpperCase() + provider.slice(1); -} - // Parse the `provider` query param used by the create flow into a creatable // provider, defaulting to Docker for anything unexpected. export function parseCreatableProvider(value: string | null): EnvironmentProvider { diff --git a/apps/fabro-web/app/lib/environment-providers.ts b/apps/fabro-web/app/lib/environment-providers.ts new file mode 100644 index 000000000..8002cf6a4 --- /dev/null +++ b/apps/fabro-web/app/lib/environment-providers.ts @@ -0,0 +1,19 @@ +import { EnvironmentProvider, type Environment } from "@qltysh/fabro-api-client"; + +// Providers a managed environment can be created with. `local` is a reserved, +// in-memory environment, never a managed-environment provider, so it is never +// offered. The provider is fixed at creation time and cannot be changed. +export const CREATABLE_PROVIDERS = [ + EnvironmentProvider.DOCKER, + EnvironmentProvider.DAYTONA, +] as const; + +// Whether a server-managed environment can back Git-targeted work such as +// automations: only the clone-based (creatable) providers qualify. +export function isCloneBasedEnvironment(environment: Environment): boolean { + return (CREATABLE_PROVIDERS as readonly string[]).includes(environment.provider); +} + +export function providerLabel(provider: string): string { + return provider.charAt(0).toUpperCase() + provider.slice(1); +} diff --git a/apps/fabro-web/app/routes/settings-environments.tsx b/apps/fabro-web/app/routes/settings-environments.tsx index 78132aef7..b3059ab52 100644 --- a/apps/fabro-web/app/routes/settings-environments.tsx +++ b/apps/fabro-web/app/routes/settings-environments.tsx @@ -9,7 +9,7 @@ import type { Environment } from "@qltysh/fabro-api-client"; import { ApiError, apiData, environmentsApi } from "../lib/api-client"; import { useEnvironments, useServerSettings } from "../lib/queries"; import { queryKeys } from "../lib/query-keys"; -import { CREATABLE_PROVIDERS, providerLabel } from "../components/environment-form"; +import { CREATABLE_PROVIDERS, providerLabel } from "../lib/environment-providers"; import { Badge, Muted,