mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-02 02:40:58 +01:00
Use radio buttons with explanatory text to select commit rule types
Summary: Ref T4264. Instead of a dropdown, make this step more informative. Test Plan: {F93928} Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4264 Differential Revision: https://secure.phabricator.com/D7846
This commit is contained in:
parent
79f57cf517
commit
f38a565aa5
8 changed files with 96 additions and 8 deletions
|
@ -31,6 +31,16 @@ final class HeraldPreCommitContentAdapter extends HeraldAdapter {
|
||||||
return pht('Commit Hook: Commit Content');
|
return pht('Commit Hook: Commit Content');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterSortOrder() {
|
||||||
|
return 2500;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
"React to commits being pushed to hosted repositories.\n".
|
||||||
|
"Hook rules can block changes.");
|
||||||
|
}
|
||||||
|
|
||||||
public function getFieldNameMap() {
|
public function getFieldNameMap() {
|
||||||
return array(
|
return array(
|
||||||
) + parent::getFieldNameMap();
|
) + parent::getFieldNameMap();
|
||||||
|
|
|
@ -34,6 +34,16 @@ final class HeraldPreCommitRefAdapter extends HeraldAdapter {
|
||||||
return pht('Commit Hook: Branches/Tags/Bookmarks');
|
return pht('Commit Hook: Branches/Tags/Bookmarks');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterSortOrder() {
|
||||||
|
return 2000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
"React to branches and tags being pushed to hosted repositories.\n".
|
||||||
|
"Hook rules can block changes.");
|
||||||
|
}
|
||||||
|
|
||||||
public function getFieldNameMap() {
|
public function getFieldNameMap() {
|
||||||
return array(
|
return array(
|
||||||
self::FIELD_REF_TYPE => pht('Ref type'),
|
self::FIELD_REF_TYPE => pht('Ref type'),
|
||||||
|
|
|
@ -136,9 +136,21 @@ abstract class HeraldAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function getAdapterContentName();
|
abstract public function getAdapterContentName();
|
||||||
|
abstract public function getAdapterContentDescription();
|
||||||
abstract public function getAdapterApplicationClass();
|
abstract public function getAdapterApplicationClass();
|
||||||
abstract public function getObject();
|
abstract public function getObject();
|
||||||
|
|
||||||
|
public function getAdapterSortKey() {
|
||||||
|
return sprintf(
|
||||||
|
'%08d%s',
|
||||||
|
$this->getAdapterSortOrder(),
|
||||||
|
$this->getAdapterContentName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdapterSortOrder() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Fields )------------------------------------------------------------- */
|
/* -( Fields )------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -814,6 +826,7 @@ abstract class HeraldAdapter {
|
||||||
$adapters = id(new PhutilSymbolLoader())
|
$adapters = id(new PhutilSymbolLoader())
|
||||||
->setAncestorClass(__CLASS__)
|
->setAncestorClass(__CLASS__)
|
||||||
->loadObjects();
|
->loadObjects();
|
||||||
|
$adapters = msort($adapters, 'getAdapterSortKey');
|
||||||
}
|
}
|
||||||
return $adapters;
|
return $adapters;
|
||||||
}
|
}
|
||||||
|
@ -846,7 +859,6 @@ abstract class HeraldAdapter {
|
||||||
$map[$type] = $name;
|
$map[$type] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
asort($map);
|
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,13 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
||||||
return pht('Commits');
|
return pht('Commits');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
"React to new commits appearing in tracked repositories.\n".
|
||||||
|
"Commit rules can send email, flag commits, trigger audits, ".
|
||||||
|
"and run build plans.");
|
||||||
|
}
|
||||||
|
|
||||||
public function getFieldNameMap() {
|
public function getFieldNameMap() {
|
||||||
return array(
|
return array(
|
||||||
self::FIELD_NEED_AUDIT_FOR_PACKAGE =>
|
self::FIELD_NEED_AUDIT_FOR_PACKAGE =>
|
||||||
|
|
|
@ -36,6 +36,13 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
|
||||||
return pht('Differential Revisions');
|
return pht('Differential Revisions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
"React to revisions being created or updated.\n".
|
||||||
|
"Revision rules can send email, flag revisions, add reviewers, ".
|
||||||
|
"and run build plans.");
|
||||||
|
}
|
||||||
|
|
||||||
public function getFields() {
|
public function getFields() {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -14,6 +14,11 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
return 'PhabricatorApplicationManiphest';
|
return 'PhabricatorApplicationManiphest';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
'React to tasks being created or updated.');
|
||||||
|
}
|
||||||
|
|
||||||
public function setTask(ManiphestTask $task) {
|
public function setTask(ManiphestTask $task) {
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -12,6 +12,11 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
|
||||||
return 'PhabricatorApplicationPholio';
|
return 'PhabricatorApplicationPholio';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAdapterContentDescription() {
|
||||||
|
return pht(
|
||||||
|
'React to mocks being created or updated.');
|
||||||
|
}
|
||||||
|
|
||||||
public function getObject() {
|
public function getObject() {
|
||||||
return $this->mock;
|
return $this->mock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,19 +53,21 @@ final class HeraldNewController extends HeraldController {
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setAction($this->getApplicationURI('new/'));
|
->setAction($this->getApplicationURI('new/'));
|
||||||
|
|
||||||
$rule_types = $this->renderRuleTypeControl($rule_type_map, $e_rule);
|
$content_types = $this->renderContentTypeControl(
|
||||||
|
$content_type_map,
|
||||||
|
$e_type);
|
||||||
|
|
||||||
|
$rule_types = $this->renderRuleTypeControl(
|
||||||
|
$rule_type_map,
|
||||||
|
$e_rule);
|
||||||
|
|
||||||
switch ($step) {
|
switch ($step) {
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
$form
|
$form
|
||||||
->addHiddenInput('step', 1)
|
->addHiddenInput('step', 1)
|
||||||
->appendChild(
|
->appendChild($content_types);
|
||||||
id(new AphrontFormSelectControl())
|
|
||||||
->setLabel(pht('New Rule for'))
|
|
||||||
->setName('content_type')
|
|
||||||
->setValue($request->getStr('content_type'))
|
|
||||||
->setOptions($content_type_map));
|
|
||||||
$cancel_text = null;
|
$cancel_text = null;
|
||||||
$cancel_uri = $this->getApplicationURI();
|
$cancel_uri = $this->getApplicationURI();
|
||||||
break;
|
break;
|
||||||
|
@ -73,7 +75,16 @@ final class HeraldNewController extends HeraldController {
|
||||||
$form
|
$form
|
||||||
->addHiddenInput('content_type', $request->getStr('content_type'))
|
->addHiddenInput('content_type', $request->getStr('content_type'))
|
||||||
->addHiddenInput('step', 2)
|
->addHiddenInput('step', 2)
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormStaticControl())
|
||||||
|
->setLabel(pht('Rule for'))
|
||||||
|
->setValue(
|
||||||
|
phutil_tag(
|
||||||
|
'strong',
|
||||||
|
array(),
|
||||||
|
idx($content_type_map, $content_type))))
|
||||||
->appendChild($rule_types);
|
->appendChild($rule_types);
|
||||||
|
|
||||||
$cancel_text = pht('Back');
|
$cancel_text = pht('Back');
|
||||||
$cancel_uri = id(new PhutilURI('new/'))
|
$cancel_uri = id(new PhutilURI('new/'))
|
||||||
->setQueryParams(
|
->setQueryParams(
|
||||||
|
@ -112,6 +123,27 @@ final class HeraldNewController extends HeraldController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderContentTypeControl(array $content_type_map, $e_type) {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
$radio = id(new AphrontFormRadioButtonControl())
|
||||||
|
->setLabel(pht('New Rule for'))
|
||||||
|
->setName('content_type')
|
||||||
|
->setValue($request->getStr('content_type'))
|
||||||
|
->setError($e_type);
|
||||||
|
|
||||||
|
foreach ($content_type_map as $value => $name) {
|
||||||
|
$adapter = HeraldAdapter::getAdapterForContentType($value);
|
||||||
|
$radio->addButton(
|
||||||
|
$value,
|
||||||
|
$name,
|
||||||
|
phutil_escape_html_newlines($adapter->getAdapterContentDescription()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $radio;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function renderRuleTypeControl(array $rule_type_map, $e_rule) {
|
private function renderRuleTypeControl(array $rule_type_map, $e_rule) {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue