Improve handling missing files and README

This commit is contained in:
Sebastian Martinez
2023-12-12 10:41:27 +01:00
parent 29a53f1ff6
commit 24628f57d8
2 changed files with 22 additions and 12 deletions
+14 -12
View File
@@ -6,14 +6,12 @@
import { HttpdClient } from "@httpd-client";
import Button from "@app/components/Button.svelte";
import File from "@app/components/File.svelte";
import Header from "./Source/Header.svelte";
import Layout from "./Layout.svelte";
import Placeholder from "@app/components/Placeholder.svelte";
import BlobComponent from "./Source/Blob.svelte";
import TreeComponent from "./Source/Tree.svelte";
import FilePath from "@app/components/FilePath.svelte";
export let baseUrl: BaseUrl;
export let rawPath: (commit?: string) => string;
@@ -98,6 +96,11 @@
min-width: var(--content-min-width);
width: 100%;
}
.placeholder {
padding: 4rem 0;
border: 1px solid var(--color-border-hint);
border-radius: var(--border-radius-small);
}
.source-tree {
overflow-x: hidden;
@@ -209,20 +212,19 @@
blob={blobResult.blob}
highlighted={blobResult.highlighted}
rawPath={rawPath(tree.lastCommit.id)} />
{:else if path === "/"}
<div class="placeholder">
<Placeholder iconName="no-file" caption="No README found." />
</div>
{:else}
<File>
<FilePath
slot="left-header"
filenameWithPath={blobResult.error.path} />
<div style:margin="4rem 0" style:width="100%">
<Placeholder iconName="no-file" caption="File not found" />
</div>
</File>
<div class="placeholder">
<Placeholder iconName="no-file" caption="File not found." />
</div>
{/if}
</div>
{:else}
<div style:margin="4rem 0" style:width="100%">
<Placeholder iconName="no-file" caption="No files at this revision" />
<div class="placeholder">
<Placeholder iconName="no-file" caption="No files at this revision." />
</div>
{/if}
</div>
+8
View File
@@ -4,6 +4,7 @@ import {
cobUrl,
sourceBrowsingUrl,
aliceRemote,
markdownUrl,
} from "@tests/support/fixtures.js";
test("source page", async ({ page }) => {
@@ -84,6 +85,13 @@ test("project not found", async ({ page }) => {
await expect(page).toHaveScreenshot();
});
test("readme not found", async ({ page }) => {
await page.goto(`${markdownUrl}/tree`, {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot();
});
test("file not found", async ({ page }) => {
await page.goto(`${sourceBrowsingUrl}/tree/this.file.does.not.exist`, {
waitUntil: "networkidle",