diff --git a/explorer/src/lib/shareAction.ts b/explorer/src/lib/shareAction.ts new file mode 100644 index 000000000..c7c3a9f4f --- /dev/null +++ b/explorer/src/lib/shareAction.ts @@ -0,0 +1,17 @@ +import storedWritable from "@app/lib/localStore"; +import { z } from "zod"; + +const shareActionSchema = z.enum([ + "openInApp", + "copyLink", + "copyId", + "copyUri", +]); +export type ShareAction = z.infer; + +export const shareAction = storedWritable( + "shareAction", + shareActionSchema, + "copyLink", + !window.localStorage, +); diff --git a/explorer/src/views/repos/Commit.svelte b/explorer/src/views/repos/Commit.svelte index c2aac61f6..b94e64b3f 100644 --- a/explorer/src/views/repos/Commit.svelte +++ b/explorer/src/views/repos/Commit.svelte @@ -20,6 +20,7 @@ import Link from "@app/components/Link.svelte"; import Popover from "@app/components/Popover.svelte"; import Separator from "./Separator.svelte"; + import Share from "./Share.svelte"; export let baseUrl: BaseUrl; export let commit: Commit; @@ -75,7 +76,7 @@ } - + {/if}
+ { - shareIcon = "link"; - }, 1000); - function tabRoute(): string { if (activeTab === "issues") { return routeToPath({ @@ -60,13 +54,6 @@ }); } } - - async function copyLink() { - const origin = new URL(config.nodes.fallbackPublicExplorer).origin; - await toClipboard(origin.concat(tabRoute())); - shareIcon = "checkmark"; - restoreIcon(); - } + + + + { + if (event.key === "Escape") hideNotice(); + }} /> + +
+ + +
+ + + + + { + $shareAction = item.kind; + closeFocused(); + void run(item.kind); + }}> + + {item.title} + + + +
+ + {#if notice} +
+
+ Opening in app. Didn't open? + (notice = false)}> + Get Radicle Desktop + +
+ (notice = false)}> + + +
+ {/if} +
diff --git a/explorer/tests/e2e/repo/issue.spec.ts b/explorer/tests/e2e/repo/issue.spec.ts index 1bf4c4b9a..84fcbd369 100644 --- a/explorer/tests/e2e/repo/issue.spec.ts +++ b/explorer/tests/e2e/repo/issue.spec.ts @@ -6,3 +6,14 @@ test("navigate single issue", async ({ page }) => { await expect(page).toHaveURL(/\/issues\/[0-9a-f]{40}/); }); + +test("open in app offers the download page", async ({ page }) => { + await page.goto(`${cobUrl}/issues`); + await page.getByText("This title has **markdown**").click(); + await page.getByRole("button", { name: "Share options" }).click(); + await page.getByText("Open in app").click(); + + await expect(page.getByRole("status")).toContainText("Didn't open?"); + await page.getByRole("link", { name: "Get Radicle Desktop" }).click(); + await expect(page).toHaveURL(/\/desktop$/); +});