mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-08 22:21:45 +00:00
Move environment provider helpers into a lib module
Importing them from the environment form component pulled headlessui Disclosure into the automation form, which the automations-new test mocks without it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
88dae80c6d
commit
7c261f2ae6
4 changed files with 22 additions and 20 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
19
apps/fabro-web/app/lib/environment-providers.ts
Normal file
19
apps/fabro-web/app/lib/environment-providers.ts
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue