Example #1
0
 public static final function callConduitWithDiffusionRequest(PhabricatorUser $user, DiffusionRequest $drequest, $method, array $params = array())
 {
     $repository = $drequest->getRepository();
     $core_params = array('callsign' => $repository->getCallsign());
     if ($drequest->getBranch() !== null) {
         $core_params['branch'] = $drequest->getBranch();
     }
     $params = $params + $core_params;
     return id(new ConduitCall($method, $params))->setUser($user)->execute();
 }
Example #2
0
 public static final function callConduitWithDiffusionRequest(PhabricatorUser $user, DiffusionRequest $drequest, $method, array $params = array())
 {
     $repository = $drequest->getRepository();
     $core_params = array('repository' => $repository->getPHID());
     if ($drequest->getBranch() !== null) {
         $core_params['branch'] = $drequest->getBranch();
     }
     // If the method we're calling doesn't actually take some of the implicit
     // parameters we derive from the DiffusionRequest, omit them.
     $method_object = ConduitAPIMethod::getConduitMethod($method);
     $method_params = $method_object->getParamTypes();
     foreach ($core_params as $key => $value) {
         if (empty($method_params[$key])) {
             unset($core_params[$key]);
         }
     }
     $params = $params + $core_params;
     $client = $repository->newConduitClient($user, $drequest->getIsClusterRequest());
     if (!$client) {
         return id(new ConduitCall($method, $params))->setUser($user)->execute();
     } else {
         return $client->callMethodSynchronous($method, $params);
     }
 }
 private function buildBranchListTable(DiffusionRequest $drequest)
 {
     $viewer = $this->getRequest()->getUser();
     if ($drequest->getBranch() === null) {
         return null;
     }
     $limit = 15;
     $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('closed' => false, 'limit' => $limit + 1));
     if (!$branches) {
         return null;
     }
     $more_branches = count($branches) > $limit;
     $branches = array_slice($branches, 0, $limit);
     $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
     $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($drequest->getRepository())->execute();
     $table = id(new DiffusionBranchTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setBranches($branches)->setCommits($commits);
     $panel = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $header->setHeader(pht('Branches'));
     if ($more_branches) {
         $header->setSubHeader(pht('Showing %d branches.', $limit));
     }
     $icon = id(new PHUIIconView())->setIconFont('fa-code-fork');
     $button = new PHUIButtonView();
     $button->setText(pht('Show All Branches'));
     $button->setTag('a');
     $button->setIcon($icon);
     $button->setHref($drequest->generateURI(array('action' => 'branches')));
     $header->addActionLink($button);
     $panel->setHeader($header);
     $panel->setTable($table);
     return $panel;
 }
 private function buildBranchListTable(DiffusionRequest $drequest)
 {
     if ($drequest->getBranch() !== null) {
         $limit = 15;
         $branch_query = DiffusionBranchQuery::newFromDiffusionRequest($drequest);
         $branch_query->setLimit($limit + 1);
         $branches = $branch_query->loadBranches();
         if (!$branches) {
             return null;
         }
         $more_branches = count($branches) > $limit;
         $branches = array_slice($branches, 0, $limit);
         $commits = id(new PhabricatorAuditCommitQuery())->withIdentifiers($drequest->getRepository()->getID(), mpull($branches, 'getHeadCommitIdentifier'))->needCommitData(true)->execute();
         $table = new DiffusionBranchTableView();
         $table->setDiffusionRequest($drequest);
         $table->setBranches($branches);
         $table->setCommits($commits);
         $table->setUser($this->getRequest()->getUser());
         $panel = new AphrontPanelView();
         $panel->setHeader('Branches');
         if ($more_branches) {
             $panel->setCaption('Showing ' . $limit . ' branches.');
         }
         $panel->addButton(phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'branches')), 'class' => 'grey button'), "Show All Branches ยป"));
         $panel->appendChild($table);
         return $panel;
     }
     return null;
 }