import { useCreateEnvironment } from '../hooks/useCreateEnvironment'; import { useEnvironments } from '../hooks/useEnvironments'; import type { Environment } from '../lib/models'; import { Button } from './core/Button'; import classNames from 'classnames'; import { useActiveEnvironment } from '../hooks/useActiveEnvironment'; import { useAppRoutes } from '../hooks/useAppRoutes'; import { PairEditor } from './core/PairEditor'; import type { PairEditorProps } from './core/PairEditor'; import { useCallback, useMemo } from 'react'; import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment'; import { HStack, VStack } from './core/Stacks'; import { IconButton } from './core/IconButton'; import { useDeleteEnvironment } from '../hooks/useDeleteEnvironment'; import type { GenericCompletionConfig } from './core/Editor/genericCompletion'; export const EnvironmentEditDialog = function () { const routes = useAppRoutes(); const environments = useEnvironments(); const createEnvironment = useCreateEnvironment(); const activeEnvironment = useActiveEnvironment(); return (
{environments.map((e) => ( ))} {activeEnvironment != null && }
); }; const EnvironmentEditor = function ({ environment }: { environment: Environment }) { const environments = useEnvironments(); const updateEnvironment = useUpdateEnvironment(environment.id); const deleteEnvironment = useDeleteEnvironment(environment); const handleChange = useCallback( (variables) => { updateEnvironment.mutate({ variables }); }, [updateEnvironment], ); const nameAutocomplete = useMemo(() => { const otherVariableNames = environments.flatMap((e) => e.variables.map((v) => v.name)); const variableNames = otherVariableNames.filter( (name) => !environment.variables.some((v) => v.name === name), ); return { options: variableNames.map((name) => ({ label: name, type: 'constant' })) }; }, [environments, environment.variables]); return (

{environment.name}

deleteEnvironment.mutate()} />
); };