This repository has no description
1<script module lang="ts">
2 import { defineMeta } from "@storybook/addon-svelte-csf";
3 import type { loadRepoIndex } from "$lib/api/repoIndex";
4 import StoryAuthProvider from "../../../../.storybook/StoryAuthProvider.svelte";
5 import RepoIndexView from "./RepoIndexView.svelte";
6 import type { RepoInfo } from "./types";
7
8 const repo: RepoInfo = {
9 uri: "at://did:plc:repo/sh.tangled.repo.repo/3jzrepo",
10 rkey: "3jzrepo",
11 name: "tangled",
12 ownerDid: "did:plc:owner",
13 ownerHandle: "dawn",
14 repoDid: "did:plc:repo",
15 knot: "knot1.tangled.sh",
16 defaultBranch: "main"
17 };
18
19 const data = {
20 ref: "main",
21 availability: "ok",
22 files: [
23 { name: "src", kind: "directory" as const, size: 0 },
24 { name: "README.md", kind: "file" as const, size: 512 }
25 ],
26 readme: { filename: "README.md", contents: "# tangled" },
27 readmeHtml: "<h1>tangled</h1>",
28 commits: [
29 {
30 hash: "0123456789abcdef0123456789abcdef01234567",
31 shortHash: "01234567",
32 subject: "add the repository index",
33 body: "",
34 authorName: "dawn",
35 authorEmail: "dawn@example.test",
36 when: "2026-07-28T09:00:00Z"
37 }
38 ],
39 tagsByCommit: {},
40 totalCommits: 42,
41 branches: [
42 {
43 name: "main",
44 hash: "0123456789abcdef0123456789abcdef01234567",
45 when: "2026-07-28T09:00:00Z",
46 isDefault: true
47 }
48 ],
49 totalBranches: 1,
50 tags: [{ name: "v1.0.0", hash: "abcdef0123456789", commitHash: "0123456789abcdef" }],
51 totalTags: 1,
52 refs: { branches: ["main"], tags: ["v1.0.0"], capped: false },
53 languages: [
54 { name: "TypeScript", percentage: 70, share: 70 },
55 { name: "Svelte", percentage: 30, share: 30 }
56 ]
57 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
58 const cappedData = {
59 ...data,
60 totalBranches: 100,
61 totalTags: 100,
62 refs: { ...data.refs, capped: true }
63 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
64 const emptyData = {
65 ...data,
66 availability: "empty",
67 files: [],
68 readme: null,
69 readmeHtml: null,
70 commits: [],
71 tagsByCommit: {},
72 totalCommits: 0,
73 branches: [],
74 totalBranches: 0,
75 tags: [],
76 totalTags: 0,
77 refs: { branches: [], tags: [], capped: false },
78 languages: []
79 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
80
81 const { Story } = defineMeta({
82 title: "Repo/RepoIndexView",
83 component: RepoIndexView,
84 tags: ["autodocs"],
85 args: { repo, data, bobbinUrl: "https://bobbin.example.test" }
86 });
87</script>
88
89<Story name="Populated repository" />
90<Story name="Reference counts are lower bounds" args={{ data: cappedData }} />
91<Story name="Knot needs upgrade" args={{ data: { ...data, availability: "needs-upgrade" } }} />
92<Story name="Knot is unreachable" args={{ data: { ...data, availability: "unreachable" } }} />
93<Story name="Empty repository" asChild>
94 <StoryAuthProvider>
95 <RepoIndexView {repo} data={emptyData} bobbinUrl="https://bobbin.example.test" />
96 </StoryAuthProvider>
97</Story>