Add list_repo and config commands

This commit is contained in:
Sebastian Martinez
2024-09-05 12:37:00 +02:00
parent 3edfcf9192
commit b6711a5698
23 changed files with 332 additions and 146 deletions
+2 -2
View File
@@ -7,9 +7,9 @@
import { theme } from "@app/components/ThemeSwitch.svelte";
import { unreachable } from "@app/lib/utils";
import AuthenticationError from "@app/views/AuthenticationError.svelte";
import DesignSystem from "@app/views/DesignSystem.svelte";
import Home from "@app/views/Home.svelte";
import AuthenticationError from "@app/views/AuthenticationError.svelte";
const activeRouteStore = router.activeRouteStore;
void router.loadFromLocation();
@@ -36,7 +36,7 @@
{#if $activeRouteStore.resource === "booting"}
<!-- Don't show anything -->
{:else if $activeRouteStore.resource === "home"}
<Home />
<Home {...$activeRouteStore.params} />
{:else if $activeRouteStore.resource === "authenticationError"}
<AuthenticationError {...$activeRouteStore.params} />
{:else if $activeRouteStore.resource === "designSystem"}
+17 -11
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import type { Repo } from "@app/lib/api/repo";
import type { RepoInfo } from "@bindings/RepoInfo";
import { formatRepositoryId, formatTimestamp } from "@app/lib/utils";
@@ -7,13 +7,10 @@
import Fill from "./Fill.svelte";
import Icon from "./Icon.svelte";
// TODO: Pass this via repo.
export let updatedAt: number = 1725360130;
export let repo: Repo;
export let repo: RepoInfo;
export let selfDid: string;
$: project = repo.payloads["xyz.radicle.project"];
$: project = repo.payloads["xyz.radicle.project"]!;
</script>
<style>
@@ -66,17 +63,26 @@
</div>
</div>
<div class="title">Radicle Heartwood Protocol & Stack</div>
<div class="title">
{#if project.data.description}
{project.data.description}
{:else}
No description
{/if}
</div>
<div class="global-oid">{formatRepositoryId(repo.rid)}</div>
<div class="global-flex footer">
<div class="global-flex">
<div class="global-flex" style:gap="4px"><Icon name="issue" /> 4</div>
<div class="global-flex" style:gap="4px"><Icon name="patch" /> 6</div>
<div class="global-flex" style:gap="4px">
<Icon name="issue" />{project.meta.issues.open}
</div>
<div class="global-flex" style:gap="4px">
<Icon name="patch" />{project.meta.patches.open}
</div>
</div>
<span style:color="var(--color-fill-gray)">
Updated {formatTimestamp(updatedAt)}
Updated {formatTimestamp(project.meta.lastCommit)}
</span>
</div>
</div>
-8
View File
@@ -1,8 +0,0 @@
import { object, string, z } from "zod";
export type Author = z.infer<typeof authorSchema>;
export const authorSchema = object({
id: string(),
alias: string().optional(),
});
-36
View File
@@ -1,36 +0,0 @@
{
"rid": "rad:z3trNYnLWS11cJWC6BbxDs5niGo82",
"payloads": {
"xyz.radicle.project": {
"data": {
"name": "rips",
"description": "Radicle Improvement Proposals (RIPs)",
"defaultBranch": "master"
},
"meta": {
"head": "329dee9a4b65169ea3889a7da239892b705d0d68",
"patches": {
"open": 0,
"draft": 2,
"archived": 0,
"merged": 0
},
"issues": {
"open": 1,
"closed": 0
}
}
}
},
"delegates": [
{
"id": "did:key:z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT",
"alias": "cloudhead"
}
],
"threshold": 1,
"visibility": {
"type": "private"
},
"seeding": 29
}
-48
View File
@@ -1,48 +0,0 @@
import {
array,
literal,
number,
object,
optional,
string,
union,
z,
} from "zod";
import { authorSchema } from "./author";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const repoSchema = object({
rid: string(),
payloads: object({
"xyz.radicle.project": object({
data: object({
name: string(),
description: string(),
defaultBranch: string(),
}),
meta: object({
head: string(),
patches: object({
open: number(),
draft: number(),
archived: number(),
merged: number(),
}),
issues: object({
open: number(),
closed: number(),
}),
}),
}),
}),
delegates: array(authorSchema),
threshold: number(),
visibility: union([
object({ type: literal("public") }),
object({ type: literal("private"), allow: optional(array(string())) }),
]),
seeding: number(),
});
export type Repo = z.infer<typeof repoSchema>;
+16 -1
View File
@@ -1,3 +1,8 @@
import type { RepoInfo } from "@bindings/RepoInfo";
import type { Config } from "@bindings/Config";
import { invoke } from "@tauri-apps/api/core";
interface BootingRoute {
resource: "booting";
}
@@ -14,6 +19,11 @@ interface HomeRoute {
resource: "home";
}
interface LoadedHomeRoute {
resource: "home";
params: { repos: RepoInfo[]; config: Config };
}
interface DesignSystemRoute {
resource: "designSystem";
}
@@ -27,12 +37,17 @@ export type Route =
export type LoadedRoute =
| BootingRoute
| DesignSystemRoute
| HomeRoute
| LoadedHomeRoute
| AuthenticationErrorRoute;
export async function loadRoute(
route: Route,
_previousLoaded: LoadedRoute,
): Promise<LoadedRoute> {
if (route.resource === "home") {
const repos: RepoInfo[] = await invoke("list_repos");
const config: Config = await invoke("config");
return { resource: "home", params: { repos, config } };
}
return route;
}
+9 -23
View File
@@ -1,13 +1,13 @@
<script lang="ts">
import type { Repo } from "@app/lib/api/repo";
import repoFixture from "@app/lib/api/fixtures/heartwood-repo.json";
import type { Config } from "@bindings/Config";
import type { RepoInfo } from "@bindings/RepoInfo";
import Header from "@app/components/Header.svelte";
import Link from "@app/components/Link.svelte";
import RepoCard from "@app/components/RepoCard.svelte";
const selfDid = "did:key:z6MksFqXN3Yhqk8pTJdUGLwATkRfQvwZXPqR2qMEhbS9wzpT";
export let repos: RepoInfo[];
export let config: Config;
</script>
<style>
@@ -24,25 +24,11 @@
<Header currentPage="Repositories" />
<div class="layout">
<div class="repo-grid">
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
<RepoCard repo={repoFixture as Repo} {selfDid} />
{#each repos as repo}
{#if repo.payloads["xyz.radicle.project"]}
<RepoCard {repo} selfDid={`did:key:${config.publicKey}`} />
{/if}
{/each}
</div>
<div style:margin-top="1rem">