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 isEmpty: false,
22 needsUpgrade: false,
23 knotUnreachable: false,
24 files: [
25 { name: "src", kind: "directory" as const, size: 0 },
26 { name: "README.md", kind: "file" as const, size: 512 }
27 ],
28 readme: { filename: "README.md", contents: "# tangled" },
29 readmeHtml: "<h1>tangled</h1>",
30 commits: [
31 {
32 hash: "0123456789abcdef0123456789abcdef01234567",
33 shortHash: "01234567",
34 subject: "add the repository index",
35 body: "",
36 authorName: "dawn",
37 authorEmail: "dawn@example.test",
38 when: "2026-07-28T09:00:00Z"
39 }
40 ],
41 tagsByCommit: {},
42 totalCommits: 42,
43 branches: [
44 {
45 name: "main",
46 hash: "0123456789abcdef0123456789abcdef01234567",
47 when: "2026-07-28T09:00:00Z",
48 isDefault: true
49 }
50 ],
51 totalBranches: 1,
52 tags: [{ name: "v1.0.0", hash: "abcdef0123456789", commitHash: "0123456789abcdef" }],
53 totalTags: 1,
54 refs: { branches: ["main"], tags: ["v1.0.0"], capped: false },
55 languages: [
56 { name: "TypeScript", percentage: 70, share: 70 },
57 { name: "Svelte", percentage: 30, share: 30 }
58 ]
59 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
60 const cappedData = {
61 ...data,
62 totalBranches: 100,
63 totalTags: 100,
64 refs: { ...data.refs, capped: true }
65 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
66 const emptyData = {
67 ...data,
68 isEmpty: true,
69 files: [],
70 readme: null,
71 readmeHtml: null,
72 commits: [],
73 tagsByCommit: {},
74 totalCommits: 0,
75 branches: [],
76 totalBranches: 0,
77 tags: [],
78 totalTags: 0,
79 refs: { branches: [], tags: [], capped: false },
80 languages: []
81 } satisfies Awaited<ReturnType<typeof loadRepoIndex>>;
82
83 const { Story } = defineMeta({
84 title: "Repo/RepoIndexView",
85 component: RepoIndexView,
86 tags: ["autodocs"],
87 args: { repo, data, bobbinUrl: "https://bobbin.example.test" }
88 });
89</script>
90
91<Story name="Populated repository" />
92<Story name="Reference counts are lower bounds" args={{ data: cappedData }} />
93<Story name="Knot needs upgrade" args={{ data: { ...data, needsUpgrade: true } }} />
94<Story name="Knot is unreachable" args={{ data: { ...data, knotUnreachable: true } }} />
95<Story name="Empty repository" asChild>
96 <StoryAuthProvider>
97 <RepoIndexView {repo} data={emptyData} bobbinUrl="https://bobbin.example.test" />
98 </StoryAuthProvider>
99</Story>