diff --git a/packages/ui/app/src/api-page/endpoints/EndpointContentCodeSnippets.tsx b/packages/ui/app/src/api-page/endpoints/EndpointContentCodeSnippets.tsx index 25ffa24491..a00ec4e027 100644 --- a/packages/ui/app/src/api-page/endpoints/EndpointContentCodeSnippets.tsx +++ b/packages/ui/app/src/api-page/endpoints/EndpointContentCodeSnippets.tsx @@ -1,6 +1,5 @@ import type { APIV1Read } from "@fern-api/fdr-sdk/client/types"; import * as FernNavigation from "@fern-api/fdr-sdk/navigation"; -import { EnvironmentId } from "@fern-api/fdr-sdk/navigation"; import { FernButton, FernButtonGroup, FernScrollArea } from "@fern-ui/components"; import { EMPTY_OBJECT, visitDiscriminatedUnion } from "@fern-ui/core-utils"; import { useResizeObserver } from "@fern-ui/react-commons"; @@ -10,7 +9,6 @@ import { useNavigationNodes } from "../../atoms"; import { useSelectedEnvironmentId } from "../../atoms/environment"; import { StatusCodeTag, statusCodeToIntent } from "../../commons/StatusCodeTag"; import { FernErrorTag } from "../../components/FernErrorBoundary"; -import { usePlaygroundSettings } from "../../hooks/usePlaygroundSettings"; import { mergeEndpointSchemaWithExample } from "../../resolver/SchemaWithExample"; import { ResolvedEndpointDefinition, @@ -130,7 +128,6 @@ const UnmemoizedEndpointContentCodeSnippets: React.FC @@ -168,15 +165,12 @@ const UnmemoizedEndpointContentCodeSnippets: React.FC - {node != null && - (!environmentFilters || - (environmentFilters && - environmentFilters.includes(selectedEnvironmentId as EnvironmentId))) && ( - - )} + {node != null && ( + + )} {clients.length > 1 ? ( = ({ websocket, isLastInApi, types }) const maybeNode = nodes.get(websocket.nodeId); const node = maybeNode != null && FernNavigation.isApiLeaf(maybeNode) ? maybeNode : undefined; - const environmentFilters = usePlaygroundSettings(maybeNode?.id); - const route = `/${websocket.slug}`; const ref = useRef(null); @@ -314,17 +310,7 @@ const WebhookContent: FC = ({ websocket, isLastInApi, types })
- ) : undefined - } + actions={node != null ? : undefined} disableClipboard={true} > diff --git a/packages/ui/app/src/api-playground/PlaygroundButton.tsx b/packages/ui/app/src/api-playground/PlaygroundButton.tsx index 31381f1959..74458744e6 100644 --- a/packages/ui/app/src/api-playground/PlaygroundButton.tsx +++ b/packages/ui/app/src/api-playground/PlaygroundButton.tsx @@ -5,7 +5,9 @@ import { useAtomValue } from "jotai"; import { FC } from "react"; import { HAS_PLAYGROUND_ATOM, useSetAndOpenPlayground } from "../atoms"; -export const PlaygroundButton: FC<{ state: FernNavigation.NavigationNodeApiLeaf }> = ({ state }) => { +export const PlaygroundButton: FC<{ + state: FernNavigation.NavigationNodeApiLeaf; +}> = ({ state }) => { const openPlayground = useSetAndOpenPlayground(); const hasPlayground = useAtomValue(HAS_PLAYGROUND_ATOM); diff --git a/packages/ui/app/src/atoms/playground.ts b/packages/ui/app/src/atoms/playground.ts index 33b914d32f..739efda4f9 100644 --- a/packages/ui/app/src/atoms/playground.ts +++ b/packages/ui/app/src/atoms/playground.ts @@ -279,6 +279,7 @@ export function useSetAndOpenPlayground(): (node: FernNavigation.NavigationNodeA captureMessage("Could not find endpoint for API playground selection state", "fatal"); return; } + set( formStateAtom, getInitialEndpointRequestFormStateWithExample(endpoint, endpoint.examples[0], apiPackage.types), diff --git a/packages/ui/app/src/components/MaybeEnvironmentDropdown.tsx b/packages/ui/app/src/components/MaybeEnvironmentDropdown.tsx index c482e50902..9db7e39e6c 100644 --- a/packages/ui/app/src/components/MaybeEnvironmentDropdown.tsx +++ b/packages/ui/app/src/components/MaybeEnvironmentDropdown.tsx @@ -17,9 +17,15 @@ export function MaybeEnvironmentDropdown(props: MaybeEnvironmentDropdownProps): const [selectedEnvironmentId, setSelectedEnvironmentId] = useAtom(SELECTED_ENVIRONMENT_ATOM); const { selectedEnvironment, urlTextStyle, protocolTextStyle, small, environmentFilters } = props; - const url = selectedEnvironment?.baseUrl && parse(selectedEnvironment?.baseUrl); - const environmentIds = environmentFilters ? environmentFilters : allEnvironmentIds; + const environmentIds = environmentFilters + ? environmentFilters.filter((environmentFilter) => allEnvironmentIds.includes(environmentFilter)) + : allEnvironmentIds; + + if (environmentFilters && selectedEnvironment && !environmentFilters.includes(selectedEnvironment.id)) { + setSelectedEnvironmentId(environmentIds[0]); + } + const url = selectedEnvironment?.baseUrl && parse(selectedEnvironment?.baseUrl); return (