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

Move "Next Step" to a custom field in Differential

Summary:
Fixes T9672. This was never turned into a custom field, for no particular reason. Convert it into one.

This is substantially similar to the existing "Apply Patch" field, which does the same thing (only shows a command).

We might rethink or remove this eventually (e.g., in a post-"Land Revision" world) but this makes it easier, at the very least.

Test Plan:
  - Viewed a non-accepted revision (no hint).
  - Viewed an accepted revision from a raw diff source (no hint).
  - Viewed an accepted revision from Git (`arc land` hint).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9672

Differential Revision: https://secure.phabricator.com/D14367
This commit is contained in:
epriestley 2015-10-30 16:00:53 +00:00 committed by epriestley
parent 1b8337871b
commit 2c3dbc48ee
4 changed files with 69 additions and 30 deletions

View file

@ -416,6 +416,7 @@ phutil_register_library_map(array(
'DifferentialLocalCommitsView' => 'applications/differential/view/DifferentialLocalCommitsView.php',
'DifferentialManiphestTasksField' => 'applications/differential/customfield/DifferentialManiphestTasksField.php',
'DifferentialModernHunk' => 'applications/differential/storage/DifferentialModernHunk.php',
'DifferentialNextStepField' => 'applications/differential/customfield/DifferentialNextStepField.php',
'DifferentialParseCacheGarbageCollector' => 'applications/differential/garbagecollector/DifferentialParseCacheGarbageCollector.php',
'DifferentialParseCommitMessageConduitAPIMethod' => 'applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php',
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
@ -4160,6 +4161,7 @@ phutil_register_library_map(array(
'DifferentialLocalCommitsView' => 'AphrontView',
'DifferentialManiphestTasksField' => 'DifferentialCoreCustomField',
'DifferentialModernHunk' => 'DifferentialHunk',
'DifferentialNextStepField' => 'DifferentialCustomField',
'DifferentialParseCacheGarbageCollector' => 'PhabricatorGarbageCollector',
'DifferentialParseCommitMessageConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',

View file

@ -25,6 +25,8 @@ final class PhabricatorDifferentialConfigOptions
$custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType';
$fields = array(
new DifferentialNextStepField(),
new DifferentialTitleField(),
new DifferentialSummaryField(),
new DifferentialTestPlanField(),

View file

@ -0,0 +1,65 @@
<?php
final class DifferentialNextStepField
extends DifferentialCustomField {
public function getFieldKey() {
return 'differential:next-step';
}
public function getFieldName() {
return pht('Next Step');
}
public function getFieldDescription() {
return pht('Provides a hint for the next step to take.');
}
public function shouldAppearInPropertyView() {
return true;
}
public function renderPropertyViewLabel() {
return $this->getFieldName();
}
public function renderPropertyViewValue(array $handles) {
$revision = $this->getObject();
$diff = $revision->getActiveDiff();
$status = $revision->getStatus();
if ($status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
return null;
}
$local_vcs = $diff->getSourceControlSystem();
switch ($local_vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$bookmark = $diff->getBookmark();
if (strlen($bookmark)) {
$next_step = csprintf('arc land %R', $bookmark);
} else {
$next_step = csprintf('arc land');
}
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$branch = $diff->getBranch();
if (strlen($branch)) {
$next_step = csprintf('arc land %R', $branch);
} else {
$next_step = csprintf('arc land');
}
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$next_step = csprintf('arc commit');
break;
default:
return null;
}
$next_step = phutil_tag('tt', array(), (string)$next_step);
return $next_step;
}
}

View file

@ -73,36 +73,6 @@ final class DifferentialRevisionDetailView extends AphrontView {
->setUser($user)
->setObject($revision);
$status = $revision->getStatus();
$local_vcs = $this->getDiff()->getSourceControlSystem();
$next_step = null;
if ($status == ArcanistDifferentialRevisionStatus::ACCEPTED) {
switch ($local_vcs) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$bookmark = $this->getDiff()->getBookmark();
$next_step = ($bookmark != ''
? csprintf('arc land %s', $bookmark)
: 'arc land');
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$branch = $this->getDiff()->getBranch();
$next_step = ($branch != ''
? csprintf('arc land %s', $branch)
: 'arc land');
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$next_step = 'arc commit';
break;
}
}
if ($next_step) {
$next_step = phutil_tag('tt', array(), $next_step);
$properties->addProperty(pht('Next Step'), $next_step);
}
$properties->setHasKeyboardShortcuts(true);
$properties->setActionList($actions);
$this->setActionList($actions);