Skip to content

Commit

Permalink
fix: adding branch in url for search entities (#36938)
Browse files Browse the repository at this point in the history
## Description
Fixes application redirection issue from search bar ~
1. Appends branch to the url

Fixes #36782

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11390479742>
> Commit: 02eb26e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11390479742&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Thu, 17 Oct 2024 18:34:15 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
  • Loading branch information
brayn003 authored Oct 18, 2024
1 parent 5e4b026 commit f547821
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions app/client/src/pages/common/SearchBar/EntitySearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -135,12 +136,34 @@ 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 viewURL = viewerURL({
basePageId: defaultPage.baseId,
});

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) {
const defaultBranch =
searchedApplication?.gitApplicationMetadata?.defaultBranchName;

viewURL = viewerURL({
basePageId: defaultPage.baseId,
branch: defaultBranch,
});
} else {
viewURL = viewerURL({
basePageId: defaultPage.baseId,
});
}

window.location.href = `${viewURL}`;
}
Expand Down

0 comments on commit f547821

Please sign in to comment.