1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-17 20:32:41 +01:00

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
This commit is contained in:
epriestley 2018-04-03 08:39:13 -07:00
parent 38e788c99a
commit 615d27c8e9
5 changed files with 46 additions and 15 deletions

View file

@ -0,0 +1,20 @@
<?php
$table = new DifferentialRevision();
$conn = $table->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());
}

View file

@ -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;
}

View file

@ -101,7 +101,7 @@ final class DifferentialDraftField
public function getWarningsForDetailView() {
$revision = $this->getObject();
if (!$revision->isDraft()) {
if ($revision->getShouldBroadcast()) {
return array();
}

View file

@ -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);

View file

@ -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)) {