Add alias to Patch

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
xphoniex
2023-05-29 12:14:17 +00:00
parent 46494461f2
commit 39874d8d51
4 changed files with 56 additions and 19 deletions
+8 -5
View File
@@ -4,6 +4,12 @@
export let authorId: string;
export let authorAlias: string | undefined = undefined;
export let authorAliasColor:
| "--color-primary-5"
| "--color-foreground-5"
| "--color-positive-5"
| "--color-negative-5"
| undefined = "--color-foreground-5";
export let caption: string | undefined = undefined;
export let noAvatar: boolean = false;
export let timestamp: number | undefined = undefined;
@@ -28,9 +34,6 @@
.body {
white-space: nowrap;
}
.alias {
color: var(--color-foreground-5);
}
</style>
<span class="authorship txt-tiny">
@@ -40,13 +43,13 @@
<span class="id layout-desktop">
{formatNodeId(authorId)}
{#if authorAlias}
<span class="alias">({authorAlias})</span>
<span style:color="var({authorAliasColor})">({authorAlias})</span>
{/if}
</span>
<span class="id layout-mobile">
{formatNodeId(authorId).replace("did:key:", "")}
{#if authorAlias}
<span class="alias">({authorAlias})</span>
<span style:color="var({authorAliasColor})">({authorAlias})</span>
{/if}
</span>
{#if !caption}
+35 -6
View File
@@ -21,6 +21,7 @@
import ThreadComponent from "@app/components/Thread.svelte";
export let authorId: string;
export let authorAlias: string | undefined = undefined;
export let baseUrl: BaseUrl;
export let expanded: boolean = true;
export let patchId: string;
@@ -48,6 +49,17 @@
}
}
function aliasColorForVerdict(verdict?: string | null) {
switch (verdict) {
case "accept":
return "--color-positive-5";
case "reject":
return "--color-negative-5";
default:
return "--color-foreground-5";
}
}
let response: DiffResponse | undefined = undefined;
let error: any | undefined = undefined;
@@ -228,13 +240,17 @@
<CommentComponent
{caption}
{authorId}
{authorAlias}
timestamp={element.timestamp}
rawPath={utils.getRawBasePath(projectId, baseUrl, projectHead)}
body={element.inner.description} />
</div>
{:else}
<div class="action-padding action-background txt-tiny">
<Authorship {authorId} timestamp={element.timestamp}>
<Authorship
{authorId}
{authorAlias}
timestamp={element.timestamp}>
{caption}
</Authorship>
</div>
@@ -275,8 +291,10 @@
class="action-padding action-background merge layout-desktop txt-tiny">
<div class="action-content">
<Authorship
authorId={element.inner.node}
timestamp={element.timestamp}>
authorId={element.inner.author.id}
authorAlias={element.inner.author.alias}
timestamp={element.timestamp}
authorAliasColor="--color-primary-5">
merged
{utils.formatCommit(element.inner.commit)}
</Authorship>
@@ -285,7 +303,10 @@
<div
class="action-padding action-background merge layout-mobile txt-tiny">
<div class="action-content">
<Authorship authorId={element.inner.node}>
<Authorship
authorId={element.inner.author.id}
authorAlias={element.inner.author.alias}
authorAliasColor="--color-primary-5">
merged
{utils.formatCommit(element.inner.commit)}
</Authorship>
@@ -301,6 +322,7 @@
<CommentComponent
caption={formatVerdict(revisionId, review.verdict)}
authorId={author}
authorAlias={review.author.alias}
timestamp={review.timestamp}
rawPath={utils.getRawBasePath(projectId, baseUrl, projectHead)}
body={review.comment} />
@@ -311,7 +333,11 @@
class:positive-review={element.inner[2].verdict === "accept"}
class:negative-review={element.inner[2].verdict === "reject"}>
<div class="action-content">
<Authorship authorId={author} timestamp={element.timestamp}>
<Authorship
authorId={author}
authorAlias={review.author.alias}
authorAliasColor={aliasColorForVerdict(review.verdict)}
timestamp={element.timestamp}>
{formatVerdict(revisionId, review.verdict)}
</Authorship>
</div>
@@ -321,7 +347,10 @@
class:positive-review={element.inner[2].verdict === "accept"}
class:negative-review={element.inner[2].verdict === "reject"}>
<div class="action-content">
<Authorship authorId={author}>
<Authorship
authorId={author}
authorAlias={review.author.alias}
authorAliasColor={aliasColorForVerdict(review.verdict)}>
{formatVerdict(revisionId, review.verdict)}
</Authorship>
</div>
+6 -3
View File
@@ -153,10 +153,10 @@
revisionOid: rev.oid,
},
[
...rev.reviews.map<TimelineReview>(([author, review]) => ({
...rev.reviews.map<TimelineReview>(review => ({
timestamp: review.timestamp,
type: "review",
inner: [rev.id, author, review],
inner: [rev.id, review.author.id, review],
})),
...rev.merges.map<TimelineMerge>(inner => ({
timestamp: inner.timestamp,
@@ -279,7 +279,9 @@
{/if}
</svelte:fragment>
<div class="author" slot="author">
opened by <Authorship authorId={patch.author.id} />
opened by <Authorship
authorId={patch.author.id}
authorAlias={patch.author.alias} />
{utils.formatTimestamp(patch.revisions[0].timestamp)}
</div>
</CobHeader>
@@ -379,6 +381,7 @@
on:reply={createReply}
patchId={patch.id}
authorId={patch.author.id}
authorAlias={patch.author.alias}
expanded={index === patch.revisions.length - 1}
previousRevId={previousRevision?.id}
previousRevOid={previousRevision?.oid} />