mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
frontend: default to use case onboarding on console
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9253 Co-authored-by: Rishichandra Wawhal <27274869+wawhal@users.noreply.github.com> GitOrigin-RevId: 08a7905acfc17d84ffcbb0f84867a5d44a999805
This commit is contained in:
parent
81636e0a48
commit
ea3c640943
@ -54,5 +54,6 @@ export const WithoutSurvey: StoryObj = {
|
||||
onboardingDataEmptyActivity,
|
||||
fetchAnsweredSurveysHandler,
|
||||
],
|
||||
chromatic: { disableSnapshot: true },
|
||||
},
|
||||
};
|
||||
|
@ -93,11 +93,15 @@ describe('Check different configurations of Onboarding wizard depending on onboa
|
||||
);
|
||||
});
|
||||
|
||||
it('should show wizard as user activity is empty', async () => {
|
||||
it('should not show wizard', async () => {
|
||||
server.use(onboardingDataEmptyActivity);
|
||||
render(<Root />, { wrapper });
|
||||
|
||||
await screen.findByText('Welcome to your new Hasura project!');
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByText('Welcome to your new Hasura project!')
|
||||
).not.toBeInTheDocument()
|
||||
);
|
||||
});
|
||||
|
||||
it('should hide wizard as onboarding skipped by user', async () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React, { useEffect, useState, useMemo } from 'react';
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { Button } from '../../../../../new-components/Button';
|
||||
import { LS_KEYS, removeLSItem } from '../../../../../utils/localStorage';
|
||||
import { emitOnboardingEvent } from '../../utils';
|
||||
import {
|
||||
getUseCaseExperimentOnboardingVariables,
|
||||
@ -10,10 +9,7 @@ import { Analytics, trackCustomEvent } from '../../../../Analytics';
|
||||
import { Dispatch } from '../../../../../types';
|
||||
import _push from '../../../../../components/Services/Data/push';
|
||||
|
||||
type UseCaseScreenProps = {
|
||||
dismiss: () => void;
|
||||
dispatch: Dispatch;
|
||||
};
|
||||
type UseCaseScreenProps = { dismiss: () => void; dispatch: Dispatch };
|
||||
|
||||
export type UseCases =
|
||||
| 'data-api'
|
||||
@ -78,15 +74,16 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
||||
return useCasesAssets.sort(() => Math.random() - 0.5);
|
||||
}, [useCasesAssets]);
|
||||
|
||||
const onSubmit = () => {
|
||||
const useCase = useCasesAssets.filter(
|
||||
useCase => useCase.id === selectedUseCase
|
||||
)[0];
|
||||
const useCase = useCasesAssets.find(
|
||||
useCase => useCase.id === selectedUseCase
|
||||
);
|
||||
|
||||
removeLSItem(LS_KEYS.useCaseExperimentOnboarding);
|
||||
props.dispatch(_push(useCase.consoleUrl));
|
||||
window.open(useCase.docsUrl, '_blank', 'noreferrer,noopener');
|
||||
emitOnboardingEvent(getUseCaseExperimentOnboardingVariables(useCase.id));
|
||||
const onSubmit = () => {
|
||||
if (useCase) {
|
||||
props.dispatch(_push(useCase.consoleUrl));
|
||||
emitOnboardingEvent(getUseCaseExperimentOnboardingVariables(useCase.id));
|
||||
props.dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@ -117,7 +114,7 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
||||
</div>
|
||||
<div className="use-cases flex flex-wrap justify-around gap-y-15 gap-y-8">
|
||||
{randomUseCaseAssets.map((item, index) => (
|
||||
<div className="flex relative h-[250px]">
|
||||
<div className="flex relative h-[250px]" key={index}>
|
||||
<label
|
||||
key={index}
|
||||
htmlFor={item.id}
|
||||
@ -155,28 +152,33 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
||||
className="ml-xs mr-4 text-secondary flex items-center cursor-pointer"
|
||||
onClick={() => {
|
||||
props.dismiss();
|
||||
removeLSItem(LS_KEYS.useCaseExperimentOnboarding);
|
||||
emitOnboardingEvent(skippedUseCaseExperimentOnboarding);
|
||||
}}
|
||||
>
|
||||
Skip
|
||||
</div>
|
||||
</Analytics>
|
||||
<Analytics
|
||||
name={`use-case-onboarding-${selectedUseCase}`}
|
||||
passHtmlAttributesToChildren
|
||||
>
|
||||
<Button
|
||||
mode="primary"
|
||||
disabled={selectedUseCase === null}
|
||||
onClick={() => {
|
||||
props.dismiss();
|
||||
onSubmit();
|
||||
}}
|
||||
{useCase ? (
|
||||
<Analytics name={`use-case-onboarding-${selectedUseCase}`}>
|
||||
<a
|
||||
href={useCase.docsUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={onSubmit}
|
||||
>
|
||||
<Button mode="primary">Continue</Button>
|
||||
</a>
|
||||
</Analytics>
|
||||
) : (
|
||||
<Analytics
|
||||
name={`use-case-onboarding-unselected`}
|
||||
passHtmlAttributesToChildren
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</Analytics>
|
||||
<Button mode="primary" disabled>
|
||||
Continue
|
||||
</Button>
|
||||
</Analytics>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -90,11 +90,8 @@ export function getWizardState(
|
||||
// transform the onboarding data if present, to a consumable format
|
||||
const transformedOnboardingData = onboardingDataTransformFn(onboardingData);
|
||||
if (shouldShowOnboarding(transformedOnboardingData)) {
|
||||
if (getLSItem(LS_KEYS.useCaseExperimentOnboarding)) {
|
||||
return 'use-case-onboarding';
|
||||
}
|
||||
if (showFamiliaritySurvey) return 'familiarity-survey';
|
||||
return 'landing-page';
|
||||
return 'use-case-onboarding';
|
||||
}
|
||||
return 'hidden';
|
||||
}
|
||||
|
@ -125,7 +125,6 @@ export const LS_KEYS = {
|
||||
notificationsLastSeen: 'notifications:lastSeen',
|
||||
authState: 'AUTH_STATE',
|
||||
skipOnboarding: 'SKIP_CLOUD_ONBOARDING',
|
||||
useCaseExperimentOnboarding: 'onboarding:useCaseExperiment',
|
||||
showUseCaseOverviewPopup: 'onboarding:showUseCaseOverviewPopup',
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user