Browse files using repo HEAD

This commit is contained in:
Alexis Sellier
2021-06-11 10:03:23 +02:00
parent c76e42d493
commit b9999209de
3 changed files with 20 additions and 7 deletions
+1 -4
View File
@@ -12,6 +12,7 @@
export let commit: string;
export let config: Config;
export let path: string;
export let onSelect: (event: { detail: string }) => void;
let info: "loading" | proj.Info | null = null;
let blob: Promise<proj.Blob | null> | null = null;
@@ -20,10 +21,6 @@
return proj.getTree(urn, commit, path, config);
};
const onSelect = async ({ detail: path }: { detail: string }) => {
navigate(`/projects/${urn}/${commit}/${path}`);
};
$: if (path === "/") {
blob = proj.getReadme(urn, commit, config);
} else {
+9 -1
View File
@@ -10,6 +10,10 @@
};
</script>
<Route path="/projects/:urn/head/:path/*" let:params>
<View {config} urn={params.urn} path={joinPaths(params.path, params['*'])} />
</Route>
<Route path="/projects/:urn/:commit/:path/*" let:params>
<View {config} urn={params.urn} commit={params.commit} path={joinPaths(params.path, params['*'])} />
</Route>
@@ -18,6 +22,10 @@
<View {config} urn={params.urn} commit={params.commit} path="/" />
</Route>
<Route path="/projects/:urn/head" let:params>
<View {config} urn={params.urn} path="/" />
</Route>
<Route path="/projects/:urn" let:params>
<View {config} urn={params.urn} commit={null} path="/" />
<View {config} urn={params.urn} path="/" />
</Route>
+10 -2
View File
@@ -12,12 +12,20 @@
};
export let urn: string;
export let commit: string | null;
export let commit: string | null = null;
export let config: Config;
export let path: string;
let project: State.Loading | proj.Info | null = null;
const onSelect = ({ detail: path }: { detail: string }) => {
if (commit) {
navigate(`/projects/${urn}/${commit}/${path}`);
} else {
navigate(`/projects/${urn}/head/${path}`);
}
};
onMount(async () => {
project = State.Loading;
project = await proj.getInfo(urn, config);
@@ -72,7 +80,7 @@
commit {commit || project.head}
</div>
</header>
<Browser {urn} commit={commit || project.head} {path} {config} />
<Browser {urn} commit={commit || project.head} {path} {onSelect} {config} />
{:else}
<!-- Not found -->
{/if}