diff --git a/src/components/ExpandButton.svelte b/src/components/ExpandButton.svelte index 7aa839f49..d7e03cc40 100644 --- a/src/components/ExpandButton.svelte +++ b/src/components/ExpandButton.svelte @@ -1,9 +1,15 @@ - - (expanded = !expanded)}> + { + expanded = !expanded; + dispatch("toggle", { expanded }); + }}>
{#if expanded} diff --git a/src/components/File.svelte b/src/components/File.svelte index 38fd4c3f4..7165eab12 100644 --- a/src/components/File.svelte +++ b/src/components/File.svelte @@ -1,65 +1,86 @@ + + -
- +
+
+ {#if collapsable} + { + expanded = !expanded; + if (!expanded) { + await tick(); + header.scrollIntoView({ behavior: "smooth", block: "nearest" }); + } + }} /> + {/if} - +
+
-
- -
+{#if expanded} +
+ +
+{/if} diff --git a/src/components/FilePath.svelte b/src/components/FilePath.svelte index 96ed5ac5f..1069d03a1 100644 --- a/src/components/FilePath.svelte +++ b/src/components/FilePath.svelte @@ -10,8 +10,9 @@ -{path}{filename} +{path}{filename} diff --git a/src/components/Markdown.svelte b/src/components/Markdown.svelte index 3501edfc7..1937eb9b0 100644 --- a/src/components/Markdown.svelte +++ b/src/components/Markdown.svelte @@ -158,6 +158,9 @@ -
+
{diffDescription(diff)} with 0}> @@ -84,7 +89,8 @@ {pluralize("deletion", diff.stats.deletions)}
-
+ +
{#each diff.added as file}
diff --git a/src/views/projects/Changeset/FileDiff.svelte b/src/views/projects/Changeset/FileDiff.svelte index 9694f910f..aea6db61f 100644 --- a/src/views/projects/Changeset/FileDiff.svelte +++ b/src/views/projects/Changeset/FileDiff.svelte @@ -7,7 +7,7 @@ import * as Syntax from "@app/lib/syntax"; import Badge from "@app/components/Badge.svelte"; - import ExpandButton from "@app/components/ExpandButton.svelte"; + import File from "@app/components/File.svelte"; import FilePath from "@app/components/FilePath.svelte"; import IconButton from "@app/components/IconButton.svelte"; import IconSmall from "@app/components/IconSmall.svelte"; @@ -31,7 +31,6 @@ export let projectId: string; export let visible: boolean = false; - let expanded = true; let selection: Selection | undefined = undefined; let highlighting: { new?: string[]; old?: string[] } | undefined = undefined; let syntaxHighlightingLoading: boolean = false; @@ -49,7 +48,7 @@ "-", ), ) - ?.scrollIntoView(); + ?.scrollIntoView({ block: "center" }); } }); @@ -239,25 +238,8 @@ -
-
- -
- {#if (headerBadgeCaption === "moved" || headerBadgeCaption === "copied") && oldFilePath} - - → - - {:else} - - {/if} - {#if headerBadgeCaption === "added"} - added - {:else if headerBadgeCaption === "deleted"} - deleted - {:else if headerBadgeCaption === "moved"} - moved - {:else if headerBadgeCaption === "copied"} - copied - {/if} -
- {#if revision} -
- {#if syntaxHighlightingLoading} - - {/if} - - - - - -
+ + + {#if (headerBadgeCaption === "moved" || headerBadgeCaption === "copied") && oldFilePath} + + → + + {:else} + {/if} -
- {#if expanded} -
- {#if fileDiff.type === "plain"} - {#if fileDiff.hunks.length > 0} - - {#each fileDiff.hunks as hunk, hunkIdx} + + {#if headerBadgeCaption === "added"} + added + {:else if headerBadgeCaption === "deleted"} + deleted + {:else if headerBadgeCaption === "moved"} + moved + {:else if headerBadgeCaption === "copied"} + copied + {/if} + + + + {#if revision} + {#if syntaxHighlightingLoading} + + {/if} + + + + + + {/if} + + +
+ {#if fileDiff.type === "plain"} + {#if fileDiff.hunks.length > 0} +
+ {#each fileDiff.hunks as hunk, hunkIdx} + + + + + {#each hunk.lines as line, lineIdx} - - - {#each hunk.lines as line, lineIdx} - - - - - + -
-
- {/each} + {:else} + {line.line} + {/if} + +
+ {/each} -
+
+
+ {hunk.header} +
+
+ style:position="relative" + class={`diff-line type-${line.type}`} + class:selection-start={selection?.startHunk === hunkIdx && + selection.startLine === lineIdx} + class:selection-end={(selection?.endHunk === hunkIdx && + selection.endLine === lineIdx) || + (selection?.startHunk === hunkIdx && + selection.startLine === lineIdx && + selection?.endHunk === undefined)} + class:selected={isLineSelected(selection, hunkIdx, lineIdx)}> + selectLine(hunkIdx, lineIdx, e)}>
+ {lineNumberL(line)}
- {hunk.header} -
+ class="diff-line-number right" + on:click={e => selectLine(hunkIdx, lineIdx, e)}> + {lineNumberR(line)}
selectLine(hunkIdx, lineIdx, e)}> -
- {lineNumberL(line)} -
selectLine(hunkIdx, lineIdx, e)}> - {lineNumberR(line)} - - {lineSign(line)} - - {#if highlighting} - {#if line.type === "addition" && highlighting.new} - {@html highlighting.new[line.lineNo - 1]} - {:else if line.type === "context" && highlighting.new} - {@html highlighting.new[line.lineNoNew - 1]} - {:else if line.type === "deletion" && highlighting.old} - {@html highlighting.old[line.lineNo - 1]} - {/if} - {:else} - {line.line} + + {lineSign(line)} + + {#if highlighting} + {#if line.type === "addition" && highlighting.new} + {@html highlighting.new[line.lineNo - 1]} + {:else if line.type === "context" && highlighting.new} + {@html highlighting.new[line.lineNoNew - 1]} + {:else if line.type === "deletion" && highlighting.old} + {@html highlighting.old[line.lineNo - 1]} {/if} -
- {:else} -
- -
- {/if} + {/each} + {:else}
- +
{/if} -
- {/if} -
+ {:else} +
+ +
+ {/if} + + diff --git a/src/views/projects/Cob/CobCommitTeaser.svelte b/src/views/projects/Cob/CobCommitTeaser.svelte index 46ada2fc1..35eb537fa 100644 --- a/src/views/projects/Cob/CobCommitTeaser.svelte +++ b/src/views/projects/Cob/CobCommitTeaser.svelte @@ -71,7 +71,11 @@
{#if commit.description} - + { + commitMessageVisible = !commitMessageVisible; + }} /> {/if}
{#if commitMessageVisible} diff --git a/src/views/projects/Cob/Revision.svelte b/src/views/projects/Cob/Revision.svelte index 73468ffad..e528a93e1 100644 --- a/src/views/projects/Cob/Revision.svelte +++ b/src/views/projects/Cob/Revision.svelte @@ -23,7 +23,7 @@ import Thread from "@app/components/Thread.svelte"; export let baseUrl: BaseUrl; - export let expanded: boolean = true; + export let expanded: boolean = false; export let patchId: string; export let projectHead: string; export let projectDefaultBranch: string; @@ -124,7 +124,7 @@ background: none; padding: 0.5rem; font-size: var(--font-size-small); - height: 2.5rem; + height: 3rem; } .revision-name { display: flex; @@ -200,7 +200,10 @@
- + { + expanded = !expanded; + }} /> Revision {utils.formatObjectId(revisionId)} diff --git a/src/views/projects/Commit/CommitTeaser.svelte b/src/views/projects/Commit/CommitTeaser.svelte index 42bbf2a9c..6fcefc6e8 100644 --- a/src/views/projects/Commit/CommitTeaser.svelte +++ b/src/views/projects/Commit/CommitTeaser.svelte @@ -79,7 +79,11 @@
{#if commit.description} - + { + commitMessageVisible = !commitMessageVisible; + }} /> {/if}
{#if commitMessageVisible} diff --git a/src/views/projects/Source/Blob.svelte b/src/views/projects/Source/Blob.svelte index ed9ab0286..0d3c3c082 100644 --- a/src/views/projects/Source/Blob.svelte +++ b/src/views/projects/Source/Blob.svelte @@ -10,13 +10,14 @@ import { routeToPath } from "@app/lib/router"; import Button from "@app/components/Button.svelte"; + import File from "@app/components/File.svelte"; import FilePath from "@app/components/FilePath.svelte"; import IconSmall from "@app/components/IconSmall.svelte"; + import InlineMarkdown from "@app/components/InlineMarkdown.svelte"; import Link from "@app/components/Link.svelte"; import Markdown from "@app/components/Markdown.svelte"; import Placeholder from "@app/components/Placeholder.svelte"; import Radio from "@app/components/Radio.svelte"; - import InlineMarkdown from "@app/components/InlineMarkdown.svelte"; export let baseUrl: BaseUrl; export let projectId: string; @@ -82,7 +83,7 @@ const target = document.getElementById(selectedLineId); if (target) { target.classList.add("highlight"); - target.scrollIntoView(); + target.scrollIntoView({ block: "center" }); } } }); @@ -97,34 +98,6 @@ -
- - - -
+ + +
- +
+ +
{#if isMarkdown} @@ -283,10 +232,8 @@
-
-
+ -
{#if blob.binary}
@@ -304,4 +251,4 @@
{/if} -
+ diff --git a/tests/e2e/project.spec.ts b/tests/e2e/project.spec.ts index e7a56e10c..887f11c60 100644 --- a/tests/e2e/project.spec.ts +++ b/tests/e2e/project.spec.ts @@ -56,7 +56,7 @@ test("navigate to project", async ({ page }) => { } // Navigate to the project README.md by default. - await expect(page.locator(".file-name")).toContainText("README.md"); + await expect(page.locator(".filename")).toContainText("README.md"); // Show a commit teaser. await expect(page.getByText("dd068e9 Add README.md")).toBeVisible(); @@ -170,40 +170,40 @@ test("files with special characters in the filename", async ({ page }) => { await sourceTree.getByText("special").click(); await sourceTree.getByText("+plus+").click(); - await expect(page.locator(".file-name")).toContainText("+plus"); + await expect(page.locator(".filename")).toContainText("+plus"); await sourceTree.getByText("-dash-").click(); - await expect(page.locator(".file-name")).toContainText("-dash-"); + await expect(page.locator(".filename")).toContainText("-dash-"); await sourceTree.getByText(":colon:").click(); - await expect(page.locator(".file-name")).toContainText(":colon:"); + await expect(page.locator(".filename")).toContainText(":colon:"); await sourceTree.getByText(";semicolon;").click(); - await expect(page.locator(".file-name")).toContainText(";semicolon;"); + await expect(page.locator(".filename")).toContainText(";semicolon;"); await sourceTree.getByText("@at@").click(); - await expect(page.locator(".file-name")).toContainText("@at@"); + await expect(page.locator(".filename")).toContainText("@at@"); await sourceTree.getByText("_underscore_").click(); - await expect(page.locator(".file-name")).toContainText("_underscore_"); + await expect(page.locator(".filename")).toContainText("_underscore_"); // TODO: fix these errors in `radicle-httpd` for the following edge cases. // // await sourceTree.getByText("back\\slash").click(); - // await expect(page.locator(".file-name")).toContainText("back\\slash"); + // await expect(page.locator(".filename")).toContainText("back\\slash"); // await sourceTree.getByText("qs?param1=value?param2=value2#hash").click(); - // await expect(page.locator(".file-name")).toContainText( + // await expect(page.locator(".filename")).toContainText( // "qs?param1=value?param2=value2#hash", // ); await sourceTree.getByText("spaces are okay").click(); - await expect(page.locator(".file-name")).toContainText("spaces are okay"); + await expect(page.locator(".filename")).toContainText("spaces are okay"); await sourceTree.getByText("~tilde~").click(); - await expect(page.locator(".file-name")).toContainText("~tilde~"); + await expect(page.locator(".filename")).toContainText("~tilde~"); await sourceTree.getByText("👹👹👹").click(); - await expect(page.locator(".file-name")).toContainText("👹👹👹"); + await expect(page.locator(".filename")).toContainText("👹👹👹"); }); test("binary files", async ({ page }) => { @@ -453,7 +453,7 @@ test("internal file markdown link", async ({ page }) => { await page.getByRole("link", { name: "Markdown Cheatsheet" }).click(); await expect(page).toHaveURL(`${markdownUrl}/tree/main/cheatsheet.md`); await expect( - page.locator(".file-header", { hasText: "cheatsheet.md" }), + page.locator(".filename", { hasText: "cheatsheet.md" }), ).toBeVisible(); await page.goto(`${markdownUrl}/tree/main/link-files.md`); @@ -462,7 +462,7 @@ test("internal file markdown link", async ({ page }) => { `${markdownUrl}/tree/main/assets/black-square.png`, ); await expect( - page.locator(".file-header", { + page.locator(".file-path", { hasText: "assets/black-square.png", }), ).toBeVisible();