From 9766775d05af45d43fe4646b5d40211b5ce42522 Mon Sep 17 00:00:00 2001 From: Jacques Ikot Date: Mon, 8 Jul 2024 11:10:09 +0100 Subject: [PATCH] fix: hide generate page button in DSFormHeader (#34780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description In PR #34655, the "Generate Page" button was removed from the datasource preview page (Footer). However, the `DSFormHeader` for other datasource types still included this button, leading to inconsistencies across the application. This PR addresses the issue by removing the "Generate Page" button from the DSFormHeader for all datasource types, ensuring uniformity in the datasource preview pages and aligning with the changes made in PR #34655. Fixes #34771 ## Automation /ok-to-test tags="@tag.Datasource" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: bde150dd6010e110f32288a52e39657f96945704 > Cypress dashboard. > Tags: `@tag.Datasource` >
Mon, 08 Jul 2024 09:44:32 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Introduced a feature flag to control the visibility of the "generate page" button in the DataSource Editor. - **Tests** - Added a new test case to ensure the "generate page" button is hidden when the `release_drag_drop_building_blocks_enabled` feature is enabled. --- .../pages/Editor/DataSourceEditor/hooks.ts | 10 ++++++- .../HideGeneratePageButton.test.tsx | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/client/src/pages/Editor/DataSourceEditor/hooks.ts b/app/client/src/pages/Editor/DataSourceEditor/hooks.ts index 0fb97c8752..92dbc646e9 100644 --- a/app/client/src/pages/Editor/DataSourceEditor/hooks.ts +++ b/app/client/src/pages/Editor/DataSourceEditor/hooks.ts @@ -123,6 +123,10 @@ export const useShowPageGenerationOnHeader = ( const isGoogleSheetPlugin = isGoogleSheetPluginDS(plugin?.packageName); + const releaseDragDropBuildingBlocks = useFeatureFlag( + FEATURE_FLAG.release_drag_drop_building_blocks_enabled, + ); + const isPluginAllowedToPreviewData = DATASOURCES_ALLOWED_FOR_PREVIEW_MODE.includes(plugin?.name || "") || (plugin?.name === PluginName.MONGO && @@ -151,5 +155,9 @@ export const useShowPageGenerationOnHeader = ( !isPluginAllowedToPreviewData && !!generateCRUDSupportedPlugin[(datasource as Datasource).pluginId]; - return supportTemplateGeneration && canGeneratePage; + return ( + !releaseDragDropBuildingBlocks && // only show generate page button if dragging of building blocks is not enabled (product decision) + supportTemplateGeneration && + canGeneratePage + ); }; diff --git a/app/client/src/pages/Editor/DatasourceInfo/HideGeneratePageButton.test.tsx b/app/client/src/pages/Editor/DatasourceInfo/HideGeneratePageButton.test.tsx index a2b3878aa2..38b4c33738 100644 --- a/app/client/src/pages/Editor/DatasourceInfo/HideGeneratePageButton.test.tsx +++ b/app/client/src/pages/Editor/DatasourceInfo/HideGeneratePageButton.test.tsx @@ -160,6 +160,36 @@ describe("GoogleSheetSchema Component", () => { }); }); +describe("DSFormHeader Component", () => { + it("1. should not render the 'generate page' button when release_drag_drop_building_blocks_enabled is enabled", () => { + (useFeatureFlag as jest.Mock).mockReturnValue(true); + const mockHistoryPush = jest.fn(); + const mockHistoryReplace = jest.fn(); + const mockHistoryLocation = { + pathname: "/", + search: "", + hash: "", + state: {}, + }; + + jest.spyOn(reactRouter, "useHistory").mockReturnValue({ + push: mockHistoryPush, + replace: mockHistoryReplace, + location: mockHistoryLocation, + }); + + jest.spyOn(reactRouter, "useLocation").mockReturnValue(mockHistoryLocation); + + renderDSFormHeader(); + + // Check that the "generate page" button is not rendered + const generatePageButton = screen.queryByText( + createMessage(DATASOURCE_GENERATE_PAGE_BUTTON), + ); + expect(generatePageButton).not.toBeInTheDocument(); + }); +}); + const mockDatasource: Datasource = { id: "667941878b418b52eb273895", userPermissions: [