From da8f726eb80363ad87c2adbc52fc1244401f10d3 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Wed, 9 Oct 2024 13:22:27 +0530 Subject: [PATCH] fix: New query button does not show up issue fixed (#36766) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR fixes two issues: 1. When importing older application jsons with applicationVersion 1, they get redirected to `/applications` (older url) as opposed to `/app` (newer slug based url). This results in new query button not showing up on datasource view page, because new query button is hidden behind a condition of editorType and editorType was depending on the new url path. This PR fixes the issue by adding support for older path as well to provide backwards compatibility. 2. Second similar issue was seen intermittently, when we do save and authorise in REST API datasource, then sometimes the redirection was happening to older url (/applications), in that case new query button would not show up. This has been fixed too Fixes #35626 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > ๐ŸŸข ๐ŸŸข ๐ŸŸข All cypress tests have passed! ๐ŸŽ‰ ๐ŸŽ‰ ๐ŸŽ‰ > Workflow run: > Commit: 015ef2a11ff65ec213dd36593b624ba268494325 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Tue, 08 Oct 2024 18:19:47 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No Co-authored-by: โ€œsneha122โ€ <โ€œsneha@appsmith.comโ€> --- app/client/src/ce/hooks/hooks.test.ts | 25 +++++++++++++++++++++++++ app/client/src/ce/hooks/index.ts | 1 + 2 files changed, 26 insertions(+) create mode 100644 app/client/src/ce/hooks/hooks.test.ts diff --git a/app/client/src/ce/hooks/hooks.test.ts b/app/client/src/ce/hooks/hooks.test.ts new file mode 100644 index 0000000000..8259537e9d --- /dev/null +++ b/app/client/src/ce/hooks/hooks.test.ts @@ -0,0 +1,25 @@ +import { useEditorType, EditorNames } from "./index"; +import { + BUILDER_VIEWER_PATH_PREFIX, + BUILDER_BASE_PATH_DEPRECATED, +} from "constants/routes"; + +describe("useEditorType", () => { + it('should return "app" for BUILDER_VIEWER_PATH_PREFIX', () => { + const result = useEditorType(BUILDER_VIEWER_PATH_PREFIX); + + expect(result).toBe(EditorNames.APPLICATION); + }); + + it('should return "app" for BUILDER_BASE_PATH_DEPRECATED', () => { + const result = useEditorType(BUILDER_BASE_PATH_DEPRECATED); + + expect(result).toBe(EditorNames.APPLICATION); + }); + + it('should default to "app" for unmatched paths', () => { + const result = useEditorType("/some-random-path"); + + expect(result).toBe(EditorNames.APPLICATION); + }); +}); diff --git a/app/client/src/ce/hooks/index.ts b/app/client/src/ce/hooks/index.ts index 2112914bd3..cd84f5ca1d 100644 --- a/app/client/src/ce/hooks/index.ts +++ b/app/client/src/ce/hooks/index.ts @@ -15,6 +15,7 @@ export interface EditorType { export const editorType: EditorType = { [BUILDER_VIEWER_PATH_PREFIX]: EditorNames.APPLICATION, + [BUILDER_BASE_PATH_DEPRECATED]: EditorNames.APPLICATION, }; export const useEditorType = (path: string) => {