1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Add a "Draft" state for revisions, and action bucket support

Summary:
Ref T2543. There's no way to put revisions into this state yet, but start adding support for when there is.

Adds the status constant, plus support for bucketing them.

Test Plan:
  - Manually put a revision in "Draft" state by updating the database directly.
  - Verified my drafts showed up in a "Drafts" section on the bucket view.
  - Verified others' drafts did not appear on the action bucket view.
  - Viewed revisions, queried for "Draft" revisions, etc (stuff we get for free).

{F5186781}

{F5186782}

{F5186783}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18625
This commit is contained in:
epriestley 2017-09-18 12:54:14 -07:00
parent 156adccef0
commit 23867c1487
3 changed files with 59 additions and 0 deletions

View file

@ -8,6 +8,7 @@ final class DifferentialRevisionStatus extends Phobject {
const ACCEPTED = 'accepted'; const ACCEPTED = 'accepted';
const PUBLISHED = 'published'; const PUBLISHED = 'published';
const ABANDONED = 'abandoned'; const ABANDONED = 'abandoned';
const DRAFT = 'draft';
private $key; private $key;
private $spec = array(); private $spec = array();
@ -76,6 +77,10 @@ final class DifferentialRevisionStatus extends Phobject {
return ($this->key === self::CHANGES_PLANNED); return ($this->key === self::CHANGES_PLANNED);
} }
public function isDraft() {
return ($this->key === self::DRAFT);
}
public static function newForStatus($status) { public static function newForStatus($status) {
$result = new self(); $result = new self();
@ -163,6 +168,16 @@ final class DifferentialRevisionStatus extends Phobject {
'color.tag' => 'indigo', 'color.tag' => 'indigo',
'color.ansi' => null, 'color.ansi' => null,
), ),
self::DRAFT => array(
'name' => pht('Draft'),
// For legacy clients, treat this as though it is "Needs Review".
'legacy' => 0,
'icon' => 'fa-file-text-o',
'closed' => false,
'color.icon' => 'grey',
'color.tag' => 'grey',
'color.ansi' => null,
),
); );
} }

View file

@ -37,6 +37,9 @@ final class DifferentialRevisionRequiredActionResultBucket
// other project or package reviewers which they have authority over. // other project or package reviewers which they have authority over.
$this->filterResigned($phids); $this->filterResigned($phids);
// We also throw away draft revisions which you aren't the author of.
$this->filterOtherDrafts($phids);
$groups = array(); $groups = array();
$groups[] = $this->newGroup() $groups[] = $this->newGroup()
@ -61,6 +64,11 @@ final class DifferentialRevisionRequiredActionResultBucket
->setNoDataString(pht('No revisions are waiting for updates.')) ->setNoDataString(pht('No revisions are waiting for updates.'))
->setObjects($this->filterShouldUpdate($phids)); ->setObjects($this->filterShouldUpdate($phids));
$groups[] = $this->newGroup()
->setName(pht('Drafts'))
->setNoDataString(pht('You have no draft revisions.'))
->setObjects($this->filterDrafts($phids));
$groups[] = $this->newGroup() $groups[] = $this->newGroup()
->setName(pht('Waiting on Review')) ->setName(pht('Waiting on Review'))
->setNoDataString(pht('None of your revisions are waiting on review.')) ->setNoDataString(pht('None of your revisions are waiting on review.'))
@ -247,4 +255,36 @@ final class DifferentialRevisionRequiredActionResultBucket
return $results; return $results;
} }
private function filterOtherDrafts(array $phids) {
$objects = $this->getRevisionsNotAuthored($this->objects, $phids);
$results = array();
foreach ($objects as $key => $object) {
if (!$object->isDraft()) {
continue;
}
$results[$key] = $object;
unset($this->objects[$key]);
}
return $results;
}
private function filterDrafts(array $phids) {
$objects = $this->getRevisionsAuthored($this->objects, $phids);
$results = array();
foreach ($objects as $key => $object) {
if (!$object->isDraft()) {
continue;
}
$results[$key] = $object;
unset($this->objects[$key]);
}
return $results;
}
} }

View file

@ -653,6 +653,10 @@ final class DifferentialRevision extends DifferentialDAO
return $this->getStatusObject()->isPublished(); return $this->getStatusObject()->isPublished();
} }
public function isDraft() {
return $this->getStatusObject()->isDraft();
}
public function getStatusIcon() { public function getStatusIcon() {
return $this->getStatusObject()->getIcon(); return $this->getStatusObject()->getIcon();
} }