mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-12 13:30:35 +08:00
Browse files using repo HEAD
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user