mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-02 02:00:31 +08:00
Make project head optional
This is useful since some seeds may not have delegates synced. Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -65,19 +65,21 @@
|
||||
{#each projects as project}
|
||||
{@const anchor = anchors[project.urn]}
|
||||
{@const pendingAnchor = pendingAnchors[project.urn]}
|
||||
<div class="project">
|
||||
<Widget {project} {anchor} on:click={() => onClick(project)}>
|
||||
<span class="actions" slot="actions">
|
||||
{#if profile?.org?.safe && account && anchor}
|
||||
{#if pendingAnchor} <!-- Pending anchor -->
|
||||
<AnchorActions
|
||||
{account} {config} anchor={pendingAnchor} safe={profile.org.safe}
|
||||
on:success={() => loadAnchors()} />
|
||||
{#if project.head}
|
||||
<div class="project">
|
||||
<Widget {project} {anchor} on:click={() => onClick(project)}>
|
||||
<span class="actions" slot="actions">
|
||||
{#if profile?.org?.safe && account && anchor}
|
||||
{#if pendingAnchor} <!-- Pending anchor -->
|
||||
<AnchorActions
|
||||
{account} {config} anchor={pendingAnchor} safe={profile.org.safe}
|
||||
on:success={() => loadAnchors()} />
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</span>
|
||||
</Widget>
|
||||
</div>
|
||||
</span>
|
||||
</Widget>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{:catch err}
|
||||
<Message error>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let anchors: Array<string> = [];
|
||||
export let head: string;
|
||||
export let head: string | null;
|
||||
export let commit: string;
|
||||
export let noText = false;
|
||||
export let noBg = false;
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if anchors}
|
||||
{#if anchors && head}
|
||||
<!-- commit is head and latest anchor -->
|
||||
{#if commit == anchors[0] && commit === head}
|
||||
<span class="anchor-widget anchor-latest" class:no-bg={noBg}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { Readable } from 'svelte/store';
|
||||
import * as proj from '@app/project';
|
||||
import type * as proj from '@app/project';
|
||||
import Loading from '@app/Loading.svelte';
|
||||
import Placeholder from '@app/Placeholder.svelte';
|
||||
import * as utils from '@app/utils';
|
||||
@@ -21,10 +21,11 @@
|
||||
export let project: proj.Project;
|
||||
export let tree: proj.Tree;
|
||||
export let browserStore: Readable<proj.Browser>;
|
||||
export let commit: string;
|
||||
|
||||
$: browser = $browserStore;
|
||||
$: path = browser.path || "/";
|
||||
$: revision = browser.revision || project.branches[project.head];
|
||||
$: revision = browser.revision;
|
||||
|
||||
// When the component is loaded the first time, the blob is yet to be loaded.
|
||||
let state: State = { status: Status.Loading, path };
|
||||
@@ -70,7 +71,6 @@
|
||||
mobileFileTree = !mobileFileTree;
|
||||
};
|
||||
|
||||
$: commit = proj.getOid(revision, project.branches) || project.head;
|
||||
$: getBlob = loadBlob(path);
|
||||
$: loadingPath = state.status == Status.Loading ? state.path : null;
|
||||
</script>
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
<Header {tree} {commit} {browserStore} {project} peerSelector={! project.profile} />
|
||||
|
||||
{#if content == proj.ProjectContent.Tree}
|
||||
<Browser {project} {tree} {browserStore} />
|
||||
<Browser {project} {commit} {tree} {browserStore} />
|
||||
{:else if content == proj.ProjectContent.History}
|
||||
<History {project} {commit} />
|
||||
{:else if content == proj.ProjectContent.Commit}
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
{#if project.head}
|
||||
{project.head}
|
||||
{:else}
|
||||
<span class="subtle">Could not retrieve HEAD</span>
|
||||
<span class="subtle">✗ No head</span>
|
||||
{/if}
|
||||
</slot>
|
||||
</span>
|
||||
@@ -104,7 +104,7 @@
|
||||
</span>
|
||||
<span class="anchor-badge">
|
||||
<slot name="anchor">
|
||||
{#if anchor}
|
||||
{#if anchor && project.head}
|
||||
<AnchorBadge
|
||||
commit={project.head}
|
||||
head={project.head} noText noBg
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ export enum ProjectContent {
|
||||
}
|
||||
|
||||
export interface ProjectInfo {
|
||||
head: string;
|
||||
head: string | null;
|
||||
urn: string;
|
||||
name: string;
|
||||
description: string;
|
||||
@@ -205,7 +205,7 @@ export function parseRoute(input: string, branches: Branches): { path?: string;
|
||||
|
||||
export class Project implements ProjectInfo {
|
||||
urn: string;
|
||||
head: string;
|
||||
head: string | null;
|
||||
name: string;
|
||||
description: string;
|
||||
defaultBranch: string;
|
||||
@@ -345,7 +345,7 @@ export class Project implements ProjectInfo {
|
||||
: [];
|
||||
|
||||
let remote: Remote = {
|
||||
heads: { [info.defaultBranch]: info.head }
|
||||
heads: info.head ? { [info.defaultBranch]: info.head } : {}
|
||||
};
|
||||
|
||||
if (peer) {
|
||||
|
||||
Reference in New Issue
Block a user