console: update root component for onboarding to have cloud console check

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6093
GitOrigin-RevId: ba8ba274d4a7da7745926cefa63fab2989dfaba0
This commit is contained in:
Abhijeet Khangarot 2022-09-29 08:48:41 +05:30 committed by hasura-bot
parent d32dc881e3
commit 0a72b8edd0
3 changed files with 17 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import React from 'react';
import { ComponentMeta, Story } from '@storybook/react';
import { ReactQueryDecorator } from '@/storybook/decorators/react-query';
import { useQueryClient } from 'react-query';
import { Root } from './Root';
import { RootWithCloudCheck as Root } from './Root';
import {
baseHandlers,
fetchAnsweredSurveysHandler,

View File

@ -1,5 +1,7 @@
import React from 'react';
import * as Dialog from '@radix-ui/react-dialog';
import globals from '@/Globals';
import { isCloudConsole } from '@/utils/cloudConsole';
import { TopHeaderBar, ConnectDBScreen } from './components';
import { useWizardState } from './hooks';
import { GrowthExperimentsClient } from '../GrowthExperiments';
@ -12,7 +14,7 @@ type Props = {
/**
* Parent container for the onboarding wizard. Takes care of assembling and rendering all steps.
*/
export function Root(props: Props) {
function Root(props: Props) {
const { growthExperimentsClient } = props;
// dialog cannot be reopened once closed
@ -56,3 +58,14 @@ export function Root(props: Props) {
</Dialog.Root>
);
}
export function RootWithCloudCheck(props: Props) {
/*
* Don't render Root component if current context is not cloud-console
* and current user is not project owner
*/
if (isCloudConsole(globals)) {
return null;
}
return <Root {...props} />;
}

View File

@ -1,3 +1,3 @@
import { Root } from './Root';
import { RootWithCloudCheck } from './Root';
export const OnboardingWizard = Root;
export const OnboardingWizard = RootWithCloudCheck;