mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
129 lines
3.4 KiB
TypeScript
129 lines
3.4 KiB
TypeScript
import {useMemo, useState} from 'react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import {AuthTokenGeneratorProvider} from 'sentry/components/onboarding/gettingStartedDoc/authTokenGenerator';
|
|
import type {OnboardingLayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/onboardingLayout';
|
|
import {Step, StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
|
|
import type {DocsParams} from 'sentry/components/onboarding/gettingStartedDoc/types';
|
|
import {useSourcePackageRegistries} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
|
|
import {useUrlPlatformOptions} from 'sentry/components/onboarding/platformOptionsControl';
|
|
import ReplayConfigToggle from 'sentry/components/replaysOnboarding/replayConfigToggle';
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
|
export function ReplayOnboardingLayout({
|
|
cdn,
|
|
docsConfig,
|
|
dsn,
|
|
platformKey,
|
|
projectId,
|
|
projectSlug,
|
|
newOrg,
|
|
configType = 'onboarding',
|
|
}: OnboardingLayoutProps) {
|
|
const organization = useOrganization();
|
|
const {isLoading: isLoadingRegistry, data: registryData} =
|
|
useSourcePackageRegistries(organization);
|
|
const selectedOptions = useUrlPlatformOptions(docsConfig.platformOptions);
|
|
const [mask, setMask] = useState(true);
|
|
const [block, setBlock] = useState(true);
|
|
const {steps} = useMemo(() => {
|
|
const doc = docsConfig[configType] ?? docsConfig.onboarding;
|
|
|
|
const docParams: DocsParams<any> = {
|
|
cdn,
|
|
dsn,
|
|
organization,
|
|
platformKey,
|
|
projectId,
|
|
projectSlug,
|
|
isPerformanceSelected: false,
|
|
isProfilingSelected: false,
|
|
isReplaySelected: true,
|
|
sourcePackageRegistries: {
|
|
isLoading: isLoadingRegistry,
|
|
data: registryData,
|
|
},
|
|
platformOptions: selectedOptions,
|
|
newOrg,
|
|
replayOptions: {
|
|
mask,
|
|
block,
|
|
},
|
|
};
|
|
|
|
return {
|
|
introduction: doc.introduction?.(docParams),
|
|
steps: [
|
|
...doc.install(docParams),
|
|
...doc.configure(docParams),
|
|
...doc.verify(docParams),
|
|
],
|
|
nextSteps: doc.nextSteps?.(docParams) || [],
|
|
};
|
|
}, [
|
|
cdn,
|
|
docsConfig,
|
|
dsn,
|
|
isLoadingRegistry,
|
|
newOrg,
|
|
organization,
|
|
platformKey,
|
|
projectId,
|
|
projectSlug,
|
|
registryData,
|
|
selectedOptions,
|
|
configType,
|
|
mask,
|
|
block,
|
|
]);
|
|
|
|
return (
|
|
<AuthTokenGeneratorProvider projectSlug={projectSlug}>
|
|
<Wrapper>
|
|
<Steps>
|
|
{steps.map(step =>
|
|
step.type === StepType.CONFIGURE ? (
|
|
<Step
|
|
key={step.title ?? step.type}
|
|
{...{
|
|
...step,
|
|
codeHeader: (
|
|
<ReplayConfigToggle
|
|
blockToggle={block}
|
|
maskToggle={mask}
|
|
onBlockToggle={() => setBlock(!block)}
|
|
onMaskToggle={() => setMask(!mask)}
|
|
/>
|
|
),
|
|
}}
|
|
/>
|
|
) : (
|
|
<Step key={step.title ?? step.type} {...step} />
|
|
)
|
|
)}
|
|
</Steps>
|
|
</Wrapper>
|
|
</AuthTokenGeneratorProvider>
|
|
);
|
|
}
|
|
|
|
const Steps = styled('div')`
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1.5rem;
|
|
`;
|
|
|
|
const Wrapper = styled('div')`
|
|
h4 {
|
|
margin-bottom: 0.5em;
|
|
}
|
|
&& {
|
|
p {
|
|
margin-bottom: 0;
|
|
}
|
|
h5 {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
`;
|