Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add context menu for sidebar items
✓ CI success Rūdolfs Ošiņš committed 28 days ago
commit 7570f4aed53abf5feb9ce6d93a4780eb21d83af1
parent 071504fda70e9bcbc4f8c508eff408b3f75cd61b
1 passed (1 total) View logs
2 files changed +54 -7
modified crates/radicle-tauri/capabilities/default.json
@@ -19,6 +19,9 @@
    "core:window:default",
    "dialog:default",
    "log:default",
-
    "shell:allow-open"
+
    {
+
      "identifier": "shell:allow-open",
+
      "allow": [{ "url": "https://radicle.network/**" }]
+
    }
  ]
}
modified src/components/SidebarRepoList.svelte
@@ -9,13 +9,16 @@

  import { nodeRunning } from "@app/lib/events";
  import { dynamicInterval, resetDynamicInterval } from "@app/lib/interval";
-
  import { cachedRepoCommitCount, invoke } from "@app/lib/invoke";
+
  import {
+
    cachedRepoCommitCount,
+
    invoke,
+
    writeToClipboard,
+
  } from "@app/lib/invoke";
  import * as router from "@app/lib/router";
  import useLocalStorage from "@app/lib/useLocalStorage.svelte";
-
  import { formatRepositoryId } from "@app/lib/utils";
+
  import { explorerUrl, formatRepositoryId } from "@app/lib/utils";

  import AddRepoButton from "@app/components/AddRepoButton.svelte";
-
  import Clipboard from "@app/components/Clipboard.svelte";
  import Icon from "@app/components/Icon.svelte";
  import RepoAvatar from "@app/components/RepoAvatar.svelte";
  import ScrollArea from "@app/components/ScrollArea.svelte";
@@ -47,6 +50,49 @@
    repos = initialRepos;
  });

+
  async function showRepoContextMenu(event: MouseEvent, repo: RepoSummary) {
+
    event.preventDefault();
+
    if (!window.__TAURI_INTERNALS__) return;
+

+
    const { Menu } = await import("@tauri-apps/api/menu");
+
    const { open } = await import("@tauri-apps/plugin-shell");
+
    const url = explorerUrl(repo.rid);
+

+
    const menu = await Menu.new({
+
      items: [
+
        {
+
          id: "copy-rid",
+
          text: "Copy RID",
+
          action: () => {
+
            void writeToClipboard(repo.rid);
+
          },
+
        },
+
        {
+
          id: "copy-checkout",
+
          text: "Copy checkout command",
+
          action: () => {
+
            void writeToClipboard(`rad checkout ${repo.rid}`);
+
          },
+
        },
+
        {
+
          id: "copy-link",
+
          text: "Copy link to radicle.network",
+
          action: () => {
+
            void writeToClipboard(url);
+
          },
+
        },
+
        {
+
          id: "open-explorer",
+
          text: "Open on radicle.network",
+
          action: () => {
+
            void open(url);
+
          },
+
        },
+
      ],
+
    });
+
    await menu.popup();
+
  }
+

  $effect(() => {
    seededNotReplicated = initialSeededNotReplicated;
  });
@@ -581,6 +627,7 @@
    draggable="false"
    onmousedown={pinned ? e => drag.onMouseDown(e, repo.rid) : undefined}
    onclick={pinned ? drag.onClick : undefined}
+
    oncontextmenu={e => showRepoContextMenu(e, repo)}
    href={router.routeToPath({ resource: "repo.home", rid: repo.rid })}>
    <RepoAvatar name={repo.name} rid={repo.rid} styleWidth="1rem" />
    <span class="txt-overflow">{repo.name}</span>
@@ -597,9 +644,6 @@
        onclick={() => togglePin(repo.rid)}>
        <Icon name={pinState ? "pin-filled" : "pin-hollow"} />
      </button>
-
      <span title="Copy RID">
-
        <Clipboard text={repo.rid} noPopover />
-
      </span>
      {#if pinned}
        <span class="drag-handle" title="Drag to reorder">
          <Icon name="drag-handle" />