diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js index 96a7b22941..25bffe320d 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/ForkTemplateToGitConnectedApp.js @@ -38,6 +38,7 @@ describe("Fork a template to the current app", () => { .scrollIntoView() .wait(500) .click(); + cy.get(template.templateViewForkButton).first().click(); cy.waitUntil(() => cy.xpath("//span[text()='Setting up the template']"), { errorMsg: "Setting Templates did not finish even after 75 seconds", timeout: 950000, diff --git a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js index b4ad1026ca..e534a5c0e5 100644 --- a/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js +++ b/app/client/cypress/integration/Regression_TestSuite/ClientSideTests/Templates/Fork_Template_Existing_app_spec.js @@ -73,4 +73,22 @@ describe("Fork a template to the current app from new page popover", () => { "template added successfully", ); }); + + it("Fork template button should take user to 'select pages from template' page", () => { + _.agHelper.RefreshPage(); + cy.AddPageFromTemplate(); + cy.get(_.templates.locators._forkApp).first().click(); + cy.get(template.templateViewForkButton).should("be.visible"); + }); + + it("Similar templates add icon should take user to 'select pages from template' page", () => { + _.agHelper.RefreshPage(); + cy.AddPageFromTemplate(); + // We are currentlyon on templates list page + cy.get(_.templates.locators._forkApp).first().click(); + // Here we are on template detail page, with similar templates at the bottom + cy.get(_.templates.locators._forkApp).first().click(); + + cy.get(template.templateViewForkButton).should("be.visible"); + }); }); diff --git a/app/client/src/pages/Templates/TemplatesModal/TemplateDetailedView.tsx b/app/client/src/pages/Templates/TemplatesModal/TemplateDetailedView.tsx index 883a01468f..23b8a8c85b 100644 --- a/app/client/src/pages/Templates/TemplatesModal/TemplateDetailedView.tsx +++ b/app/client/src/pages/Templates/TemplatesModal/TemplateDetailedView.tsx @@ -3,31 +3,30 @@ import { FETCHING_TEMPLATES, FORKING_TEMPLATE, } from "@appsmith/constants/messages"; +import type { AppState } from "@appsmith/reducers"; import { getSimilarTemplatesInit, getTemplateInformation, - importTemplateIntoApplication, } from "actions/templateActions"; +import type { Template } from "api/TemplatesApi"; +import { VIEWER_PATH, VIEWER_PATH_DEPRECATED } from "constants/routes"; import { Text, TextType } from "design-system-old"; -import React, { useEffect, useState, useRef } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; +import { generatePath, matchPath } from "react-router"; import { getActiveTemplateSelector, isFetchingTemplateSelector, isImportingTemplateToAppSelector, } from "selectors/templatesSelectors"; import styled from "styled-components"; -import { IframeTopBar, IframeWrapper } from "../TemplateView"; -import PageSelection from "./PageSelection"; -import LoadingScreen from "./LoadingScreen"; -import type { Template } from "api/TemplatesApi"; -import { generatePath, matchPath } from "react-router"; import { isURLDeprecated, trimQueryString } from "utils/helpers"; -import { VIEWER_PATH, VIEWER_PATH_DEPRECATED } from "constants/routes"; -import TemplateModalHeader from "./Header"; -import TemplateDescription from "../Template/TemplateDescription"; import SimilarTemplates from "../Template/SimilarTemplates"; -import type { AppState } from "@appsmith/reducers"; +import TemplateDescription from "../Template/TemplateDescription"; +import { IframeTopBar, IframeWrapper } from "../TemplateView"; +import TemplateModalHeader from "./Header"; +import LoadingScreen from "./LoadingScreen"; +import PageSelection from "./PageSelection"; const breakpointColumns = { default: 4, @@ -104,10 +103,6 @@ function TemplateDetailedView(props: TemplateDetailedViewProps) { } }; - const onForkTemplateClick = (template: Template) => { - dispatch(importTemplateIntoApplication(template.id, template.title)); - }; - if (isFetchingTemplate || isImportingTemplateToApp) { return ; } @@ -157,7 +152,7 @@ function TemplateDetailedView(props: TemplateDetailedViewProps) { isForkingEnabled onBackPress={props.onBackPress} onClick={onSimilarTemplateClick} - onFork={onForkTemplateClick} + onFork={onSimilarTemplateClick} similarTemplates={similarTemplates} /> diff --git a/app/client/src/pages/Templates/TemplatesModal/TemplateList.tsx b/app/client/src/pages/Templates/TemplatesModal/TemplateList.tsx index 76c25dcbd0..0f3ee8dbc3 100644 --- a/app/client/src/pages/Templates/TemplatesModal/TemplateList.tsx +++ b/app/client/src/pages/Templates/TemplatesModal/TemplateList.tsx @@ -1,6 +1,11 @@ -import { importTemplateIntoApplication } from "actions/templateActions"; +import { + FETCHING_TEMPLATE_LIST, + FORKING_TEMPLATE, + createMessage, +} from "@appsmith/constants/messages"; +import type { Template } from "api/TemplatesApi"; import React from "react"; -import { useDispatch, useSelector } from "react-redux"; +import { useSelector } from "react-redux"; import { isFetchingTemplatesSelector, isImportingTemplateToAppSelector, @@ -8,14 +13,8 @@ import { import styled from "styled-components"; import { TemplatesContent } from ".."; import Filters from "../Filters"; -import LoadingScreen from "./LoadingScreen"; -import type { Template } from "api/TemplatesApi"; import TemplateModalHeader from "./Header"; -import { - createMessage, - FETCHING_TEMPLATE_LIST, - FORKING_TEMPLATE, -} from "@appsmith/constants/messages"; +import LoadingScreen from "./LoadingScreen"; const Wrapper = styled.div` display: flex; @@ -50,9 +49,8 @@ type TemplateListProps = { }; function TemplateList(props: TemplateListProps) { - const dispatch = useDispatch(); const onForkTemplateClick = (template: Template) => { - dispatch(importTemplateIntoApplication(template.id, template.title)); + props.onTemplateClick(template.id); }; const isImportingTemplateToApp = useSelector( isImportingTemplateToAppSelector,