feat: start with data default option added (#30412)

This commit is contained in:
sneha122 2024-01-26 14:16:26 +05:30 committed by GitHub
parent 78ff390851
commit 4fb02bd07b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 93 additions and 42 deletions

View File

@ -15,7 +15,7 @@ import type { Middleware } from "redux";
export const handler = (action: ReduxAction<any>) => { export const handler = (action: ReduxAction<any>) => {
let appParams: ApplicationURLParams = {}; let appParams: ApplicationURLParams = {};
let pageParams: PageURLParams[] = []; let pageParams: PageURLParams[] = [];
switch (action.type) { switch (action?.type) {
case ReduxActionTypes.IMPORT_APPLICATION_SUCCESS: case ReduxActionTypes.IMPORT_APPLICATION_SUCCESS:
case ReduxActionTypes.IMPORT_TEMPLATE_TO_WORKSPACE_SUCCESS: case ReduxActionTypes.IMPORT_TEMPLATE_TO_WORKSPACE_SUCCESS:
case ReduxActionTypes.FETCH_APPLICATION_SUCCESS: { case ReduxActionTypes.FETCH_APPLICATION_SUCCESS: {

View File

@ -52,6 +52,7 @@ export const FEATURE_FLAG = {
"ab_flip_primary_secondary_ctas_dsform_enabled", "ab_flip_primary_secondary_ctas_dsform_enabled",
rollout_consolidated_page_load_fetch_enabled: rollout_consolidated_page_load_fetch_enabled:
"rollout_consolidated_page_load_fetch_enabled", "rollout_consolidated_page_load_fetch_enabled",
ab_start_with_data_default_enabled: "ab_start_with_data_default_enabled",
} as const; } as const;
export type FeatureFlag = keyof typeof FEATURE_FLAG; export type FeatureFlag = keyof typeof FEATURE_FLAG;
@ -94,6 +95,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = {
ab_appsmith_ai_query: false, ab_appsmith_ai_query: false,
ab_flip_primary_secondary_ctas_dsform_enabled: false, ab_flip_primary_secondary_ctas_dsform_enabled: false,
rollout_consolidated_page_load_fetch_enabled: false, rollout_consolidated_page_load_fetch_enabled: false,
ab_start_with_data_default_enabled: false,
}; };
export const AB_TESTING_EVENT_KEYS = { export const AB_TESTING_EVENT_KEYS = {

View File

@ -34,7 +34,7 @@ import { isEmpty } from "lodash";
import CreateNewDatasourceTab from "pages/Editor/IntegrationEditor/CreateNewDatasourceTab"; import CreateNewDatasourceTab from "pages/Editor/IntegrationEditor/CreateNewDatasourceTab";
import { getApplicationsOfWorkspace } from "@appsmith/selectors/selectedWorkspaceSelectors"; import { getApplicationsOfWorkspace } from "@appsmith/selectors/selectedWorkspaceSelectors";
import { TemplateView } from "pages/Templates/TemplateView"; import { TemplateView } from "pages/Templates/TemplateView";
import { default as React, useEffect, useState } from "react"; import { default as React, useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { import {
allTemplatesFiltersSelector, allTemplatesFiltersSelector,
@ -55,6 +55,8 @@ import DatasourceForm from "pages/Editor/SaaSEditor/DatasourceForm";
import type { Datasource } from "entities/Datasource"; import type { Datasource } from "entities/Datasource";
import { fetchingEnvironmentConfigs } from "@appsmith/actions/environmentAction"; import { fetchingEnvironmentConfigs } from "@appsmith/actions/environmentAction";
import StartWithTemplatesWrapper from "./StartWithTemplatesWrapper"; import StartWithTemplatesWrapper from "./StartWithTemplatesWrapper";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
const SectionWrapper = styled.div` const SectionWrapper = styled.div`
display: flex; display: flex;
@ -83,6 +85,10 @@ const BackWrapper = styled.div<{ hidden?: boolean }>`
${(props) => `${props.hidden && "visibility: hidden; opacity: 0;"}`} ${(props) => `${props.hidden && "visibility: hidden; opacity: 0;"}`}
`; `;
const LinkWrapper = styled(Link)<{ hidden?: boolean }>`
${(props) => `${props.hidden && "visibility: hidden; opacity: 0;"}`}
`;
const OptionWrapper = styled.div` const OptionWrapper = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
@ -190,6 +196,10 @@ const CreateNewAppsOption = ({
getDatasource(state, TEMP_DATASOURCE_ID || ""), getDatasource(state, TEMP_DATASOURCE_ID || ""),
); );
const isEnabledForStartWithDataDefault = useFeatureFlag(
FEATURE_FLAG.ab_start_with_data_default_enabled,
);
const dispatch = useDispatch(); const dispatch = useDispatch();
const onClickStartFromTemplate = () => { const onClickStartFromTemplate = () => {
AnalyticsUtil.logEvent("CREATE_APP_FROM_TEMPLATE"); AnalyticsUtil.logEvent("CREATE_APP_FROM_TEMPLATE");
@ -217,9 +227,12 @@ const CreateNewAppsOption = ({
}; };
const onClickStartWithData = () => { const onClickStartWithData = () => {
AnalyticsUtil.logEvent("CREATE_APP_FROM_DATA"); AnalyticsUtil.logEvent("CREATE_APP_FROM_DATA", {
[FEATURE_FLAG.ab_start_with_data_default_enabled]:
isEnabledForStartWithDataDefault,
});
// fetch plugins information to show list of all plugins // fetch plugins information to show list of all plugins
dispatch(fetchPlugins()); dispatch(fetchPlugins({ workspaceId: application?.workspaceId }));
dispatch(fetchMockDatasources()); dispatch(fetchMockDatasources());
if (application?.workspaceId) { if (application?.workspaceId) {
dispatch( dispatch(
@ -286,11 +299,19 @@ const CreateNewAppsOption = ({
if (createNewAppPluginId) { if (createNewAppPluginId) {
AnalyticsUtil.logEvent( AnalyticsUtil.logEvent(
"ONBOARDING_FLOW_CLICK_SKIP_BUTTON_DATASOURCE_FORM_PAGE", "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_DATASOURCE_FORM_PAGE",
{ pluginId: createNewAppPluginId }, {
pluginId: createNewAppPluginId,
[FEATURE_FLAG.ab_start_with_data_default_enabled]:
isEnabledForStartWithDataDefault,
},
); );
} else { } else {
AnalyticsUtil.logEvent( AnalyticsUtil.logEvent(
"ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_DATA_PAGE", "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_DATA_PAGE",
{
[FEATURE_FLAG.ab_start_with_data_default_enabled]:
isEnabledForStartWithDataDefault,
},
); );
} }
} }
@ -363,6 +384,38 @@ const CreateNewAppsOption = ({
} }
}; };
const renderStartWithData = useCallback(() => {
return (
<Flex flexDirection="column" pl="spaces-3" pr="spaces-3">
<Header
subtitle={createMessage(START_WITH_DATA_CONNECT_SUBHEADING)}
title={createMessage(START_WITH_DATA_CONNECT_HEADING)}
/>
<WithDataWrapper>
{createNewAppPluginId && !!selectedDatasource ? (
selectedPlugin?.type === PluginType.SAAS ? (
<DatasourceForm
datasourceId={TEMP_DATASOURCE_ID}
isOnboardingFlow
pageId={application?.defaultPageId || ""}
pluginPackageName={PluginPackageName.GOOGLE_SHEETS}
/>
) : (
<DataSourceEditor
applicationId={currentApplicationIdForCreateNewApp}
datasourceId={TEMP_DATASOURCE_ID}
isOnboardingFlow
pageId={application?.defaultPageId}
/>
)
) : (
<CreateNewDatasourceTab isOnboardingScreen />
)}
</WithDataWrapper>
</Flex>
);
}, [createNewAppPluginId, selectedDatasource, selectedPlugin]);
const selectionOptions: CardProps[] = [ const selectionOptions: CardProps[] = [
{ {
onClick: onClickStartWithData, onClick: onClickStartWithData,
@ -388,10 +441,7 @@ const CreateNewAppsOption = ({
]; ];
useEffect(() => { useEffect(() => {
AnalyticsUtil.logEvent("ONBOARDING_CREATE_APP_FLOW", { if (application) {
totalOptions: selectionOptions.length,
});
if (application)
urlBuilder.updateURLParams( urlBuilder.updateURLParams(
{ {
applicationSlug: application.slug, applicationSlug: application.slug,
@ -405,33 +455,51 @@ const CreateNewAppsOption = ({
})), })),
); );
if (isEnabledForStartWithDataDefault) {
onClickStartWithData();
}
}
}, [application]);
useEffect(() => {
AnalyticsUtil.logEvent("ONBOARDING_CREATE_APP_FLOW", {
totalOptions: selectionOptions.length,
});
return () => { return () => {
resetCreateNewAppFlow(); resetCreateNewAppFlow();
}; };
}, []); }, []);
const isBackButtonHidden =
isEnabledForStartWithDataDefault &&
(!createNewAppPluginId || !selectedDatasource);
return ( return (
<SectionWrapper> <SectionWrapper>
<BackWrapper hidden={!useType}> <BackWrapper hidden={!useType}>
<Link <LinkWrapper
className="t--create-new-app-option-goback" className="t--create-new-app-option-goback"
data-testid="t--create-new-app-option-goback" data-testid="t--create-new-app-option-goback"
hidden={isBackButtonHidden}
onClick={onClickBackButton} onClick={onClickBackButton}
startIcon="arrow-left-line" startIcon="arrow-left-line"
> >
{createMessage(GO_BACK)} {createMessage(GO_BACK)}
</Link> </LinkWrapper>
<Link <LinkWrapper
className="t--create-new-app-option-skip" className="t--create-new-app-option-skip"
data-testid="t--create-new-app-option-skip" data-testid="t--create-new-app-option-skip"
endIcon="arrow-right-line" endIcon="arrow-right-line"
onClick={onClickSkipButton} onClick={onClickSkipButton}
> >
{createMessage(SKIP_START_WITH_USE_CASE_TEMPLATES)} {createMessage(SKIP_START_WITH_USE_CASE_TEMPLATES)}
</Link> </LinkWrapper>
</BackWrapper> </BackWrapper>
{useType === START_WITH_TYPE.TEMPLATE ? ( {isEnabledForStartWithDataDefault ? (
renderStartWithData()
) : useType === START_WITH_TYPE.TEMPLATE ? (
selectedTemplate ? ( selectedTemplate ? (
<TemplateView <TemplateView
onClickUseTemplate={onClickUseTemplate} onClickUseTemplate={onClickUseTemplate}
@ -448,33 +516,7 @@ const CreateNewAppsOption = ({
/> />
) )
) : useType === START_WITH_TYPE.DATA ? ( ) : useType === START_WITH_TYPE.DATA ? (
<Flex flexDirection="column" pl="spaces-3" pr="spaces-3"> renderStartWithData()
<Header
subtitle={createMessage(START_WITH_DATA_CONNECT_SUBHEADING)}
title={createMessage(START_WITH_DATA_CONNECT_HEADING)}
/>
<WithDataWrapper>
{createNewAppPluginId && !!selectedDatasource ? (
selectedPlugin?.type === PluginType.SAAS ? (
<DatasourceForm
datasourceId={TEMP_DATASOURCE_ID}
isOnboardingFlow
pageId={application?.defaultPageId || ""}
pluginPackageName={PluginPackageName.GOOGLE_SHEETS}
/>
) : (
<DataSourceEditor
applicationId={currentApplicationIdForCreateNewApp}
datasourceId={TEMP_DATASOURCE_ID}
isOnboardingFlow
pageId={application?.defaultPageId}
/>
)
) : (
<CreateNewDatasourceTab />
)}
</WithDataWrapper>
</Flex>
) : ( ) : (
<OptionWrapper> <OptionWrapper>
<Text kind="heading-xl"> <Text kind="heading-xl">

View File

@ -138,6 +138,8 @@ export const SchemaStateMessageWrapper = styled.div`
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
position: relative; position: relative;
text-align: center;
padding: 0 var(--ads-spaces-3);
img { img {
padding-bottom: var(--ads-v2-spaces-7); padding-bottom: var(--ads-v2-spaces-7);
} }

View File

@ -127,6 +127,8 @@ function CreateNewDatasource({
active, active,
history, history,
isCreating, isCreating,
isOnboardingScreen,
pageId,
showMostPopularPlugins, showMostPopularPlugins,
showUnsupportedPluginDialog, showUnsupportedPluginDialog,
}: any) { }: any) {
@ -158,7 +160,7 @@ function CreateNewDatasource({
history={history} history={history}
isCreating={isCreating} isCreating={isCreating}
location={location} location={location}
parentEntityId={parentEntityId} parentEntityId={parentEntityId || (isOnboardingScreen && pageId) || ""}
parentEntityType={parentEntityType} parentEntityType={parentEntityType}
showMostPopularPlugins={showMostPopularPlugins} showMostPopularPlugins={showMostPopularPlugins}
showUnsupportedPluginDialog={showUnsupportedPluginDialog} showUnsupportedPluginDialog={showUnsupportedPluginDialog}
@ -239,6 +241,7 @@ interface CreateNewDatasourceScreenProps {
pageId: string; pageId: string;
isAppSidebarEnabled: boolean; isAppSidebarEnabled: boolean;
isEnabledForCreateNew: boolean; isEnabledForCreateNew: boolean;
isOnboardingScreen?: boolean;
} }
interface CreateNewDatasourceScreenState { interface CreateNewDatasourceScreenState {
@ -271,6 +274,7 @@ class CreateNewDatasourceTab extends React.Component<
isAppSidebarEnabled, isAppSidebarEnabled,
isCreating, isCreating,
isEnabledForCreateNew, isEnabledForCreateNew,
isOnboardingScreen,
pageId, pageId,
} = this.props; } = this.props;
if (!canCreateDatasource) return null; if (!canCreateDatasource) return null;
@ -301,6 +305,7 @@ class CreateNewDatasourceTab extends React.Component<
active={false} active={false}
history={history} history={history}
isCreating={isCreating} isCreating={isCreating}
isOnboardingScreen={!!isOnboardingScreen}
location={location} location={location}
pageId={pageId} pageId={pageId}
showMostPopularPlugins showMostPopularPlugins