Dough Git

commit

Add dedicated settings page

commit
9215d6f30ca1ddaf317166e419d38c3491532ac4
author
Clove <[email protected]>
date
2026-11-24 15:41

diff --git a/src/lib/components/RepoNav.svelte b/src/lib/components/RepoNav.svelte
index 1910485..cfb2deb 100644
--- a/src/lib/components/RepoNav.svelte
+++ b/src/lib/components/RepoNav.svelte
@@ -6,6 +6,7 @@
   import IcCommit from "~icons/ic/outline-commit";
   import IcDescription from "~icons/ic/outline-description";
   import IcFolder from "~icons/ic/outline-folder";
+  import IcSettings from "~icons/ic/outline-settings";
   import Tabs from "#lib/components/Tabs.svelte";
 
   let {
@@ -13,11 +14,13 @@
     name,
     active,
     query,
+    canManage,
   }: {
     owner: string;
     name: string;
-    active: "summary" | "log" | "tree";
+    active: "summary" | "log" | "tree" | "settings";
     query: string;
+    canManage: boolean;
   } = $props();
 
   const base = $derived(`/${owner}/${name}`);
@@ -44,5 +47,15 @@
       icon: IcFolder,
       href: `${base}/tree${query}`,
     },
+    ...(canManage
+      ? [
+        {
+          id: "settings",
+          label: "settings",
+          icon: IcSettings,
+          href: `${base}/settings`,
+        },
+      ]
+      : []),
   ]}
 />
diff --git a/src/routes/[owner]/[name=repo]/+page.server.ts b/src/routes/[owner]/[name=repo]/+page.server.ts
index 95c5634..d8fde69 100644
--- a/src/routes/[owner]/[name=repo]/+page.server.ts
+++ b/src/routes/[owner]/[name=repo]/+page.server.ts
@@ -2,64 +2,16 @@
  * LICENCED DASL-1.0 (c) Clove Twilight
  */
 
+import type { PageServerLoad } from "./$types";
 import { background } from "#lib/server/background.ts";
-import { redirect } from "@sveltejs/kit";
-import type { Actions, PageServerLoad } from "./$types";
 import { config } from "#lib/server/config.ts";
 import { sessionSlug } from "#lib/server/auth.ts";
-import { findUserBySlug } from "#lib/server/users.ts";
-import { siteRole } from "#lib/server/roles.ts";
-import { removeRepoImage, saveRepoImage } from "#lib/server/avatars.ts";
 import { getSettings } from "#lib/server/settings.ts";
-import { clearRepoMetadata } from "#lib/server/repometa.ts";
-import { notifyRepoDeleted } from "#lib/server/notify.ts";
 import { renderMarkdown, plainSummary, repositoryLinks } from "#lib/server/markdown.ts";
 import { describeMirror } from "#lib/server/mirrorview.ts";
-import {
-  isLevel,
-  listCollaborators,
-  removeCollaborator,
-  setCollaborator,
-} from "#lib/server/access.ts";
-import {
-  MIRROR_KINDS,
-  mirrorHost,
-  mirrorSlug,
-  mirrorUrl,
-  type MirrorKind,
-} from "#lib/server/urls.ts";
-import {
-  checkAllMirrors,
-  dropMirrorStatusKind,
-  getStatuses,
-  needsCheck,
-} from "#lib/server/mirror.ts";
-import {
-  description,
-  isRepoPublic,
-  localMirrorRefs,
-  log,
-  readLinks,
-  readme,
-  refSlug,
-  setDescription,
-  setLinks,
-  setRepoPublic,
-  trashRepo,
-  type MirrorLink,
-  type RepoRef,
-} from "#lib/server/git.ts";
-import {
-  fail,
-  field,
-  me,
-  notAnImage,
-  ownedRef,
-  uploadedImage,
-  revQuery,
-  viewable,
-  writableRef,
-} from "#lib/server/web.ts";
+import { checkAllMirrors, getStatuses, needsCheck } from "#lib/server/mirror.ts";
+import { description, localMirrorRefs, log, readLinks, readme, refSlug } from "#lib/server/git.ts";
+import { revQuery, viewable } from "#lib/server/web.ts";
 
 export const load: PageServerLoad = async (event) => {
   const { ref, isPublic, access, refs, rev } = await viewable(event);
@@ -122,152 +74,7 @@ export const load: PageServerLoad = async (event) => {
       : null,
     canPush,
     isOwner,
-    collaborators: isOwner
-      ? await Promise.all(
-          (await listCollaborators(ref)).map(async (person) => ({
-            ...person,
-            role: await siteRole(person.slug),
-          })),
-        )
-      : null,
     mirrors: links.map((link) => describeMirror(link, statuses.get(link.kind) ?? null, nowSec)),
-    canCheckMirrors: canPush && links.some((l) => !l.isPrivate),
-    mirrorFields: MIRROR_KINDS.map((kind) => {
-      const existing = links.find((l) => l.kind === kind);
-      return {
-        kind,
-        value: existing ? mirrorSlug(kind, existing.url) : "",
-        isPrivate: existing?.isPrivate ?? false,
-      };
-    }),
-    mirrorHosts: MIRROR_KINDS.map(mirrorHost).join(" or "),
     localSha,
   };
 };
-
-function back(ref: RepoRef): never {
-  redirect(303, `/${ref.owner}/${ref.name}`);
-}
-
-export const actions: Actions = {
-  description: async (event) => {
-    const ref = await writableRef(event);
-    const form = await event.request.formData();
-    await setDescription(ref, field(form, "description"));
-    back(ref);
-  },
-
-  image: async (event) => {
-    const ref = await ownedRef(event);
-    if (!(await saveRepoImage(ref, await uploadedImage(event, "image")))) notAnImage();
-    back(ref);
-  },
-
-  removeImage: async (event) => {
-    const ref = await ownedRef(event);
-    await removeRepoImage(ref);
-    back(ref);
-  },
-
-  visibility: async (event) => {
-    const ref = await ownedRef(event);
-    const form = await event.request.formData();
-    await setRepoPublic(ref, form.get("public") === "on");
-    back(ref);
-  },
-
-  delete: async (event) => {
-    const ref = await ownedRef(event);
-    const slug = sessionSlug(me(event));
-    const wasPublic = await isRepoPublic(ref);
-
-    const result = await trashRepo(ref, {
-      deletedAt: Math.floor(Date.now() / 1000),
-      deletedBy: slug,
-      grants: (await listCollaborators(ref)).map((g) => ({
-        slug: g.slug,
-        level: g.level,
-      })),
-    });
-    if (!result.ok) fail("could not delete", result.error ?? "unknown error");
-
-    await clearRepoMetadata(ref);
-    notifyRepoDeleted(ref, slug, wasPublic);
-    redirect(303, "/settings/deleted");
-  },
-
-  collaborator: async (event) => {
-    const ref = await ownedRef(event);
-    const form = await event.request.formData();
-    const slug = field(form, "slug").trim().toLowerCase();
-    const levelRaw = field(form, "level") || "read";
-    const level = isLevel(levelRaw) ? levelRaw : "read";
-
-    const invited = await findUserBySlug(slug);
-    if (!invited) {
-      fail(
-        "no such user",
-        `Nobody on this instance goes by "${slug}". They have to sign in ` +
-          `to this instance once before they can be added.`,
-      );
-    }
-    if (invited.slug === ref.owner) {
-      fail("already the owner", "You can't add yourself as a collaborator on your own repo.");
-    }
-
-    await setCollaborator(ref, invited.slug, level);
-    back(ref);
-  },
-
-  uncollaborate: async (event) => {
-    const ref = await ownedRef(event);
-    const form = await event.request.formData();
-    await removeCollaborator(ref, field(form, "slug"));
-    back(ref);
-  },
-
-  mirrors: async (event) => {
-    const ref = await ownedRef(event);
-    const form = await event.request.formData();
-
-    const links: MirrorLink[] = [];
-    const rejected: MirrorKind[] = [];
-    for (const kind of MIRROR_KINDS) {
-      const raw = field(form, kind).trim();
-      if (!raw) continue;
-      const url = mirrorUrl(kind, raw);
-      if (!url) {
-        rejected.push(kind);
-        continue;
-      }
-      links.push({
-        kind,
-        url,
-        isPrivate: form.get(`${kind}_private`) != null,
-      });
-    }
-
-    if (rejected.length > 0) {
-      fail(
-        "that isn't a mirror URL",
-        `The ${rejected.join(" and ")} link was refused. Give the repository as ` +
-          `owner/repo — for example doughmination/dough-git — and it is looked up on ` +
-          `${mirrorHost(rejected[0]!)}.`,
-      );
-    }
-
-    const before = await readLinks(ref);
-    await setLinks(ref, links);
-    for (const old of before) {
-      const still = links.find((l) => l.kind === old.kind && l.url === old.url);
-      if (!still) await dropMirrorStatusKind(ref, old.kind);
-    }
-    back(ref);
-  },
-
-  check: async (event) => {
-    const ref = await writableRef(event);
-    await checkAllMirrors(ref, await readLinks(ref));
-    back(ref);
-  },
-};
diff --git a/src/routes/[owner]/[name=repo]/+page.svelte b/src/routes/[owner]/[name=repo]/+page.svelte
index 68b85c2..1dcd565 100644
--- a/src/routes/[owner]/[name=repo]/+page.svelte
+++ b/src/routes/[owner]/[name=repo]/+page.svelte
@@ -8,34 +8,19 @@
   import IcArrowUpward from "~icons/ic/outline-arrow-upward";
   import IcCancel from "~icons/ic/outline-cancel";
   import IcCheckCircle from "~icons/ic/outline-check-circle";
-  import IcDelete from "~icons/ic/outline-delete";
   import IcDescription from "~icons/ic/outline-description";
   import IcDownload from "~icons/ic/outline-download";
   import IcHelpOutline from "~icons/ic/outline-help-outline";
   import IcHome from "~icons/ic/outline-home";
-  import IcImage from "~icons/ic/outline-image";
   import IcLock from "~icons/ic/outline-lock";
-  import IcLockOpen from "~icons/ic/outline-lock-open";
   import IcOpenInNew from "~icons/ic/outline-open-in-new";
-  import IcPeople from "~icons/ic/outline-people";
-  import IcPerson from "~icons/ic/outline-person";
-  import IcPersonAdd from "~icons/ic/outline-person-add";
-  import IcPersonRemove from "~icons/ic/outline-person-remove";
   import IcPublic from "~icons/ic/outline-public";
-  import IcRefresh from "~icons/ic/outline-refresh";
-  import IcSave from "~icons/ic/outline-save";
-  import IcSettings from "~icons/ic/outline-settings";
-  import IcUpload from "~icons/ic/outline-upload";
-  import IcStickyNote2 from "~icons/ic/outline-sticky-note-2";
   import IcStorage from "~icons/ic/outline-storage";
   import IcWarning from "~icons/ic/outline-warning";
-  import { fmtDate } from "#lib";
   import Meta from "#lib/components/Meta.svelte";
   import RepoNav from "#lib/components/RepoNav.svelte";
   import RevPicker from "#lib/components/RevPicker.svelte";
   import Visibility from "#lib/components/Visibility.svelte";
-  import ConfirmForm from "#lib/components/ConfirmForm.svelte";
-  import RoleBadge from "#lib/components/RoleBadge.svelte";
 
   let { data } = $props();
 
@@ -77,24 +62,9 @@
     </p>
   </div>
 
-  <RepoNav owner={data.owner} name={data.name} active="summary" query={data.query} />
+  <RepoNav owner={data.owner} name={data.name} active="summary" query={data.query} canManage={data.canPush} />
 
-  {#if data.canPush}
-    <form method="post" action="?/description" class="panel row">
-      <label class="field-label with-icon" for="repo-description">
-        <IcStickyNote2 class="icon" width="16" height="16" />description
-      </label>
-      <input
-        id="repo-description"
-        type="text"
-        name="description"
-        maxlength="300"
-        value={data.rawDescription}
-        placeholder="what this repository is for"
-      />
-      <button type="submit"><IcSave class="icon" width="16" height="16" />save</button>
-    </form>
-  {:else if data.rawDescription}
+  {#if data.rawDescription}
     <p class="muted">{data.rawDescription}</p>
   {/if}
 
@@ -119,79 +89,36 @@ git push --mirror mirror</code></pre>
     <p class="panel empty">This repository is empty.</p>
   {/if}
 
-  {#if data.mirrors.length > 0 || data.isOwner}
+  {#if data.mirrors.length > 0}
     <h2 class="section-title"><IcStorage class="icon" width="20" height="20" />External mirrors</h2>
 
-    {#if data.mirrors.length > 0}
-      <section class="panel mirrors">
-        {#each data.mirrors as mirror (mirror.kind)}
-          {@const Glyph = MIRROR_GLYPHS[mirror.glyph] ?? IcHelpOutline}
-          <div class="mirror-row">
-            <a class="with-icon" href={mirror.url} rel="nofollow noopener noreferrer">
-              <IcPublic class="icon" width="16" height="16" />{mirror.slug}
-            </a>
-            <span class="{mirror.cls} with-icon">
-              <Glyph class="icon" width="16" height="16" />{mirror.label}
-            </span>
-            <span class="mono">{mirror.sha}</span>
-            <span class="muted">{mirror.detail}</span>
-          </div>
-          {#if mirror.note}
-            <p class={mirror.noteCls}>{mirror.note}</p>
-          {/if}
-        {/each}
-
-        {#if data.localSha}
-          <div class="mirror-row">
-            <span class="with-icon"><IcHome class="icon" width="16" height="16" />local</span>
-            <span class="empty">this repository</span>
-            <span class="mono">{data.localSha.slice(0, 7)}</span>
-            <span></span>
-          </div>
-        {/if}
-
-        {#if data.canCheckMirrors}
-          <form method="post" action="?/check">
-            <button type="submit"><IcRefresh class="icon" width="16" height="16" />check now</button>
-          </form>
+    <section class="panel mirrors">
+      {#each data.mirrors as mirror (mirror.kind)}
+        {@const Glyph = MIRROR_GLYPHS[mirror.glyph] ?? IcHelpOutline}
+        <div class="mirror-row">
+          <a class="with-icon" href={mirror.url} rel="nofollow noopener noreferrer">
+            <IcPublic class="icon" width="16" height="16" />{mirror.slug}
+          </a>
+          <span class="{mirror.cls} with-icon">
+            <Glyph class="icon" width="16" height="16" />{mirror.label}
+          </span>
+          <span class="mono">{mirror.sha}</span>
+          <span class="muted">{mirror.detail}</span>
+        </div>
+        {#if mirror.note}
+          <p class={mirror.noteCls}>{mirror.note}</p>
         {/if}
-      </section>
-    {:else}
-      <p class="empty">No mirrors configured.</p>
-    {/if}
-
-    {#if data.isOwner}
-      <form method="post" action="?/mirrors" class="panel">
-        {#each data.mirrorFields as mirror (mirror.kind)}
-          <div class="row">
-            <label class="field-label with-icon" for="mirror-{mirror.kind}">
-              <IcPublic class="icon" width="16" height="16" />{mirror.kind}
-            </label>
-            <input
-              id="mirror-{mirror.kind}"
-              type="text"
-              name={mirror.kind}
-              value={mirror.value}
-              placeholder="user/repo"
-              pattern={"[^\\s/]+/[^\\s/]+/?"}
-              autocapitalize="off"
-              spellcheck="false"
-            />
-            <label class="check">
-              <input type="checkbox" name="{mirror.kind}_private" checked={mirror.isPrivate} /> private
-            </label>
-          </div>
-        {/each}
-        <p class="muted small">
-          Give the <code>user/repo</code> on {data.mirrorHosts} — not a full URL. Mark a mirror <em>private</em> to
-          skip status checks — they are anonymous, so a private mirror would otherwise always look unreachable.
-          Clear a field to remove it.
-        </p>
-        <div>
-          <button type="submit"><IcSave class="icon" width="16" height="16" />save mirrors</button>
+      {/each}
+
+      {#if data.localSha}
+        <div class="mirror-row">
+          <span class="with-icon"><IcHome class="icon" width="16" height="16" />local</span>
+          <span class="empty">this repository</span>
+          <span class="mono">{data.localSha.slice(0, 7)}</span>
+          <span></span>
         </div>
-      </form>
-    {/if}
+      {/if}
+    </section>
   {/if}
 
   {#if data.readme}
@@ -201,87 +128,6 @@ git push --mirror mirror</code></pre>
     <h2 class="section-title"><IcDescription class="icon" width="20" height="20" />Readme</h2>
     <p class="empty">No ReadMe was found, commit one to add a summary</p>
   {/if}
-
-  {#if data.isOwner && data.collaborators}
-    <h2 class="section-title"><IcSettings class="icon" width="20" height="20" />Manage</h2>
-    <div class="buttons">
-      <form method="post" action="?/visibility">
-        <input type="hidden" name="public" value={data.isPublic ? "" : "on"} />
-        <button type="submit">
-          {#if data.isPublic}
-            <IcLock class="icon" width="16" height="16" />
-          {:else}
-            <IcLockOpen class="icon" width="16" height="16" />
-          {/if}
-          make {data.isPublic ? "private" : "public"}
-        </button>
-      </form>
-      <ConfirmForm action="?/delete" prompt="Delete {title}? It moves to Recently Deleted.">
-        <button type="submit" class="danger"><IcDelete class="icon" width="16" height="16" />delete repository</button>
-      </ConfirmForm>
-    </div>
-
-    <h2 class="section-title"><IcImage class="icon" width="20" height="20" />Image</h2>
-    <p class="muted">
-      Shown beside the name and in link embeds, in place of your avatar. Private repositories keep your avatar in
-      embeds, since Discord can't fetch their image.
-    </p>
-    <section class="panel">
-      <form method="post" action="?/image" enctype="multipart/form-data" class="row">
-        <input type="file" name="image" accept="image/png,image/jpeg,image/gif,image/webp" aria-label="repository image" required />
-        <button type="submit" class="primary"><IcUpload class="icon" width="16" height="16" />upload</button>
-      </form>
-      {#if data.repoImage}
-        <ConfirmForm action="?/removeImage" prompt="Remove the image from {title}?">
-          <button type="submit" class="danger"><IcDelete class="icon" width="16" height="16" />remove image</button>
-        </ConfirmForm>
-      {/if}
-    </section>
-
-    <h2 class="section-title"><IcPeople class="icon" width="20" height="20" />Collaborators</h2>
-    <p class="muted">
-      People here can see this repository even while it is private. <code>write</code> also lets them push to it.
-    </p>
-    <form method="post" action="?/collaborator" class="panel row">
-      <label class="field-label with-icon" for="collab-slug"><IcPerson class="icon" width="16" height="16" />username</label>
-      <input id="collab-slug" type="text" name="slug" placeholder="their handle" pattern="[A-Za-z0-9._\-]+" required />
-      <select name="level" aria-label="access level">
-        <option value="read">read</option>
-        <option value="write">write</option>
-      </select>
-      <button type="submit"><IcPersonAdd class="icon" width="16" height="16" />add</button>
-    </form>
-
-    <div class="table-wrap">
-      <table>
-        <thead>
-          <tr>
-            <th>user</th>
-            <th>access</th>
-            <th>added</th>
-            <th></th>
-          </tr>
-        </thead>
-        <tbody>
-          {#each data.collaborators as person (person.slug)}
-            <tr>
-              <td><IcPerson class="icon" width="14" height="14" /> <a href="/{person.slug}">{person.slug}</a> <RoleBadge role={person.role} /></td>
-              <td class="mono">{person.level}</td>
-              <td class="mono">{fmtDate(person.added_at)}</td>
-              <td>
-                <form method="post" action="?/uncollaborate">
-                  <input type="hidden" name="slug" value={person.slug} />
-                  <button type="submit" class="small"><IcPersonRemove class="icon" width="14" height="14" />remove</button>
-                </form>
-              </td>
-            </tr>
-          {:else}
-            <tr><td colspan="4" class="empty">nobody else has access</td></tr>
-          {/each}
-        </tbody>
-      </table>
-    </div>
-  {/if}
 </div>
 
 <style>
diff --git a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
index 5e6ffdf..ead4f89 100644
--- a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
+++ b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.server.ts
@@ -7,7 +7,7 @@ import { blob } from "#lib/server/git.ts";
 import { notFound, revQuery, viewable } from "#lib/server/web.ts";
 
 export const load: PageServerLoad = async (event) => {
-  const { ref, refs, rev } = await viewable(event);
+  const { ref, access, refs, rev } = await viewable(event);
   const path = event.params.path;
 
   const file = await blob(ref, rev, path);
@@ -16,6 +16,7 @@ export const load: PageServerLoad = async (event) => {
   return {
     owner: ref.owner,
     name: ref.name,
+    canManage: access === "write",
     path,
     query: revQuery(rev, refs.head),
     ...file,
diff --git a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
index 138cd63..308af47 100644
--- a/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
+++ b/src/routes/[owner]/[name=repo]/blob/[...path]/+page.svelte
@@ -26,7 +26,7 @@
     <h1 class="path">{data.path}</h1>
   </div>
 
-  <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} />
+  <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} canManage={data.canManage} />
 
   <p class="muted">
     <a class="with-icon" href="/{data.owner}/{data.name}/tree/{up}{data.query}">
diff --git a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
index 7b4ef8c..027078d 100644
--- a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
+++ b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.server.ts
@@ -7,7 +7,7 @@ import { commit } from "#lib/server/git.ts";
 import { notFound, viewable } from "#lib/server/web.ts";
 
 export const load: PageServerLoad = async (event) => {
-  const { ref, rev } = await viewable(event);
+  const { ref, access, rev } = await viewable(event);
 
   const detail = await commit(ref, event.params.sha);
   if (!detail) notFound();
@@ -15,6 +15,7 @@ export const load: PageServerLoad = async (event) => {
   return {
     owner: ref.owner,
     name: ref.name,
+    canManage: access === "write",
     query: `?h=${encodeURIComponent(rev)}`,
     commit: detail,
   };
diff --git a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
index 9093f38..c2f4ab7 100644
--- a/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
+++ b/src/routes/[owner]/[name=repo]/commit/[sha]/+page.svelte
@@ -27,7 +27,7 @@
     <h1>{commit.subject}</h1>
   </div>
 
-  <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} />
+  <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} canManage={data.canManage} />
 
   <dl class="panel commit-meta">
     <dt class="with-icon"><IcCommit class="icon" width="14" height="14" />commit</dt>
diff --git a/src/routes/[owner]/[name=repo]/log/+page.server.ts b/src/routes/[owner]/[name=repo]/log/+page.server.ts
index 7faa5f9..a27136e 100644
--- a/src/routes/[owner]/[name=repo]/log/+page.server.ts
+++ b/src/routes/[owner]/[name=repo]/log/+page.server.ts
@@ -7,10 +7,11 @@ import { log } from "#lib/server/git.ts";
 import { revQuery, viewable } from "#lib/server/web.ts";
 
 export const load: PageServerLoad = async (event) => {
-  const { ref, refs, rev } = await viewable(event);
+  const { ref, access, refs, rev } = await viewable(event);
   return {
     owner: ref.owner,
     name: ref.name,
+    canManage: access === "write",
     refs,
     rev,
     query: revQuery(rev, refs.head),
diff --git a/src/routes/[owner]/[name=repo]/log/+page.svelte b/src/routes/[owner]/[name=repo]/log/+page.svelte
index 59842bb..cfd8c78 100644
--- a/src/routes/[owner]/[name=repo]/log/+page.svelte
+++ b/src/routes/[owner]/[name=repo]/log/+page.svelte
@@ -26,7 +26,7 @@
     <h1>{title}</h1>
   </div>
 
-  <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} />
+  <RepoNav owner={data.owner} name={data.name} active="log" query={data.query} canManage={data.canManage} />
   <RevPicker refs={data.refs} rev={data.rev} />
 
   <div class="table-wrap">
diff --git a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
index d56d431..f78ec74 100644
--- a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
+++ b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.server.ts
@@ -7,11 +7,12 @@ import { tree } from "#lib/server/git.ts";
 import { revQuery, viewable } from "#lib/server/web.ts";
 
 export const load: PageServerLoad = async (event) => {
-  const { ref, refs, rev } = await viewable(event);
+  const { ref, access, refs, rev } = await viewable(event);
   const path = event.params.path.replace(/\/+$/, "");
   return {
     owner: ref.owner,
     name: ref.name,
+    canManage: access === "write",
     path,
     refs,
     rev,
diff --git a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
index d99180a..26ae8bf 100644
--- a/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
+++ b/src/routes/[owner]/[name=repo]/tree/[...path]/+page.svelte
@@ -32,7 +32,7 @@
     <h1>{data.owner}/{data.name}</h1>
   </div>
 
-  <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} />
+  <RepoNav owner={data.owner} name={data.name} active="tree" query={data.query} canManage={data.canManage} />
   <RevPicker refs={data.refs} rev={data.rev} />
 
   <div class="table-wrap">