From f32a4358a6eee46304112ec4a71d631f563c48b9 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Thu, 17 Oct 2024 18:13:03 +0800 Subject: [PATCH 1/2] fix: adding branch in url for search entities --- .../common/SearchBar/EntitySearchBar.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx b/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx index 319c4e5bfe05..3e332eaf4931 100644 --- a/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx +++ b/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx @@ -138,9 +138,23 @@ function EntitySearchBar(props: any) { const defaultPage = searchedApplication?.pages.find( (page: PageDefaultMeta) => page.isDefault === true, ); - const viewURL = viewerURL({ - basePageId: defaultPage.baseId, - }); + + const isGitEnabled = searchedApplication?.gitApplicationMetadata; + let viewURL = null; + + if (isGitEnabled) { + const defaultBranch = + searchedApplication?.gitApplicationMetadata?.defaultBranchName; + + viewURL = viewerURL({ + basePageId: defaultPage.baseId, + branch: defaultBranch, + }); + } else { + viewURL = viewerURL({ + basePageId: defaultPage.baseId, + }); + } window.location.href = `${viewURL}`; } From 02eb26e4911a4854daeb068f1c80004cec66de96 Mon Sep 17 00:00:00 2001 From: Rudraprasad Das Date: Fri, 18 Oct 2024 02:03:21 +0800 Subject: [PATCH 2/2] fix: adding review comments --- .../src/pages/common/SearchBar/EntitySearchBar.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx b/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx index 3e332eaf4931..71e2c00ce521 100644 --- a/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx +++ b/app/client/src/pages/common/SearchBar/EntitySearchBar.tsx @@ -36,6 +36,7 @@ import { getPackagesList } from "ee/selectors/packageSelectors"; import Fuse from "fuse.js"; import { useOutsideClick } from "ee/hooks"; import type { PageDefaultMeta } from "ee/api/ApplicationApi"; +import log from "loglevel"; const HeaderSection = styled.div` display: flex; @@ -135,11 +136,19 @@ function EntitySearchBar(props: any) { (app: ApplicationPayload) => app.id === applicationId, ); - const defaultPage = searchedApplication?.pages.find( + let defaultPage = searchedApplication?.pages.find( (page: PageDefaultMeta) => page.isDefault === true, ); - const isGitEnabled = searchedApplication?.gitApplicationMetadata; + if (!defaultPage) { + defaultPage = searchedApplication?.pages[0]; + } + + if (!defaultPage) { + log.error("No default page or pages found for the application"); + } + + const isGitEnabled = !!searchedApplication?.gitApplicationMetadata; let viewURL = null; if (isGitEnabled) {