mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: Select sdk onboarding pt 1 (#8065)
This commit is contained in:
parent
9eb80a8d48
commit
3f24728693
@ -6,7 +6,9 @@ import {
|
|||||||
useMediaQuery,
|
useMediaQuery,
|
||||||
useTheme,
|
useTheme,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { GenrateApiKeyConcepts, GeneratApiKey } from './GenerateApiKey';
|
import { GenrateApiKeyConcepts, GenerateApiKey } from './GenerateApiKey';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { SelectSdk } from './SelectSdk';
|
||||||
|
|
||||||
interface IConnectSDKDialogProps {
|
interface IConnectSDKDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -53,7 +55,12 @@ const NextStepSectionSpacedContainer = styled('div')(({ theme }) => ({
|
|||||||
padding: theme.spacing(3, 8, 3, 8),
|
padding: theme.spacing(3, 8, 3, 8),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ConnectSDKDialog = ({
|
type OnboardingStage =
|
||||||
|
| { name: 'select-sdk' }
|
||||||
|
| { name: 'generate-api-key'; sdkType: 'CLIENT' | 'FRONTEND' }
|
||||||
|
| { name: 'test-connection' };
|
||||||
|
|
||||||
|
export const ConnectSdkDialog = ({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
environments,
|
environments,
|
||||||
@ -61,23 +68,31 @@ export const ConnectSDKDialog = ({
|
|||||||
}: IConnectSDKDialogProps) => {
|
}: IConnectSDKDialogProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isLargeScreen = useMediaQuery(theme.breakpoints.up('lg'));
|
const isLargeScreen = useMediaQuery(theme.breakpoints.up('lg'));
|
||||||
|
const [stage, setStage] = useState<OnboardingStage>({ name: 'select-sdk' });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDialog open={open} onClose={onClose}>
|
<StyledDialog open={open} onClose={onClose}>
|
||||||
<Box sx={{ display: 'flex' }}>
|
<Box sx={{ display: 'flex' }}>
|
||||||
<ConnectSdk>
|
<ConnectSdk>
|
||||||
<GeneratApiKey
|
{stage.name === 'select-sdk' ? <SelectSdk /> : null}
|
||||||
environments={environments}
|
{stage.name === 'generate-api-key' ? (
|
||||||
project={project}
|
<GenerateApiKey
|
||||||
/>
|
environments={environments}
|
||||||
<Navigation>
|
project={project}
|
||||||
<NextStepSectionSpacedContainer>
|
sdkType={stage.sdkType}
|
||||||
<Button variant='text' color='inherit'>
|
/>
|
||||||
Back
|
) : null}
|
||||||
</Button>
|
|
||||||
<Button variant='contained'>Next</Button>
|
{stage.name === 'generate-api-key' ? (
|
||||||
</NextStepSectionSpacedContainer>
|
<Navigation>
|
||||||
</Navigation>
|
<NextStepSectionSpacedContainer>
|
||||||
|
<Button variant='text' color='inherit'>
|
||||||
|
Back
|
||||||
|
</Button>
|
||||||
|
<Button variant='contained'>Next</Button>
|
||||||
|
</NextStepSectionSpacedContainer>
|
||||||
|
</Navigation>
|
||||||
|
) : null}
|
||||||
</ConnectSdk>
|
</ConnectSdk>
|
||||||
|
|
||||||
{isLargeScreen ? <GenrateApiKeyConcepts /> : null}
|
{isLargeScreen ? <GenrateApiKeyConcepts /> : null}
|
@ -260,15 +260,17 @@ export const GenrateApiKeyConcepts = () => (
|
|||||||
</ConceptsDefinitionsWrapper>
|
</ConceptsDefinitionsWrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
interface GeneratApiKeyProps {
|
interface GenerateApiKeyProps {
|
||||||
project: string;
|
project: string;
|
||||||
environments: string[];
|
environments: string[];
|
||||||
|
sdkType: 'CLIENT' | 'FRONTEND';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GeneratApiKey = ({
|
export const GenerateApiKey = ({
|
||||||
environments,
|
environments,
|
||||||
project,
|
project,
|
||||||
}: GeneratApiKeyProps) => {
|
sdkType,
|
||||||
|
}: GenerateApiKeyProps) => {
|
||||||
const [environment, setEnvironment] = useState('');
|
const [environment, setEnvironment] = useState('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -291,7 +293,7 @@ export const GeneratApiKey = ({
|
|||||||
await createToken(
|
await createToken(
|
||||||
{
|
{
|
||||||
environment,
|
environment,
|
||||||
type: 'CLIENT',
|
type: sdkType,
|
||||||
projects: [project],
|
projects: [project],
|
||||||
username: `api-key-${project}-${environment}`,
|
username: `api-key-${project}-${environment}`,
|
||||||
},
|
},
|
||||||
|
27
frontend/src/component/onboarding/SelectSdk.tsx
Normal file
27
frontend/src/component/onboarding/SelectSdk.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { Box, styled, Typography } from '@mui/material';
|
||||||
|
|
||||||
|
const SpacedContainer = styled('div')(({ theme }) => ({
|
||||||
|
padding: theme.spacing(5, 8, 3, 8),
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: theme.spacing(3),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const SectionHeader = styled('div')(({ theme }) => ({
|
||||||
|
fontWeight: theme.fontWeight.bold,
|
||||||
|
marginBottom: theme.spacing(1),
|
||||||
|
fontSize: theme.fontSizes.bodySize,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const SelectSdk = () => {
|
||||||
|
return (
|
||||||
|
<SpacedContainer>
|
||||||
|
<Typography variant='h2'>Connect an SDK to Unleash</Typography>
|
||||||
|
<Box sx={{ mt: 4 }}>
|
||||||
|
<SectionHeader>Select SDK</SectionHeader>
|
||||||
|
</Box>
|
||||||
|
</SpacedContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SelectSdkConcepts = () => {};
|
@ -42,7 +42,7 @@ import { AvatarCell } from './AvatarCell';
|
|||||||
import { ProjectOnboarding } from './ProjectOnboarding/ProjectOnboarding';
|
import { ProjectOnboarding } from './ProjectOnboarding/ProjectOnboarding';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import { ConnectSDKDialog } from '../../../onboarding/ConnectSDKDialog';
|
import { ConnectSdkDialog } from '../../../onboarding/ConnectSdkDialog';
|
||||||
|
|
||||||
interface IPaginatedProjectFeatureTogglesProps {
|
interface IPaginatedProjectFeatureTogglesProps {
|
||||||
environments: string[];
|
environments: string[];
|
||||||
@ -491,7 +491,7 @@ export const ProjectFeatureToggles = ({
|
|||||||
|
|
||||||
{featureToggleModals}
|
{featureToggleModals}
|
||||||
|
|
||||||
<ConnectSDKDialog
|
<ConnectSdkDialog
|
||||||
open={false}
|
open={false}
|
||||||
onClose={() => {}}
|
onClose={() => {}}
|
||||||
project={projectId}
|
project={projectId}
|
||||||
|
Loading…
Reference in New Issue
Block a user