-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
243 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import type { Issue } from "@bindings/Issue"; | ||
import type { RepoInfo } from "@bindings/RepoInfo"; | ||
import Layout from "./Layout.svelte"; | ||
export let repo: RepoInfo; | ||
export let issues: Issue[]; | ||
</script> | ||
|
||
<Layout {repo}> | ||
<pre> | ||
<!-- prettier-ignore --> | ||
{#each issues as issue} | ||
- {issue.title} | ||
{:else} | ||
No issues. | ||
{/each} | ||
</pre> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
import type { RepoInfo } from "@bindings/RepoInfo"; | ||
import Header from "@app/components/Header.svelte"; | ||
import Link from "@app/components/Link.svelte"; | ||
export let repo: RepoInfo; | ||
$: project = repo.payloads["xyz.radicle.project"]!; | ||
</script> | ||
|
||
<Header currentPage="Repositories" /> | ||
<div>{project.data.name}</div> | ||
<div>{repo.rid}</div> | ||
|
||
Issues | ||
<Link route={{ resource: "repo.issues", rid: repo.rid, status: "open" }}> | ||
Open | ||
</Link> | ||
<Link route={{ resource: "repo.issues", rid: repo.rid, status: "closed" }}> | ||
Closed | ||
</Link> | ||
|
||
<br /> | ||
Patches | ||
<Link route={{ resource: "repo.patches", rid: repo.rid, status: "draft" }}> | ||
Draft | ||
</Link> | ||
<Link route={{ resource: "repo.patches", rid: repo.rid, status: "open" }}> | ||
Open | ||
</Link> | ||
<Link route={{ resource: "repo.patches", rid: repo.rid, status: "archived" }}> | ||
Archived | ||
</Link> | ||
<Link route={{ resource: "repo.patches", rid: repo.rid, status: "merged" }}> | ||
Merged | ||
</Link> | ||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import type { Patch } from "@bindings/Patch"; | ||
import type { RepoInfo } from "@bindings/RepoInfo"; | ||
import Layout from "./Layout.svelte"; | ||
export let repo: RepoInfo; | ||
export let patches: Patch[]; | ||
</script> | ||
|
||
<Layout {repo}> | ||
<pre> | ||
<!-- prettier-ignore --> | ||
{#each patches as patch} | ||
- {patch.title} | ||
{:else} | ||
No patches. | ||
{/each} | ||
</pre> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import type { RepoInfo } from "@bindings/RepoInfo"; | ||
import type { Patch } from "@bindings/Patch"; | ||
import type { Issue } from "@bindings/Issue"; | ||
|
||
import { invoke } from "@tauri-apps/api/core"; | ||
import { unreachable } from "@app/lib/utils"; | ||
|
||
export interface RepoIssuesRoute { | ||
resource: "repo.issues"; | ||
rid: string; | ||
status?: "open" | "closed"; | ||
} | ||
|
||
export interface LoadedRepoIssuesRoute { | ||
resource: "repo.issues"; | ||
params: { repo: RepoInfo; issues: Issue[] }; | ||
} | ||
|
||
export interface RepoPatchesRoute { | ||
resource: "repo.patches"; | ||
rid: string; | ||
status?: "draft" | "open" | "archived" | "merged"; | ||
} | ||
|
||
export interface LoadedRepoPatchesRoute { | ||
resource: "repo.patches"; | ||
params: { repo: RepoInfo; patches: Patch[] }; | ||
} | ||
|
||
export type RepoRoute = RepoIssuesRoute | RepoPatchesRoute; | ||
export type LoadedRepoRoute = LoadedRepoIssuesRoute | LoadedRepoPatchesRoute; | ||
|
||
export async function loadPatches(route: RepoRoute): Promise<LoadedRepoRoute> { | ||
const repo: RepoInfo = await invoke("repo_by_id", { | ||
rid: route.rid, | ||
}); | ||
const patches: Patch[] = await invoke("list_patches", { | ||
rid: route.rid, | ||
status: route.status, | ||
}); | ||
|
||
return { resource: "repo.patches", params: { repo, patches } }; | ||
} | ||
|
||
export async function loadIssues(route: RepoRoute): Promise<LoadedRepoRoute> { | ||
const repo: RepoInfo = await invoke("repo_by_id", { | ||
rid: route.rid, | ||
}); | ||
const issues: Issue[] = await invoke("list_issues", { | ||
rid: route.rid, | ||
status: route.status, | ||
}); | ||
|
||
return { resource: "repo.issues", params: { repo, issues } }; | ||
} | ||
|
||
export function repoRouteToPath(route: RepoRoute): string { | ||
const pathSegments = ["/repos", route.rid]; | ||
|
||
if (route.resource === "repo.issues") { | ||
let url = [...pathSegments, "issues"].join("/"); | ||
const searchParams = new URLSearchParams(); | ||
if (route.status) { | ||
searchParams.set("status", route.status); | ||
url += `?${searchParams}`; | ||
} | ||
return url; | ||
} else if (route.resource === "repo.patches") { | ||
let url = [...pathSegments, "patches"].join("/"); | ||
const searchParams = new URLSearchParams(); | ||
if (route.status) { | ||
searchParams.set("status", route.status); | ||
url += `?${searchParams}`; | ||
} | ||
return url; | ||
} else { | ||
return unreachable(route); | ||
} | ||
} | ||
|
||
export function repoUrlToRoute( | ||
segments: string[], | ||
searchParams: URLSearchParams, | ||
): RepoRoute | null { | ||
const rid = segments.shift(); | ||
const resource = segments.shift(); | ||
|
||
if (rid) { | ||
if (resource === "issues") { | ||
const status = searchParams.get("status"); | ||
if (status === "open" || status === "closed") { | ||
return { resource: "repo.issues", rid, status }; | ||
} else { | ||
return { resource: "repo.issues", rid }; | ||
} | ||
} else if (resource === "patches") { | ||
const status = searchParams.get("status"); | ||
if ( | ||
status === "draft" || | ||
status === "open" || | ||
status === "archived" || | ||
status === "merged" | ||
) { | ||
return { resource: "repo.patches", rid, status }; | ||
} else { | ||
return { resource: "repo.patches", rid }; | ||
} | ||
} else { | ||
return null; | ||
} | ||
} else { | ||
return null; | ||
} | ||
} |