diff --git a/frontend/src/component/onboarding/ConnectSdkDialog.tsx b/frontend/src/component/onboarding/ConnectSdkDialog.tsx index e530c06b87..dbee6486a8 100644 --- a/frontend/src/component/onboarding/ConnectSdkDialog.tsx +++ b/frontend/src/component/onboarding/ConnectSdkDialog.tsx @@ -121,6 +121,9 @@ export const ConnectSdkDialog = ({ sdk={sdk} apiKey={apiKey} feature={feature} + onSdkChange={() => { + setStage('select-sdk'); + }} /> ) : null} diff --git a/frontend/src/component/onboarding/SelectSdk.tsx b/frontend/src/component/onboarding/SelectSdk.tsx index d630a7a458..1f062a9af8 100644 --- a/frontend/src/component/onboarding/SelectSdk.tsx +++ b/frontend/src/component/onboarding/SelectSdk.tsx @@ -1,23 +1,8 @@ import { Avatar, Box, Link, styled, Typography } from '@mui/material'; import type { FC } from 'react'; -import android from 'assets/icons/sdks/Logo-android.svg'; -import dotnet from 'assets/icons/sdks/Logo-net.svg'; -import flutter from 'assets/icons/sdks/Logo-flutter.svg'; -import go from 'assets/icons/sdks/Logo-go.svg'; -import swift from 'assets/icons/sdks/Logo-swift.svg'; -import java from 'assets/icons/sdks/Logo-java.svg'; -import javascript from 'assets/icons/sdks/Logo-javascript.svg'; -import node from 'assets/icons/sdks/Logo-node.svg'; -import php from 'assets/icons/sdks/Logo-php.svg'; -import python from 'assets/icons/sdks/Logo-python.svg'; -import react from 'assets/icons/sdks/Logo-react.svg'; -import ruby from 'assets/icons/sdks/Logo-ruby.svg'; -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 { SectionHeader } from './SharedComponents'; -import type { ClientSdkName, Sdk, ServerSdkName } from './sharedTypes'; +import { clientSdks, type Sdk, serverSdks } from './sharedTypes'; const SpacedContainer = styled('div')(({ theme }) => ({ padding: theme.spacing(5, 8, 8, 8), @@ -67,27 +52,6 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({ boxShadow: theme.shadows[2], })); -export const serverSdks: { name: ServerSdkName; icon: string }[] = [ - { name: 'Node', icon: node }, - { name: 'Golang', icon: go }, - { name: 'Ruby', icon: ruby }, - { name: 'PHP', icon: php }, - { name: 'Rust', icon: rust }, - { name: 'DotNet', icon: dotnet }, - { name: 'Java', icon: java }, - { name: 'Python', icon: python }, -]; - -export const clientSdks: { name: ClientSdkName; icon: string }[] = [ - { name: 'Javascript', icon: javascript }, - { name: 'React', icon: react }, - { name: 'Vue', icon: vue }, - { name: 'Svelte', icon: svelte }, - { name: 'Swift', icon: swift }, - { name: 'Android', icon: android }, - { name: 'Flutter', icon: flutter }, -]; - interface ISelectSdkProps { onSelect: (sdk: Sdk) => void; } diff --git a/frontend/src/component/onboarding/TestSdkConnection.tsx b/frontend/src/component/onboarding/TestSdkConnection.tsx index 2a5a7b5ae4..849cdcf712 100644 --- a/frontend/src/component/onboarding/TestSdkConnection.tsx +++ b/frontend/src/component/onboarding/TestSdkConnection.tsx @@ -1,8 +1,16 @@ import type { FC } from 'react'; -import { Box, IconButton, styled, Tooltip, Typography } from '@mui/material'; +import { + Avatar, + Box, + IconButton, + Link, + styled, + Tooltip, + Typography, +} from '@mui/material'; import { SectionHeader } from './SharedComponents'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; -import type { Sdk } from './sharedTypes'; +import { allSdks, type Sdk } from './sharedTypes'; import { checkFlagCodeSnippets, initializeCodeSnippets, @@ -11,6 +19,7 @@ import { import copy from 'copy-to-clipboard'; import useToast from 'hooks/useToast'; import CopyIcon from '@mui/icons-material/FileCopy'; +import { formatAssetPath } from '../../utils/formatPath'; const SpacedContainer = styled('div')(({ theme }) => ({ padding: theme.spacing(5, 8, 8, 8), @@ -58,15 +67,26 @@ const CopyBlock: FC<{ title: string; code: string }> = ({ title, code }) => { ); }; +const ChangeSdk = styled('div')(({ theme }) => ({ + display: 'inline-flex', + gap: theme.spacing(3), + padding: theme.spacing(1, 2), + border: `1px solid ${theme.palette.divider}`, + borderRadius: theme.shape.borderRadius, + marginBottom: theme.spacing(3), +})); + interface ITestSdkConnectionProps { sdk: Sdk; apiKey: string; feature: string; + onSdkChange: () => void; } export const TestSdkConnection: FC = ({ sdk, apiKey, feature, + onSdkChange, }) => { const { uiConfig } = useUiConfig(); @@ -89,11 +109,24 @@ export const TestSdkConnection: FC = ({ '', feature, ); + const sdkIcon = allSdks.find((item) => item.name === sdk.name)?.icon; return ( Connect an SDK to Unleash + + {sdkIcon ? ( + + ) : null} + + Change SDK + + Setup the SDK

1. Install the SDK

diff --git a/frontend/src/component/onboarding/sharedTypes.ts b/frontend/src/component/onboarding/sharedTypes.ts index c1c5117bed..c853580a08 100644 --- a/frontend/src/component/onboarding/sharedTypes.ts +++ b/frontend/src/component/onboarding/sharedTypes.ts @@ -1,3 +1,19 @@ +import node from '../../assets/icons/sdks/Logo-node.svg'; +import go from '../../assets/icons/sdks/Logo-go.svg'; +import ruby from '../../assets/icons/sdks/Logo-ruby.svg'; +import php from '../../assets/icons/sdks/Logo-php.svg'; +import rust from '../../assets/icons/sdks/Logo-rust.svg'; +import dotnet from '../../assets/icons/sdks/Logo-net.svg'; +import java from '../../assets/icons/sdks/Logo-java.svg'; +import python from '../../assets/icons/sdks/Logo-python.svg'; +import javascript from '../../assets/icons/sdks/Logo-javascript.svg'; +import react from '../../assets/icons/sdks/Logo-react.svg'; +import vue from '../../assets/icons/sdks/Logo-vue.svg'; +import svelte from '../../assets/icons/sdks/Logo-svelte.svg'; +import swift from '../../assets/icons/sdks/Logo-swift.svg'; +import android from '../../assets/icons/sdks/Logo-android.svg'; +import flutter from '../../assets/icons/sdks/Logo-flutter.svg'; + export type SdkType = 'client' | 'frontend'; export type Sdk = { name: SdkName; type: SdkType }; export type ServerSdkName = @@ -18,3 +34,26 @@ export type ClientSdkName = | 'Android' | 'Flutter'; export type SdkName = ServerSdkName | ClientSdkName; + +export const serverSdks: { name: ServerSdkName; icon: string }[] = [ + { name: 'Node', icon: node }, + { name: 'Golang', icon: go }, + { name: 'Ruby', icon: ruby }, + { name: 'PHP', icon: php }, + { name: 'Rust', icon: rust }, + { name: 'DotNet', icon: dotnet }, + { name: 'Java', icon: java }, + { name: 'Python', icon: python }, +]; +export const clientSdks: { name: ClientSdkName; icon: string }[] = [ + { name: 'Javascript', icon: javascript }, + { name: 'React', icon: react }, + { name: 'Vue', icon: vue }, + { name: 'Svelte', icon: svelte }, + { name: 'Swift', icon: swift }, + { name: 'Android', icon: android }, + { name: 'Flutter', icon: flutter }, +]; + +export const allSdks: { name: ClientSdkName | ServerSdkName; icon: string }[] = + [...serverSdks, ...clientSdks]; diff --git a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectOnboarding/SdkExample.tsx b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectOnboarding/SdkExample.tsx index e7d41de738..da68efd621 100644 --- a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectOnboarding/SdkExample.tsx +++ b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectOnboarding/SdkExample.tsx @@ -2,7 +2,7 @@ import { type SelectChangeEvent, styled, Typography } from '@mui/material'; import { Link } from 'react-router-dom'; import Select from 'component/common/select'; import { useState } from 'react'; -import { clientSdks, serverSdks } from '../../../../onboarding/SelectSdk'; +import { allSdks } from '../../../../onboarding/sharedTypes'; const Container = styled('div')(({ theme }) => ({ display: 'flex', @@ -34,8 +34,6 @@ const StyledLink = styled(Link)({ }); export const SdkExample = () => { - const allSdks = [...serverSdks, ...clientSdks]; - const sdkOptions = allSdks.map((sdk) => ({ key: sdk.name, label: sdk.name,