Skip to content

Commit 81419b2

Browse files
refactor(web): remove domain param from getBrowsePath, use SINGLE_TENANT_ORG_DOMAIN internally (#1074)
1 parent 7da5d55 commit 81419b2

File tree

18 files changed

+7
-47
lines changed

18 files changed

+7
-47
lines changed

packages/web/src/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ export const getRepos = async ({
277277
repoName: repo.name,
278278
path: '',
279279
pathType: 'tree',
280-
domain: org.domain,
281280
})}`,
282281
externalWebUrl: repo.webUrl ?? undefined,
283282
imageUrl: repo.imageUrl ?? undefined,

packages/web/src/app/[domain]/browse/[...path]/components/pureTreePreviewPanel.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { FileTreeItemComponent } from "@/app/[domain]/browse/components/fileTree
55
import { getBrowsePath } from "../../hooks/utils";
66
import { ScrollArea } from "@/components/ui/scroll-area";
77
import { useBrowseParams } from "../../hooks/useBrowseParams";
8-
import { useDomain } from "@/hooks/useDomain";
98
import { FileTreeItem } from "@/features/git";
109

1110
interface PureTreePreviewPanelProps {
@@ -15,7 +14,6 @@ interface PureTreePreviewPanelProps {
1514
export const PureTreePreviewPanel = ({ items }: PureTreePreviewPanelProps) => {
1615
const { repoName, revisionName } = useBrowseParams();
1716
const scrollAreaRef = useRef<HTMLDivElement>(null);
18-
const domain = useDomain();
1917

2018
return (
2119
<ScrollArea
@@ -35,7 +33,6 @@ export const PureTreePreviewPanel = ({ items }: PureTreePreviewPanelProps) => {
3533
revisionName,
3634
path: item.path,
3735
pathType: item.type === 'tree' ? 'tree' : 'blob',
38-
domain,
3936
})}
4037
/>
4138
))}

packages/web/src/app/[domain]/browse/components/pureFileTreePanel.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import React, { useCallback, useMemo, useRef } from "react";
66
import { FileTreeItemComponent } from "./fileTreeItemComponent";
77
import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
88
import { useBrowseParams } from "@/app/[domain]/browse/hooks/useBrowseParams";
9-
import { useDomain } from "@/hooks/useDomain";
109

1110
const renderLoadingSkeleton = (depth: number) => {
1211
return (
@@ -28,7 +27,6 @@ interface PureFileTreePanelProps {
2827
export const PureFileTreePanel = ({ tree, openPaths, path, onTreeNodeClicked }: PureFileTreePanelProps) => {
2928
const scrollAreaRef = useRef<HTMLDivElement>(null);
3029
const { repoName, revisionName } = useBrowseParams();
31-
const domain = useDomain();
3230

3331
const renderTree = useCallback((nodes: FileTreeNode, depth = 0): React.ReactNode => {
3432
return (
@@ -42,7 +40,6 @@ export const PureFileTreePanel = ({ tree, openPaths, path, onTreeNodeClicked }:
4240
revisionName,
4341
path: node.path,
4442
pathType: node.type === 'tree' ? 'tree' : 'blob',
45-
domain,
4643
})}
4744
key={node.path}
4845
node={node}
@@ -80,7 +77,7 @@ export const PureFileTreePanel = ({ tree, openPaths, path, onTreeNodeClicked }:
8077
})}
8178
</>
8279
);
83-
}, [domain, onTreeNodeClicked, path, repoName, revisionName, openPaths]);
80+
}, [onTreeNodeClicked, path, repoName, revisionName, openPaths]);
8481

8582
const renderedTree = useMemo(() => renderTree(tree), [tree, renderTree]);
8683

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
'use client';
22

33
import { useRouter } from "next/navigation";
4-
import { useDomain } from "@/hooks/useDomain";
54
import { useCallback } from "react";
65
import { getBrowsePath, GetBrowsePathProps } from "./utils";
76

87
export const useBrowseNavigation = () => {
98
const router = useRouter();
10-
const domain = useDomain();
119

1210
const navigateToPath = useCallback(({
1311
repoName,
@@ -16,21 +14,20 @@ export const useBrowseNavigation = () => {
1614
pathType,
1715
highlightRange,
1816
setBrowseState,
19-
}: Omit<GetBrowsePathProps, 'domain'>) => {
17+
}: GetBrowsePathProps) => {
2018
const browsePath = getBrowsePath({
2119
repoName,
2220
revisionName,
2321
path,
2422
pathType,
2523
highlightRange,
2624
setBrowseState,
27-
domain,
2825
});
2926

3027
router.push(browsePath);
31-
}, [domain, router]);
28+
}, [router]);
3229

3330
return {
3431
navigateToPath,
3532
};
36-
};
33+
};

packages/web/src/app/[domain]/browse/hooks/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BrowseState, SET_BROWSE_STATE_QUERY_PARAM } from "../browseStateProvider";
2+
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
23

34
export const HIGHLIGHT_RANGE_QUERY_PARAM = 'highlightRange';
45

@@ -17,7 +18,6 @@ export interface GetBrowsePathProps {
1718
pathType: 'blob' | 'tree';
1819
highlightRange?: BrowseHighlightRange;
1920
setBrowseState?: Partial<BrowseState>;
20-
domain: string;
2121
}
2222

2323
export const getBrowseParamsFromPathParam = (pathParam: string) => {
@@ -64,8 +64,9 @@ export const getBrowseParamsFromPathParam = (pathParam: string) => {
6464
};
6565

6666
export const getBrowsePath = ({
67-
repoName, revisionName, path, pathType, highlightRange, setBrowseState, domain,
67+
repoName, revisionName, path, pathType, highlightRange, setBrowseState,
6868
}: GetBrowsePathProps) => {
69+
const domain = SINGLE_TENANT_ORG_DOMAIN;
6970
const params = new URLSearchParams();
7071

7172
if (highlightRange) {

packages/web/src/app/[domain]/components/pathHeader.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
1616
import { CopyIconButton } from "./copyIconButton";
1717
import Link from "next/link";
18-
import { useDomain } from "@/hooks/useDomain";
1918
import { CodeHostType } from "@sourcebot/db";
2019

2120
interface FileHeaderProps {
@@ -74,8 +73,6 @@ export const PathHeader = ({
7473
const containerRef = useRef<HTMLDivElement>(null);
7574
const breadcrumbsRef = useRef<HTMLDivElement>(null);
7675
const [visibleSegmentCount, setVisibleSegmentCount] = useState<number | null>(null);
77-
const domain = useDomain();
78-
7976
// Create breadcrumb segments from file path
8077
const breadcrumbSegments = useMemo(() => {
8178
const pathParts = path.split('/').filter(Boolean);
@@ -223,7 +220,6 @@ export const PathHeader = ({
223220
path: '/',
224221
pathType: 'tree',
225222
revisionName,
226-
domain,
227223
})}
228224
>
229225
{info?.displayName}
@@ -262,7 +258,6 @@ export const PathHeader = ({
262258
path: segment.fullPath,
263259
pathType: segment.isLastSegment ? pathType : 'tree',
264260
revisionName,
265-
domain,
266261
})}
267262
className="font-mono text-sm hover:cursor cursor-pointer"
268263
key={segment.fullPath}
@@ -291,7 +286,6 @@ export const PathHeader = ({
291286
path: segment.fullPath,
292287
pathType: segment.isLastSegment ? pathType : 'tree',
293288
revisionName,
294-
domain,
295289
})}
296290
>
297291
{renderSegmentWithHighlight(segment)}

packages/web/src/app/[domain]/repos/components/reposTable.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ export const getColumns = (context: ColumnsContext): ColumnDef<Repo>[] => [
138138
repoName: repo.name,
139139
path: '/',
140140
pathType: 'tree',
141-
domain: SINGLE_TENANT_ORG_DOMAIN,
142141
})}
143142
className="font-medium hover:underline"
144143
>

packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatch.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { SearchResultFile, SearchResultChunk } from "@/features/search";
44
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
55
import Link from "next/link";
66
import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
7-
import { useDomain } from "@/hooks/useDomain";
87

98

109
interface FileMatchProps {
@@ -16,8 +15,6 @@ export const FileMatch = ({
1615
match,
1716
file,
1817
}: FileMatchProps) => {
19-
const domain = useDomain();
20-
2118
// If it's just the title, don't show a code preview
2219
if (match.matchRanges.length === 0) {
2320
return null;
@@ -32,7 +29,6 @@ export const FileMatch = ({
3229
revisionName: file.branches?.[0] ?? 'HEAD',
3330
path: file.fileName.text,
3431
pathType: 'blob',
35-
domain,
3632
highlightRange: {
3733
start: {
3834
lineNumber: match.contentStart.lineNumber,

packages/web/src/app/api/(server)/repos/listReposApi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const listRepos = async ({ query, page, perPage, sort, direction, source
5454
repoName: repo.name,
5555
path: '',
5656
pathType: 'tree',
57-
domain: org.domain,
5857
})}`,
5958
repoDisplayName: repo.displayName ?? undefined,
6059
externalWebUrl: repo.webUrl ?? undefined,

packages/web/src/ee/features/codeNav/components/exploreMenu/referenceList.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { useMemo, useRef } from "react";
99
import useCaptureEvent from "@/hooks/useCaptureEvent";
1010
import { useVirtualizer } from "@tanstack/react-virtual";
1111
import Link from "next/link";
12-
import { useDomain } from "@/hooks/useDomain";
1312

1413
interface ReferenceListProps {
1514
data: FindRelatedSymbolsResponse;
@@ -23,7 +22,6 @@ export const ReferenceList = ({
2322
data,
2423
revisionName,
2524
}: ReferenceListProps) => {
26-
const domain = useDomain();
2725
const repoInfoMap = useMemo(() => {
2826
return data.repositoryInfo.reduce((acc, repo) => {
2927
acc[repo.id] = repo;
@@ -112,7 +110,6 @@ export const ReferenceList = ({
112110
path: file.fileName,
113111
pathType: 'blob',
114112
highlightRange: match.range,
115-
domain,
116113
})}
117114
onClick={() => {
118115
captureEvent('wa_explore_menu_reference_clicked', {});

0 commit comments

Comments
 (0)