-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: adding branch in url for search entities #36938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,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({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brayn003 Out of curiosity, shouldn't the routeBuilder have taken care of this routing? This way, we would have been sure that all instances of this route builder are routing accurately and are taking the Git default branch into account. Can you help me understand why that is either not possible, or complicated? |
||
| basePageId: defaultPage.baseId, | ||
| branch: defaultBranch, | ||
| }); | ||
| } else { | ||
| viewURL = viewerURL({ | ||
| basePageId: defaultPage.baseId, | ||
| }); | ||
| } | ||
|
|
||
| window.location.href = `${viewURL}`; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.