From 4266aa397380e59b0db20b66e48ebe1195a9c688 Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Sun, 4 Feb 2024 22:15:49 +0530 Subject: [PATCH 01/38] Add "Start with template" option in workspace action menu --- app/client/src/ce/constants/messages.ts | 1 + .../ce/pages/Applications/WorkspaceAction.tsx | 13 +++++ .../src/ce/pages/Applications/index.tsx | 48 +++++++++++++------ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/app/client/src/ce/constants/messages.ts b/app/client/src/ce/constants/messages.ts index 11584ab9312..cd59c1afde9 100644 --- a/app/client/src/ce/constants/messages.ts +++ b/app/client/src/ce/constants/messages.ts @@ -266,6 +266,7 @@ export const JOIN_OUR_DISCORD = () => `Join our discord`; export const WHATS_NEW = () => `What's new?`; export const WORKSPACE_ACTION_BUTTON = () => "Create New"; export const NEW_APP = () => "New app"; +export const NEW_APP_FROM_TEMPLATE = () => "Start with template"; export const NO_WORKSPACE_HEADING = () => "Oops! No workspace found"; export const NO_WORKSPACE_DESCRIPTION = () => "You can find workspace list on the left sidebar, try selecting one of them to access a workspace."; diff --git a/app/client/src/ce/pages/Applications/WorkspaceAction.tsx b/app/client/src/ce/pages/Applications/WorkspaceAction.tsx index 54f06b65d7c..4b2ac62c69b 100644 --- a/app/client/src/ce/pages/Applications/WorkspaceAction.tsx +++ b/app/client/src/ce/pages/Applications/WorkspaceAction.tsx @@ -13,6 +13,7 @@ import { getIsCreatingApplicationByWorkspaceId } from "@appsmith/selectors/appli import { hasCreateNewAppPermission } from "@appsmith/utils/permissionHelpers"; import { IMPORT_BTN_LABEL, + NEW_APP_FROM_TEMPLATE, WORKSPACE_ACTION_BUTTON, createMessage, } from "@appsmith/constants/messages"; @@ -26,6 +27,7 @@ export interface WorkspaceActionProps { enableImportExport: boolean; workspaceId: string; onCreateNewApplication: (workspaceId: string) => void; + onStartFromTemplate: (workspaceId: string) => void; setSelectedWorkspaceIdForImportApplication: (workspaceId?: string) => void; } @@ -33,8 +35,10 @@ function WorkspaceAction({ enableImportExport, isMobile, onCreateNewApplication, + onStartFromTemplate, setSelectedWorkspaceIdForImportApplication, workspace, + workspaceId, }: WorkspaceActionProps) { const [isActionMenuOpen, setIsActionMenuOpen] = useState(false); const isFetchingApplications = useSelector(getIsFetchingApplications); @@ -88,6 +92,15 @@ function WorkspaceAction({ {createMessage(NEW_APP)} + onStartFromTemplate(workspaceId)} + startIcon="group-control" + > + {createMessage(NEW_APP_FROM_TEMPLATE)} + + {enableImportExport && hasCreateNewApplicationPermission && ( { if ( Object.entries(creatingApplicationMap).length === 0 || @@ -742,6 +749,7 @@ export function ApplicationsSection(props: any) { enableImportExport={enableImportExport} isMobile={isMobile} onCreateNewApplication={onClickAddNewAppButton} + onStartFromTemplate={onStartFromTemplateClick} setSelectedWorkspaceIdForImportApplication={ setSelectedWorkspaceIdForImportApplication } @@ -935,6 +943,7 @@ export const ApplictionsMainPage = (props: any) => { - ) : null - ) : ( - - ); + ); + } else { + if (this.state.startFromTemplate) { + return
Rahul
; + } + return ( + { + this.setState({ startFromTemplate: true }); + }} + searchApplications={this.props.searchApplications} + searchKeyword={this.props.searchKeyword} + /> + ); + } } } From 260c5dc827ab21f2a83792b17185f697db362099 Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Wed, 7 Feb 2024 10:19:37 +0530 Subject: [PATCH 02/38] Add onForkTemplateClick function to StartWithTemplatesWrapper --- .../Applications/CreateNewAppsOption.tsx | 24 +++++++++-- .../StartWithTemplatesWrapper.tsx | 42 ++----------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx index 155728f1864..6c4f49ef499 100644 --- a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx +++ b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx @@ -27,6 +27,7 @@ import { getAllTemplates, getTemplateFilters, importTemplateIntoApplicationViaOnboardingFlow, + setActiveLoadingTemplateId, } from "actions/templateActions"; import { ASSETS_CDN_URL } from "constants/ThirdPartyConstants"; import { Flex, Link, Text } from "design-system"; @@ -57,6 +58,7 @@ import { fetchingEnvironmentConfigs } from "@appsmith/actions/environmentAction" import StartWithTemplatesWrapper from "./StartWithTemplatesWrapper"; import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag"; +import type { Template } from "api/TemplatesApi"; const SectionWrapper = styled.div` display: flex; @@ -475,6 +477,24 @@ const CreateNewAppsOption = ({ isEnabledForStartWithDataDefault && (!createNewAppPluginId || !selectedDatasource); + const onForkTemplateClick = (template: Template) => { + const title = template.title; + AnalyticsUtil.logEvent("FORK_TEMPLATE_WHEN_ONBOARDING", { title }); + // When fork template is clicked to add a new app using the template + if (!isImportingTemplate && application) { + dispatch(setActiveLoadingTemplateId(template.id)); + dispatch( + importTemplateIntoApplicationViaOnboardingFlow( + template.id, + template.title, + template.pages.map((p) => p.name), + application.id, + application.workspaceId, + ), + ); + } + }; + return (