Differential D20584 Diff 49116 src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function buildManagementPanelCurtain() { | ||||
$action_list->addAction( | $action_list->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setName(pht('Edit Branches')) | ->setName(pht('Edit Branches')) | ||||
->setHref($branches_uri) | ->setHref($branches_uri) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)); | ->setWorkflow(!$can_edit)); | ||||
$drequest = DiffusionRequest::newFromDictionary( | |||||
array( | |||||
'user' => $viewer, | |||||
'repository' => $repository, | |||||
)); | |||||
$view_uri = $drequest->generateURI( | |||||
array( | |||||
'action' => 'branches', | |||||
)); | |||||
$action_list->addAction( | |||||
id(new PhabricatorActionView()) | |||||
->setIcon('fa-code-fork') | |||||
->setName(pht('View Branches')) | |||||
->setHref($view_uri)); | |||||
return $this->newCurtainView() | return $this->newCurtainView() | ||||
->setActionList($action_list); | ->setActionList($action_list); | ||||
} | } | ||||
public function buildManagementPanelContent() { | public function buildManagementPanelContent() { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$content = array(); | $content = array(); | ||||
Show All 33 Lines | if ($publishing_disabled) { | ||||
} else { | } else { | ||||
$permanent_display = phutil_tag('em', array(), pht('All Branches')); | $permanent_display = phutil_tag('em', array(), pht('All Branches')); | ||||
} | } | ||||
} | } | ||||
$view->addProperty(pht('Permanent Refs'), $permanent_display); | $view->addProperty(pht('Permanent Refs'), $permanent_display); | ||||
$content[] = $this->newBox(pht('Branches'), $view); | $content[] = $this->newBox(pht('Branches'), $view); | ||||
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); | |||||
$can_close_branches = ($repository->isHg()); | |||||
$publisher = $repository->newPublisher(); | |||||
$rows = array(); | |||||
foreach ($branches as $branch) { | |||||
$branch_name = $branch->getShortName(); | |||||
$permanent = $publisher->shouldPublishRef($branch); | |||||
$default = $repository->getDefaultBranch(); | |||||
$icon = null; | |||||
if ($default == $branch->getShortName()) { | |||||
$icon = id(new PHUIIconView()) | |||||
->setIcon('fa-code-fork'); | |||||
} | |||||
$fields = $branch->getRawFields(); | |||||
$closed = idx($fields, 'closed'); | |||||
if ($closed) { | |||||
$status = pht('Closed'); | |||||
} else { | |||||
$status = pht('Open'); | |||||
} | |||||
if ($publishing_disabled) { | |||||
$permanent_status = pht('Publishing Disabled'); | |||||
} else { | |||||
if ($permanent) { | |||||
$permanent_status = pht('Permanent'); | |||||
} else { | |||||
$permanent_status = pht('Not Permanent'); | |||||
} | |||||
} | |||||
$rows[] = array( | |||||
$icon, | |||||
$branch_name, | |||||
$status, | |||||
$permanent_status, | |||||
); | |||||
} | |||||
$branch_table = new AphrontTableView($rows); | |||||
$branch_table->setHeaders( | |||||
array( | |||||
'', | |||||
pht('Branch'), | |||||
pht('Status'), | |||||
pht('Permanent'), | |||||
)); | |||||
$branch_table->setColumnClasses( | |||||
array( | |||||
'', | |||||
'pri', | |||||
'narrow', | |||||
'wide', | |||||
)); | |||||
$branch_table->setColumnVisibility( | |||||
array( | |||||
true, | |||||
true, | |||||
$can_close_branches, | |||||
true, | |||||
)); | |||||
$box = $this->newBox(pht('Branch Status'), $branch_table); | |||||
$box->setPager($pager); | |||||
$content[] = $box; | |||||
} else { | |||||
$content[] = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | |||||
->appendChild( | |||||
pht( | |||||
'Branch status is unavailable while the repository is still '. | |||||
'importing.')); | |||||
} | |||||
return $content; | return $content; | ||||
} | } | ||||
} | } |