2011-01-24 22:18:41 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DifferentialDiffViewController extends DifferentialController {
|
2011-01-24 22:18:41 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
2011-01-31 03:52:29 +01:00
|
|
|
$request = $this->getRequest();
|
|
|
|
|
2011-01-24 22:18:41 +01:00
|
|
|
$diff = id(new DifferentialDiff())->load($this->id);
|
|
|
|
if (!$diff) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2011-05-03 02:44:47 +02:00
|
|
|
if ($diff->getRevisionID()) {
|
|
|
|
$top_panel = new AphrontPanelView();
|
|
|
|
$top_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
|
2013-01-18 03:43:35 +01:00
|
|
|
$link = phutil_tag(
|
2011-05-03 02:44:47 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => PhabricatorEnv::getURI('/D'.$diff->getRevisionID()),
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
'D'.$diff->getRevisionID());
|
2013-01-24 19:46:47 +01:00
|
|
|
$top_panel->appendChild(
|
|
|
|
"<h1>".pht('This diff belongs to revision %s', $link)."</h1>");
|
2011-05-03 02:44:47 +02:00
|
|
|
} else {
|
|
|
|
$action_panel = new AphrontPanelView();
|
|
|
|
$action_panel->setHeader('Preview Diff');
|
|
|
|
$action_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
|
|
|
|
$action_panel->appendChild(
|
2013-01-24 19:46:47 +01:00
|
|
|
'<p class="aphront-panel-instructions">'.pht('Review the diff for '.
|
2011-05-03 02:44:47 +02:00
|
|
|
'correctness. When you are satisfied, either <strong>create a new '.
|
2013-01-24 19:46:47 +01:00
|
|
|
'revision</strong> or <strong>update an existing revision</strong>.'));
|
2011-05-03 02:44:47 +02:00
|
|
|
|
|
|
|
// TODO: implmenent optgroup support in AphrontFormSelectControl?
|
|
|
|
$select = array();
|
|
|
|
$select[] = '<optgroup label="Create New Revision">';
|
2013-01-24 19:46:47 +01:00
|
|
|
$select[] = '<option value="">'.
|
|
|
|
pht('Create a new Revision...').
|
|
|
|
'</option>';
|
2011-02-04 00:41:58 +01:00
|
|
|
$select[] = '</optgroup>';
|
|
|
|
|
2011-05-03 02:44:47 +02:00
|
|
|
$revision_data = new DifferentialRevisionListData(
|
|
|
|
DifferentialRevisionListData::QUERY_OPEN_OWNED,
|
|
|
|
array($request->getUser()->getPHID()));
|
|
|
|
$revisions = $revision_data->loadRevisions();
|
|
|
|
|
|
|
|
if ($revisions) {
|
2013-01-24 19:46:47 +01:00
|
|
|
$select[] = '<optgroup label="'.pht('Update Existing Revision').'">';
|
2011-05-03 02:44:47 +02:00
|
|
|
foreach ($revisions as $revision) {
|
2013-01-18 03:43:35 +01:00
|
|
|
$select[] = phutil_tag(
|
2011-05-03 02:44:47 +02:00
|
|
|
'option',
|
|
|
|
array(
|
|
|
|
'value' => $revision->getID(),
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$revision->getTitle());
|
2011-05-03 02:44:47 +02:00
|
|
|
}
|
|
|
|
$select[] = '</optgroup>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$select =
|
|
|
|
'<select name="revisionID">'.
|
2011-02-04 00:41:58 +01:00
|
|
|
implode("\n", $select).
|
2011-05-03 02:44:47 +02:00
|
|
|
'</select>';
|
|
|
|
|
|
|
|
$action_form = new AphrontFormView();
|
|
|
|
$action_form
|
|
|
|
->setUser($request->getUser())
|
|
|
|
->setAction('/differential/revision/edit/')
|
|
|
|
->addHiddenInput('diffID', $diff->getID())
|
|
|
|
->addHiddenInput('viaDiffView', 1)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setLabel(pht('Attach To'))
|
2011-02-04 00:41:58 +01:00
|
|
|
->setValue($select))
|
2011-05-03 02:44:47 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-01-24 19:46:47 +01:00
|
|
|
->setValue(pht('Continue')));
|
2011-01-26 00:19:06 +01:00
|
|
|
|
2011-05-03 02:44:47 +02:00
|
|
|
$action_panel->appendChild($action_form);
|
|
|
|
|
|
|
|
$top_panel = $action_panel;
|
|
|
|
}
|
2011-01-26 00:19:06 +01:00
|
|
|
|
2012-11-16 20:48:17 +01:00
|
|
|
$props = id(new DifferentialDiffProperty())->loadAllWhere(
|
|
|
|
'diffID = %d',
|
|
|
|
$diff->getID());
|
|
|
|
$props = mpull($props, 'getData', 'getName');
|
|
|
|
|
|
|
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
|
|
|
->getFieldSpecifications();
|
|
|
|
foreach ($aux_fields as $key => $aux_field) {
|
|
|
|
if (!$aux_field->shouldAppearOnDiffView()) {
|
|
|
|
unset($aux_fields[$key]);
|
|
|
|
} else {
|
|
|
|
$aux_field->setUser($this->getRequest()->getUser());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$dict = array();
|
|
|
|
foreach ($aux_fields as $key => $aux_field) {
|
|
|
|
$aux_field->setDiff($diff);
|
|
|
|
$aux_field->setManualDiff($diff);
|
|
|
|
$aux_field->setDiffProperties($props);
|
|
|
|
$value = $aux_field->renderValueForDiffView();
|
|
|
|
if (strlen($value)) {
|
|
|
|
$label = rtrim($aux_field->renderLabelForDiffView(), ':');
|
|
|
|
$dict[$label] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 20:30:38 +01:00
|
|
|
$property_view = new PhabricatorPropertyListView();
|
|
|
|
foreach ($dict as $key => $value) {
|
|
|
|
$property_view->addProperty($key, $value);
|
|
|
|
}
|
2012-11-16 20:48:17 +01:00
|
|
|
|
2011-01-24 22:18:41 +01:00
|
|
|
$changesets = $diff->loadChangesets();
|
|
|
|
$changesets = msort($changesets, 'getSortKey');
|
|
|
|
|
|
|
|
$table_of_contents = id(new DifferentialDiffTableOfContentsView())
|
2012-03-15 18:45:35 +01:00
|
|
|
->setChangesets($changesets)
|
2012-11-07 00:33:56 +01:00
|
|
|
->setVisibleChangesets($changesets)
|
2012-11-19 23:52:01 +01:00
|
|
|
->setUnitTestData(idx($props, 'arc:unit', array()));
|
2011-01-24 22:18:41 +01:00
|
|
|
|
2011-05-13 21:27:12 +02:00
|
|
|
$refs = array();
|
|
|
|
foreach ($changesets as $changeset) {
|
|
|
|
$refs[$changeset->getID()] = $changeset->getID();
|
|
|
|
}
|
|
|
|
|
2011-01-25 20:57:47 +01:00
|
|
|
$details = id(new DifferentialChangesetListView())
|
2011-05-13 21:27:12 +02:00
|
|
|
->setChangesets($changesets)
|
2012-05-01 21:09:50 +02:00
|
|
|
->setVisibleChangesets($changesets)
|
2012-01-16 20:08:54 +01:00
|
|
|
->setRenderingReferences($refs)
|
2012-04-13 07:08:44 +02:00
|
|
|
->setStandaloneURI('/differential/changeset/')
|
2012-12-13 06:21:56 +01:00
|
|
|
->setDiff($diff)
|
2013-01-24 19:46:47 +01:00
|
|
|
->setTitle(pht('Diff %d', $diff->getID()))
|
2012-01-16 20:08:54 +01:00
|
|
|
->setUser($request->getUser());
|
2011-01-24 22:18:41 +01:00
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
2011-06-08 21:39:03 +02:00
|
|
|
id(new DifferentialPrimaryPaneView())
|
|
|
|
->appendChild(
|
2011-01-26 00:19:06 +01:00
|
|
|
array(
|
2011-05-03 02:44:47 +02:00
|
|
|
$top_panel->render(),
|
2013-01-30 20:30:38 +01:00
|
|
|
$property_view,
|
2011-01-26 00:19:06 +01:00
|
|
|
$table_of_contents->render(),
|
|
|
|
$details->render(),
|
2011-06-08 21:39:03 +02:00
|
|
|
)),
|
2011-01-24 22:18:41 +01:00
|
|
|
array(
|
2013-01-24 19:46:47 +01:00
|
|
|
'title' => pht('Diff View'),
|
2011-01-24 22:18:41 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|