@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

Show an additional "Draft" tag on non-broadcasting revisions in a non-draft state

Summary:
Depends on D19284. Ref T13110. It's now possible to get a revision into a "Abandoned + But, Never Promoted From Draft" state. Show this in the header and provide the draft hint above the comment area.

Also, remove `shouldBroadcast()`. The method `getShouldBroadcast()` now has the same meaning.

Finally, migrate existing drafts to `shouldBroadcast = false` and default `shouldBroadcast` to `true`. If we don't do this, every older revision becomes a non-broadcasting revision because this flag was not explicitly set on revision creation before, only on promotion out of draft.

Test Plan: Ran migration; abandoned draft revisions and ended up in a draft + abandoned state.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13110

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

+46 -15
+20
resources/sql/autopatches/20180403.draft.01.broadcast.php
··· 1 + <?php 2 + 3 + $table = new DifferentialRevision(); 4 + $conn = $table->establishConnection('w'); 5 + 6 + $drafts = $table->loadAllWhere( 7 + 'status = %s', 8 + DifferentialRevisionStatus::DRAFT); 9 + foreach ($drafts as $draft) { 10 + $properties = $draft->getProperties(); 11 + 12 + $properties[DifferentialRevision::PROPERTY_SHOULD_BROADCAST] = false; 13 + 14 + queryfx( 15 + $conn, 16 + 'UPDATE %T SET properties = %s WHERE id = %d', 17 + id(new DifferentialRevision())->getTableName(), 18 + phutil_json_encode($properties), 19 + $draft->getID()); 20 + }
+17 -1
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 525 525 $status_tag = id(new PHUITagView()) 526 526 ->setName($revision->getStatusDisplayName()) 527 527 ->setIcon($revision->getStatusIcon()) 528 - ->setColor($revision->getStatusIconColor()) 528 + ->setColor($revision->getStatusTagColor()) 529 529 ->setType(PHUITagView::TYPE_SHADE); 530 530 531 531 $view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_tag); 532 + 533 + // If the revision is in a status other than "Draft", but not broadcasting, 534 + // add an additional "Draft" tag to the header to make it clear that this 535 + // revision hasn't promoted yet. 536 + if (!$revision->getShouldBroadcast() && !$revision->isDraft()) { 537 + $draft_status = DifferentialRevisionStatus::newForStatus( 538 + DifferentialRevisionStatus::DRAFT); 539 + 540 + $draft_tag = id(new PHUITagView()) 541 + ->setName($draft_status->getDisplayName()) 542 + ->setIcon($draft_status->getIcon()) 543 + ->setColor($draft_status->getTagColor()) 544 + ->setType(PHUITagView::TYPE_SHADE); 545 + 546 + $view->addTag($draft_tag); 547 + } 532 548 533 549 return $view; 534 550 }
+1 -1
src/applications/differential/customfield/DifferentialDraftField.php
··· 101 101 public function getWarningsForDetailView() { 102 102 $revision = $this->getObject(); 103 103 104 - if (!$revision->isDraft()) { 104 + if ($revision->getShouldBroadcast()) { 105 105 return array(); 106 106 } 107 107
+3 -3
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 487 487 PhabricatorLiskDAO $object, 488 488 array $xactions) { 489 489 490 - if (!$object->shouldBroadcast()) { 490 + if (!$object->getShouldBroadcast()) { 491 491 return false; 492 492 } 493 493 ··· 498 498 PhabricatorLiskDAO $object, 499 499 array $xactions) { 500 500 501 - if (!$object->shouldBroadcast()) { 501 + if (!$object->getShouldBroadcast()) { 502 502 return false; 503 503 } 504 504 ··· 1152 1152 1153 1153 // If the object is still a draft, prevent "Send me an email" and other 1154 1154 // similar rules from acting yet. 1155 - if (!$object->shouldBroadcast()) { 1155 + if (!$object->getShouldBroadcast()) { 1156 1156 $adapter->setForbiddenAction( 1157 1157 HeraldMailableState::STATECONST, 1158 1158 DifferentialHeraldStateReasons::REASON_DRAFT);
+5 -10
src/applications/differential/storage/DifferentialRevision.php
··· 679 679 return $this->getStatusObject()->getIconColor(); 680 680 } 681 681 682 + public function getStatusTagColor() { 683 + return $this->getStatusObject()->getTagColor(); 684 + } 685 + 682 686 public function getStatusObject() { 683 687 $status = $this->getStatus(); 684 688 return DifferentialRevisionStatus::newForStatus($status); ··· 704 708 return $this; 705 709 } 706 710 707 - public function shouldBroadcast() { 708 - if (!$this->isDraft()) { 709 - return true; 710 - } 711 - 712 - return false; 713 - } 714 - 715 711 public function getHoldAsDraft() { 716 712 return $this->getProperty(self::PROPERTY_DRAFT_HOLD, false); 717 713 } ··· 721 717 } 722 718 723 719 public function getShouldBroadcast() { 724 - return $this->getProperty(self::PROPERTY_SHOULD_BROADCAST, false); 720 + return $this->getProperty(self::PROPERTY_SHOULD_BROADCAST, true); 725 721 } 726 722 727 723 public function setShouldBroadcast($should_broadcast) { ··· 745 741 public function getRemovedLineCount() { 746 742 return $this->getProperty(self::PROPERTY_LINES_REMOVED); 747 743 } 748 - 749 744 750 745 public function getBuildableStatus($phid) { 751 746 $buildables = $this->getProperty(self::PROPERTY_BUILDABLES);