From b91a2a430c366f6d1f303d8821f86824e87709d2 Mon Sep 17 00:00:00 2001 From: eti Date: Wed, 2 Sep 2026 10:50:44 +0200 Subject: [PATCH] web/repo: merge the diff file views Signed-off-by: eti --- .../components/repo/CommitView.stories.svelte | 6 +- .../lib/components/repo/DiffCardChrome.svelte | 67 +++++++ .../lib/components/repo/DiffFileCard.svelte | 106 +++++----- .../lib/components/repo/DiffFileList.svelte | 84 -------- ...ies.svelte => DiffFileTree.stories.svelte} | 6 +- ...ullFileTree.svelte => DiffFileTree.svelte} | 49 +++-- .../lib/components/repo/DiffStatPill.svelte | 72 ++++--- .../components/repo/DiffTopbar.stories.svelte | 8 +- web/src/lib/components/repo/DiffTopbar.svelte | 22 +- .../components/repo/DiffView.stories.svelte | 2 +- web/src/lib/components/repo/DiffView.svelte | 13 +- web/src/lib/components/repo/pierreDiff.css | 11 + .../lib/components/repo/pulls/PullDiff.svelte | 36 ++-- .../pulls/PullDiffFileCard.stories.svelte | 188 ++++++++++++++++++ .../repo/pulls/PullDiffFileCard.svelte | 78 +++----- ...ffFileList.svelte => PullDiffFiles.svelte} | 13 -- web/src/lib/components/repo/types.ts | 4 +- 17 files changed, 475 insertions(+), 290 deletions(-) create mode 100644 web/src/lib/components/repo/DiffCardChrome.svelte delete mode 100644 web/src/lib/components/repo/DiffFileList.svelte rename web/src/lib/components/repo/{DiffFileList.stories.svelte => DiffFileTree.stories.svelte} (93%) rename web/src/lib/components/repo/{pulls/PullFileTree.svelte => DiffFileTree.svelte} (62%) create mode 100644 web/src/lib/components/repo/pulls/PullDiffFileCard.stories.svelte rename web/src/lib/components/repo/pulls/{PullDiffFileList.svelte => PullDiffFiles.svelte} (71%) diff --git a/web/src/lib/components/repo/CommitView.stories.svelte b/web/src/lib/components/repo/CommitView.stories.svelte index 3d2e2cb90..f100809ec 100644 --- a/web/src/lib/components/repo/CommitView.stories.svelte +++ b/web/src/lib/components/repo/CommitView.stories.svelte @@ -80,7 +80,7 @@ await expect(canvas.getByText("co-author")).toBeVisible(); await expect(canvas.getByText("committer")).toBeVisible(); - await expect(canvas.getByRole("link", { name: ".patch" })).toHaveAttribute( + await expect(canvas.getByRole("link", { name: "Download patch" })).toHaveAttribute( "href", "/dawn/tangled/commit/0123456789abcdef0123456789abcdef01234567.patch" ); @@ -96,8 +96,8 @@ const hidesDownloadsForShortRef = async ({ canvas }: PlayContext) => { await expect(canvas.getByText("add a storybook fixture")).toBeVisible(); - await expect(canvas.queryByRole("link", { name: ".patch" })).toBeNull(); - await expect(canvas.queryByRole("link", { name: ".diff" })).toBeNull(); + await expect(canvas.queryByRole("link", { name: "Download patch" })).toBeNull(); + await expect(canvas.queryByRole("link", { name: "Download diff" })).toBeNull(); }; const { Story } = defineMeta({ diff --git a/web/src/lib/components/repo/DiffCardChrome.svelte b/web/src/lib/components/repo/DiffCardChrome.svelte new file mode 100644 index 000000000..cc378489f --- /dev/null +++ b/web/src/lib/components/repo/DiffCardChrome.svelte @@ -0,0 +1,67 @@ + + + + +
+ +
+
+ {#if open} +
+ {#if actions} +
+ {@render actions()} +
+ {/if} +
+
+ +
+ {@render body()} +
+
diff --git a/web/src/lib/components/repo/DiffFileCard.svelte b/web/src/lib/components/repo/DiffFileCard.svelte index f90c791af..198c677ff 100644 --- a/web/src/lib/components/repo/DiffFileCard.svelte +++ b/web/src/lib/components/repo/DiffFileCard.svelte @@ -1,12 +1,12 @@ - -
- -
-
- {#if open} - - {:else} - - {/if} - - -
- {#if file.name.old && file.name.new && file.name.old !== file.name.new} - {file.name.old} - - {file.name.new} - {:else} - {name} - {/if} -
-
-
- {#if blobUrl} - - {/if} - {@render headerActions?.(file)} -
+ + {#snippet header()} + +
+ {#if file.name.old && file.name.new && file.name.old !== file.name.new} + {file.name.old} + + {file.name.new} + {:else} + {name} + {/if}
-
+ {/snippet} + + {#snippet actions()} + {#if blobUrl} + + {/if} + {@render headerActions?.(file)} + {/snippet} - {#if file.is_binary} -

- This is a binary file and will not be displayed. -

- {:else} - - {/if} -
+ {#snippet body()} + {#if file.is_binary} + + {:else} + + {/if} + {/snippet} + diff --git a/web/src/lib/components/repo/DiffFileList.svelte b/web/src/lib/components/repo/DiffFileList.svelte deleted file mode 100644 index faef388b9..000000000 --- a/web/src/lib/components/repo/DiffFileList.svelte +++ /dev/null @@ -1,84 +0,0 @@ - - - - -{#snippet nodes(list: TreeNode[])} - {#each list as node (`${node.type}:${node.name}`)} - {#if node.type === "dir"} -
- - - - - -
- {@render nodes(node.children)} -
-
- {:else} - - {/if} - {/each} -{/snippet} - -{@render nodes(tree)} diff --git a/web/src/lib/components/repo/DiffFileList.stories.svelte b/web/src/lib/components/repo/DiffFileTree.stories.svelte similarity index 93% rename from web/src/lib/components/repo/DiffFileList.stories.svelte rename to web/src/lib/components/repo/DiffFileTree.stories.svelte index 4c67508a6..90abedbcd 100644 --- a/web/src/lib/components/repo/DiffFileList.stories.svelte +++ b/web/src/lib/components/repo/DiffFileTree.stories.svelte @@ -1,7 +1,7 @@ {#snippet nodes(list: TreeNode[])} @@ -63,28 +80,24 @@ {#if node.type === "dir"} {@const open = !closed[node.path]}
(closed[node.path] = !e.currentTarget.open)}> - - + + {#if open} - -
+
{@render nodes(node.children)}
{:else} -
-