diff --git a/resources/sql/autopatches/20180403.draft.01.broadcast.php b/resources/sql/autopatches/20180403.draft.01.broadcast.php new file mode 100644 index 0000000000..b237894c90 --- /dev/null +++ b/resources/sql/autopatches/20180403.draft.01.broadcast.php @@ -0,0 +1,20 @@ +establishConnection('w'); + +$drafts = $table->loadAllWhere( + 'status = %s', + DifferentialRevisionStatus::DRAFT); +foreach ($drafts as $draft) { + $properties = $draft->getProperties(); + + $properties[DifferentialRevision::PROPERTY_SHOULD_BROADCAST] = false; + + queryfx( + $conn, + 'UPDATE %T SET properties = %s WHERE id = %d', + id(new DifferentialRevision())->getTableName(), + phutil_json_encode($properties), + $draft->getID()); +} diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index d7280cb0b6..b03c4e8c4f 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -525,11 +525,27 @@ final class DifferentialRevisionViewController extends DifferentialController { $status_tag = id(new PHUITagView()) ->setName($revision->getStatusDisplayName()) ->setIcon($revision->getStatusIcon()) - ->setColor($revision->getStatusIconColor()) + ->setColor($revision->getStatusTagColor()) ->setType(PHUITagView::TYPE_SHADE); $view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_tag); + // If the revision is in a status other than "Draft", but not broadcasting, + // add an additional "Draft" tag to the header to make it clear that this + // revision hasn't promoted yet. + if (!$revision->getShouldBroadcast() && !$revision->isDraft()) { + $draft_status = DifferentialRevisionStatus::newForStatus( + DifferentialRevisionStatus::DRAFT); + + $draft_tag = id(new PHUITagView()) + ->setName($draft_status->getDisplayName()) + ->setIcon($draft_status->getIcon()) + ->setColor($draft_status->getTagColor()) + ->setType(PHUITagView::TYPE_SHADE); + + $view->addTag($draft_tag); + } + return $view; } diff --git a/src/applications/differential/customfield/DifferentialDraftField.php b/src/applications/differential/customfield/DifferentialDraftField.php index 70f7291148..f89007590f 100644 --- a/src/applications/differential/customfield/DifferentialDraftField.php +++ b/src/applications/differential/customfield/DifferentialDraftField.php @@ -101,7 +101,7 @@ final class DifferentialDraftField public function getWarningsForDetailView() { $revision = $this->getObject(); - if (!$revision->isDraft()) { + if ($revision->getShouldBroadcast()) { return array(); } diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index 3bdbc11c7b..81ba158d20 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -487,7 +487,7 @@ final class DifferentialTransactionEditor PhabricatorLiskDAO $object, array $xactions) { - if (!$object->shouldBroadcast()) { + if (!$object->getShouldBroadcast()) { return false; } @@ -498,7 +498,7 @@ final class DifferentialTransactionEditor PhabricatorLiskDAO $object, array $xactions) { - if (!$object->shouldBroadcast()) { + if (!$object->getShouldBroadcast()) { return false; } @@ -1152,7 +1152,7 @@ final class DifferentialTransactionEditor // If the object is still a draft, prevent "Send me an email" and other // similar rules from acting yet. - if (!$object->shouldBroadcast()) { + if (!$object->getShouldBroadcast()) { $adapter->setForbiddenAction( HeraldMailableState::STATECONST, DifferentialHeraldStateReasons::REASON_DRAFT); diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php index 434b3222fa..7b67dc27ef 100644 --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -679,6 +679,10 @@ final class DifferentialRevision extends DifferentialDAO return $this->getStatusObject()->getIconColor(); } + public function getStatusTagColor() { + return $this->getStatusObject()->getTagColor(); + } + public function getStatusObject() { $status = $this->getStatus(); return DifferentialRevisionStatus::newForStatus($status); @@ -704,14 +708,6 @@ final class DifferentialRevision extends DifferentialDAO return $this; } - public function shouldBroadcast() { - if (!$this->isDraft()) { - return true; - } - - return false; - } - public function getHoldAsDraft() { return $this->getProperty(self::PROPERTY_DRAFT_HOLD, false); } @@ -721,7 +717,7 @@ final class DifferentialRevision extends DifferentialDAO } public function getShouldBroadcast() { - return $this->getProperty(self::PROPERTY_SHOULD_BROADCAST, false); + return $this->getProperty(self::PROPERTY_SHOULD_BROADCAST, true); } public function setShouldBroadcast($should_broadcast) { @@ -746,7 +742,6 @@ final class DifferentialRevision extends DifferentialDAO return $this->getProperty(self::PROPERTY_LINES_REMOVED); } - public function getBuildableStatus($phid) { $buildables = $this->getProperty(self::PROPERTY_BUILDABLES); if (!is_array($buildables)) {