@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add modern releeph.queryproducts and releeph.querybranches

Summary:
Ref T3662. Ref T3549. These methods are pretty conservative for now, but get the structure in place.

Also do a bunch more project -> product stuff.

Test Plan: Made calls to both methods, browsed around the UI a fair amount.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3549, T3662

Differential Revision: https://secure.phabricator.com/D8816

+224 -29
+4
src/__phutil_library_map__.php
··· 230 230 'ConduitAPI_releeph_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_Method.php', 231 231 'ConduitAPI_releeph_getbranches_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_getbranches_Method.php', 232 232 'ConduitAPI_releeph_projectinfo_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_projectinfo_Method.php', 233 + 'ConduitAPI_releeph_querybranches_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php', 234 + 'ConduitAPI_releeph_queryproducts_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php', 233 235 'ConduitAPI_releeph_queryrequests_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php', 234 236 'ConduitAPI_releeph_request_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_request_Method.php', 235 237 'ConduitAPI_releephwork_canpush_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_canpush_Method.php', ··· 2816 2818 'ConduitAPI_releeph_Method' => 'ConduitAPIMethod', 2817 2819 'ConduitAPI_releeph_getbranches_Method' => 'ConduitAPI_releeph_Method', 2818 2820 'ConduitAPI_releeph_projectinfo_Method' => 'ConduitAPI_releeph_Method', 2821 + 'ConduitAPI_releeph_querybranches_Method' => 'ConduitAPI_releeph_Method', 2822 + 'ConduitAPI_releeph_queryproducts_Method' => 'ConduitAPI_releeph_Method', 2819 2823 'ConduitAPI_releeph_queryrequests_Method' => 'ConduitAPI_releeph_Method', 2820 2824 'ConduitAPI_releeph_request_Method' => 'ConduitAPI_releeph_Method', 2821 2825 'ConduitAPI_releephwork_canpush_Method' => 'ConduitAPI_releeph_Method',
+1 -1
src/applications/releeph/application/PhabricatorApplicationReleeph.php
··· 40 40 41 41 '/releeph/' => array( 42 42 '' => 'ReleephProductListController', 43 - 'project/' => array( 43 + '(?:product|project)/' => array( 44 44 '(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductListController', 45 45 'create/' => 'ReleephProductCreateController', 46 46 '(?P<projectID>[1-9]\d*)/' => array(
+8
src/applications/releeph/conduit/ConduitAPI_releeph_Method.php
··· 2 2 3 3 abstract class ConduitAPI_releeph_Method extends ConduitAPIMethod { 4 4 5 + public function getMethodStatus() { 6 + return self::METHOD_STATUS_UNSTABLE; 7 + } 8 + 9 + public function getMethodStatusDescription() { 10 + return pht('All Releeph methods are subject to abrupt change.'); 11 + } 12 + 5 13 public function getApplication() { 6 14 return PhabricatorApplication::getByClass('PhabricatorApplicationReleeph'); 7 15 }
+73
src/applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php
··· 1 + <?php 2 + 3 + final class ConduitAPI_releeph_querybranches_Method 4 + extends ConduitAPI_releeph_Method { 5 + 6 + public function getMethodDescription() { 7 + return pht('Query information about Releeph branches.'); 8 + } 9 + 10 + public function defineParamTypes() { 11 + return array( 12 + 'ids' => 'optional list<id>', 13 + 'phids' => 'optional list<phid>', 14 + 'productPHIDs' => 'optional list<phid>', 15 + ) + $this->getPagerParamTypes(); 16 + } 17 + 18 + public function defineReturnType() { 19 + return 'query-results'; 20 + } 21 + 22 + public function defineErrorTypes() { 23 + return array(); 24 + } 25 + 26 + protected function execute(ConduitAPIRequest $request) { 27 + $viewer = $request->getUser(); 28 + 29 + $query = id(new ReleephBranchQuery()) 30 + ->setViewer($viewer); 31 + 32 + $ids = $request->getValue('ids'); 33 + if ($ids !== null) { 34 + $query->withIDs($ids); 35 + } 36 + 37 + $phids = $request->getValue('phids'); 38 + if ($phids !== null) { 39 + $query->withPHIDs($phids); 40 + } 41 + 42 + $product_phids = $request->getValue('productPHIDs'); 43 + if ($product_phids !== null) { 44 + $query->withProductPHIDs($product_phids); 45 + } 46 + 47 + $pager = $this->newPager($request); 48 + $branches = $query->executeWithCursorPager($pager); 49 + 50 + $data = array(); 51 + foreach ($branches as $branch) { 52 + $id = $branch->getID(); 53 + 54 + $uri = '/releeph/branch/'.$id.'/'; 55 + $uri = PhabricatorEnv::getProductionURI($uri); 56 + 57 + $data[] = array( 58 + 'id' => $id, 59 + 'phid' => $branch->getPHID(), 60 + 'uri' => $uri, 61 + 'name' => $branch->getName(), 62 + 'productPHID' => $branch->getProduct()->getPHID(), 63 + ); 64 + } 65 + 66 + return $this->addPagerResults( 67 + array( 68 + 'data' => $data, 69 + ), 70 + $pager); 71 + } 72 + 73 + }
+80
src/applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php
··· 1 + <?php 2 + 3 + final class ConduitAPI_releeph_queryproducts_Method 4 + extends ConduitAPI_releeph_Method { 5 + 6 + public function getMethodDescription() { 7 + return pht('Query information about Releeph products.'); 8 + } 9 + 10 + public function defineParamTypes() { 11 + return array( 12 + 'ids' => 'optional list<id>', 13 + 'phids' => 'optional list<phid>', 14 + 'repositoryPHIDs' => 'optional list<phid>', 15 + 'isActive' => 'optional bool', 16 + ) + $this->getPagerParamTypes(); 17 + } 18 + 19 + public function defineReturnType() { 20 + return 'query-results'; 21 + } 22 + 23 + public function defineErrorTypes() { 24 + return array(); 25 + } 26 + 27 + protected function execute(ConduitAPIRequest $request) { 28 + $viewer = $request->getUser(); 29 + 30 + $query = id(new ReleephProductQuery()) 31 + ->setViewer($viewer); 32 + 33 + $ids = $request->getValue('ids'); 34 + if ($ids !== null) { 35 + $query->withIDs($ids); 36 + } 37 + 38 + $phids = $request->getValue('phids'); 39 + if ($phids !== null) { 40 + $query->withPHIDs($phids); 41 + } 42 + 43 + $repository_phids = $request->getValue('repositoryPHIDs'); 44 + if ($repository_phids !== null) { 45 + $query->withRepositoryPHIDs($repository_phids); 46 + } 47 + 48 + $is_active = $request->getValue('isActive'); 49 + if ($is_active !== null) { 50 + $query->withActive($is_active); 51 + } 52 + 53 + $pager = $this->newPager($request); 54 + $products = $query->executeWithCursorPager($pager); 55 + 56 + $data = array(); 57 + foreach ($products as $product) { 58 + $id = $product->getID(); 59 + 60 + $uri = '/releeph/product/'.$id.'/'; 61 + $uri = PhabricatorEnv::getProductionURI($uri); 62 + 63 + $data[] = array( 64 + 'id' => $id, 65 + 'phid' => $product->getPHID(), 66 + 'uri' => $uri, 67 + 'name' => $product->getName(), 68 + 'isActive' => (bool)$product->getIsActive(), 69 + 'repositoryPHID' => $product->getRepositoryPHID(), 70 + ); 71 + } 72 + 73 + return $this->addPagerResults( 74 + array( 75 + 'data' => $data, 76 + ), 77 + $pager); 78 + } 79 + 80 + }
+1 -1
src/applications/releeph/controller/project/ReleephProductEditController.php
··· 203 203 $form 204 204 ->appendChild( 205 205 id(new AphrontFormSubmitControl()) 206 - ->addCancelButton('/releeph/project/') 206 + ->addCancelButton('/releeph/product/') 207 207 ->setValue(pht('Save'))); 208 208 209 209 $box = id(new PHUIObjectBoxView())
+2 -2
src/applications/releeph/controller/project/ReleephProductListController.php
··· 37 37 38 38 $item = id(new PHUIObjectItemView()) 39 39 ->setHeader($product->getName()) 40 - ->setHref($this->getApplicationURI("project/{$id}/")); 40 + ->setHref($this->getApplicationURI("product/{$id}/")); 41 41 42 42 if (!$product->getIsActive()) { 43 43 $item->setDisabled(true); ··· 70 70 $crumbs->addAction( 71 71 id(new PHUIListItemView()) 72 72 ->setName(pht('Create Product')) 73 - ->setHref($this->getApplicationURI('project/create/')) 73 + ->setHref($this->getApplicationURI('product/create/')) 74 74 ->setIcon('create')); 75 75 76 76 return $crumbs;
+9 -9
src/applications/releeph/controller/project/ReleephProductViewController.php
··· 33 33 ->setPreface($this->renderPreface()) 34 34 ->setSearchEngine( 35 35 id(new ReleephBranchSearchEngine()) 36 - ->setProjectID($product->getID())) 36 + ->setProduct($product)) 37 37 ->setNavigation($this->buildSideNavView()); 38 38 39 39 return $this->delegateToController($controller); ··· 46 46 47 47 $viewer = $this->getRequest()->getUser(); 48 48 49 - $products = mpull($branches, 'getProject'); 49 + $products = mpull($branches, 'getProduct'); 50 50 $repo_phids = mpull($products, 'getRepositoryPHID'); 51 51 52 52 $repos = id(new PhabricatorRepositoryQuery()) ··· 72 72 ->setUser($viewer); 73 73 foreach ($branches as $branch) { 74 74 $diffusion_href = null; 75 - $repo = idx($repos, $branch->getProject()->getRepositoryPHID()); 75 + $repo = idx($repos, $branch->getProduct()->getRepositoryPHID()); 76 76 if ($repo) { 77 77 $drequest = DiffusionRequest::newFromDictionary( 78 78 array( ··· 135 135 $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 136 136 137 137 if ($for_app) { 138 - $nav->addFilter('project/create/', pht('Create Product')); 138 + $nav->addFilter('product/create/', pht('Create Product')); 139 139 } 140 140 141 141 id(new ReleephBranchSearchEngine()) 142 - ->setProjectID($product->getID()) 142 + ->setProduct($product) 143 143 ->setViewer($viewer) 144 144 ->addNavigationItems($nav->getMenu()); 145 145 ··· 190 190 $product, 191 191 PhabricatorPolicyCapability::CAN_EDIT); 192 192 193 - $edit_uri = $this->getApplicationURI("project/{$id}/edit/"); 194 - $history_uri = $this->getApplicationURI("project/{$id}/history/"); 193 + $edit_uri = $this->getApplicationURI("product/{$id}/edit/"); 194 + $history_uri = $this->getApplicationURI("product/{$id}/history/"); 195 195 196 196 $actions->addAction( 197 197 id(new PhabricatorActionView()) ··· 203 203 204 204 if ($product->getIsActive()) { 205 205 $status_name = pht('Deactivate Product'); 206 - $status_href = "project/{$id}/action/deactivate/"; 206 + $status_href = "product/{$id}/action/deactivate/"; 207 207 $status_icon = 'delete'; 208 208 } else { 209 209 $status_name = pht('Reactivate Product'); 210 - $status_href = "project/{$id}/action/activate/"; 210 + $status_href = "product/{$id}/action/activate/"; 211 211 $status_icon = 'new'; 212 212 } 213 213
+24 -7
src/applications/releeph/query/ReleephBranchQuery.php
··· 5 5 6 6 private $ids; 7 7 private $phids; 8 - private $projectIDs; 8 + private $productPHIDs; 9 + private $productIDs; 9 10 10 11 const STATUS_ALL = 'status-all'; 11 12 const STATUS_OPEN = 'status-open'; ··· 33 34 return $this; 34 35 } 35 36 36 - public function withProjectIDs(array $ids) { 37 - $this->projectIDs = $ids; 37 + public function withProductPHIDs($product_phids) { 38 + $this->productPHIDs = $product_phids; 38 39 return $this; 39 40 } 40 41 ··· 53 54 return $table->loadAllFromArray($data); 54 55 } 55 56 57 + public function willExecute() { 58 + if ($this->productPHIDs !== null) { 59 + $products = id(new ReleephProductQuery()) 60 + ->setViewer($this->getViewer()) 61 + ->withPHIDs($this->productPHIDs) 62 + ->execute(); 63 + 64 + if (!$products) { 65 + throw new PhabricatorEmptyQueryException(); 66 + } 67 + 68 + $this->productIDs = mpull($products, 'getID'); 69 + } 70 + } 71 + 72 + 56 73 public function willFilterPage(array $branches) { 57 74 $project_ids = mpull($branches, 'getReleephProjectID'); 58 75 ··· 90 107 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 91 108 $where = array(); 92 109 93 - if ($this->ids) { 110 + if ($this->ids !== null) { 94 111 $where[] = qsprintf( 95 112 $conn_r, 96 113 'id IN (%Ld)', 97 114 $this->ids); 98 115 } 99 116 100 - if ($this->phids) { 117 + if ($this->phids !== null) { 101 118 $where[] = qsprintf( 102 119 $conn_r, 103 120 'phid IN (%Ls)', 104 121 $this->phids); 105 122 } 106 123 107 - if ($this->projectIDs) { 124 + if ($this->productIDs !== null) { 108 125 $where[] = qsprintf( 109 126 $conn_r, 110 127 'releephProjectID IN (%Ld)', 111 - $this->projectIDs); 128 + $this->productIDs); 112 129 } 113 130 114 131 $status = $this->status;
+7 -7
src/applications/releeph/query/ReleephBranchSearchEngine.php
··· 3 3 final class ReleephBranchSearchEngine 4 4 extends PhabricatorApplicationSearchEngine { 5 5 6 - private $projectID; 6 + private $product; 7 7 8 - public function setProjectID($project_id) { 9 - $this->projectID = $project_id; 8 + public function setProduct(ReleephProject $product) { 9 + $this->product = $product; 10 10 return $this; 11 11 } 12 12 13 - public function getProjectID() { 14 - return $this->projectID; 13 + public function getProduct() { 14 + return $this->product; 15 15 } 16 16 17 17 public function buildSavedQueryFromRequest(AphrontRequest $request) { ··· 25 25 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 26 26 $query = id(new ReleephBranchQuery()) 27 27 ->needCutPointCommits(true) 28 - ->withProjectIDs(array($this->getProjectID())); 28 + ->withProductPHIDs(array($this->getProduct()->getPHID())); 29 29 30 30 $active = $saved->getParameter('active'); 31 31 $value = idx($this->getActiveValues(), $active); ··· 49 49 } 50 50 51 51 protected function getURI($path) { 52 - return '/releeph/project/'.$this->getProjectID().'/'.$path; 52 + return '/releeph/product/'.$this->getProduct()->getID().'/'.$path; 53 53 } 54 54 55 55 public function getBuiltinQueryNames() {
+15 -2
src/applications/releeph/query/ReleephProductQuery.php
··· 6 6 private $active; 7 7 private $ids; 8 8 private $phids; 9 + private $repositoryPHIDs; 9 10 10 11 private $needArcanistProjects; 11 12 ··· 30 31 31 32 public function withPHIDs(array $phids) { 32 33 $this->phids = $phids; 34 + return $this; 35 + } 36 + 37 + public function withRepositoryPHIDs(array $repository_phids) { 38 + $this->repositoryPHIDs = $repository_phids; 33 39 return $this; 34 40 } 35 41 ··· 109 115 (int)$this->active); 110 116 } 111 117 112 - if ($this->ids) { 118 + if ($this->ids !== null) { 113 119 $where[] = qsprintf( 114 120 $conn_r, 115 121 'id IN (%Ls)', 116 122 $this->ids); 117 123 } 118 124 119 - if ($this->phids) { 125 + if ($this->phids !== null) { 120 126 $where[] = qsprintf( 121 127 $conn_r, 122 128 'phid IN (%Ls)', 123 129 $this->phids); 130 + } 131 + 132 + if ($this->repositoryPHIDs !== null) { 133 + $where[] = qsprintf( 134 + $conn_r, 135 + 'repositoryPHID IN (%Ls)', 136 + $this->repositoryPHIDs); 124 137 } 125 138 126 139 $where[] = $this->buildPagingClause($conn_r);