Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
index aa2bb49ccb..a735b8d580 100644
--- a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
+++ b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
@@ -1,97 +1,156 @@
<?php
final class DiffusionRepositoryBranchesManagementPanel
extends DiffusionRepositoryManagementPanel {
const PANELKEY = 'branches';
public function getManagementPanelLabel() {
return pht('Branches');
}
public function getManagementPanelOrder() {
return 1000;
}
public function shouldEnableForRepository(
PhabricatorRepository $repository) {
return ($repository->isGit() || $repository->isHg());
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$has_any =
$repository->getDetail('default-branch') ||
$repository->getDetail('branch-filter') ||
$repository->getDetail('close-commits-filter');
if ($has_any) {
return 'fa-code-fork';
} else {
return 'fa-code-fork grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'defaultBranch',
'trackOnly',
'autocloseOnly',
);
}
public function buildManagementPanelCurtain() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
$action_list = $this->getNewActionList();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$repository,
PhabricatorPolicyCapability::CAN_EDIT);
$branches_uri = $this->getEditPageURI();
$action_list->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Branches'))
->setHref($branches_uri)
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
return $this->getNewCurtainView($action_list);
}
public function buildManagementPanelContent() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
+ $content = array();
$view = id(new PHUIPropertyListView())
->setViewer($viewer);
$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);
+ $content[] = $this->newBox(pht('Branches'), $view);
+
+ // Branch Autoclose Table
+ if (!$repository->isImporting()) {
+ $request = $this->getRequest();
+ $pager = id(new PHUIPagerView())
+ ->readFromRequest($request);
+
+ $params = array(
+ 'offset' => $pager->getOffset(),
+ 'limit' => $pager->getPageSize() + 1,
+ 'repository' => $repository->getID(),
+ );
+
+ $branches = id(new ConduitCall('diffusion.branchquery', $params))
+ ->setUser($viewer)
+ ->execute();
+ $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
+ $branches = $pager->sliceResults($branches);
+
+ $rows = array();
+ foreach ($branches as $branch) {
+ $branch_name = $branch->getShortName();
+ $tracking = $repository->shouldTrackBranch($branch_name);
+ $autoclosing = $repository->shouldAutocloseBranch($branch_name);
+
+ $rows[] = array(
+ $branch_name,
+ $tracking ? pht('Tracking') : pht('Off'),
+ $autoclosing ? pht('Autoclose On') : pht('Off'),
+ );
+ }
+ $branch_table = new AphrontTableView($rows);
+ $branch_table->setHeaders(
+ array(
+ pht('Branch'),
+ pht('Track'),
+ pht('Autoclose'),
+ ));
+ $branch_table->setColumnClasses(
+ array(
+ 'pri',
+ 'narrow',
+ 'wide',
+ ));
+
+ $box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Branch Status'))
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->setTable($branch_table)
+ ->setPager($pager);
+ $content[] = $box;
+ } else {
+ $content[] = id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild(pht('Branch status in unavailable while the repository '.
+ 'is still importing.'));
+ }
- return $this->newBox(pht('Branches'), $view);
+ return $content;
}
}
diff --git a/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php
index 0098fe1df9..f9e76eb523 100644
--- a/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php
+++ b/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php
@@ -1,131 +1,135 @@
<?php
abstract class DiffusionRepositoryManagementPanel
extends Phobject {
private $viewer;
private $repository;
private $controller;
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
final public function getViewer() {
return $this->viewer;
}
final public function setRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
return $this;
}
final public function getRepository() {
return $this->repository;
}
+ final public function getRequest() {
+ return $this->controller->getRequest();
+ }
+
final public function setController(PhabricatorController $controller) {
$this->controller = $controller;
return $this;
}
final public function getManagementPanelKey() {
return $this->getPhobjectClassConstant('PANELKEY');
}
abstract public function getManagementPanelLabel();
abstract public function getManagementPanelOrder();
abstract public function buildManagementPanelContent();
abstract public function buildManagementPanelCurtain();
public function getManagementPanelIcon() {
return 'fa-pencil';
}
protected function buildManagementPanelActions() {
return array();
}
public function shouldEnableForRepository(
PhabricatorRepository $repository) {
return true;
}
public function getNewActionList() {
$viewer = $this->getViewer();
$action_id = celerity_generate_unique_node_id();
return id(new PhabricatorActionListView())
->setViewer($viewer)
->setID($action_id);
}
public function getNewCurtainView(PhabricatorActionListView $action_list) {
$viewer = $this->getViewer();
return id(new PHUICurtainView())
->setViewer($viewer)
->setActionList($action_list);
}
public static function getAllPanels() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getManagementPanelKey')
->setSortMethod('getManagementPanelOrder')
->execute();
}
final protected function newBox($header_text, $body) {
return id(new PHUIObjectBoxView())
->setHeaderText($header_text)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($body);
}
final protected function newTimeline() {
return $this->controller->newTimeline($this->getRepository());
}
final public function getPanelURI() {
$repository = $this->getRepository();
$key = $this->getManagementPanelKey();
return $repository->getPathURI("manage/{$key}/");
}
final public function newEditEnginePage() {
$field_keys = $this->getEditEngineFieldKeys();
if (!$field_keys) {
return null;
}
$key = $this->getManagementPanelKey();
$label = $this->getManagementPanelLabel();
$panel_uri = $this->getPanelURI();
return id(new PhabricatorEditPage())
->setKey($key)
->setLabel($label)
->setViewURI($panel_uri)
->setFieldKeys($field_keys);
}
protected function getEditEngineFieldKeys() {
return array();
}
protected function getEditPageURI($page = null) {
if ($page === null) {
$page = $this->getManagementPanelKey();
}
$repository = $this->getRepository();
$id = $repository->getID();
return "/diffusion/edit/{$id}/page/{$page}/";
}
public function getPanelNavigationURI() {
return $this->getPanelURI();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 24, 7:11 AM (19 h, 15 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
182588
Default Alt Text
(8 KB)

Event Timeline