From 749bfc28f3ec282ea38f828a5325ba7c14ed120f Mon Sep 17 00:00:00 2001 From: drew-u410 <77423219+drew-u410@users.noreply.github.com> Date: Tue, 3 Jun 2025 11:52:59 -0400 Subject: [PATCH] [dev + copy button] add / update local dev w/docker compose; add copy button to the right of filenames (#328) --- CHANGELOG.md | 4 +++ CONTRIBUTING.md | 20 ++++++++----- docker-compose-dev.yml | 30 +++++++++++++++++++ .../app/[domain]/components/fileHeader.tsx | 30 ++++++++++++++++--- 4 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 docker-compose-dev.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index ececd111..d9e9dd28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Added copy button for filenames. [#328](https://github.com/sourcebot-dev/sourcebot/pull/328) +- Added development docker compose file. [#328](https://github.com/sourcebot-dev/sourcebot/pull/328) + ### Fixed - Fixed issue with the symbol hover popover clipping at the top of the page. [#326](https://github.com/sourcebot-dev/sourcebot/pull/326) - Fixed slow rendering issue with large reference/definition lists. [#327](https://github.com/sourcebot-dev/sourcebot/pull/327) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3627186c..40e0c197 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ >[!NOTE] > Building from source is only required if you'd like to contribute. The recommended way to use Sourcebot is to use the [pre-built docker image](https://github.com/sourcebot-dev/sourcebot/pkgs/container/sourcebot). -1. Install go, NodeJS, [redis](https://redis.io/), and [postgres](https://www.postgresql.org/). Note that a NodeJS version of at least `21.1.0` is required. +1. Install go, and NodeJS. Note that a NodeJS version of at least `21.1.0` is required. 2. Install [ctags](https://github.com/universal-ctags/ctags) (required by zoekt) ```sh @@ -13,12 +13,18 @@ snap install universal-ctags ``` -3. Clone the repository with submodules: +3. Install docker and start the development Docker containers for PostgreSQL and Redis. + + ```sh + docker compose -f docker-compose-dev.yml up -d + ``` + +4. Clone the repository with submodules: ```sh git clone --recurse-submodules https://github.com/sourcebot-dev/sourcebot.git ``` -4. Run `make` to build zoekt and install dependencies: +5. Run `make` to build zoekt and install dependencies: ```sh cd sourcebot make @@ -26,15 +32,15 @@ The zoekt binaries and web dependencies are placed into `bin` and `node_modules` respectively. -5. Create a copy of `.env.development` and name it `.env.development.local`. Update the required environment variables. +6. Create a copy of `.env.development` and name it `.env.development.local`. Update the required environment variables. -6. If you're using a declerative configuration file (the default behavior if you didn't enable auth), create a configuration file and update the `CONFIG_PATH` environment variable in your `.env.development.local` file. +7. If you're using a declerative configuration file (the default behavior if you didn't enable auth), create a configuration file and update the `CONFIG_PATH` environment variable in your `.env.development.local` file. -7. Start Sourcebot with the command: +8. Start Sourcebot with the command: ```sh yarn dev ``` A `.sourcebot` directory will be created and zoekt will begin to index the repositories found in the `config.json` file. -8. Start searching at `http://localhost:3000`. +9. Start searching at `http://localhost:3000`. diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 00000000..5e9aaa90 --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,30 @@ +# docker-compose-dev.yml +version: '3.8' + +services: + redis: + image: redis:7-alpine + container_name: sourcebot-redis + ports: + - "6379:6379" + volumes: + - redis_data:/data + restart: unless-stopped + + postgres: + image: postgres:16-alpine + container_name: sourcebot-postgres + ports: + - "5432:5432" + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + volumes: + - postgres_data:/var/lib/postgresql/data + restart: unless-stopped + +volumes: + redis_data: + postgres_data: + diff --git a/packages/web/src/app/[domain]/components/fileHeader.tsx b/packages/web/src/app/[domain]/components/fileHeader.tsx index 3eff5be6..949c345a 100644 --- a/packages/web/src/app/[domain]/components/fileHeader.tsx +++ b/packages/web/src/app/[domain]/components/fileHeader.tsx @@ -6,6 +6,9 @@ import clsx from "clsx"; import Image from "next/image"; import Link from "next/link"; import { useBrowseNavigation } from "../browse/hooks/useBrowseNavigation"; +import { Copy, CheckCircle2 } from "lucide-react"; +import { useState } from "react"; +import { useToast } from "@/components/hooks/use-toast"; interface FileHeaderProps { fileName: string; @@ -38,6 +41,15 @@ export const FileHeader = ({ }); const { navigateToPath } = useBrowseNavigation(); + const { toast } = useToast(); + const [copied, setCopied] = useState(false); + + const handleCopy = () => { + navigator.clipboard.writeText(fileName); + setCopied(true); + toast({ description: "Copied file path!" }); + setTimeout(() => setCopied(false), 1500); + }; return (
@@ -71,11 +83,9 @@ export const FileHeader = ({

)} ยท -
+
{ navigateToPath({ repoName: repo.name, @@ -97,6 +107,18 @@ export const FileHeader = ({ )} +
)