sourcebot/packages/web/src/app/[domain]/browse/[...path]/page.tsx

76 lines
2.1 KiB
TypeScript
Raw Normal View History

import { Suspense } from "react";
import { getBrowseParamsFromPathParam } from "../hooks/utils";
2025-06-06 19:38:16 +00:00
import { CodePreviewPanel } from "./components/codePreviewPanel";
import { Loader2 } from "lucide-react";
2025-06-06 19:38:16 +00:00
import { TreePreviewPanel } from "./components/treePreviewPanel";
import { Metadata } from "next";
import { parsePathForTitle} from "@/lib/utils";
type Props = {
params: {
domain: string;
path: string[];
};
};
export async function generateMetadata({ params }: Props): Promise<Metadata> {
let title = 'Browse'; // Default Fallback
try {
title = parsePathForTitle(params.path);
} catch (error) {
// TODO: Maybe I need to look into a better way of handling this error.
// for now, it is just a log, fallback tab title and prevents the app from crashing.
console.error("Failed to generate metadata title from path:", params.path, error);
}
return {
title,
};
}
interface BrowsePageProps {
params: Promise<{
path: string[];
}>;
}
export default async function BrowsePage(props: BrowsePageProps) {
const params = await props.params;
const {
path: _rawPath,
} = params;
const rawPath = _rawPath.join('/');
console.log("rawPath:", rawPath);
const { repoName, revisionName, path, pathType } = getBrowseParamsFromPathParam(rawPath);
2025-01-07 18:27:42 +00:00
return (
2025-06-06 19:38:16 +00:00
<div className="flex flex-col h-full">
<Suspense fallback={
<div className="flex flex-col w-full min-h-full items-center justify-center">
<Loader2 className="w-4 h-4 animate-spin" />
Loading...
</div>
}>
{pathType === 'blob' ? (
<CodePreviewPanel
path={path}
repoName={repoName}
revisionName={revisionName}
/>
) : (
<TreePreviewPanel
path={path}
repoName={repoName}
revisionName={revisionName}
/>
)}
</Suspense>
2025-06-06 19:38:16 +00:00
</div>
2025-01-07 18:27:42 +00:00
)
V4 (#311) Sourcebot V4 introduces authentication, performance improvements and code navigation. Checkout the [migration guide](https://docs.sourcebot.dev/self-hosting/upgrade/v3-to-v4-guide) for information on upgrading your instance to v4. ### Changed - [**Breaking Change**] Authentication is now required by default. Notes: - When setting up your instance, email / password login will be the default authentication provider. - The first user that logs into the instance is given the `owner` role. ([docs](https://docs.sourcebot.dev/docs/more/roles-and-permissions)). - Subsequent users can request to join the instance. The `owner` can approve / deny requests to join the instance via `Settings` > `Members` > `Pending Requests`. - If a user is approved to join the instance, they are given the `member` role. - Additional login providers, including email links and SSO, can be configured with additional environment variables. ([docs](https://docs.sourcebot.dev/self-hosting/configuration/authentication)). - Clicking on a search result now takes you to the `/browse` view. Files can still be previewed by clicking the "Preview" button or holding `Cmd` / `Ctrl` when clicking on a search result. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Added - [Sourcebot EE] Added search-based code navigation, allowing you to jump between symbol definition and references when viewing source files. [Read the documentation](https://docs.sourcebot.dev/docs/search/code-navigation). [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) - Added collapsible filter panel. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Fixed - Improved scroll performance for large numbers of search results. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315)
2025-05-28 23:08:42 +00:00
}
2025-06-06 19:38:16 +00:00