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

Show yellow "draft" bubble in Audit

Summary: Fixes T6660. Uses the new stuff in Audit to build an EditEngine-aware icon.

Test Plan: {F2364304}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6660

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

+149 -34
+3
src/__phutil_library_map__.php
··· 629 629 'DiffusionCommitDiffContentHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentHeraldField.php', 630 630 'DiffusionCommitDiffContentRemovedHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentRemovedHeraldField.php', 631 631 'DiffusionCommitDiffEnormousHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffEnormousHeraldField.php', 632 + 'DiffusionCommitDraftEngine' => 'applications/diffusion/engine/DiffusionCommitDraftEngine.php', 632 633 'DiffusionCommitEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitEditConduitAPIMethod.php', 633 634 'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php', 634 635 'DiffusionCommitEditEngine' => 'applications/diffusion/editor/DiffusionCommitEditEngine.php', ··· 5341 5342 'DiffusionCommitDiffContentHeraldField' => 'DiffusionCommitHeraldField', 5342 5343 'DiffusionCommitDiffContentRemovedHeraldField' => 'DiffusionCommitHeraldField', 5343 5344 'DiffusionCommitDiffEnormousHeraldField' => 'DiffusionCommitHeraldField', 5345 + 'DiffusionCommitDraftEngine' => 'PhabricatorDraftEngine', 5344 5346 'DiffusionCommitEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 5345 5347 'DiffusionCommitEditController' => 'DiffusionController', 5346 5348 'DiffusionCommitEditEngine' => 'PhabricatorEditEngine', ··· 8794 8796 'PhabricatorApplicationTransactionInterface', 8795 8797 'PhabricatorFulltextInterface', 8796 8798 'PhabricatorConduitResultInterface', 8799 + 'PhabricatorDraftInterface', 8797 8800 ), 8798 8801 'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker', 8799 8802 'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
+4 -2
src/applications/audit/query/PhabricatorCommitSearchEngine.php
··· 14 14 public function newQuery() { 15 15 return id(new DiffusionCommitQuery()) 16 16 ->needAuditRequests(true) 17 - ->needCommitData(true); 17 + ->needCommitData(true) 18 + ->needDrafts(true); 18 19 } 19 20 20 21 protected function newResultBuckets() { ··· 140 141 $bucket = $this->getResultBucket($query); 141 142 142 143 $template = id(new PhabricatorAuditListView()) 143 - ->setViewer($viewer); 144 + ->setViewer($viewer) 145 + ->setShowDrafts(true); 144 146 145 147 $views = array(); 146 148 if ($bucket) {
+29 -3
src/applications/audit/view/PhabricatorAuditListView.php
··· 4 4 5 5 private $commits; 6 6 private $header; 7 + private $showDrafts; 7 8 private $noDataString; 8 9 private $highlightedAudits; 9 10 ··· 23 24 24 25 public function getHeader() { 25 26 return $this->header; 27 + } 28 + 29 + public function setShowDrafts($show_drafts) { 30 + $this->showDrafts = $show_drafts; 31 + return $this; 32 + } 33 + 34 + public function getShowDrafts() { 35 + return $this->showDrafts; 26 36 } 27 37 28 38 /** ··· 75 85 76 86 $handles = $viewer->loadHandles(mpull($this->commits, 'getPHID')); 77 87 88 + $show_drafts = $this->getShowDrafts(); 89 + 90 + $draft_icon = id(new PHUIIconView()) 91 + ->setIcon('fa-comment yellow') 92 + ->addSigil('has-tooltip') 93 + ->setMetadata( 94 + array( 95 + 'tip' => pht('Unsubmitted Comments'), 96 + )); 97 + 78 98 $list = new PHUIObjectItemListView(); 79 99 foreach ($this->commits as $commit) { 80 100 $commit_phid = $commit->getPHID(); ··· 88 108 89 109 $audits = mpull($commit->getAudits(), null, 'getAuditorPHID'); 90 110 $auditors = array(); 91 - $reasons = array(); 92 111 foreach ($audits as $audit) { 93 112 $auditor_phid = $audit->getAuditorPHID(); 94 113 $auditors[$auditor_phid] = $viewer->renderHandle($auditor_phid); ··· 114 133 $item = id(new PHUIObjectItemView()) 115 134 ->setObjectName($commit_name) 116 135 ->setHeader($commit_desc) 117 - ->setHref($commit_link) 136 + ->setHref($commit_link); 137 + 138 + if ($show_drafts) { 139 + if ($commit->getHasDraft($viewer)) { 140 + $item->addAttribute($draft_icon); 141 + } 142 + } 143 + 144 + $item 118 145 ->addAttribute(pht('Author: %s', $author_name)) 119 - ->addAttribute($reasons) 120 146 ->addIcon('none', $committed); 121 147 122 148 if (!empty($auditors)) {
+3 -28
src/applications/differential/query/DifferentialRevisionQuery.php
··· 473 473 } 474 474 475 475 if ($this->needDrafts) { 476 - $viewer_phid = $viewer->getPHID(); 477 - $draft_type = PhabricatorObjectHasDraftEdgeType::EDGECONST; 478 - 479 - if (!$viewer_phid) { 480 - // Viewers without a valid PHID can never have drafts. 481 - foreach ($revisions as $revision) { 482 - $revision->attachHasDraft($viewer, false); 483 - } 484 - } else { 485 - $edge_query = id(new PhabricatorEdgeQuery()) 486 - ->withSourcePHIDs(mpull($revisions, 'getPHID')) 487 - ->withEdgeTypes( 488 - array( 489 - $draft_type, 490 - )) 491 - ->withDestinationPHIDs(array($viewer_phid)); 492 - 493 - $edge_query->execute(); 494 - 495 - foreach ($revisions as $revision) { 496 - $has_draft = (bool)$edge_query->getDestinationPHIDs( 497 - array( 498 - $revision->getPHID(), 499 - )); 500 - 501 - $revision->attachHasDraft($viewer, $has_draft); 502 - } 503 - } 476 + PhabricatorDraftEngine::attachDrafts( 477 + $viewer, 478 + $revisions); 504 479 } 505 480 506 481 return $revisions;
+18
src/applications/diffusion/engine/DiffusionCommitDraftEngine.php
··· 1 + <?php 2 + 3 + final class DiffusionCommitDraftEngine 4 + extends PhabricatorDraftEngine { 5 + 6 + protected function hasCustomDraftContent() { 7 + $viewer = $this->getViewer(); 8 + $commit = $this->getObject(); 9 + 10 + $inlines = PhabricatorAuditInlineComment::loadDraftComments( 11 + $viewer, 12 + $commit->getPHID(), 13 + $raw = true); 14 + 15 + return (bool)$inlines; 16 + } 17 + 18 + }
+14
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 22 22 private $importing; 23 23 24 24 private $needCommitData; 25 + private $needDrafts; 25 26 26 27 public function withIDs(array $ids) { 27 28 $this->ids = $ids; ··· 95 96 96 97 public function needCommitData($need) { 97 98 $this->needCommitData = $need; 99 + return $this; 100 + } 101 + 102 + public function needDrafts($need) { 103 + $this->needDrafts = $need; 98 104 return $this; 99 105 } 100 106 ··· 239 245 } 240 246 241 247 protected function didFilterPage(array $commits) { 248 + $viewer = $this->getViewer(); 249 + 242 250 if ($this->needCommitData) { 243 251 $data = id(new PhabricatorRepositoryCommitData())->loadAllWhere( 244 252 'commitID in (%Ld)', ··· 266 274 $audit_request->attachCommit($commit); 267 275 } 268 276 } 277 + } 278 + 279 + if ($this->needDrafts) { 280 + PhabricatorDraftEngine::attachDrafts( 281 + $viewer, 282 + $commits); 269 283 } 270 284 271 285 return $commits;
+20 -1
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 14 14 PhabricatorCustomFieldInterface, 15 15 PhabricatorApplicationTransactionInterface, 16 16 PhabricatorFulltextInterface, 17 - PhabricatorConduitResultInterface { 17 + PhabricatorConduitResultInterface, 18 + PhabricatorDraftInterface { 18 19 19 20 protected $repositoryID; 20 21 protected $phid; ··· 39 40 private $audits = self::ATTACHABLE; 40 41 private $repository = self::ATTACHABLE; 41 42 private $customFields = self::ATTACHABLE; 43 + private $drafts = array(); 42 44 43 45 public function attachRepository(PhabricatorRepository $repository) { 44 46 $this->repository = $repository; ··· 342 344 return nonempty($parsed->getDisplayName(), $parsed->getAddress()); 343 345 } 344 346 347 + 345 348 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 346 349 347 350 public function getCapabilities() { ··· 601 604 602 605 public function getConduitSearchAttachments() { 603 606 return array(); 607 + } 608 + 609 + 610 + /* -( PhabricatorDraftInterface )------------------------------------------ */ 611 + 612 + public function newDraftEngine() { 613 + return new DiffusionCommitDraftEngine(); 614 + } 615 + 616 + public function getHasDraft(PhabricatorUser $viewer) { 617 + return $this->assertAttachedKey($this->drafts, $viewer->getCacheFragment()); 618 + } 619 + 620 + public function attachHasDraft(PhabricatorUser $viewer, $has_draft) { 621 + $this->drafts[$viewer->getCacheFragment()] = $has_draft; 622 + return $this; 604 623 } 605 624 606 625 }
+37
src/applications/transactions/draft/PhabricatorDraftEngine.php
··· 95 95 $editor->save(); 96 96 } 97 97 98 + final public static function attachDrafts( 99 + PhabricatorUser $viewer, 100 + array $objects) { 101 + assert_instances_of($objects, 'PhabricatorDraftInterface'); 102 + 103 + $viewer_phid = $viewer->getPHID(); 104 + 105 + if (!$viewer_phid) { 106 + // Viewers without a valid PHID can never have drafts. 107 + foreach ($objects as $object) { 108 + $object->attachHasDraft($viewer, false); 109 + } 110 + return; 111 + } else { 112 + $draft_type = PhabricatorObjectHasDraftEdgeType::EDGECONST; 113 + 114 + $edge_query = id(new PhabricatorEdgeQuery()) 115 + ->withSourcePHIDs(mpull($objects, 'getPHID')) 116 + ->withEdgeTypes( 117 + array( 118 + $draft_type, 119 + )) 120 + ->withDestinationPHIDs(array($viewer_phid)); 121 + 122 + $edge_query->execute(); 123 + 124 + foreach ($objects as $object) { 125 + $has_draft = (bool)$edge_query->getDestinationPHIDs( 126 + array( 127 + $object->getPHID(), 128 + )); 129 + 130 + $object->attachHasDraft($viewer, $has_draft); 131 + } 132 + } 133 + } 134 + 98 135 }
+21
src/applications/transactions/draft/PhabricatorDraftInterface.php
··· 4 4 5 5 public function newDraftEngine(); 6 6 7 + public function getHasDraft(PhabricatorUser $viewer); 8 + public function attachHasDraft(PhabricatorUser $viewer, $has_draft); 9 + 7 10 } 11 + 12 + /* -( PhabricatorDraftInterface )------------------------------------------ */ 13 + /* 14 + 15 + public function newDraftEngine() { 16 + return new <...>DraftEngine(); 17 + } 18 + 19 + public function getHasDraft(PhabricatorUser $viewer) { 20 + return $this->assertAttachedKey($this->drafts, $viewer->getCacheFragment()); 21 + } 22 + 23 + public function attachHasDraft(PhabricatorUser $viewer, $has_draft) { 24 + $this->drafts[$viewer->getCacheFragment()] = $has_draft; 25 + return $this; 26 + } 27 + 28 + */