mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Port Repository "Branches" to new UI
Summary: Ref T10748. Makes a "Branches" panel, enables these transactions in the EditEngine. Test Plan: - Edited via EditEngine + Conduit. - Viewed via manage UI. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15809
This commit is contained in:
parent
8f81930b5d
commit
4c66a92f92
4 changed files with 126 additions and 1 deletions
|
@ -745,6 +745,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
|
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
|
||||||
'DiffusionRepositoryAutomationManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php',
|
'DiffusionRepositoryAutomationManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php',
|
||||||
'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php',
|
'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php',
|
||||||
|
'DiffusionRepositoryBranchesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php',
|
||||||
'DiffusionRepositoryByIDRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryByIDRemarkupRule.php',
|
'DiffusionRepositoryByIDRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryByIDRemarkupRule.php',
|
||||||
'DiffusionRepositoryClusterEngine' => 'applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php',
|
'DiffusionRepositoryClusterEngine' => 'applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php',
|
||||||
'DiffusionRepositoryClusterEngineLogInterface' => 'applications/diffusion/protocol/DiffusionRepositoryClusterEngineLogInterface.php',
|
'DiffusionRepositoryClusterEngineLogInterface' => 'applications/diffusion/protocol/DiffusionRepositoryClusterEngineLogInterface.php',
|
||||||
|
@ -4964,6 +4965,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRenameHistoryQuery' => 'Phobject',
|
'DiffusionRenameHistoryQuery' => 'Phobject',
|
||||||
'DiffusionRepositoryAutomationManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryAutomationManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
|
'DiffusionRepositoryBranchesManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||||
'DiffusionRepositoryByIDRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
'DiffusionRepositoryByIDRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||||
'DiffusionRepositoryClusterEngine' => 'Phobject',
|
'DiffusionRepositoryClusterEngine' => 'Phobject',
|
||||||
'DiffusionRepositoryController' => 'DiffusionController',
|
'DiffusionRepositoryController' => 'DiffusionController',
|
||||||
|
|
|
@ -75,6 +75,12 @@ final class DiffusionRepositoryEditEngine
|
||||||
->setObject($object)
|
->setObject($object)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
$track_value = $object->getDetail('branch-filter', array());
|
||||||
|
$track_value = array_keys($track_value);
|
||||||
|
|
||||||
|
$autoclose_value = $object->getDetail('close-commits-filter', array());
|
||||||
|
$autoclose_value = array_keys($autoclose_value);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
id(new PhabricatorSelectEditField())
|
id(new PhabricatorSelectEditField())
|
||||||
->setKey('vcs')
|
->setKey('vcs')
|
||||||
|
@ -162,6 +168,28 @@ final class DiffusionRepositoryEditEngine
|
||||||
->setConduitDescription(pht('Set the default branch name.'))
|
->setConduitDescription(pht('Set the default branch name.'))
|
||||||
->setConduitTypeDescription(pht('New default branch name.'))
|
->setConduitTypeDescription(pht('New default branch name.'))
|
||||||
->setValue($object->getDetail('default-branch')),
|
->setValue($object->getDetail('default-branch')),
|
||||||
|
id(new PhabricatorTextAreaEditField())
|
||||||
|
->setIsStringList(true)
|
||||||
|
->setKey('trackOnly')
|
||||||
|
->setLabel(pht('Track Only'))
|
||||||
|
->setTransactionType(
|
||||||
|
PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY)
|
||||||
|
->setIsCopyable(true)
|
||||||
|
->setDescription(pht('Track only these branches.'))
|
||||||
|
->setConduitDescription(pht('Set the tracked branches.'))
|
||||||
|
->setConduitTypeDescription(pht('New tracked branchs.'))
|
||||||
|
->setValue($track_value),
|
||||||
|
id(new PhabricatorTextAreaEditField())
|
||||||
|
->setIsStringList(true)
|
||||||
|
->setKey('autocloseOnly')
|
||||||
|
->setLabel(pht('Autoclose Only'))
|
||||||
|
->setTransactionType(
|
||||||
|
PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY)
|
||||||
|
->setIsCopyable(true)
|
||||||
|
->setDescription(pht('Autoclose commits on only these branches.'))
|
||||||
|
->setConduitDescription(pht('Set the autoclose branches.'))
|
||||||
|
->setConduitTypeDescription(pht('New default tracked branchs.'))
|
||||||
|
->setValue($autoclose_value),
|
||||||
id(new PhabricatorTextEditField())
|
id(new PhabricatorTextEditField())
|
||||||
->setKey('stagingAreaURI')
|
->setKey('stagingAreaURI')
|
||||||
->setLabel(pht('Staging Area URI'))
|
->setLabel(pht('Staging Area URI'))
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionRepositoryBranchesManagementPanel
|
||||||
|
extends DiffusionRepositoryManagementPanel {
|
||||||
|
|
||||||
|
const PANELKEY = 'branches';
|
||||||
|
|
||||||
|
public function getManagementPanelLabel() {
|
||||||
|
return pht('Branches');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getManagementPanelOrder() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildManagementPanelActions() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$repository,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$branches_uri = $repository->getPathURI('edit/branches/');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setIcon('fa-pencil')
|
||||||
|
->setName(pht('Edit Branches'))
|
||||||
|
->setHref($branches_uri)
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildManagementPanelContent() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->setActionList($this->newActions());
|
||||||
|
|
||||||
|
$default_branch = nonempty(
|
||||||
|
$repository->getHumanReadableDetail('default-branch'),
|
||||||
|
phutil_tag('em', array(), $repository->getDefaultBranch()));
|
||||||
|
$view->addProperty(pht('Default Branch'), $default_branch);
|
||||||
|
|
||||||
|
$track_only = nonempty(
|
||||||
|
$repository->getHumanReadableDetail('branch-filter', array()),
|
||||||
|
phutil_tag('em', array(), pht('Track All Branches')));
|
||||||
|
$view->addProperty(pht('Track Only'), $track_only);
|
||||||
|
|
||||||
|
$autoclose_only = nonempty(
|
||||||
|
$repository->getHumanReadableDetail('close-commits-filter', array()),
|
||||||
|
phutil_tag('em', array(), pht('Autoclose On All Branches')));
|
||||||
|
|
||||||
|
if ($repository->getDetail('disable-autoclose')) {
|
||||||
|
$autoclose_only = phutil_tag('em', array(), pht('Disabled'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->addProperty(pht('Autoclose Only'), $autoclose_only);
|
||||||
|
|
||||||
|
return $this->newBox(pht('Branches'), $view);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ final class PhabricatorTextAreaEditField
|
||||||
|
|
||||||
private $monospaced;
|
private $monospaced;
|
||||||
private $height;
|
private $height;
|
||||||
|
private $isStringList;
|
||||||
|
|
||||||
public function setMonospaced($monospaced) {
|
public function setMonospaced($monospaced) {
|
||||||
$this->monospaced = $monospaced;
|
$this->monospaced = $monospaced;
|
||||||
|
@ -24,6 +25,15 @@ final class PhabricatorTextAreaEditField
|
||||||
return $this->height;
|
return $this->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsStringList($is_string_list) {
|
||||||
|
$this->isStringList = $is_string_list;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsStringList() {
|
||||||
|
return $this->isStringList;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newControl() {
|
protected function newControl() {
|
||||||
$control = new AphrontFormTextAreaControl();
|
$control = new AphrontFormTextAreaControl();
|
||||||
|
|
||||||
|
@ -39,8 +49,25 @@ final class PhabricatorTextAreaEditField
|
||||||
return $control;
|
return $control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getValueForControl() {
|
||||||
|
$value = $this->getValue();
|
||||||
|
return implode("\n", $value);
|
||||||
|
}
|
||||||
|
|
||||||
protected function newConduitParameterType() {
|
protected function newConduitParameterType() {
|
||||||
|
if ($this->getIsStringList()) {
|
||||||
|
return new ConduitStringListParameterType();
|
||||||
|
} else {
|
||||||
return new ConduitStringParameterType();
|
return new ConduitStringParameterType();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newHTTPParameterType() {
|
||||||
|
if ($this->getIsStringList()) {
|
||||||
|
return new AphrontStringListHTTPParameterType();
|
||||||
|
} else {
|
||||||
|
return new AphrontStringHTTPParameterType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue