From 6c1e13a6e988a2fab409139b34b47d8a03cfd129 Mon Sep 17 00:00:00 2001 From: satbir121 <39981226+satbir121@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:44:39 +0530 Subject: [PATCH] Revert create new app flow to use the old flow for now (#1265) --- app/client/cypress/support/commands.js | 30 ++++------ app/client/cypress/support/index.js | 1 - .../form/FormDialogComponent.tsx | 6 +- .../pages/Applications/ApplicationCard.tsx | 10 ---- .../Applications/CreateApplicationForm.tsx | 2 +- app/client/src/pages/Applications/index.tsx | 57 +++++++++---------- .../Actions/ActionEntityContextMenu.tsx | 21 ++++--- app/client/src/sagas/ApplicationSagas.tsx | 12 +++- 8 files changed, 67 insertions(+), 72 deletions(-) diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 9364db459a..82c3cab0e0 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -214,34 +214,28 @@ Cypress.Commands.add("CreateAppForOrg", (orgName, appname) => { .scrollIntoView() .should("be.visible") .click(); - cy.wait("@createNewApplication").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - cy.get(homePage.applicationName).type(appname + "{enter}"); - cy.wait("@updateApplicationName").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); + cy.get(homePage.inputAppName).type(appname); + cy.get(homePage.CreateApp) + .contains("Submit") + .click({ force: true }); + cy.get("#loading").should("not.exist"); }); Cypress.Commands.add("CreateApp", appname => { cy.get(homePage.createNew) .first() .click({ force: true }); - cy.wait("@createNewApplication").should( - "have.nested.property", - "response.body.responseMeta.status", - 201, - ); - cy.get(homePage.applicationName).type(appname + "{enter}"); - cy.wait("@updateApplicationName").should( + cy.get(homePage.inputAppName).type(appname); + cy.get(homePage.CreateApp) + .contains("Submit") + .click({ force: true }); + cy.get("#loading").should("not.exist"); + cy.wait("@getPagesForApp").should( "have.nested.property", "response.body.responseMeta.status", 200, ); + cy.get("h2").contains("Drag and drop a widget here"); }); Cypress.Commands.add("DeleteApp", appName => { diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index 46a651f0bd..bbdf39e556 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -46,7 +46,6 @@ before(function() { cy.generateUUID().then(id => { appId = id; cy.CreateApp(id); - cy.EditApp(id); localStorage.setItem("AppName", appId); }); diff --git a/app/client/src/components/editorComponents/form/FormDialogComponent.tsx b/app/client/src/components/editorComponents/form/FormDialogComponent.tsx index b7f9d98ffd..3ea23fdb79 100644 --- a/app/client/src/components/editorComponents/form/FormDialogComponent.tsx +++ b/app/client/src/components/editorComponents/form/FormDialogComponent.tsx @@ -74,7 +74,11 @@ export const FormDialogComponent = (props: FormDialogComponentProps) => { return ( - setIsOpen(true)}> + { + setIsOpen(true); + }} + > {props.trigger} diff --git a/app/client/src/pages/Applications/ApplicationCard.tsx b/app/client/src/pages/Applications/ApplicationCard.tsx index c942d70c5f..cf9075b054 100644 --- a/app/client/src/pages/Applications/ApplicationCard.tsx +++ b/app/client/src/pages/Applications/ApplicationCard.tsx @@ -248,18 +248,12 @@ export const ApplicationCard = (props: ApplicationCardProps) => { const [selectedColor, setSelectedColor] = useState(colorCode); const [moreActionItems, setMoreActionItems] = useState([]); const [isMenuOpen, setIsMenuOpen] = useState(false); - const [isNewCard, setIsNewCard] = useState(false); const [lastUpdatedValue, setLastUpdatedValue] = useState(""); const menuIconRef = createRef(); useEffect(() => { setSelectedColor(colorCode); }, [colorCode]); - useEffect(() => { - if (isNewCard && menuIconRef.current) { - menuIconRef.current.click(); - } - }, [isNewCard]); useEffect(() => { if (props.share) { moreActionItems.push({ @@ -283,7 +277,6 @@ export const ApplicationCard = (props: ApplicationCardProps) => { }, []); useEffect(() => { if (props.activeAppCard) { - setIsNewCard(true); setShowOverlay(true); } }, [props.activeAppCard]); @@ -380,7 +373,6 @@ export const ApplicationCard = (props: ApplicationCardProps) => { onClosing={() => { setIsMenuOpen(false); setShowOverlay(false); - setIsNewCard(false); addDeleteOption(); if (lastUpdatedValue && props.application.name !== lastUpdatedValue) { props.update && @@ -392,7 +384,6 @@ export const ApplicationCard = (props: ApplicationCardProps) => { > {hasEditPermission && ( { @@ -413,7 +404,6 @@ export const ApplicationCard = (props: ApplicationCardProps) => { } fill={true} onBlur={(value: string) => { - setIsNewCard(false); props.update && props.update(props.application.id, { name: value, diff --git a/app/client/src/pages/Applications/CreateApplicationForm.tsx b/app/client/src/pages/Applications/CreateApplicationForm.tsx index b1fe32f8f9..2565bab1a7 100644 --- a/app/client/src/pages/Applications/CreateApplicationForm.tsx +++ b/app/client/src/pages/Applications/CreateApplicationForm.tsx @@ -36,7 +36,7 @@ const validate = (values: CreateApplicationFormValues) => { // TODO(abhinav): abstract onCancel out. -export const CreateApplicationForm = (props: Props) => { +const CreateApplicationForm = (props: Props) => { const { error, handleSubmit, pristine, submitting, invalid } = props; return (
diff --git a/app/client/src/pages/Applications/index.tsx b/app/client/src/pages/Applications/index.tsx index d1f4816dd3..e02e8a199b 100644 --- a/app/client/src/pages/Applications/index.tsx +++ b/app/client/src/pages/Applications/index.tsx @@ -28,7 +28,10 @@ import FormDialogComponent from "components/editorComponents/form/FormDialogComp import { User } from "constants/userConstants"; import { getCurrentUser } from "selectors/usersSelectors"; import CreateOrganizationForm from "pages/organization/CreateOrganizationForm"; -import { CREATE_ORGANIZATION_FORM_NAME } from "constants/forms"; +import { + CREATE_ORGANIZATION_FORM_NAME, + CREATE_APPLICATION_FORM_NAME, +} from "constants/forms"; import { getOnSelectAction, DropdownOnSelectActions, @@ -49,8 +52,8 @@ import { UpdateApplicationPayload } from "api/ApplicationApi"; import PerformanceTracker, { PerformanceTransactionName, } from "utils/PerformanceTracker"; -import { getNextEntityName } from "utils/AppsmithUtils"; -import { AppLoader, loadingUserOrgs } from "./ApplicationLoaders"; +import { loadingUserOrgs } from "./ApplicationLoaders"; +import CreateApplicationForm from "./CreateApplicationForm"; import { creatingApplicationMap } from "reducers/uiReducers/applicationsReducer"; import CenteredWrapper from "../../components/designSystems/appsmith/CenteredWrapper"; import NoSearchImage from "../../assets/images/NoSearchResult.svg"; @@ -342,6 +345,18 @@ ${props => { } `; +const AddApplicationCard = ( + + + + Create New + + +); const NoSearchResultImg = styled.img` margin: 1em; `; @@ -525,30 +540,14 @@ const ApplicationsSection = (props: any) => { ) && !isFetchingApplications && ( - - createNewApplication( - getNextEntityName( - "New App", - applications.map((el: any) => el.name), - ), - organization.id, - ) - } - > - - - Create New - - + )} {applications.map((application: any) => { @@ -572,10 +571,6 @@ const ApplicationsSection = (props: any) => { ) ); })} - {creatingApplicationMap && - creatingApplicationMap[organization.id] ? ( - - ) : null} diff --git a/app/client/src/pages/Editor/Explorer/Actions/ActionEntityContextMenu.tsx b/app/client/src/pages/Editor/Explorer/Actions/ActionEntityContextMenu.tsx index fc9802a490..c86ca49508 100644 --- a/app/client/src/pages/Editor/Explorer/Actions/ActionEntityContextMenu.tsx +++ b/app/client/src/pages/Editor/Explorer/Actions/ActionEntityContextMenu.tsx @@ -108,15 +108,18 @@ export const ActionEntityContextMenu = (props: EntityContextMenuProps) => { value: "move", onSelect: noop, label: "Move to page", - children: menuPages.length > 1 ? - menuPages - .filter(page => page.id !== props.pageId) // Remove current page from the list - .map(page => { - return { - ...page, - onSelect: () => moveActionToPage(props.id, props.name, page.id), - }; - }) : [{ value: "No Pages", onSelect: noop, label: "No Pages" }] + children: + menuPages.length > 1 + ? menuPages + .filter(page => page.id !== props.pageId) // Remove current page from the list + .map(page => { + return { + ...page, + onSelect: () => + moveActionToPage(props.id, props.name, page.id), + }; + }) + : [{ value: "No Pages", onSelect: noop, label: "No Pages" }], }, { value: "delete", diff --git a/app/client/src/sagas/ApplicationSagas.tsx b/app/client/src/sagas/ApplicationSagas.tsx index 4e1dfc4f09..cf79512d42 100644 --- a/app/client/src/sagas/ApplicationSagas.tsx +++ b/app/client/src/sagas/ApplicationSagas.tsx @@ -312,9 +312,11 @@ export function* createApplicationSaga( action: ReduxAction<{ applicationName: string; orgId: string; + resolve: any; + reject: any; }>, ) { - const { applicationName, orgId } = action.payload; + const { applicationName, orgId, resolve, reject } = action.payload; try { const userOrgs = yield select(getUserApplicationsOrgsList); const existingOrgs = userOrgs.filter( @@ -327,6 +329,9 @@ export function* createApplicationSaga( ) : null; if (existingApplication) { + yield call(reject, { + _error: "An application with this name already exists", + }); yield put({ type: ReduxActionErrorTypes.CREATE_APPLICATION_ERROR, payload: { @@ -360,6 +365,11 @@ export function* createApplicationSaga( application, }, }); + const pageURL = BUILDER_PAGE_URL( + application.id, + application.defaultPageId, + ); + history.push(pageURL); } } } catch (error) {