@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.

Give Audit an informational "This commit now requires (something)..." transaction

Summary: Ref T2393. This adds a state-change transaction hint to Audit, like we have in Differential. This is partly for consistency and partly to make it more clear what should happen next.

Test Plan: {F2477848}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2393

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

+113
+2
src/__phutil_library_map__.php
··· 671 671 'DiffusionCommitRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php', 672 672 'DiffusionCommitRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php', 673 673 'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php', 674 + 'DiffusionCommitStateTransaction' => 'applications/diffusion/xaction/DiffusionCommitStateTransaction.php', 674 675 'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php', 675 676 'DiffusionCommitTransactionType' => 'applications/diffusion/xaction/DiffusionCommitTransactionType.php', 676 677 'DiffusionCompareController' => 'applications/diffusion/controller/DiffusionCompareController.php', ··· 5378 5379 'DiffusionCommitRevisionReviewersHeraldField' => 'DiffusionCommitHeraldField', 5379 5380 'DiffusionCommitRevisionSubscribersHeraldField' => 'DiffusionCommitHeraldField', 5380 5381 'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 5382 + 'DiffusionCommitStateTransaction' => 'DiffusionCommitTransactionType', 5381 5383 'DiffusionCommitTagsController' => 'DiffusionController', 5382 5384 'DiffusionCommitTransactionType' => 'PhabricatorModularTransactionType', 5383 5385 'DiffusionCompareController' => 'DiffusionController',
+27
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 361 361 } 362 362 } 363 363 364 + $old_status = $object->getAuditStatus(); 365 + 364 366 $requests = $object->getAudits(); 365 367 $object->updateAuditStatus($requests); 368 + 369 + $new_status = $object->getAuditStatus(); 370 + 366 371 $object->save(); 367 372 368 373 if ($import_status_flag) { 369 374 $object->writeImportStatusFlag($import_status_flag); 375 + } 376 + 377 + $partial_status = PhabricatorAuditCommitStatusConstants::PARTIALLY_AUDITED; 378 + 379 + // If the commit has changed state after this edit, add an informational 380 + // transaction about the state change. 381 + if ($old_status !== $new_status) { 382 + if ($new_status === $partial_status) { 383 + // This state isn't interesting enough to get a transaction. The 384 + // best way we could lead the user forward is something like "This 385 + // commit still requires additional audits." but that's redundant and 386 + // probably not very useful. 387 + } else { 388 + $xaction = $object->getApplicationTransactionTemplate() 389 + ->setTransactionType(DiffusionCommitStateTransaction::TRANSACTIONTYPE) 390 + ->setOldValue($old_status) 391 + ->setNewValue($new_status); 392 + 393 + $xaction = $this->populateTransaction($object, $xaction); 394 + 395 + $xaction->save(); 396 + } 370 397 } 371 398 372 399 // Collect auditor PHIDs for building mail.
+18
src/applications/audit/storage/PhabricatorAuditTransaction.php
··· 498 498 } 499 499 return $tags; 500 500 } 501 + 502 + public function shouldDisplayGroupWith(array $group) { 503 + // Make the "This commit now requires audit." state message stand alone. 504 + $type_state = DiffusionCommitStateTransaction::TRANSACTIONTYPE; 505 + 506 + if ($this->getTransactionType() == $type_state) { 507 + return false; 508 + } 509 + 510 + foreach ($group as $xaction) { 511 + if ($xaction->getTransactionType() == $type_state) { 512 + return false; 513 + } 514 + } 515 + 516 + return parent::shouldDisplayGroupWith($group); 517 + } 518 + 501 519 }
+66
src/applications/diffusion/xaction/DiffusionCommitStateTransaction.php
··· 1 + <?php 2 + 3 + final class DiffusionCommitStateTransaction 4 + extends DiffusionCommitTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'diffusion.commit.state'; 7 + 8 + public function generateNewValue($object, $value) { 9 + // NOTE: This transaction can not be generated or applied normally. It is 10 + // written to the transaction log as a side effect of a state change. 11 + throw new PhutilMethodNotImplementedException(); 12 + } 13 + 14 + public function getIcon() { 15 + $new = $this->getNewValue(); 16 + return PhabricatorAuditCommitStatusConstants::getStatusIcon($new); 17 + } 18 + 19 + public function getColor() { 20 + $new = $this->getNewValue(); 21 + return PhabricatorAuditCommitStatusConstants::getStatusColor($new); 22 + } 23 + 24 + public function getTitle() { 25 + $new = $this->getNewValue(); 26 + 27 + switch ($new) { 28 + case PhabricatorAuditCommitStatusConstants::NONE: 29 + return pht('This commit no longer requires audit.'); 30 + case PhabricatorAuditCommitStatusConstants::NEEDS_AUDIT: 31 + return pht('This commit now requires audit.'); 32 + case PhabricatorAuditCommitStatusConstants::CONCERN_RAISED: 33 + return pht('This commit now has outstanding concerns.'); 34 + case PhabricatorAuditCommitStatusConstants::FULLY_AUDITED: 35 + return pht('All concerns with this commit have now been addressed.'); 36 + } 37 + 38 + return null; 39 + } 40 + 41 + public function getTitleForFeed() { 42 + $new = $this->getNewValue(); 43 + 44 + switch ($new) { 45 + case PhabricatorAuditCommitStatusConstants::NONE: 46 + return pht( 47 + '%s no longer requires audit.', 48 + $this->renderObject()); 49 + case PhabricatorAuditCommitStatusConstants::NEEDS_AUDIT: 50 + return pht( 51 + '%s now requires audit.', 52 + $this->renderObject()); 53 + case PhabricatorAuditCommitStatusConstants::CONCERN_RAISED: 54 + return pht( 55 + '%s now has outstanding concerns.', 56 + $this->renderObject()); 57 + case PhabricatorAuditCommitStatusConstants::FULLY_AUDITED: 58 + return pht( 59 + 'All concerns with %s have now been addressed.', 60 + $this->renderObject()); 61 + } 62 + 63 + return null; 64 + } 65 + 66 + }