@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow reviewers to mark their own inlines as "Done" before they submit them

Summary:
Ref T13195. Ref T8573. This allows reviewers to mark their own inline comments as "Done" before they submit them.

If you're leaving a non-actionable comment like "this is good", you can pre-check "Done" to give the author a hint that you don't expect any response.

Test Plan: On revisions and commits, added inlines as the author and a reviewer/auditor. Marked them done/not-done before submitting. As author, marked the not-done ones done after submitting. Checked preivews, toggled done/not done states.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13195, T8573

Differential Revision: https://secure.phabricator.com/D19634

+83 -24
+18 -6
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 258 258 $this->didExpandInlineState = true; 259 259 260 260 $actor_phid = $this->getActingAsPHID(); 261 - $actor_is_author = ($object->getAuthorPHID() == $actor_phid); 262 - if (!$actor_is_author) { 263 - break; 264 - } 261 + $author_phid = $object->getAuthorPHID(); 262 + $actor_is_author = ($actor_phid == $author_phid); 265 263 266 264 $state_map = PhabricatorTransactions::getInlineStateMap(); 267 265 268 - $inlines = id(new DiffusionDiffInlineCommentQuery()) 266 + $query = id(new DiffusionDiffInlineCommentQuery()) 269 267 ->setViewer($this->getActor()) 270 268 ->withCommitPHIDs(array($object->getPHID())) 271 - ->withFixedStates(array_keys($state_map)) 269 + ->withFixedStates(array_keys($state_map)); 270 + 271 + $inlines = array(); 272 + 273 + $inlines[] = id(clone $query) 274 + ->withAuthorPHIDs(array($actor_phid)) 275 + ->withHasTransaction(false) 272 276 ->execute(); 277 + 278 + if ($actor_is_author) { 279 + $inlines[] = id(clone $query) 280 + ->withHasTransaciton(true) 281 + ->execute(); 282 + } 283 + 284 + $inlines = array_mergev($inlines); 273 285 274 286 if (!$inlines) { 275 287 break;
+15 -2
src/applications/differential/controller/DifferentialInlineCommentEditController.php
··· 118 118 throw new Exception(pht('Unable to load revision.')); 119 119 } 120 120 121 - if ($revision->getAuthorPHID() !== $viewer->getPHID()) { 122 - throw new Exception(pht('You are not the revision owner.')); 121 + $viewer_phid = $viewer->getPHID(); 122 + $is_owner = ($viewer_phid == $revision->getAuthorPHID()); 123 + $is_author = ($viewer_phid == $inline->getAuthorPHID()); 124 + $is_draft = ($inline->isDraft()); 125 + 126 + if ($is_owner) { 127 + // You own the revision, so you can mark the comment as "Done". 128 + } else if ($is_author && $is_draft) { 129 + // You made this comment and it's still a draft, so you can mark 130 + // it as "Done". 131 + } else { 132 + throw new Exception( 133 + pht( 134 + 'You are not the revision owner, and this is not a draft comment '. 135 + 'you authored.')); 123 136 } 124 137 125 138 return $inline;
+21 -6
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 248 248 $this->didExpandInlineState = true; 249 249 250 250 $actor_phid = $this->getActingAsPHID(); 251 - $actor_is_author = ($object->getAuthorPHID() == $actor_phid); 252 - if (!$actor_is_author) { 253 - break; 254 - } 251 + $author_phid = $object->getAuthorPHID(); 252 + $actor_is_author = ($actor_phid == $author_phid); 255 253 256 254 $state_map = PhabricatorTransactions::getInlineStateMap(); 257 255 258 - $inlines = id(new DifferentialDiffInlineCommentQuery()) 256 + $query = id(new DifferentialDiffInlineCommentQuery()) 259 257 ->setViewer($this->getActor()) 260 258 ->withRevisionPHIDs(array($object->getPHID())) 261 - ->withFixedStates(array_keys($state_map)) 259 + ->withFixedStates(array_keys($state_map)); 260 + 261 + $inlines = array(); 262 + 263 + // We're going to undraft any "done" marks on your own inlines. 264 + $inlines[] = id(clone $query) 265 + ->withAuthorPHIDs(array($actor_phid)) 266 + ->withHasTransaction(false) 262 267 ->execute(); 268 + 269 + // If you're the author, we also undraft any "done" marks on other 270 + // inlines. 271 + if ($actor_is_author) { 272 + $inlines[] = id(clone $query) 273 + ->withHasTransaction(true) 274 + ->execute(); 275 + } 276 + 277 + $inlines = array_mergev($inlines); 263 278 264 279 if (!$inlines) { 265 280 break;
+15 -3
src/applications/diffusion/controller/DiffusionInlineCommentController.php
··· 75 75 throw new Exception(pht('Failed to load commit.')); 76 76 } 77 77 78 - if ((!$commit->getAuthorPHID()) || 79 - ($commit->getAuthorPHID() != $viewer->getPHID())) { 80 - throw new Exception(pht('You can not mark this comment as complete.')); 78 + $owner_phid = $commit->getAuthorPHID(); 79 + $viewer_phid = $viewer->getPHID(); 80 + $viewer_is_owner = ($owner_phid && ($owner_phid == $viewer_phid)); 81 + $viewer_is_author = ($viewer_phid == $inline->getAuthorPHID()); 82 + $is_draft = $inline->isDraft(); 83 + 84 + if ($viewer_is_owner) { 85 + // You can mark inlines on your own commits as "Done". 86 + } else if ($viewer_is_author && $is_draft) { 87 + // You can mark your own unsubmitted inlines as "Done". 88 + } else { 89 + throw new Exception( 90 + pht( 91 + 'You can not mark this comment as complete: you did not author '. 92 + 'the commit and the comment is not a draft you wrote.')); 81 93 } 82 94 83 95 return $inline;
+14 -7
src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
··· 287 287 288 288 $done_button = null; 289 289 290 + $mark_done = $this->getCanMarkDone(); 291 + 292 + // Allow users to mark their own draft inlines as "Done". 293 + if ($viewer_phid == $inline->getAuthorPHID()) { 294 + if ($inline->isDraft()) { 295 + $mark_done = true; 296 + } 297 + } 298 + 290 299 if (!$is_synthetic) { 291 300 $draft_state = false; 292 301 switch ($inline->getFixedState()) { 293 302 case PhabricatorInlineCommentInterface::STATE_DRAFT: 294 - $is_done = ($this->getCanMarkDone()); 303 + $is_done = $mark_done; 295 304 $draft_state = true; 296 305 break; 297 306 case PhabricatorInlineCommentInterface::STATE_UNDRAFT: 298 - $is_done = !($this->getCanMarkDone()); 307 + $is_done = !$mark_done; 299 308 $draft_state = true; 300 309 break; 301 310 case PhabricatorInlineCommentInterface::STATE_DONE: ··· 309 318 310 319 // If you don't have permission to mark the comment as "Done", you also 311 320 // can not see the draft state. 312 - if (!$this->getCanMarkDone()) { 321 + if (!$mark_done) { 313 322 $draft_state = false; 314 323 } 315 324 ··· 321 330 $classes[] = 'inline-state-is-draft'; 322 331 } 323 332 324 - if ($this->getCanMarkDone()) { 333 + if ($mark_done && !$this->preview) { 325 334 $done_input = javelin_tag( 326 335 'input', 327 336 array( 328 337 'type' => 'checkbox', 329 338 'checked' => ($is_done ? 'checked' : null), 330 - 'disabled' => ($this->getCanMarkDone() ? null : 'disabled'), 331 339 'class' => 'differential-inline-done', 332 340 'sigil' => 'differential-inline-done', 333 341 )); 334 342 $done_button = phutil_tag( 335 343 'label', 336 344 array( 337 - 'class' => 'differential-inline-done-label '. 338 - ($this->getCanMarkDone() ? null : 'done-is-disabled'), 345 + 'class' => 'differential-inline-done-label ', 339 346 ), 340 347 array( 341 348 $done_input,