mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-11 16:16:14 +01:00
2e36653965
Summary: Ref T2543. These are currently numeric values, like "0" and "3". I want to replace them with strings, like "accepted", and move definitions from Arcanist to Phabricator. To set the stage for this, reduce the number of callsites where Phabricator invokes `ArcanistDifferentialRevisionStatus`. This is just the easy ones. I'll hold this until the release cut. Test Plan: - Called `differential.find`. - Called `differential.getrevision`. - Called `differential.query`. - Removed all reviewers from a revision, saw warning. - Abandoned the no-reviewers revision, no more warning. - Attached a revision to a task to get it to show the state icon with the status on a tooltip. - Viewed revision bucketing on dashboard. - Used `bin/search index` to reindex a revision. - Hit the "Land Revision" endpoint. I didn't explicitly test these cases: - Doorkeeper Asana integration, since setup takes a thousand years. - Disambiguation logic when multiple hashes match, since setup is also very involved. - Releeph because it's Releeph. Reviewers: chad Reviewed By: chad Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18339
94 lines
2.2 KiB
PHP
94 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class DifferentialReviewersField
|
|
extends DifferentialCoreCustomField {
|
|
|
|
public function getFieldKey() {
|
|
return 'differential:reviewers';
|
|
}
|
|
|
|
public function getFieldName() {
|
|
return pht('Reviewers');
|
|
}
|
|
|
|
public function getFieldDescription() {
|
|
return pht('Manage reviewers.');
|
|
}
|
|
|
|
protected function readValueFromRevision(
|
|
DifferentialRevision $revision) {
|
|
return $revision->getReviewers();
|
|
}
|
|
|
|
public function shouldAppearInPropertyView() {
|
|
return true;
|
|
}
|
|
|
|
public function renderPropertyViewLabel() {
|
|
return $this->getFieldName();
|
|
}
|
|
|
|
public function getRequiredHandlePHIDsForPropertyView() {
|
|
return mpull($this->getUserReviewers(), 'getReviewerPHID');
|
|
}
|
|
|
|
public function renderPropertyViewValue(array $handles) {
|
|
$reviewers = $this->getUserReviewers();
|
|
if (!$reviewers) {
|
|
return phutil_tag('em', array(), pht('None'));
|
|
}
|
|
|
|
$view = id(new DifferentialReviewersView())
|
|
->setUser($this->getViewer())
|
|
->setReviewers($reviewers)
|
|
->setHandles($handles);
|
|
|
|
$diff = $this->getActiveDiff();
|
|
if ($diff) {
|
|
$view->setActiveDiff($diff);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
private function getUserReviewers() {
|
|
$reviewers = array();
|
|
foreach ($this->getObject()->getReviewers() as $reviewer) {
|
|
if ($reviewer->isUser()) {
|
|
$reviewers[] = $reviewer;
|
|
}
|
|
}
|
|
return $reviewers;
|
|
}
|
|
|
|
public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
|
|
return mpull($this->getValue(), 'getReviewerPHID');
|
|
}
|
|
|
|
public function getWarningsForRevisionHeader(array $handles) {
|
|
$revision = $this->getObject();
|
|
|
|
if (!$revision->isNeedsReview()) {
|
|
return array();
|
|
}
|
|
|
|
foreach ($this->getValue() as $reviewer) {
|
|
if (!$handles[$reviewer->getReviewerPHID()]->isDisabled()) {
|
|
return array();
|
|
}
|
|
}
|
|
|
|
$warnings = array();
|
|
if ($this->getValue()) {
|
|
$warnings[] = pht(
|
|
'This revision needs review, but all specified reviewers are '.
|
|
'disabled or inactive.');
|
|
} else {
|
|
$warnings[] = pht(
|
|
'This revision needs review, but there are no reviewers specified.');
|
|
}
|
|
|
|
return $warnings;
|
|
}
|
|
|
|
}
|