Allow Differential custom fields to appear on edit and view interfaces

Summary: Depends on D798. Extends custom fields and makes the vaguely useful:
they can appear on the edit and view interfaces. This does not integrate them
with commit messages yet; that's more complicated but I plan to do it shortly.
Test Plan: Implemented a custom field per P123, it correctly appears on the edit
interface, persists, validates, and shows up when viewing the revision.
Reviewed By: jungejason
Reviewers: jungejason, tuomaspelkonen, aran
CC: aran, epriestley, jungejason
Differential Revision: 800
This commit is contained in:
epriestley
2011-08-10 13:46:01 -07:00
parent dd74903cae
commit 9b3370368d
16 changed files with 337 additions and 17 deletions

View File

@@ -43,6 +43,8 @@ class DifferentialRevisionViewController extends DifferentialController {
"This revision has no diffs. Something has gone quite wrong.");
}
$aux_fields = $this->loadAuxiliaryFields($revision);
$diff_vs = $request->getInt('vs');
$target = end($diffs);
@@ -153,6 +155,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$revision_detail = new DifferentialRevisionDetailView();
$revision_detail->setRevision($revision);
$revision_detail->setAuxiliaryFields($aux_fields);
$custom_renderer_class = PhabricatorEnv::getEnvConfig(
'differential.revision-custom-detail-renderer');
@@ -715,4 +718,19 @@ class DifferentialRevisionViewController extends DifferentialController {
->setViewTime(time())
->replace();
}
private function loadAuxiliaryFields(DifferentialRevision $revision) {
$aux_fields = DifferentialFieldSelector::newSelector()
->getFieldSpecifications();
foreach ($aux_fields as $key => $aux_field) {
if (!$aux_field->shouldAppearOnRevisionView()) {
unset($aux_fields[$key]);
}
}
return DifferentialAuxiliaryField::loadFromStorage(
$revision,
$aux_fields);
}
}