Skip to content

Commit 749bfc2

Browse files
authored
[dev + copy button] add / update local dev w/docker compose; add copy button to the right of filenames (#328)
1 parent a755eda commit 749bfc2

File tree

4 files changed

+73
-11
lines changed

4 files changed

+73
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Added copy button for filenames. [#328](https://github.com/sourcebot-dev/sourcebot/pull/328)
12+
- Added development docker compose file. [#328](https://github.com/sourcebot-dev/sourcebot/pull/328)
13+
1014
### Fixed
1115
- Fixed issue with the symbol hover popover clipping at the top of the page. [#326](https://github.com/sourcebot-dev/sourcebot/pull/326)
1216
- Fixed slow rendering issue with large reference/definition lists. [#327](https://github.com/sourcebot-dev/sourcebot/pull/327)

CONTRIBUTING.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
>[!NOTE]
33
> 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).
44
5-
1. Install <a href="https://go.dev/doc/install"><img src="https://go.dev/favicon.ico" width="16" height="16"> go</a>, <a href="https://nodejs.org/"><img src="https://nodejs.org/favicon.ico" width="16" height="16"> NodeJS</a>, [redis](https://redis.io/), and [postgres](https://www.postgresql.org/). Note that a NodeJS version of at least `21.1.0` is required.
5+
1. Install <a href="https://go.dev/doc/install"><img src="https://go.dev/favicon.ico" width="16" height="16"> go</a>, and <a href="https://nodejs.org/"><img src="https://nodejs.org/favicon.ico" width="16" height="16"> NodeJS</a>. Note that a NodeJS version of at least `21.1.0` is required.
66

77
2. Install [ctags](https://github.com/universal-ctags/ctags) (required by zoekt)
88
```sh
@@ -13,28 +13,34 @@
1313
snap install universal-ctags
1414
```
1515

16-
3. Clone the repository with submodules:
16+
3. Install <a href="https://docs.docker.com/get-started/get-docker/"><img src="https://www.docker.com/favicon.ico" width="16" height="16"> docker</a> and start the development Docker containers for PostgreSQL and Redis.
17+
18+
```sh
19+
docker compose -f docker-compose-dev.yml up -d
20+
```
21+
22+
4. Clone the repository with submodules:
1723
```sh
1824
git clone --recurse-submodules https://github.com/sourcebot-dev/sourcebot.git
1925
```
2026

21-
4. Run `make` to build zoekt and install dependencies:
27+
5. Run `make` to build zoekt and install dependencies:
2228
```sh
2329
cd sourcebot
2430
make
2531
```
2632

2733
The zoekt binaries and web dependencies are placed into `bin` and `node_modules` respectively.
2834

29-
5. Create a copy of `.env.development` and name it `.env.development.local`. Update the required environment variables.
35+
6. Create a copy of `.env.development` and name it `.env.development.local`. Update the required environment variables.
3036

31-
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.
37+
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.
3238

33-
7. Start Sourcebot with the command:
39+
8. Start Sourcebot with the command:
3440
```sh
3541
yarn dev
3642
```
3743

3844
A `.sourcebot` directory will be created and zoekt will begin to index the repositories found in the `config.json` file.
3945

40-
8. Start searching at `http://localhost:3000`.
46+
9. Start searching at `http://localhost:3000`.

docker-compose-dev.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# docker-compose-dev.yml
2+
version: '3.8'
3+
4+
services:
5+
redis:
6+
image: redis:7-alpine
7+
container_name: sourcebot-redis
8+
ports:
9+
- "6379:6379"
10+
volumes:
11+
- redis_data:/data
12+
restart: unless-stopped
13+
14+
postgres:
15+
image: postgres:16-alpine
16+
container_name: sourcebot-postgres
17+
ports:
18+
- "5432:5432"
19+
environment:
20+
POSTGRES_DB: postgres
21+
POSTGRES_USER: postgres
22+
POSTGRES_PASSWORD: postgres
23+
volumes:
24+
- postgres_data:/var/lib/postgresql/data
25+
restart: unless-stopped
26+
27+
volumes:
28+
redis_data:
29+
postgres_data:
30+

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import clsx from "clsx";
66
import Image from "next/image";
77
import Link from "next/link";
88
import { useBrowseNavigation } from "../browse/hooks/useBrowseNavigation";
9+
import { Copy, CheckCircle2 } from "lucide-react";
10+
import { useState } from "react";
11+
import { useToast } from "@/components/hooks/use-toast";
912

1013
interface FileHeaderProps {
1114
fileName: string;
@@ -38,6 +41,15 @@ export const FileHeader = ({
3841
});
3942

4043
const { navigateToPath } = useBrowseNavigation();
44+
const { toast } = useToast();
45+
const [copied, setCopied] = useState(false);
46+
47+
const handleCopy = () => {
48+
navigator.clipboard.writeText(fileName);
49+
setCopied(true);
50+
toast({ description: "Copied file path!" });
51+
setTimeout(() => setCopied(false), 1500);
52+
};
4153

4254
return (
4355
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
@@ -71,11 +83,9 @@ export const FileHeader = ({
7183
</p>
7284
)}
7385
<span>·</span>
74-
<div
75-
className="flex-1 flex items-center overflow-hidden mt-0.5"
76-
>
86+
<div className="flex-1 flex items-center overflow-hidden mt-0.5">
7787
<span
78-
className="inline-block w-full truncate-start font-mono text-sm cursor-pointer hover:underline"
88+
className="inline-block truncate-start font-mono text-sm cursor-pointer hover:underline"
7989
onClick={() => {
8090
navigateToPath({
8191
repoName: repo.name,
@@ -97,6 +107,18 @@ export const FileHeader = ({
97107
</>
98108
)}
99109
</span>
110+
<button
111+
className="ml-2 p-1 rounded transition-colors"
112+
onClick={handleCopy}
113+
aria-label="Copy file path"
114+
type="button"
115+
>
116+
{copied ? (
117+
<CheckCircle2 className="h-4 w-4 text-green-500" />
118+
) : (
119+
<Copy className="h-4 w-4 text-muted-foreground" />
120+
)}
121+
</button>
100122
</div>
101123
</div>
102124
)

0 commit comments

Comments
 (0)