From 622b2735f3d31143375db8e4b67eca8bb95ee3bd Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Wed, 28 Jun 2023 12:44:04 +0200 Subject: [PATCH] cob: Changes to patch code review CRDT This patch incorporates several important changes to code review: * Code review verdict is no longer editable * Made reviews redactable instead * Renamed review top-level comment to "summary" * Renamed inline comments to "comments" * Made inline comments addressable by `EntryId` * This is to allow for editing * Removed inline comments from review creation * Added a `CodeComment` action instead * Removed `Semilattice` instance from `Review` * Added a `EditReview` action instead to have more control * Made it valid for revisions to be redacted concurrently with a review/merge Most of these changes are needed to support proper inline code comments. --- radicle-httpd/src/api/json.rs | 8 ++--- radicle-httpd/src/api/v1/projects.rs | 45 ++++++++++------------------ 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/radicle-httpd/src/api/json.rs b/radicle-httpd/src/api/json.rs index 4cb5c3957..2b1d7dbae 100644 --- a/radicle-httpd/src/api/json.rs +++ b/radicle-httpd/src/api/json.rs @@ -188,8 +188,8 @@ fn review(nid: &NodeId, alias: Option, review: &Review) -> Value { "alias": alias, }, "verdict": review.verdict(), - "comment": review.comment(), - "inline": review.inline().collect::>(), + "summary": review.summary(), + "comments": review.comments().collect::>(), "timestamp": review.timestamp(), }), None => json!({ @@ -197,8 +197,8 @@ fn review(nid: &NodeId, alias: Option, review: &Review) -> Value { "id": nid, }, "verdict": review.verdict(), - "comment": review.comment(), - "inline": review.inline().collect::>(), + "summary": review.summary(), + "comments": review.comments().collect::>(), "timestamp": review.timestamp(), }), } diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index 9f97d5bbe..7c84c4be1 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -644,6 +644,13 @@ async fn patch_update_handler( } => { patch.edit_revision(revision, description, &signer)?; } + patch::Action::EditReview { + revision, + author, + summary, + } => { + patch.edit_review(revision, author, summary, &signer)?; + } patch::Action::Tag { add, remove } => { patch.tag(add, remove, &signer)?; } @@ -662,11 +669,13 @@ async fn patch_update_handler( } patch::Action::Review { revision, - comment, + summary, verdict, - inline, } => { - patch.review(revision, verdict, comment, inline, &signer)?; + patch.review(revision, verdict, summary, &signer)?; + } + patch::Action::CodeComment { .. } => { + todo!() } patch::Action::Merge { revision, commit } => { patch.merge(revision, commit, &signer)?; @@ -2237,23 +2246,8 @@ mod routes { let thread_body = serde_json::to_vec(&json!({ "type": "review", "revision": CONTRIBUTOR_PATCH_ID, - "comment": "A small review", + "summary": "A small review", "verdict": "accept", - "inline": [ - { - "location": { - "blob": "82eb77880c693655bce074e3dbbd9fa711dc018b", - "path": "./README.md", - "commit": HEAD, - "lines": { - "start": 1, - "end": 3, - }, - }, - "comment": "This is a comment on line 1", - "timestamp": TIMESTAMP, - } - ] })) .unwrap(); let response = patch( @@ -2305,17 +2299,8 @@ mod routes { "id": CONTRIBUTOR_NID, }, "verdict": "accept", - "comment": "A small review", - "inline": [ - { - "location": { - "path": "./README.md", - "old": null, - "new": null, - }, - "comment": "This is a comment on line 1", - } - ], + "summary": "A small review", + "comments": [], "timestamp": TIMESTAMP, }, ],