mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Rename URN -> ID
Co-authored-by: xphoniex <dj.2dixx@gmail.com> Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
co-authored by
xphoniex
parent
caa83db480
commit
1a5430aced
@@ -69,7 +69,7 @@ RAD_HOME=$ALICE_RAD_HOME rad init --name "source-browsing" --description "Git re
|
||||
|
||||
sleep 10
|
||||
RAD_HOME=$ALICE_RAD_HOME rad push --seed 0.0.0.0:8778 --all --sync
|
||||
PROJECT_URN=$(rad .)
|
||||
PROJECT_ID=$(rad .)
|
||||
|
||||
|
||||
GIT_AUTHOR_NAME="Bob Belcher"
|
||||
@@ -80,7 +80,7 @@ GIT_COMMITTER_EMAIL="bob@radicle.xyz"
|
||||
RAD_HOME=$BOB_RAD_HOME rad auth --init --name bob --passphrase $PASSPHRASE
|
||||
|
||||
cd $BOB_CHECKOUT
|
||||
RAD_HOME=$BOB_RAD_HOME rad clone $PROJECT_URN --seed 0.0.0.0:8778 --no-confirm
|
||||
RAD_HOME=$BOB_RAD_HOME rad clone $PROJECT_ID --seed 0.0.0.0:8778 --no-confirm
|
||||
|
||||
cd $TEST_REPO_NAME
|
||||
echo "Updated readme" > README.md
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
}
|
||||
|
||||
const projectOnSeeds = config.seeds.pinned.map(seed => ({
|
||||
nameOrUrn: query,
|
||||
nameOrId: query,
|
||||
seed: seed.host,
|
||||
}));
|
||||
|
||||
// The query is a radicle project URN.
|
||||
// The query is a radicle project ID.
|
||||
if (utils.isRadicleId(query)) {
|
||||
const projects = await Project.getMulti(projectOnSeeds);
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
resource: "projects",
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
urn: searchResult.id,
|
||||
id: searchResult.id,
|
||||
peer: undefined,
|
||||
profile: undefined,
|
||||
seed: searchResult.seedHost,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" strictEvents>
|
||||
import Modal from "@app/components/Modal.svelte";
|
||||
import { formatRadicleUrn, getSeedEmoji, twemoji } from "@app/lib/utils";
|
||||
import { formatRadicleId, getSeedEmoji, twemoji } from "@app/lib/utils";
|
||||
import type { Wallet } from "@app/lib/wallet";
|
||||
import Address from "@app/components/Address.svelte";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
@@ -26,7 +26,7 @@
|
||||
li {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
.urn {
|
||||
.id {
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
</style>
|
||||
@@ -54,15 +54,15 @@
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
seed: project.seed.host,
|
||||
urn: project.info.urn,
|
||||
id: project.info.id,
|
||||
},
|
||||
}}>
|
||||
<span title={project.seed.host}>
|
||||
<span>
|
||||
{getSeedEmoji(project.seed.host)} {project.info.name}
|
||||
</span>
|
||||
<span class="urn">
|
||||
{formatRadicleUrn(project.info.urn)}
|
||||
<span class="id">
|
||||
{formatRadicleId(project.info.id)}
|
||||
</span>
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Address from "@app/components/Address.svelte";
|
||||
import { Profile, ProfileType } from "@app/lib/profile";
|
||||
import { formatRadicleUrn, formatTimestamp } from "@app/lib/utils";
|
||||
import { formatRadicleId, formatTimestamp } from "@app/lib/utils";
|
||||
|
||||
export let noAvatar = false;
|
||||
export let author: Author;
|
||||
@@ -63,7 +63,7 @@
|
||||
</span>
|
||||
{:else}
|
||||
<span class="highlight">
|
||||
{formatRadicleUrn(author.urn)}
|
||||
{formatRadicleId(author.id)}
|
||||
</span>
|
||||
{/if}
|
||||
<span class="caption"> {caption} </span>
|
||||
|
||||
@@ -35,10 +35,10 @@ Please enter a comment message for your patch update. Leaving this
|
||||
blank is also okay.
|
||||
-->`;
|
||||
|
||||
$: source = profile?.avatar || comment.author.urn;
|
||||
$: source = profile?.avatar || comment.author.id;
|
||||
$: title =
|
||||
profile?.name ||
|
||||
(comment.author.profile ? comment.author.profile.name : comment.author.urn);
|
||||
(comment.author.profile ? comment.author.profile.name : comment.author.id);
|
||||
|
||||
const selectReaction = (event: { detail: string }) => {
|
||||
// TODO: Once we allow adding reactions through the http-api, we should call it here.
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
import { parseRadicleId, toClipboard, twemoji } from "@app/lib/utils";
|
||||
import Button from "@app/components/Button.svelte";
|
||||
|
||||
export let urn: string;
|
||||
export let id: string;
|
||||
|
||||
let copied = false;
|
||||
|
||||
function copy() {
|
||||
toClipboard(urn).then(() => {
|
||||
toClipboard(id).then(() => {
|
||||
copied = true;
|
||||
setTimeout(() => {
|
||||
copied = false;
|
||||
@@ -17,7 +17,7 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.urn {
|
||||
.id {
|
||||
display: inline-flex;
|
||||
font-size: var(--font-size-regular);
|
||||
line-height: 2rem;
|
||||
@@ -28,16 +28,16 @@
|
||||
width: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
.urn > * {
|
||||
.id > * {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layout-desktop">
|
||||
<div class="urn">
|
||||
<div class="id">
|
||||
<span class="icon" use:twemoji>🌱</span>
|
||||
<span class="txt-faded">rad:git:</span>
|
||||
<span>{parseRadicleId(urn)}</span>
|
||||
<span class="txt-faded">rad:</span>
|
||||
<span>{parseRadicleId(id)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
+12
-12
@@ -15,62 +15,62 @@
|
||||
"pinned": [
|
||||
{
|
||||
"name": "radicle-cli",
|
||||
"urn": "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
"id": "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
"seed": "clients.radicle.xyz"
|
||||
},
|
||||
{
|
||||
"name": "radicle-interface",
|
||||
"urn": "rad:git:hnrkjajuucc6zp5eknt3s9xykqsrus44cjimy",
|
||||
"id": "rad:git:hnrkjajuucc6zp5eknt3s9xykqsrus44cjimy",
|
||||
"seed": "clients.radicle.xyz"
|
||||
},
|
||||
{
|
||||
"name": "radicle-client-services",
|
||||
"urn": "rad:git:hnrkk9c4zt9thuxhwi1ukxqcrs5tmhbtcsony",
|
||||
"id": "rad:git:hnrkk9c4zt9thuxhwi1ukxqcrs5tmhbtcsony",
|
||||
"seed": "clients.radicle.xyz"
|
||||
},
|
||||
{
|
||||
"name": "solmate",
|
||||
"urn": "rad:git:hnrkbgczcfh9ycjtdfynmqyg478bqrso1hnty",
|
||||
"id": "rad:git:hnrkbgczcfh9ycjtdfynmqyg478bqrso1hnty",
|
||||
"seed": "willow.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "openzeppelin-contracts",
|
||||
"urn": "rad:git:hnrkbx9xzjg8tf9hj9uh5qdxwuyjddsxyaw6o",
|
||||
"id": "rad:git:hnrkbx9xzjg8tf9hj9uh5qdxwuyjddsxyaw6o",
|
||||
"seed": "willow.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "haskell-language-server",
|
||||
"urn": "rad:git:hnrkf1jaje1e93rua64zgphg7zb14qo9zexgy",
|
||||
"id": "rad:git:hnrkf1jaje1e93rua64zgphg7zb14qo9zexgy",
|
||||
"seed": "pine.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "rx",
|
||||
"urn": "rad:git:hnrk8aoks6w3tdbcwt9dqnor9aqy8tjha3k5o",
|
||||
"id": "rad:git:hnrk8aoks6w3tdbcwt9dqnor9aqy8tjha3k5o",
|
||||
"seed": "maple.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "astrolabe",
|
||||
"urn": "rad:git:hnrkrwewct7pb1biwmf59qa3rzod8mauundzy",
|
||||
"id": "rad:git:hnrkrwewct7pb1biwmf59qa3rzod8mauundzy",
|
||||
"seed": "willow.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "svelte-dappkit",
|
||||
"urn": "rad:git:hnrkgcm1e588ewy7iiq4abrrgtf5ioq577eno",
|
||||
"id": "rad:git:hnrkgcm1e588ewy7iiq4abrrgtf5ioq577eno",
|
||||
"seed": "maple.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "tmyxer",
|
||||
"urn": "rad:git:hnrkp5jgfxwxrffjsp148fyzdc457pa9ja38y",
|
||||
"id": "rad:git:hnrkp5jgfxwxrffjsp148fyzdc457pa9ja38y",
|
||||
"seed": "pine.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "pax",
|
||||
"urn": "rad:git:hnrkffdfm4et8c4g1ebpbkjj46nagyiepmu5o",
|
||||
"id": "rad:git:hnrkffdfm4et8c4g1ebpbkjj46nagyiepmu5o",
|
||||
"seed": "pine.radicle.garden"
|
||||
},
|
||||
{
|
||||
"name": "hexade",
|
||||
"urn": "rad:git:hnrkxj511yr48oo3usrt4jzfoucj88zphpryo",
|
||||
"id": "rad:git:hnrkxj511yr48oo3usrt4jzfoucj88zphpryo",
|
||||
"seed": "pine.radicle.garden"
|
||||
}
|
||||
]
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import type { PeerId } from "@app/lib/project";
|
||||
|
||||
export interface Author {
|
||||
peer: PeerId;
|
||||
urn: string;
|
||||
id: string;
|
||||
profile: {
|
||||
name: string;
|
||||
ens: {
|
||||
@@ -12,7 +12,7 @@ export interface Author {
|
||||
}
|
||||
|
||||
export interface PeerIdentity {
|
||||
urn: string;
|
||||
id: string;
|
||||
name: string;
|
||||
ens: {
|
||||
name: string;
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export interface Config {
|
||||
projects: {
|
||||
pinned: {
|
||||
name: string;
|
||||
urn: string;
|
||||
id: string;
|
||||
seed: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
+4
-8
@@ -81,21 +81,17 @@ export class Issue {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
static async getIssues(urn: string, host: Host): Promise<Issue[]> {
|
||||
static async getIssues(id: string, host: Host): Promise<Issue[]> {
|
||||
const response: IIssue[] = await new Request(
|
||||
`projects/${urn}/issues`,
|
||||
`projects/${id}/issues`,
|
||||
host,
|
||||
).get();
|
||||
return response.map(issue => new Issue(issue));
|
||||
}
|
||||
|
||||
static async getIssue(
|
||||
urn: string,
|
||||
issue: string,
|
||||
host: Host,
|
||||
): Promise<Issue> {
|
||||
static async getIssue(id: string, issue: string, host: Host): Promise<Issue> {
|
||||
const response: IIssue = await new Request(
|
||||
`projects/${urn}/issues/${issue}`,
|
||||
`projects/${id}/issues/${issue}`,
|
||||
host,
|
||||
).get();
|
||||
return new Issue(response);
|
||||
|
||||
+6
-10
@@ -3,7 +3,7 @@ import type { Comment, Thread } from "@app/lib/issue";
|
||||
import type { Commit, DiffStats } from "@app/lib/commit";
|
||||
import type { Diff } from "@app/lib/diff";
|
||||
import type { Host } from "@app/lib/api";
|
||||
import type { PeerId, Urn } from "@app/lib/project";
|
||||
import type { PeerId, Id } from "@app/lib/project";
|
||||
|
||||
import { Request } from "@app/lib/api";
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface Revision {
|
||||
oid: string;
|
||||
comment: Comment;
|
||||
discussion: Thread[];
|
||||
reviews: Record<Urn, Review>;
|
||||
reviews: Record<Id, Review>;
|
||||
merges: Merge[];
|
||||
changeset: {
|
||||
diff: Diff;
|
||||
@@ -142,21 +142,17 @@ export class Patch implements IPatch {
|
||||
return timeline.sort((a, b) => a.timestamp - b.timestamp);
|
||||
}
|
||||
|
||||
static async getPatches(urn: string, host: Host): Promise<Patch[]> {
|
||||
static async getPatches(id: string, host: Host): Promise<Patch[]> {
|
||||
const response: IPatch[] = await new Request(
|
||||
`projects/${urn}/patches`,
|
||||
`projects/${id}/patches`,
|
||||
host,
|
||||
).get();
|
||||
return response.map(patch => new Patch(patch));
|
||||
}
|
||||
|
||||
static async getPatch(
|
||||
urn: string,
|
||||
patch: string,
|
||||
host: Host,
|
||||
): Promise<Patch> {
|
||||
static async getPatch(id: string, patch: string, host: Host): Promise<Patch> {
|
||||
const response: IPatch = await new Request(
|
||||
`projects/${urn}/patches/${patch}`,
|
||||
`projects/${id}/patches/${patch}`,
|
||||
host,
|
||||
).get();
|
||||
return new Patch(response);
|
||||
|
||||
+38
-29
@@ -6,7 +6,7 @@ import { Profile, ProfileType } from "@app/lib/profile";
|
||||
import { Seed } from "@app/lib/seed";
|
||||
import { isFulfilled, isOid, isRadicleId } from "@app/lib/utils";
|
||||
|
||||
export type Urn = string;
|
||||
export type Id = string;
|
||||
export type PeerId = string;
|
||||
export type Branches = { [key: string]: string };
|
||||
export type MaybeBlob = Blob | undefined;
|
||||
@@ -15,7 +15,7 @@ export type MaybeTree = Tree | undefined;
|
||||
export type Delegate =
|
||||
| {
|
||||
type: "indirect";
|
||||
urn: Urn;
|
||||
id: Id;
|
||||
ids: PeerId[];
|
||||
}
|
||||
| {
|
||||
@@ -36,7 +36,7 @@ export enum ProjectContent {
|
||||
|
||||
export interface ProjectInfo {
|
||||
head: string | null;
|
||||
urn: string;
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
defaultBranch: string;
|
||||
@@ -139,7 +139,7 @@ export function parseRoute(
|
||||
}
|
||||
|
||||
export class Project implements ProjectInfo {
|
||||
urn: string;
|
||||
id: string;
|
||||
head: string | null;
|
||||
name: string;
|
||||
description: string;
|
||||
@@ -155,14 +155,14 @@ export class Project implements ProjectInfo {
|
||||
issues?: number;
|
||||
|
||||
constructor(
|
||||
urn: string,
|
||||
id: string,
|
||||
info: ProjectInfo,
|
||||
seed: Seed,
|
||||
peers: Peer[],
|
||||
branches: Branches,
|
||||
profile: Profile | null,
|
||||
) {
|
||||
this.urn = urn;
|
||||
this.id = id;
|
||||
this.head = info.head;
|
||||
this.name = info.name;
|
||||
this.description = info.description;
|
||||
@@ -191,8 +191,11 @@ export class Project implements ProjectInfo {
|
||||
return { tree, commit };
|
||||
}
|
||||
|
||||
static async getInfo(nameOrUrn: string, host: Host): Promise<ProjectInfo> {
|
||||
return await new Request(`projects/${nameOrUrn}`, host).get();
|
||||
static async getInfo(nameOrId: string, host: Host): Promise<ProjectInfo> {
|
||||
const result = await new Request(`projects/${nameOrId}`, host).get();
|
||||
result["id"] = result["urn"];
|
||||
delete result["urn"];
|
||||
return result;
|
||||
}
|
||||
|
||||
static async getProjects(
|
||||
@@ -206,7 +209,13 @@ export class Project implements ProjectInfo {
|
||||
"per-page": opts?.perPage,
|
||||
page: opts?.page,
|
||||
};
|
||||
return new Request("projects", host).get(params);
|
||||
const results = await new Request("projects", host).get(params);
|
||||
results.forEach((result: { [x: string]: any }) => {
|
||||
result["id"] = result["urn"];
|
||||
delete result["urn"];
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
static async getDelegateProjects(
|
||||
@@ -225,19 +234,19 @@ export class Project implements ProjectInfo {
|
||||
}
|
||||
|
||||
static async getRemote(
|
||||
urn: string,
|
||||
id: string,
|
||||
peer: string,
|
||||
host: Host,
|
||||
): Promise<Remote> {
|
||||
return new Request(`projects/${urn}/remotes/${peer}`, host).get();
|
||||
return new Request(`projects/${id}/remotes/${peer}`, host).get();
|
||||
}
|
||||
|
||||
static async getRemotes(urn: string, host: Host): Promise<Peer[]> {
|
||||
return new Request(`projects/${urn}/remotes`, host).get();
|
||||
static async getRemotes(id: string, host: Host): Promise<Peer[]> {
|
||||
return new Request(`projects/${id}/remotes`, host).get();
|
||||
}
|
||||
|
||||
static async getCommits(
|
||||
urn: string,
|
||||
id: string,
|
||||
host: Host,
|
||||
opts?: {
|
||||
parent?: string | null;
|
||||
@@ -256,19 +265,19 @@ export class Project implements ProjectInfo {
|
||||
page: opts?.page,
|
||||
verified: opts?.verified,
|
||||
};
|
||||
return new Request(`projects/${urn}/commits`, host).get(params);
|
||||
return new Request(`projects/${id}/commits`, host).get(params);
|
||||
}
|
||||
|
||||
static async getActivity(
|
||||
urn: string,
|
||||
id: string,
|
||||
host: Host,
|
||||
): Promise<{ activity: number[] }> {
|
||||
return new Request(`projects/${urn}/activity`, host).get();
|
||||
return new Request(`projects/${id}/activity`, host).get();
|
||||
}
|
||||
|
||||
async getCommit(commit: string): Promise<Commit> {
|
||||
return new Request(
|
||||
`projects/${this.urn}/commits/${commit}`,
|
||||
`projects/${this.id}/commits/${commit}`,
|
||||
this.seed.api,
|
||||
).get();
|
||||
}
|
||||
@@ -276,21 +285,21 @@ export class Project implements ProjectInfo {
|
||||
async getTree(commit: string, path: string): Promise<Tree> {
|
||||
if (path === "/") path = "";
|
||||
return new Request(
|
||||
`projects/${this.urn}/tree/${commit}/${path}`,
|
||||
`projects/${this.id}/tree/${commit}/${path}`,
|
||||
this.seed.api,
|
||||
).get();
|
||||
}
|
||||
|
||||
async getBlob(commit: string, path: string): Promise<Blob> {
|
||||
return new Request(
|
||||
`projects/${this.urn}/blob/${commit}/${path}`,
|
||||
`projects/${this.id}/blob/${commit}/${path}`,
|
||||
this.seed.api,
|
||||
).get();
|
||||
}
|
||||
|
||||
async getReadme(commit: string): Promise<Blob> {
|
||||
return new Request(
|
||||
`projects/${this.urn}/readme/${commit}`,
|
||||
`projects/${this.id}/readme/${commit}`,
|
||||
this.seed.api,
|
||||
).get();
|
||||
}
|
||||
@@ -324,13 +333,13 @@ export class Project implements ProjectInfo {
|
||||
}
|
||||
|
||||
const info = await Project.getInfo(id, seed.api);
|
||||
const urn = isRadicleId(id) ? id : info.urn;
|
||||
id = isRadicleId(id) ? id : info.id;
|
||||
|
||||
// Older versions of http-api don't include the URN.
|
||||
if (!info.urn) info.urn = urn;
|
||||
// Older versions of http-api don't include the ID.
|
||||
if (!info.id) info.id = id;
|
||||
|
||||
const peers: Peer[] = info.delegates
|
||||
? await Project.getRemotes(urn, seed.api)
|
||||
? await Project.getRemotes(id, seed.api)
|
||||
: [];
|
||||
|
||||
let remote: Remote = {
|
||||
@@ -339,24 +348,24 @@ export class Project implements ProjectInfo {
|
||||
|
||||
if (peer) {
|
||||
try {
|
||||
remote = await Project.getRemote(urn, peer, seed.api);
|
||||
remote = await Project.getRemote(id, peer, seed.api);
|
||||
} catch {
|
||||
remote.heads = {};
|
||||
}
|
||||
}
|
||||
|
||||
return new Project(urn, info, seed, peers, remote.heads, profile);
|
||||
return new Project(id, info, seed, peers, remote.heads, profile);
|
||||
}
|
||||
|
||||
static async getMulti(
|
||||
projs: { nameOrUrn: Urn; seed: string }[],
|
||||
projs: { nameOrId: Id; seed: string }[],
|
||||
): Promise<{ info: ProjectInfo; seed: Host }[]> {
|
||||
const promises = [];
|
||||
|
||||
for (const proj of projs) {
|
||||
const seed = { host: proj.seed, port: null };
|
||||
promises.push(
|
||||
Project.getInfo(proj.nameOrUrn, seed).then(info => {
|
||||
Project.getInfo(proj.nameOrId, seed).then(info => {
|
||||
return { info, seed };
|
||||
}),
|
||||
);
|
||||
|
||||
+26
-26
@@ -206,21 +206,21 @@ function pathToRoute(path: string): Route | null {
|
||||
case "seeds": {
|
||||
const host = segments.shift();
|
||||
if (host) {
|
||||
const urn = segments.shift();
|
||||
if (urn) {
|
||||
const id = segments.shift();
|
||||
if (id) {
|
||||
if (segments.length === 0) {
|
||||
return {
|
||||
resource: "projects",
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
urn,
|
||||
id,
|
||||
peer: undefined,
|
||||
profile: undefined,
|
||||
seed: host,
|
||||
},
|
||||
};
|
||||
}
|
||||
const params = resolveProjectRoute(url, urn, segments);
|
||||
const params = resolveProjectRoute(url, id, segments);
|
||||
if (params) {
|
||||
return {
|
||||
resource: "projects",
|
||||
@@ -228,7 +228,7 @@ function pathToRoute(path: string): Route | null {
|
||||
...params,
|
||||
search: url.search,
|
||||
seed: host,
|
||||
urn,
|
||||
id,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -242,27 +242,27 @@ function pathToRoute(path: string): Route | null {
|
||||
return { resource: "home" };
|
||||
default: {
|
||||
if (resource) {
|
||||
const urn = segments.shift();
|
||||
if (urn) {
|
||||
const id = segments.shift();
|
||||
if (id) {
|
||||
if (segments.length === 0) {
|
||||
return {
|
||||
resource: "projects",
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
urn,
|
||||
id,
|
||||
peer: undefined,
|
||||
profile: resource,
|
||||
seed: undefined,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
const params = resolveProjectRoute(url, urn, segments);
|
||||
const params = resolveProjectRoute(url, id, segments);
|
||||
if (params) {
|
||||
return {
|
||||
resource: "projects",
|
||||
params: {
|
||||
...params,
|
||||
urn,
|
||||
id,
|
||||
search: url.search,
|
||||
profile: resource,
|
||||
},
|
||||
@@ -339,21 +339,21 @@ export function routeToPath(route: Route) {
|
||||
}
|
||||
|
||||
if (route.params.view.resource === "tree") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/tree${suffix}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/tree${suffix}`;
|
||||
} else if (route.params.view.resource === "commits") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/commits${suffix}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/commits${suffix}`;
|
||||
} else if (route.params.view.resource === "history") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/history${suffix}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/history${suffix}`;
|
||||
} else if (route.params.view.resource === "patches") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/patches${suffix}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/patches${suffix}`;
|
||||
} else if (route.params.view.resource === "patch") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/patches/${route.params.view.params.patch}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/patches/${route.params.view.params.patch}`;
|
||||
} else if (route.params.view.resource === "issues") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/issues${suffix}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/issues${suffix}`;
|
||||
} else if (route.params.view.resource === "issue") {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}/issues/${route.params.view.params.issue}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}/issues/${route.params.view.params.issue}`;
|
||||
} else {
|
||||
return `${hostPrefix}/${route.params.urn}${peer}${content}`;
|
||||
return `${hostPrefix}/${route.params.id}${peer}${content}`;
|
||||
}
|
||||
} else if (route.resource === "registrations") {
|
||||
if (route.params.view.resource === "validateName") {
|
||||
@@ -380,7 +380,7 @@ export function routeToPath(route: Route) {
|
||||
|
||||
function resolveProjectRoute(
|
||||
url: URL,
|
||||
urn: string,
|
||||
id: string,
|
||||
segments: string[],
|
||||
): ProjectsParams | null {
|
||||
let content = segments.shift();
|
||||
@@ -395,7 +395,7 @@ function resolveProjectRoute(
|
||||
const hash = url.href.match(/#{1}[^#.]+$/)?.pop();
|
||||
return {
|
||||
view: { resource: "tree" },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -406,7 +406,7 @@ function resolveProjectRoute(
|
||||
} else if (content === "history") {
|
||||
return {
|
||||
view: { resource: "history" },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -415,7 +415,7 @@ function resolveProjectRoute(
|
||||
} else if (content === "commits") {
|
||||
return {
|
||||
view: { resource: "commits" },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -426,7 +426,7 @@ function resolveProjectRoute(
|
||||
if (patch) {
|
||||
return {
|
||||
view: { resource: "patch", params: { patch } },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -434,7 +434,7 @@ function resolveProjectRoute(
|
||||
} else {
|
||||
return {
|
||||
view: { resource: "patches" },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -445,7 +445,7 @@ function resolveProjectRoute(
|
||||
if (issue) {
|
||||
return {
|
||||
view: { resource: "issue", params: { issue } },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
@@ -453,7 +453,7 @@ function resolveProjectRoute(
|
||||
} else {
|
||||
return {
|
||||
view: { resource: "issues" },
|
||||
urn,
|
||||
id,
|
||||
peer,
|
||||
path: undefined,
|
||||
revision: undefined,
|
||||
|
||||
@@ -11,7 +11,7 @@ export type Route =
|
||||
| { resource: "seeds"; params: { host: string } };
|
||||
|
||||
export interface ProjectsParams {
|
||||
urn: string;
|
||||
id: string;
|
||||
view:
|
||||
| { resource: "tree" }
|
||||
| { resource: "commits" }
|
||||
|
||||
+3
-3
@@ -112,8 +112,8 @@ export class Seed {
|
||||
return Seed.getPeer(this.api);
|
||||
}
|
||||
|
||||
async getProject(urn: string): Promise<proj.ProjectInfo> {
|
||||
return proj.Project.getInfo(urn, this.api);
|
||||
async getProject(id: string): Promise<proj.ProjectInfo> {
|
||||
return proj.Project.getInfo(id, this.api);
|
||||
}
|
||||
|
||||
async getProjects(perPage: number, id?: string): Promise<proj.ProjectInfo[]> {
|
||||
@@ -123,7 +123,7 @@ export class Seed {
|
||||
|
||||
return result.map((project: proj.ProjectInfo) => ({
|
||||
...project,
|
||||
id: project.urn,
|
||||
id: project.id,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -102,7 +102,7 @@ export function formatSeedId(id: string): string {
|
||||
return id.substring(0, 6) + "…" + id.substring(id.length - 6, id.length);
|
||||
}
|
||||
|
||||
export function formatRadicleUrn(id: string): string {
|
||||
export function formatRadicleId(id: string): string {
|
||||
assert(isRadicleId(id));
|
||||
|
||||
return id.substring(0, 14) + "…" + id.substring(id.length - 6, id.length);
|
||||
@@ -293,9 +293,9 @@ export function formatName(input: string, wallet: Wallet): string {
|
||||
return parseEnsLabel(input, wallet);
|
||||
}
|
||||
|
||||
// Parse a Radicle Id (URN).
|
||||
export function parseRadicleId(urn: string): string {
|
||||
return urn.replace(/^rad:[a-z]+:/, "");
|
||||
// Parse a Radicle Id.
|
||||
export function parseRadicleId(id: string): string {
|
||||
return id.replace(/^rad:[a-z]+:/, "");
|
||||
}
|
||||
|
||||
// Get amount of days passed between two dates without including the end date
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
config.projects.pinned.length > 0
|
||||
? Project.getMulti(
|
||||
config.projects.pinned.map(project => ({
|
||||
nameOrUrn: project.urn,
|
||||
nameOrId: project.id,
|
||||
seed: project.seed,
|
||||
})),
|
||||
)
|
||||
@@ -31,7 +31,7 @@
|
||||
resource: "projects",
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
urn: project.urn,
|
||||
id: project.id,
|
||||
peer: undefined,
|
||||
seed: seed.host,
|
||||
profile: undefined,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import NotFound from "@app/components/NotFound.svelte";
|
||||
import Projects from "@app/views/seeds/View/Projects.svelte";
|
||||
import RadicleUrn from "@app/components/RadicleUrn.svelte";
|
||||
import RadicleId from "@app/components/RadicleId.svelte";
|
||||
import SeedAddress from "@app/components/SeedAddress.svelte";
|
||||
import SetName from "./SetName.svelte";
|
||||
import { MissingReverseRecord, NotFoundError } from "@app/lib/error";
|
||||
@@ -182,7 +182,7 @@
|
||||
<!-- ID -->
|
||||
{#if profile.id}
|
||||
<div class="txt-highlight">ID</div>
|
||||
<RadicleUrn urn={profile.id} />
|
||||
<RadicleId id={profile.id} />
|
||||
{/if}
|
||||
<!-- Seed Address -->
|
||||
{#if profile.seed && profile.seed.valid}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
import { closeFocused } from "@app/components/Floating.svelte";
|
||||
|
||||
export let seedHost: string;
|
||||
export let urn: string;
|
||||
export let id: string;
|
||||
|
||||
$: radCloneUrl = `rad clone rad://${seedHost}/${utils.parseRadicleId(urn)}`;
|
||||
$: gitCloneUrl = `https://${seedHost}/${utils.parseRadicleId(urn)}.git`;
|
||||
$: radCloneUrl = `rad clone rad://${seedHost}/${utils.parseRadicleId(id)}`;
|
||||
$: gitCloneUrl = `https://${seedHost}/${utils.parseRadicleId(id)}.git`;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
export let tree: Tree;
|
||||
export let commit: string;
|
||||
|
||||
const { urn, peers, branches, seed } = project;
|
||||
const { id, peers, branches, seed } = project;
|
||||
|
||||
$: revision = activeRoute.params.revision ?? commit;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
view: {
|
||||
resource: activeRoute.params.view.resource === input ? "tree" : input,
|
||||
},
|
||||
urn: project.urn,
|
||||
id: project.id,
|
||||
revision: revision,
|
||||
...(keepSourceInPath ? null : { revision: undefined, path: undefined }),
|
||||
});
|
||||
@@ -98,7 +98,7 @@
|
||||
on:branchChanged={event => updateRevision(event.detail)} />
|
||||
|
||||
{#if seed.git.host}
|
||||
<CloneButton seedHost={seed.git.host} {urn} />
|
||||
<CloneButton seedHost={seed.git.host} {id} />
|
||||
{/if}
|
||||
<span>
|
||||
{#if seed.api.host}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
export let history: CommitsHistory;
|
||||
|
||||
const fetchMoreCommits = async (): Promise<CommitMetadata[]> => {
|
||||
const response = await Project.getCommits(project.urn, project.seed.api, {
|
||||
const response = await Project.getCommits(project.id, project.seed.api, {
|
||||
// Fetching 31 elements since we remove the first one
|
||||
parent: history.headers[history.headers.length - 1].header.sha1,
|
||||
perPage: 31,
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<Authorship
|
||||
author={{
|
||||
peer: element.inner.peer.id,
|
||||
urn: element.inner.peer.person.urn,
|
||||
id: element.inner.peer.person.id,
|
||||
profile: element.inner.peer.person,
|
||||
}}
|
||||
caption={`merged to ${formatSeedId(element.inner.peer.id)}`}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
.project-name:hover {
|
||||
color: inherit;
|
||||
}
|
||||
.urn {
|
||||
.id {
|
||||
font-family: var(--font-family-monospace);
|
||||
font-size: var(--font-size-tiny);
|
||||
color: var(--color-foreground-5);
|
||||
@@ -108,9 +108,9 @@
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="urn">
|
||||
<span class="truncate">{project.urn}</span>
|
||||
<Clipboard small text={project.urn} />
|
||||
<div class="id">
|
||||
<span class="truncate">{project.id}</span>
|
||||
<Clipboard small text={project.id} />
|
||||
</div>
|
||||
<div class="description">{project.description}</div>
|
||||
</header>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
export let wallet: Wallet;
|
||||
export let activeRoute: ProjectRoute;
|
||||
|
||||
$: urn = activeRoute.params.urn;
|
||||
$: id = activeRoute.params.id;
|
||||
$: peer = activeRoute.params.peer ?? null;
|
||||
$: seed = activeRoute.params.seed ?? null;
|
||||
$: profile = activeRoute.params.profile ?? null;
|
||||
@@ -37,12 +37,12 @@
|
||||
$: patchFilter = (searchParams.get("state") as PatchState) || "proposed";
|
||||
|
||||
const getProject = async (
|
||||
urn: string,
|
||||
id: string,
|
||||
peer: string | null,
|
||||
profile: string | null,
|
||||
seed: string | null,
|
||||
) => {
|
||||
const project = await proj.Project.get(urn, peer, profile, seed, wallet);
|
||||
const project = await proj.Project.get(id, peer, profile, seed, wallet);
|
||||
if (activeRoute.params.route) {
|
||||
const { revision, path } = proj.parseRoute(
|
||||
activeRoute.params.route,
|
||||
@@ -101,7 +101,7 @@
|
||||
</style>
|
||||
|
||||
<main>
|
||||
{#await getProject(urn, peer, profile, seed)}
|
||||
{#await getProject(id, peer, profile, seed)}
|
||||
<header>
|
||||
<Loading center />
|
||||
</header>
|
||||
@@ -115,7 +115,7 @@
|
||||
{#if activeRoute.params.view.resource === "tree"}
|
||||
<Browser {project} {commit} {tree} {activeRoute} />
|
||||
{:else if activeRoute.params.view.resource === "history"}
|
||||
{#await proj.Project.getCommits( project.urn, project.seed.api, { parent: commit, verified: true }, )}
|
||||
{#await proj.Project.getCommits( project.id, project.seed.api, { parent: commit, verified: true }, )}
|
||||
<Loading center />
|
||||
{:then history}
|
||||
<History {project} {history} />
|
||||
@@ -135,7 +135,7 @@
|
||||
</div>
|
||||
{/await}
|
||||
{:else if activeRoute.params.view.resource === "issues"}
|
||||
{#await issue.Issue.getIssues(project.urn, project.seed.api)}
|
||||
{#await issue.Issue.getIssues(project.id, project.seed.api)}
|
||||
<Loading center />
|
||||
{:then issues}
|
||||
<Issues state={issueFilter} {wallet} {issues} />
|
||||
@@ -145,7 +145,7 @@
|
||||
</div>
|
||||
{/await}
|
||||
{:else if activeRoute.params.view.resource === "issue"}
|
||||
{#await issue.Issue.getIssue(project.urn, activeRoute.params.view.params.issue, project.seed.api)}
|
||||
{#await issue.Issue.getIssue(project.id, activeRoute.params.view.params.issue, project.seed.api)}
|
||||
<Loading center />
|
||||
{:then issue}
|
||||
<Issue {project} {wallet} {issue} />
|
||||
@@ -155,7 +155,7 @@
|
||||
</div>
|
||||
{/await}
|
||||
{:else if activeRoute.params.view.resource === "patches"}
|
||||
{#await patch.Patch.getPatches(project.urn, project.seed.api)}
|
||||
{#await patch.Patch.getPatches(project.id, project.seed.api)}
|
||||
<Loading center />
|
||||
{:then patches}
|
||||
<Patches {wallet} state={patchFilter} {patches} />
|
||||
@@ -165,7 +165,7 @@
|
||||
</div>
|
||||
{/await}
|
||||
{:else if activeRoute.params.view.resource === "patch"}
|
||||
{#await patch.Patch.getPatch(project.urn, activeRoute.params.view.params.patch, project.seed.api)}
|
||||
{#await patch.Patch.getPatch(project.id, activeRoute.params.view.params.patch, project.seed.api)}
|
||||
<Loading center />
|
||||
{:then patch}
|
||||
<Patch {project} {wallet} {patch} />
|
||||
@@ -202,6 +202,6 @@
|
||||
</div>
|
||||
{/await}
|
||||
{:catch}
|
||||
<NotFound title={urn} subtitle="This project was not found." />
|
||||
<NotFound title={id} subtitle="This project was not found." />
|
||||
{/await}
|
||||
</main>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
export let compact = false;
|
||||
|
||||
const loadCommits = async () => {
|
||||
const commits = await Project.getActivity(project.urn, seed.api);
|
||||
const commits = await Project.getActivity(project.id, seed.api);
|
||||
|
||||
return groupCommitsByWeek(commits.activity);
|
||||
};
|
||||
@@ -92,14 +92,14 @@
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
article .id .urn {
|
||||
article .id .rid {
|
||||
visibility: hidden;
|
||||
color: var(--color-foreground-5);
|
||||
font-weight: var(--font-weight-normal);
|
||||
font-family: var(--font-family-monospace);
|
||||
font-size: var(--font-size-tiny);
|
||||
}
|
||||
article:hover .id .urn {
|
||||
article:hover .id .rid {
|
||||
visibility: visible;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
@@ -147,7 +147,7 @@
|
||||
{#if !compact}
|
||||
<div class="right">
|
||||
<div class="id">
|
||||
<span class="urn layout-desktop">{project.urn}</span>
|
||||
<span class="rid layout-desktop">{project.id}</span>
|
||||
</div>
|
||||
{#await loadCommits() then points}
|
||||
<div class="layout-desktop activity">
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
name: "id",
|
||||
label: "Radicle",
|
||||
validate: "identity",
|
||||
placeholder: "Radicle URN, eg. rad:git:hnrkqdpm9ub19oc8d…",
|
||||
placeholder: "Radicle ID, eg. rad:git:hnrkqdpm9ub19oc8d…",
|
||||
description: "The local radicle identity associated with this name.",
|
||||
value: r.profile.id ?? "",
|
||||
editable: true,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
resource: "projects",
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
urn: project.urn,
|
||||
id: project.id,
|
||||
seed: seed.api.port
|
||||
? `${seed.api.host}:${seed.api.port}`
|
||||
: seed.api.host,
|
||||
|
||||
@@ -27,9 +27,9 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
|
||||
// Reset system clipboard to a known state.
|
||||
await page.evaluate<string>("navigator.clipboard.writeText('')");
|
||||
|
||||
// Project URN.
|
||||
// Project ID.
|
||||
{
|
||||
await page.locator(".urn > .clipboard").click();
|
||||
await page.locator(".id > .clipboard").click();
|
||||
const clipboardContent = await page.evaluate<string>(
|
||||
"navigator.clipboard.readText()",
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ test("navigate to project", async ({ page }) => {
|
||||
// Header.
|
||||
{
|
||||
const name = page.locator("text=source-browsing");
|
||||
const urn = page.locator(
|
||||
const id = page.locator(
|
||||
"text=rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
|
||||
);
|
||||
const description = page.locator(
|
||||
@@ -28,7 +28,7 @@ test("navigate to project", async ({ page }) => {
|
||||
);
|
||||
|
||||
await expect(name).toBeVisible();
|
||||
await expect(urn).toBeVisible();
|
||||
await expect(id).toBeVisible();
|
||||
await expect(description).toBeVisible();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ test("seed projects", async ({ page }) => {
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
// Show project URN on hover.
|
||||
// Show project ID on hover.
|
||||
{
|
||||
await expect(
|
||||
project.locator("text=rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy"),
|
||||
|
||||
@@ -173,7 +173,7 @@ export function appConfigWithFixture() {
|
||||
pinned: [
|
||||
{
|
||||
name: "source-browsing",
|
||||
urn: "rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
|
||||
id: "rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
|
||||
seed: "0.0.0.0",
|
||||
},
|
||||
],
|
||||
|
||||
@@ -101,7 +101,7 @@ describe("routeToPath", () => {
|
||||
params: {
|
||||
view: { resource: "tree" },
|
||||
seed: "willow.radicle.garden",
|
||||
urn: "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
id: "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
},
|
||||
},
|
||||
output:
|
||||
@@ -228,7 +228,7 @@ describe("pathToRoute", () => {
|
||||
seed: "willow.radicle.garden",
|
||||
profile: undefined,
|
||||
peer: undefined,
|
||||
urn: "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
id: "rad:git:hnrkmg77m8tfzj4gi4pa4mbhgysfgzwntjpao",
|
||||
},
|
||||
},
|
||||
description: "Seed Project Route",
|
||||
|
||||
@@ -36,15 +36,15 @@ describe("Format functions", () => {
|
||||
expect(utils.formatSeedId(id)).toEqual(expected);
|
||||
});
|
||||
|
||||
test("formatRadicleUrn", () => {
|
||||
test("formatRadicleId", () => {
|
||||
expect(
|
||||
utils.formatRadicleUrn("rad:git:hnrkemobagsicpf9sr95o3g551otspcd84c9o"),
|
||||
utils.formatRadicleId("rad:git:hnrkemobagsicpf9sr95o3g551otspcd84c9o"),
|
||||
).toEqual("rad:git:hnrkem…d84c9o");
|
||||
});
|
||||
|
||||
test("formatRadicleUrn throw when wrong URN", () => {
|
||||
test("formatRadicleId throw when wrong ID", () => {
|
||||
expect(() =>
|
||||
utils.formatRadicleUrn("hnrkemobagsicpf9sr95o3g551otspcd84c9o"),
|
||||
utils.formatRadicleId("hnrkemobagsicpf9sr95o3g551otspcd84c9o"),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user