Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/components/sdkOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import {serverContext} from 'sentry-docs/serverContext';
import {PlatformCategory} from 'sentry-docs/types';

import {PlatformCategorySection} from './platformCategorySection';

Check failure on line 5 in src/components/sdkOption.tsx

View workflow job for this annotation

GitHub Actions / Lint

'PlatformCategorySection' is declared but its value is never read.
import {PlatformSection} from './platformSection';

Check failure on line 6 in src/components/sdkOption.tsx

View workflow job for this annotation

GitHub Actions / Lint

'PlatformSection' is declared but its value is never read.
import {SdkDefinition, SdkDefinitionTable} from './sdkDefinition';

type Props = {
Expand All @@ -28,6 +28,21 @@
categorySupported = [],
}: Props) {
const {showBrowserOnly, showServerLikeOnly} = getPlatformHints(categorySupported);
const {rootNode, path} = serverContext();
const currentPlatformOrGuide = getCurrentPlatformOrGuide(rootNode, path);
const shouldShowEnvVar = () => {
if (!currentPlatformOrGuide) return false;

const isServerPlatform =
currentPlatformOrGuide.categories?.includes('server') ||
currentPlatformOrGuide.categories?.includes('serverless');

const isExcludedPlatform =
currentPlatformOrGuide.key === 'javascript.nextjs' ||
currentPlatformOrGuide.key === 'javascript.svelte';

return isServerPlatform && !isExcludedPlatform;
};

return (
<SdkDefinition name={name} categorySupported={categorySupported}>
Expand All @@ -39,11 +54,10 @@
{defaultValue && (
<OptionDefRow label="Default" value={defaultValue} note={defaultNote} />
)}
<PlatformCategorySection supported={['server', 'serverless']}>
<PlatformSection notSupported={['javascript.nextjs', 'javascript.sveltekit']}>
{envVar && <OptionDefRow label="ENV Variable" value={envVar} />}
</PlatformSection>
</PlatformCategorySection>

{shouldShowEnvVar() && envVar && (
<OptionDefRow label="ENV Variable" value={envVar} />
)}

{showBrowserOnly && <OptionDefRow label="Only available on" value="Client" />}
{showServerLikeOnly && <OptionDefRow label="Only available on" value="Server" />}
Expand Down
Loading