Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17632432
D9793.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D9793.diff
View Options
diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -115,6 +115,22 @@
}
}
+ $field_list = PhabricatorCustomField::getObjectFields(
+ $revision,
+ PhabricatorCustomField::ROLE_VIEW);
+
+ $field_list->setViewer($user);
+ $field_list->readFieldsFromStorage($revision);
+
+ $warning_handle_map = array();
+ foreach ($field_list->getFields() as $key => $field) {
+ $req = $field->getRequiredHandlePHIDsForRevisionHeaderWarnings();
+ foreach ($req as $phid) {
+ $warning_handle_map[$key][] = $phid;
+ $object_phids[] = $phid;
+ }
+ }
+
$handles = $this->loadViewerHandles($object_phids);
$request_uri = $request->getRequestURI();
@@ -169,13 +185,6 @@
$visible_changesets = $changesets;
}
- $field_list = PhabricatorCustomField::getObjectFields(
- $revision,
- PhabricatorCustomField::ROLE_VIEW);
-
- $field_list->setViewer($user);
- $field_list->readFieldsFromStorage($revision);
-
// TODO: This should be in a DiffQuery or similar.
$need_props = array();
@@ -245,8 +254,15 @@
$revision_detail_box = $revision_detail->render();
- $revision_warnings = $this->buildRevisionWarnings($revision, $handles);
+ $revision_warnings = $this->buildRevisionWarnings(
+ $revision,
+ $field_list,
+ $warning_handle_map,
+ $handles);
if ($revision_warnings) {
+ $revision_warnings = id(new AphrontErrorView())
+ ->setSeverity(AphrontErrorView::SEVERITY_WARNING)
+ ->setErrors($revision_warnings);
$revision_detail_box->setErrorView($revision_warnings);
}
@@ -935,32 +951,21 @@
private function buildRevisionWarnings(
DifferentialRevision $revision,
+ PhabricatorCustomFieldList $field_list,
+ array $warning_handle_map,
array $handles) {
- $status_needs_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
- if ($revision->getStatus() != $status_needs_review) {
- return;
- }
-
- foreach ($revision->getReviewers() as $reviewer) {
- if (!$handles[$reviewer]->isDisabled()) {
- return;
- }
- }
-
$warnings = array();
- if ($revision->getReviewers()) {
- $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.');
+ foreach ($field_list->getFields() as $key => $field) {
+ $phids = idx($warning_handle_map, $key, array());
+ $field_handles = array_select_keys($handles, $phids);
+ $field_warnings = $field->getWarningsForRevisionHeader($field_handles);
+ foreach ($field_warnings as $warning) {
+ $warnings[] = $warning;
+ }
}
- return id(new AphrontErrorView())
- ->setSeverity(AphrontErrorView::SEVERITY_WARNING)
- ->setErrors($warnings);
+ return $warnings;
}
}
diff --git a/src/applications/differential/customfield/DifferentialCustomField.php b/src/applications/differential/customfield/DifferentialCustomField.php
--- a/src/applications/differential/customfield/DifferentialCustomField.php
+++ b/src/applications/differential/customfield/DifferentialCustomField.php
@@ -74,6 +74,14 @@
return array();
}
+ public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
+ return array();
+ }
+
+ public function getWarningsForRevisionHeader(array $handles) {
+ return array();
+ }
+
/* -( Integration with Commit Messages )----------------------------------- */
diff --git a/src/applications/differential/customfield/DifferentialReviewersField.php b/src/applications/differential/customfield/DifferentialReviewersField.php
--- a/src/applications/differential/customfield/DifferentialReviewersField.php
+++ b/src/applications/differential/customfield/DifferentialReviewersField.php
@@ -191,5 +191,35 @@
}
}
+ public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
+ return mpull($this->getValue(), 'getReviewerPHID');
+ }
+
+ public function getWarningsForRevisionHeader(array $handles) {
+ $revision = $this->getObject();
+
+ $status_needs_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
+ if ($revision->getStatus() != $status_needs_review) {
+ 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;
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 11 2025, 3:17 PM (6 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8321053
Default Alt Text
D9793.diff (5 KB)
Attached To
Mode
D9793: Move revision header warnings into custom fields
Attached
Detach File
Event Timeline
Log In to Comment