Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sdk snippets in test connection phase #8082

Merged
merged 10 commits into from
Sep 4, 2024
17 changes: 14 additions & 3 deletions frontend/src/component/onboarding/ConnectSdkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ import {
} from '@mui/material';
import { GenerateApiKey } from './GenerateApiKey';
import { useEffect, useState } from 'react';
import { type Sdk, SelectSdk } from './SelectSdk';
import { GenrateApiKeyConcepts, SelectSdkConcepts } from './UnleashConcepts';
import { SelectSdk } from './SelectSdk';
import {
ConceptsDefinitionsWrapper,
GenrateApiKeyConcepts,
SelectSdkConcepts,
} from './UnleashConcepts';
import { TestSdkConnection } from './TestSdkConnection';
import type { Sdk } from './SharedComponents';

interface IConnectSDKDialogProps {
open: boolean;
Expand Down Expand Up @@ -107,7 +113,9 @@ export const ConnectSdkDialog = ({
}}
/>
) : null}
{isTestConnectionStage ? <div>Last stage</div> : null}
{isTestConnectionStage ? (
<TestSdkConnection sdk={sdk} apiKey={apiKey} />
) : null}

{stage === 'generate-api-key' ? (
<Navigation>
Expand Down Expand Up @@ -163,6 +171,9 @@ export const ConnectSdkDialog = ({
{isLargeScreen && isGenerateApiKeyStage ? (
<GenrateApiKeyConcepts />
) : null}
{isLargeScreen && isTestConnectionStage ? (
<ConceptsDefinitionsWrapper />
) : null}
</Box>
</StyledDialog>
);
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/component/onboarding/GenerateApiKey.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useProjectApiTokens } from '../../hooks/api/getters/useProjectApiTokens/useProjectApiTokens';
import useProjectApiTokensApi from '../../hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi';
import { useProjectApiTokens } from 'hooks/api/getters/useProjectApiTokens/useProjectApiTokens';
import useProjectApiTokensApi from 'hooks/api/actions/useProjectApiTokensApi/useProjectApiTokensApi';
import { parseToken } from './parseToken';
import useToast from '../../hooks/useToast';
import { formatUnknownError } from '../../utils/formatUnknownError';
import useToast from 'hooks/useToast';
import { formatUnknownError } from 'utils/formatUnknownError';
import {
Box,
Button,
Expand All @@ -15,6 +15,7 @@ import { SingleSelectConfigButton } from '../common/DialogFormTemplate/ConfigBut
import EnvironmentsIcon from '@mui/icons-material/CloudCircle';
import { ArcherContainer, ArcherElement } from 'react-archer';
import { useEffect } from 'react';
import { SectionHeader } from './SharedComponents';

const ChooseEnvironment = ({
environments,
Expand Down Expand Up @@ -79,12 +80,6 @@ const TokenExplanationBox = styled(Box)(({ theme }) => ({
flexWrap: 'wrap',
}));

const SectionHeader = styled('div')(({ theme }) => ({
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(1),
fontSize: theme.typography.body1.fontSize,
}));

const SectionDescription = styled('p')(({ theme }) => ({
color: theme.palette.text.secondary,
fontSize: theme.typography.body2.fontSize,
Expand Down
22 changes: 9 additions & 13 deletions frontend/src/component/onboarding/SelectSdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import rust from 'assets/icons/sdks/Logo-rust.svg';
import svelte from 'assets/icons/sdks/Logo-svelte.svg';
import vue from 'assets/icons/sdks/Logo-vue.svg';
import { formatAssetPath } from 'utils/formatPath';
import {
type ClientSdkName,
type Sdk,
SectionHeader,
type ServerSdkName,
} from './SharedComponents';

const SpacedContainer = styled('div')(({ theme }) => ({
padding: theme.spacing(5, 8, 8, 8),
Expand All @@ -24,12 +30,6 @@ const SpacedContainer = styled('div')(({ theme }) => ({
gap: theme.spacing(3),
}));

const PrimarySectionHeader = styled('div')(({ theme }) => ({
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(1),
fontSize: theme.typography.body1.fontSize,
}));

const SecondarySectionHeader = styled('div')(({ theme }) => ({
marginTop: theme.spacing(4),
marginBottom: theme.spacing(2),
Expand Down Expand Up @@ -71,7 +71,7 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({
boxShadow: theme.shadows[2],
}));

const serverSdks = [
const serverSdks: { name: ServerSdkName; icon: string }[] = [
{ name: 'Node', icon: node },
{ name: 'Golang', icon: go },
{ name: 'Ruby', icon: ruby },
Expand All @@ -82,7 +82,7 @@ const serverSdks = [
{ name: 'Python', icon: python },
];

const clientSdks = [
const clientSdks: { name: ClientSdkName; icon: string }[] = [
{ name: 'Javascript', icon: javascript },
{ name: 'React', icon: react },
{ name: 'Vue', icon: vue },
Expand All @@ -92,8 +92,6 @@ const clientSdks = [
{ name: 'Flutter', icon: flutter },
];

type SdkType = 'client' | 'frontend';
export type Sdk = { name: string; type: SdkType };
interface ISelectSdkProps {
onSelect: (sdk: Sdk) => void;
}
Expand All @@ -102,7 +100,7 @@ export const SelectSdk: FC<ISelectSdkProps> = ({ onSelect }) => {
<SpacedContainer>
<Typography variant='h2'>Connect an SDK to Unleash</Typography>
<Box sx={{ mt: 4 }}>
<PrimarySectionHeader>Select SDK</PrimarySectionHeader>
<SectionHeader>Select SDK</SectionHeader>
<SecondarySectionHeader>
Server side SDKs
</SecondarySectionHeader>
Expand Down Expand Up @@ -155,5 +153,3 @@ export const SelectSdk: FC<ISelectSdkProps> = ({ onSelect }) => {
</SpacedContainer>
);
};

export const SelectSdkConcepts = () => {};
29 changes: 29 additions & 0 deletions frontend/src/component/onboarding/SharedComponents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { styled } from '@mui/material';

export type SdkType = 'client' | 'frontend';
export type Sdk = { name: SdkName; type: SdkType };

export const SectionHeader = styled('div')(({ theme }) => ({
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(1),
fontSize: theme.typography.body1.fontSize,
}));

export type ServerSdkName =
| 'Node'
| 'Golang'
| 'Ruby'
| 'PHP'
| 'Rust'
| 'DotNet'
| 'Java'
| 'Python';
export type ClientSdkName =
| 'Javascript'
| 'React'
| 'Vue'
| 'Svelte'
| 'Swift'
| 'Android'
| 'Flutter';
export type SdkName = ServerSdkName | ClientSdkName;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added for extra type safety to avoid typos in other places

Loading
Loading