Remove commit from Avatar params

This commit is contained in:
Mattias Granlund 2024-06-02 17:21:37 +02:00
parent 6d2643eb32
commit 2948428632
2 changed files with 48 additions and 30 deletions

View File

@ -1,41 +1,41 @@
<script lang="ts">
import { getAvatarTooltip } from '$lib/utils/avatar';
import { tooltip } from '$lib/utils/tooltip';
import type { Commit, RemoteCommit } from '$lib/vbranches/types';
import type { Author, CommitStatus } from '$lib/vbranches/types';
export let commit: Commit | RemoteCommit | undefined;
export let status: CommitStatus | undefined;
export let author: Author | undefined;
export let help: string | undefined = undefined;
export let first = false;
export let shadow: boolean = false;
export let remoteLane: boolean = false;
export let shadowLane: boolean = false;
export let first = false;
$: tooltipText = getAvatarTooltip(commit);
</script>
{#if shadow}
<div
class:first
class="shadow-marker"
class:upstream={commit?.status == 'upstream'}
class:integrated={commit?.status == 'integrated'}
class:upstream={status == 'upstream'}
class:integrated={status == 'integrated'}
class:shadow-lane={shadowLane}
use:tooltip={tooltipText}
use:tooltip={help}
></div>
{:else}
<img
class="avatar"
alt="Gravatar for {commit?.author.email}"
srcset="{commit?.author.gravatarUrl} 2x"
alt="Gravatar for {author?.email}"
srcset="{author?.gravatarUrl} 2x"
width="100"
height="100"
class:first
class:local={commit?.status == 'local'}
class:remote={commit?.status == 'remote'}
class:upstream={commit?.status == 'upstream'}
class:integrated={commit?.status == 'integrated'}
class:local={status == 'local'}
class:remote={status == 'remote'}
class:upstream={status == 'upstream'}
class:integrated={status == 'integrated'}
class:remote-lane={remoteLane}
class:shadow-lane={shadowLane}
use:tooltip={tooltipText}
use:tooltip={help}
on:error
/>
{/if}

View File

@ -3,6 +3,7 @@
import LocalLine from './LocalLine.svelte';
import RemoteLine from './RemoteLine.svelte';
import ShadowLine from './ShadowLine.svelte';
import { getAvatarTooltip } from '$lib/utils/avatar';
import type { Commit, CommitStatus, RemoteCommit } from '$lib/vbranches/types';
export let hasShadowColumn = false;
@ -26,39 +27,56 @@
$: short = !upstreamType && (lastLocalCommit || lastRemoteCommit);
$: relatedToOther = localCommit?.relatedTo && localCommit.relatedTo.id != localCommit.id;
$: upstreamIsNext = !!localCommit?.relatedTo && upstreamType == 'upstream';
$: tooltipText = getAvatarTooltip(localCommit || remoteCommit);
$: commitStatus = localCommit?.status || remoteCommit?.status;
$: author = localCommit?.author || remoteCommit?.author;
</script>
<div class="lines">
{#if hasShadowColumn}
<ShadowLine line={shadowLine} dashed={base} {upstreamLine} {upstreamType} {first} {short}>
<Avatar shadow={!!localCommit} shadowLane commit={localCommit || remoteCommit} {first} />
<Avatar
{first}
{author}
help={tooltipText}
status={commitStatus}
shadow={!!localCommit}
shadowLane
/>
</ShadowLine>
{/if}
<RemoteLine
commit={localCommit?.status == 'remote' || localCommit?.status == 'integrated'
? localCommit
: undefined}
line={remoteLine}
{root}
upstreamLine={upstreamLine && !hasShadowColumn}
{first}
short={root || short || (!!localCommit?.relatedTo && upstreamType == 'upstream')}
{upstreamType}
{base}
{first}
{upstreamType}
line={remoteLine}
commit={localCommit}
short={root || short || upstreamIsNext}
upstreamLine={upstreamLine && !hasShadowColumn}
>
{#if relatedToOther || remoteCommit}
<Avatar remoteLane shadow={relatedToOther} commit={localCommit || remoteCommit} {first} />
<Avatar
{first}
{author}
help={tooltipText}
status={commitStatus}
shadow={relatedToOther}
remoteLane
/>
{/if}
</RemoteLine>
{#if hasLocalColumn}
<LocalLine
isEmpty={base}
commit={localCommit?.status == 'local' ? localCommit : undefined}
dashed={localLine}
{first}
isEmpty={base}
dashed={localLine}
commit={localCommit?.status == 'local' ? localCommit : undefined}
>
<Avatar commit={localCommit} {first} />
<Avatar {first} {author} help={tooltipText} status={commitStatus} />
</LocalLine>
{/if}
</div>