Differential D7452 Diff 16803 src/applications/diffusion/controller/DiffusionRepositoryController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryController.php
Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | private function buildBranchListTable(DiffusionRequest $drequest) { | ||||
$branches = array_slice($branches, 0, $limit); | $branches = array_slice($branches, 0, $limit); | ||||
$commits = id(new DiffusionCommitQuery()) | $commits = id(new DiffusionCommitQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIdentifiers(mpull($branches, 'getHeadCommitIdentifier')) | ->withIdentifiers(mpull($branches, 'getHeadCommitIdentifier')) | ||||
->withRepositoryIDs(array($drequest->getRepository()->getID())) | ->withRepositoryIDs(array($drequest->getRepository()->getID())) | ||||
->execute(); | ->execute(); | ||||
$table = new DiffusionBranchTableView(); | $table = id(new DiffusionBranchTableView()) | ||||
$table->setDiffusionRequest($drequest); | ->setUser($viewer) | ||||
$table->setBranches($branches); | ->setDiffusionRequest($drequest) | ||||
$table->setCommits($commits); | ->setBranches($branches) | ||||
$table->setUser($this->getRequest()->getUser()); | ->setCommits($commits); | ||||
$panel = new AphrontPanelView(); | $panel = id(new AphrontPanelView()) | ||||
$panel->setHeader(pht('Branches')); | ->setHeader(pht('Branches')) | ||||
$panel->setNoBackground(); | ->setNoBackground(); | ||||
if ($more_branches) { | if ($more_branches) { | ||||
$panel->setCaption(pht('Showing %d branches.', $limit)); | $panel->setCaption(pht('Showing %d branches.', $limit)); | ||||
} | } | ||||
$panel->addButton( | $panel->addButton( | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $drequest->generateURI( | 'href' => $drequest->generateURI( | ||||
array( | array( | ||||
'action' => 'branches', | 'action' => 'branches', | ||||
)), | )), | ||||
'class' => 'grey button', | 'class' => 'grey button', | ||||
), | ), | ||||
pht("Show All Branches \xC2\xBB"))); | pht("Show All Branches \xC2\xBB"))); | ||||
$panel->appendChild($table); | $panel->appendChild($table); | ||||
return $panel; | return $panel; | ||||
} | } | ||||
private function buildTagListTable(DiffusionRequest $drequest) { | private function buildTagListTable(DiffusionRequest $drequest) { | ||||
$viewer = $this->getRequest()->getUser(); | |||||
$tag_limit = 15; | $tag_limit = 15; | ||||
$tags = array(); | $tags = array(); | ||||
try { | try { | ||||
$tags = DiffusionRepositoryTag::newFromConduit( | $tags = DiffusionRepositoryTag::newFromConduit( | ||||
$this->callConduitWithDiffusionRequest( | $this->callConduitWithDiffusionRequest( | ||||
'diffusion.tagsquery', | 'diffusion.tagsquery', | ||||
array( | array( | ||||
// On the home page, we want to find tags on any branch. | // On the home page, we want to find tags on any branch. | ||||
'commit' => null, | 'commit' => null, | ||||
'limit' => $tag_limit + 1, | 'limit' => $tag_limit + 1, | ||||
))); | ))); | ||||
} catch (ConduitException $e) { | } catch (ConduitException $e) { | ||||
if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') { | if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') { | ||||
throw $e; | throw $e; | ||||
} | } | ||||
} | } | ||||
if (!$tags) { | if (!$tags) { | ||||
return null; | return null; | ||||
} | } | ||||
$more_tags = (count($tags) > $tag_limit); | $more_tags = (count($tags) > $tag_limit); | ||||
$tags = array_slice($tags, 0, $tag_limit); | $tags = array_slice($tags, 0, $tag_limit); | ||||
$commits = id(new PhabricatorAuditCommitQuery()) | $commits = id(new DiffusionCommitQuery()) | ||||
->withIdentifiers( | ->setViewer($viewer) | ||||
$drequest->getRepository()->getID(), | ->withIdentifiers(mpull($tags, 'getCommitIdentifier')) | ||||
mpull($tags, 'getCommitIdentifier')) | ->withRepositoryIDs(array($drequest->getRepository()->getID())) | ||||
->needCommitData(true) | ->needCommitData(true) | ||||
->execute(); | ->execute(); | ||||
$view = new DiffusionTagListView(); | $view = id(new DiffusionTagListView()) | ||||
$view->setDiffusionRequest($drequest); | ->setUser($viewer) | ||||
$view->setTags($tags); | ->setDiffusionRequest($drequest) | ||||
$view->setUser($this->getRequest()->getUser()); | ->setTags($tags) | ||||
$view->setCommits($commits); | ->setCommits($commits); | ||||
$phids = $view->getRequiredHandlePHIDs(); | $phids = $view->getRequiredHandlePHIDs(); | ||||
$handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
$view->setHandles($handles); | $view->setHandles($handles); | ||||
$panel = new AphrontPanelView(); | $panel = id(new AphrontPanelView()) | ||||
$panel->setHeader(pht('Tags')); | ->setHeader(pht('Tags')) | ||||
$panel->setNoBackground(true); | ->setNoBackground(true); | ||||
if ($more_tags) { | if ($more_tags) { | ||||
$panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit)); | $panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit)); | ||||
} | } | ||||
$panel->addButton( | $panel->addButton( | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |