mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +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,
|
onboardingDataEmptyActivity,
|
||||||
fetchAnsweredSurveysHandler,
|
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);
|
server.use(onboardingDataEmptyActivity);
|
||||||
render(<Root />, { wrapper });
|
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 () => {
|
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 { Button } from '../../../../../new-components/Button';
|
||||||
import { LS_KEYS, removeLSItem } from '../../../../../utils/localStorage';
|
|
||||||
import { emitOnboardingEvent } from '../../utils';
|
import { emitOnboardingEvent } from '../../utils';
|
||||||
import {
|
import {
|
||||||
getUseCaseExperimentOnboardingVariables,
|
getUseCaseExperimentOnboardingVariables,
|
||||||
@ -10,10 +9,7 @@ import { Analytics, trackCustomEvent } from '../../../../Analytics';
|
|||||||
import { Dispatch } from '../../../../../types';
|
import { Dispatch } from '../../../../../types';
|
||||||
import _push from '../../../../../components/Services/Data/push';
|
import _push from '../../../../../components/Services/Data/push';
|
||||||
|
|
||||||
type UseCaseScreenProps = {
|
type UseCaseScreenProps = { dismiss: () => void; dispatch: Dispatch };
|
||||||
dismiss: () => void;
|
|
||||||
dispatch: Dispatch;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type UseCases =
|
export type UseCases =
|
||||||
| 'data-api'
|
| 'data-api'
|
||||||
@ -78,15 +74,16 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
|||||||
return useCasesAssets.sort(() => Math.random() - 0.5);
|
return useCasesAssets.sort(() => Math.random() - 0.5);
|
||||||
}, [useCasesAssets]);
|
}, [useCasesAssets]);
|
||||||
|
|
||||||
const onSubmit = () => {
|
const useCase = useCasesAssets.find(
|
||||||
const useCase = useCasesAssets.filter(
|
useCase => useCase.id === selectedUseCase
|
||||||
useCase => useCase.id === selectedUseCase
|
);
|
||||||
)[0];
|
|
||||||
|
|
||||||
removeLSItem(LS_KEYS.useCaseExperimentOnboarding);
|
const onSubmit = () => {
|
||||||
props.dispatch(_push(useCase.consoleUrl));
|
if (useCase) {
|
||||||
window.open(useCase.docsUrl, '_blank', 'noreferrer,noopener');
|
props.dispatch(_push(useCase.consoleUrl));
|
||||||
emitOnboardingEvent(getUseCaseExperimentOnboardingVariables(useCase.id));
|
emitOnboardingEvent(getUseCaseExperimentOnboardingVariables(useCase.id));
|
||||||
|
props.dismiss();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -117,7 +114,7 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="use-cases flex flex-wrap justify-around gap-y-15 gap-y-8">
|
<div className="use-cases flex flex-wrap justify-around gap-y-15 gap-y-8">
|
||||||
{randomUseCaseAssets.map((item, index) => (
|
{randomUseCaseAssets.map((item, index) => (
|
||||||
<div className="flex relative h-[250px]">
|
<div className="flex relative h-[250px]" key={index}>
|
||||||
<label
|
<label
|
||||||
key={index}
|
key={index}
|
||||||
htmlFor={item.id}
|
htmlFor={item.id}
|
||||||
@ -155,28 +152,33 @@ export const UseCaseScreen = (props: UseCaseScreenProps) => {
|
|||||||
className="ml-xs mr-4 text-secondary flex items-center cursor-pointer"
|
className="ml-xs mr-4 text-secondary flex items-center cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
props.dismiss();
|
props.dismiss();
|
||||||
removeLSItem(LS_KEYS.useCaseExperimentOnboarding);
|
|
||||||
emitOnboardingEvent(skippedUseCaseExperimentOnboarding);
|
emitOnboardingEvent(skippedUseCaseExperimentOnboarding);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Skip
|
Skip
|
||||||
</div>
|
</div>
|
||||||
</Analytics>
|
</Analytics>
|
||||||
<Analytics
|
{useCase ? (
|
||||||
name={`use-case-onboarding-${selectedUseCase}`}
|
<Analytics name={`use-case-onboarding-${selectedUseCase}`}>
|
||||||
passHtmlAttributesToChildren
|
<a
|
||||||
>
|
href={useCase.docsUrl}
|
||||||
<Button
|
target="_blank"
|
||||||
mode="primary"
|
rel="noopener noreferrer"
|
||||||
disabled={selectedUseCase === null}
|
onClick={onSubmit}
|
||||||
onClick={() => {
|
>
|
||||||
props.dismiss();
|
<Button mode="primary">Continue</Button>
|
||||||
onSubmit();
|
</a>
|
||||||
}}
|
</Analytics>
|
||||||
|
) : (
|
||||||
|
<Analytics
|
||||||
|
name={`use-case-onboarding-unselected`}
|
||||||
|
passHtmlAttributesToChildren
|
||||||
>
|
>
|
||||||
Continue
|
<Button mode="primary" disabled>
|
||||||
</Button>
|
Continue
|
||||||
</Analytics>
|
</Button>
|
||||||
|
</Analytics>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -90,11 +90,8 @@ export function getWizardState(
|
|||||||
// transform the onboarding data if present, to a consumable format
|
// transform the onboarding data if present, to a consumable format
|
||||||
const transformedOnboardingData = onboardingDataTransformFn(onboardingData);
|
const transformedOnboardingData = onboardingDataTransformFn(onboardingData);
|
||||||
if (shouldShowOnboarding(transformedOnboardingData)) {
|
if (shouldShowOnboarding(transformedOnboardingData)) {
|
||||||
if (getLSItem(LS_KEYS.useCaseExperimentOnboarding)) {
|
|
||||||
return 'use-case-onboarding';
|
|
||||||
}
|
|
||||||
if (showFamiliaritySurvey) return 'familiarity-survey';
|
if (showFamiliaritySurvey) return 'familiarity-survey';
|
||||||
return 'landing-page';
|
return 'use-case-onboarding';
|
||||||
}
|
}
|
||||||
return 'hidden';
|
return 'hidden';
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,6 @@ export const LS_KEYS = {
|
|||||||
notificationsLastSeen: 'notifications:lastSeen',
|
notificationsLastSeen: 'notifications:lastSeen',
|
||||||
authState: 'AUTH_STATE',
|
authState: 'AUTH_STATE',
|
||||||
skipOnboarding: 'SKIP_CLOUD_ONBOARDING',
|
skipOnboarding: 'SKIP_CLOUD_ONBOARDING',
|
||||||
useCaseExperimentOnboarding: 'onboarding:useCaseExperiment',
|
|
||||||
showUseCaseOverviewPopup: 'onboarding:showUseCaseOverviewPopup',
|
showUseCaseOverviewPopup: 'onboarding:showUseCaseOverviewPopup',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user