Use configured explorer and seed for links

explorerUrl() hardcoded both the seed ("iris.radicle.network") and
the explorer base ("https://radicle.network"), so every "Copy Link"
and "Open in …" action ignored the user's config and could point at
a host that does not replicate the repo.

Expose publicExplorer and preferredSeeds on the Config type (both
already carried by radicle::profile::Config) and thread config
through to every explorerUrl() call site. URLs are now built from
the publicExplorer template, filling $host from the first preferred
seed (falling back to rosa only when none are configured), and link
labels show the configured explorer's host.

Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
hlatimer266
2026-07-21 13:26:31 +02:00
committed by Rūdolfs Ošiņš
co-authored by Rūdolfs Ošiņš
parent 7fe26dc4e5
commit 74aaa6ef14
13 changed files with 109 additions and 28 deletions
+1
View File
@@ -199,6 +199,7 @@
<SidebarRepoList
initialRepos={sidebarData.repos}
initialSeededNotReplicated={sidebarData.seededNotReplicated}
config={sidebarData.config}
{activeRepo} />
</div>
+11 -3
View File
@@ -4,7 +4,12 @@
import debounce from "lodash/debounce";
import { writeToClipboard } from "@app/lib/invoke";
import { didFromPublicKey, explorerUrl, truncateDid } from "@app/lib/utils";
import {
didFromPublicKey,
explorerHost,
explorerUrl,
truncateDid,
} from "@app/lib/utils";
import Button from "@app/components/Button.svelte";
import DropdownListItem from "@app/components/DropdownListItem.svelte";
@@ -60,11 +65,14 @@
style:text-decoration="none"
style:width="100%"
onclick={closeFocused}
href={explorerUrl(`users/${didFromPublicKey(config.publicKey)}`)}
href={explorerUrl(
`users/${didFromPublicKey(config.publicKey)}`,
config,
)}
target="_blank">
<DropdownListItem styleGap="0.5rem" styleWidth="100%" selected={false}>
<Icon name="seed" />
view on iris.radicle.network
Open in {explorerHost(config)}
<span style:margin-left="auto"><Icon name="open-external" /></span>
</DropdownListItem>
</a>
+5 -3
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import type { Config } from "@bindings/config/Config";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import debounce from "lodash/debounce";
@@ -15,9 +16,10 @@
interface Props {
repo: RepoInfo;
config: Config;
}
const { repo }: Props = $props();
const { repo, config }: Props = $props();
const project = $derived(repo.payloads["xyz.radicle.project"]!);
@@ -27,7 +29,7 @@
}, 1000);
async function copyLink() {
await writeToClipboard(explorerUrl(repo.rid));
await writeToClipboard(explorerUrl(repo.rid, config));
copyIcon = "checkmark";
restoreCopyIcon();
}
@@ -131,7 +133,7 @@
style:white-space="nowrap"
style:text-decoration="none"
style:width="100%"
href={explorerUrl(`users/${delegate.did}`)}
href={explorerUrl(`users/${delegate.did}`, config)}
target="_blank">
{#if delegate.alias}
<span class="txt-overflow alias">
+11 -4
View File
@@ -37,6 +37,7 @@
</script>
<script lang="ts">
import type { Config } from "@bindings/config/Config";
import type { RepoInfo } from "@bindings/repo/RepoInfo";
import type { RepoSummary } from "@bindings/repo/RepoSummary";
@@ -53,7 +54,11 @@
writeToClipboard,
} from "@app/lib/invoke";
import * as router from "@app/lib/router";
import { explorerUrl, formatRepositoryId } from "@app/lib/utils";
import {
explorerHost,
explorerUrl,
formatRepositoryId,
} from "@app/lib/utils";
import AddRepoButton from "@app/components/AddRepoButton.svelte";
import ContextMenu from "@app/components/ContextMenu.svelte";
@@ -69,12 +74,14 @@
initialRepos: RepoSummary[];
initialSeededNotReplicated: string[];
activeRepo?: RepoInfo;
config: Config;
}
const {
initialRepos,
initialSeededNotReplicated,
activeRepo = undefined,
config,
}: Props = $props();
let repos: RepoSummary[] = $derived(initialRepos);
@@ -716,7 +723,7 @@
{#if contextMenu}
{@const repo = contextMenu.repo}
{@const url = explorerUrl(repo.rid)}
{@const url = explorerUrl(repo.rid, config)}
<ContextMenu
x={contextMenu.x}
y={contextMenu.y}
@@ -741,7 +748,7 @@
role="menuitem"
onclick={() => writeToClipboard(url)}>
<Icon name="link" />
Copy link to radicle.network
Copy link to {explorerHost(config)}
</button>
<a
class="menu-item"
@@ -750,7 +757,7 @@
target="_blank"
rel="noreferrer noopener">
<Icon name="open-external" />
Open on radicle.network
Open in {explorerHost(config)}
</a>
</ContextMenu>
{/if}