Start review from code-comment on revision diff

Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Brandon Oxendine
2026-04-30 16:49:41 +02:00
committed by Rūdolfs Ošiņš
co-authored by Rūdolfs Ošiņš
parent e0aafa7de2
commit ec49ecbd36
7 changed files with 132 additions and 21 deletions
+20 -10
View File
@@ -171,9 +171,18 @@
...(selectedRevision.reviews ?? []),
].filter((review): review is Review | DraftReview => Boolean(review)),
);
const hasOwnReview = $derived(
const ownDraftReview = $derived(
reviewsOfSelectedRevision.find(
value =>
value.author.did === didFromPublicKey(config.publicKey) &&
"draft" in value,
),
);
const hasOwnPublishedReview = $derived(
reviewsOfSelectedRevision.some(
value => value.author.did === didFromPublicKey(config.publicKey),
value =>
value.author.did === didFromPublicKey(config.publicKey) &&
!("draft" in value),
),
);
const patchDescription = $derived(
@@ -327,12 +336,11 @@
patchId={patch.id} />
<Button
variant="secondary"
disabled={hasOwnReview}
disabled={hasOwnPublishedReview}
onclick={() => {
const id = draftReviewStorage.create(
repo.rid,
selectedRevision.id,
);
const id =
ownDraftReview?.id ??
draftReviewStorage.create(repo.rid, selectedRevision.id);
void router.push({
resource: "repo.patch",
rid: repo.rid,
@@ -341,13 +349,15 @@
status,
});
}}
title={hasOwnReview
title={hasOwnPublishedReview
? "You already created a review for this revision"
: "Review revision"}>
: ownDraftReview
? "Continue review"
: "Review revision"}>
<Icon name="comment" />
<span
class="txt-body-m-regular global-hide-on-medium-desktop-down">
Review revision
{ownDraftReview ? "Continue review" : "Review revision"}
</span>
</Button>
</div>