Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18502223
D8816.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D8816.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -230,6 +230,8 @@
'ConduitAPI_releeph_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_Method.php',
'ConduitAPI_releeph_getbranches_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_getbranches_Method.php',
'ConduitAPI_releeph_projectinfo_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_projectinfo_Method.php',
+ 'ConduitAPI_releeph_querybranches_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php',
+ 'ConduitAPI_releeph_queryproducts_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php',
'ConduitAPI_releeph_queryrequests_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php',
'ConduitAPI_releeph_request_Method' => 'applications/releeph/conduit/ConduitAPI_releeph_request_Method.php',
'ConduitAPI_releephwork_canpush_Method' => 'applications/releeph/conduit/work/ConduitAPI_releephwork_canpush_Method.php',
@@ -2816,6 +2818,8 @@
'ConduitAPI_releeph_Method' => 'ConduitAPIMethod',
'ConduitAPI_releeph_getbranches_Method' => 'ConduitAPI_releeph_Method',
'ConduitAPI_releeph_projectinfo_Method' => 'ConduitAPI_releeph_Method',
+ 'ConduitAPI_releeph_querybranches_Method' => 'ConduitAPI_releeph_Method',
+ 'ConduitAPI_releeph_queryproducts_Method' => 'ConduitAPI_releeph_Method',
'ConduitAPI_releeph_queryrequests_Method' => 'ConduitAPI_releeph_Method',
'ConduitAPI_releeph_request_Method' => 'ConduitAPI_releeph_Method',
'ConduitAPI_releephwork_canpush_Method' => 'ConduitAPI_releeph_Method',
diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
--- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php
+++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
@@ -40,7 +40,7 @@
'/releeph/' => array(
'' => 'ReleephProductListController',
- 'project/' => array(
+ '(?:product|project)/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductListController',
'create/' => 'ReleephProductCreateController',
'(?P<projectID>[1-9]\d*)/' => array(
diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_Method.php
--- a/src/applications/releeph/conduit/ConduitAPI_releeph_Method.php
+++ b/src/applications/releeph/conduit/ConduitAPI_releeph_Method.php
@@ -2,6 +2,14 @@
abstract class ConduitAPI_releeph_Method extends ConduitAPIMethod {
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_UNSTABLE;
+ }
+
+ public function getMethodStatusDescription() {
+ return pht('All Releeph methods are subject to abrupt change.');
+ }
+
public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorApplicationReleeph');
}
diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/releeph/conduit/ConduitAPI_releeph_querybranches_Method.php
@@ -0,0 +1,73 @@
+<?php
+
+final class ConduitAPI_releeph_querybranches_Method
+ extends ConduitAPI_releeph_Method {
+
+ public function getMethodDescription() {
+ return pht('Query information about Releeph branches.');
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'ids' => 'optional list<id>',
+ 'phids' => 'optional list<phid>',
+ 'productPHIDs' => 'optional list<phid>',
+ ) + $this->getPagerParamTypes();
+ }
+
+ public function defineReturnType() {
+ return 'query-results';
+ }
+
+ public function defineErrorTypes() {
+ return array();
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $viewer = $request->getUser();
+
+ $query = id(new ReleephBranchQuery())
+ ->setViewer($viewer);
+
+ $ids = $request->getValue('ids');
+ if ($ids !== null) {
+ $query->withIDs($ids);
+ }
+
+ $phids = $request->getValue('phids');
+ if ($phids !== null) {
+ $query->withPHIDs($phids);
+ }
+
+ $product_phids = $request->getValue('productPHIDs');
+ if ($product_phids !== null) {
+ $query->withProductPHIDs($product_phids);
+ }
+
+ $pager = $this->newPager($request);
+ $branches = $query->executeWithCursorPager($pager);
+
+ $data = array();
+ foreach ($branches as $branch) {
+ $id = $branch->getID();
+
+ $uri = '/releeph/branch/'.$id.'/';
+ $uri = PhabricatorEnv::getProductionURI($uri);
+
+ $data[] = array(
+ 'id' => $id,
+ 'phid' => $branch->getPHID(),
+ 'uri' => $uri,
+ 'name' => $branch->getName(),
+ 'productPHID' => $branch->getProduct()->getPHID(),
+ );
+ }
+
+ return $this->addPagerResults(
+ array(
+ 'data' => $data,
+ ),
+ $pager);
+ }
+
+}
diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/releeph/conduit/ConduitAPI_releeph_queryproducts_Method.php
@@ -0,0 +1,80 @@
+<?php
+
+final class ConduitAPI_releeph_queryproducts_Method
+ extends ConduitAPI_releeph_Method {
+
+ public function getMethodDescription() {
+ return pht('Query information about Releeph products.');
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'ids' => 'optional list<id>',
+ 'phids' => 'optional list<phid>',
+ 'repositoryPHIDs' => 'optional list<phid>',
+ 'isActive' => 'optional bool',
+ ) + $this->getPagerParamTypes();
+ }
+
+ public function defineReturnType() {
+ return 'query-results';
+ }
+
+ public function defineErrorTypes() {
+ return array();
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $viewer = $request->getUser();
+
+ $query = id(new ReleephProductQuery())
+ ->setViewer($viewer);
+
+ $ids = $request->getValue('ids');
+ if ($ids !== null) {
+ $query->withIDs($ids);
+ }
+
+ $phids = $request->getValue('phids');
+ if ($phids !== null) {
+ $query->withPHIDs($phids);
+ }
+
+ $repository_phids = $request->getValue('repositoryPHIDs');
+ if ($repository_phids !== null) {
+ $query->withRepositoryPHIDs($repository_phids);
+ }
+
+ $is_active = $request->getValue('isActive');
+ if ($is_active !== null) {
+ $query->withActive($is_active);
+ }
+
+ $pager = $this->newPager($request);
+ $products = $query->executeWithCursorPager($pager);
+
+ $data = array();
+ foreach ($products as $product) {
+ $id = $product->getID();
+
+ $uri = '/releeph/product/'.$id.'/';
+ $uri = PhabricatorEnv::getProductionURI($uri);
+
+ $data[] = array(
+ 'id' => $id,
+ 'phid' => $product->getPHID(),
+ 'uri' => $uri,
+ 'name' => $product->getName(),
+ 'isActive' => (bool)$product->getIsActive(),
+ 'repositoryPHID' => $product->getRepositoryPHID(),
+ );
+ }
+
+ return $this->addPagerResults(
+ array(
+ 'data' => $data,
+ ),
+ $pager);
+ }
+
+}
diff --git a/src/applications/releeph/controller/project/ReleephProductEditController.php b/src/applications/releeph/controller/project/ReleephProductEditController.php
--- a/src/applications/releeph/controller/project/ReleephProductEditController.php
+++ b/src/applications/releeph/controller/project/ReleephProductEditController.php
@@ -203,7 +203,7 @@
$form
->appendChild(
id(new AphrontFormSubmitControl())
- ->addCancelButton('/releeph/project/')
+ ->addCancelButton('/releeph/product/')
->setValue(pht('Save')));
$box = id(new PHUIObjectBoxView())
diff --git a/src/applications/releeph/controller/project/ReleephProductListController.php b/src/applications/releeph/controller/project/ReleephProductListController.php
--- a/src/applications/releeph/controller/project/ReleephProductListController.php
+++ b/src/applications/releeph/controller/project/ReleephProductListController.php
@@ -37,7 +37,7 @@
$item = id(new PHUIObjectItemView())
->setHeader($product->getName())
- ->setHref($this->getApplicationURI("project/{$id}/"));
+ ->setHref($this->getApplicationURI("product/{$id}/"));
if (!$product->getIsActive()) {
$item->setDisabled(true);
@@ -70,7 +70,7 @@
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Product'))
- ->setHref($this->getApplicationURI('project/create/'))
+ ->setHref($this->getApplicationURI('product/create/'))
->setIcon('create'));
return $crumbs;
diff --git a/src/applications/releeph/controller/project/ReleephProductViewController.php b/src/applications/releeph/controller/project/ReleephProductViewController.php
--- a/src/applications/releeph/controller/project/ReleephProductViewController.php
+++ b/src/applications/releeph/controller/project/ReleephProductViewController.php
@@ -33,7 +33,7 @@
->setPreface($this->renderPreface())
->setSearchEngine(
id(new ReleephBranchSearchEngine())
- ->setProjectID($product->getID()))
+ ->setProduct($product))
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
@@ -46,7 +46,7 @@
$viewer = $this->getRequest()->getUser();
- $products = mpull($branches, 'getProject');
+ $products = mpull($branches, 'getProduct');
$repo_phids = mpull($products, 'getRepositoryPHID');
$repos = id(new PhabricatorRepositoryQuery())
@@ -72,7 +72,7 @@
->setUser($viewer);
foreach ($branches as $branch) {
$diffusion_href = null;
- $repo = idx($repos, $branch->getProject()->getRepositoryPHID());
+ $repo = idx($repos, $branch->getProduct()->getRepositoryPHID());
if ($repo) {
$drequest = DiffusionRequest::newFromDictionary(
array(
@@ -135,11 +135,11 @@
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
- $nav->addFilter('project/create/', pht('Create Product'));
+ $nav->addFilter('product/create/', pht('Create Product'));
}
id(new ReleephBranchSearchEngine())
- ->setProjectID($product->getID())
+ ->setProduct($product)
->setViewer($viewer)
->addNavigationItems($nav->getMenu());
@@ -190,8 +190,8 @@
$product,
PhabricatorPolicyCapability::CAN_EDIT);
- $edit_uri = $this->getApplicationURI("project/{$id}/edit/");
- $history_uri = $this->getApplicationURI("project/{$id}/history/");
+ $edit_uri = $this->getApplicationURI("product/{$id}/edit/");
+ $history_uri = $this->getApplicationURI("product/{$id}/history/");
$actions->addAction(
id(new PhabricatorActionView())
@@ -203,11 +203,11 @@
if ($product->getIsActive()) {
$status_name = pht('Deactivate Product');
- $status_href = "project/{$id}/action/deactivate/";
+ $status_href = "product/{$id}/action/deactivate/";
$status_icon = 'delete';
} else {
$status_name = pht('Reactivate Product');
- $status_href = "project/{$id}/action/activate/";
+ $status_href = "product/{$id}/action/activate/";
$status_icon = 'new';
}
diff --git a/src/applications/releeph/query/ReleephBranchQuery.php b/src/applications/releeph/query/ReleephBranchQuery.php
--- a/src/applications/releeph/query/ReleephBranchQuery.php
+++ b/src/applications/releeph/query/ReleephBranchQuery.php
@@ -5,7 +5,8 @@
private $ids;
private $phids;
- private $projectIDs;
+ private $productPHIDs;
+ private $productIDs;
const STATUS_ALL = 'status-all';
const STATUS_OPEN = 'status-open';
@@ -33,8 +34,8 @@
return $this;
}
- public function withProjectIDs(array $ids) {
- $this->projectIDs = $ids;
+ public function withProductPHIDs($product_phids) {
+ $this->productPHIDs = $product_phids;
return $this;
}
@@ -53,6 +54,22 @@
return $table->loadAllFromArray($data);
}
+ public function willExecute() {
+ if ($this->productPHIDs !== null) {
+ $products = id(new ReleephProductQuery())
+ ->setViewer($this->getViewer())
+ ->withPHIDs($this->productPHIDs)
+ ->execute();
+
+ if (!$products) {
+ throw new PhabricatorEmptyQueryException();
+ }
+
+ $this->productIDs = mpull($products, 'getID');
+ }
+ }
+
+
public function willFilterPage(array $branches) {
$project_ids = mpull($branches, 'getReleephProjectID');
@@ -90,25 +107,25 @@
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->projectIDs) {
+ if ($this->productIDs !== null) {
$where[] = qsprintf(
$conn_r,
'releephProjectID IN (%Ld)',
- $this->projectIDs);
+ $this->productIDs);
}
$status = $this->status;
diff --git a/src/applications/releeph/query/ReleephBranchSearchEngine.php b/src/applications/releeph/query/ReleephBranchSearchEngine.php
--- a/src/applications/releeph/query/ReleephBranchSearchEngine.php
+++ b/src/applications/releeph/query/ReleephBranchSearchEngine.php
@@ -3,15 +3,15 @@
final class ReleephBranchSearchEngine
extends PhabricatorApplicationSearchEngine {
- private $projectID;
+ private $product;
- public function setProjectID($project_id) {
- $this->projectID = $project_id;
+ public function setProduct(ReleephProject $product) {
+ $this->product = $product;
return $this;
}
- public function getProjectID() {
- return $this->projectID;
+ public function getProduct() {
+ return $this->product;
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
@@ -25,7 +25,7 @@
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new ReleephBranchQuery())
->needCutPointCommits(true)
- ->withProjectIDs(array($this->getProjectID()));
+ ->withProductPHIDs(array($this->getProduct()->getPHID()));
$active = $saved->getParameter('active');
$value = idx($this->getActiveValues(), $active);
@@ -49,7 +49,7 @@
}
protected function getURI($path) {
- return '/releeph/project/'.$this->getProjectID().'/'.$path;
+ return '/releeph/product/'.$this->getProduct()->getID().'/'.$path;
}
public function getBuiltinQueryNames() {
diff --git a/src/applications/releeph/query/ReleephProductQuery.php b/src/applications/releeph/query/ReleephProductQuery.php
--- a/src/applications/releeph/query/ReleephProductQuery.php
+++ b/src/applications/releeph/query/ReleephProductQuery.php
@@ -6,6 +6,7 @@
private $active;
private $ids;
private $phids;
+ private $repositoryPHIDs;
private $needArcanistProjects;
@@ -33,6 +34,11 @@
return $this;
}
+ public function withRepositoryPHIDs(array $repository_phids) {
+ $this->repositoryPHIDs = $repository_phids;
+ return $this;
+ }
+
public function needArcanistProjects($need) {
$this->needArcanistProjects = $need;
return $this;
@@ -109,20 +115,27 @@
(int)$this->active);
}
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ls)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
+ if ($this->repositoryPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'repositoryPHID IN (%Ls)',
+ $this->repositoryPHIDs);
+ }
+
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sep 5 2025, 10:17 PM (12 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8743939
Default Alt Text
D8816.diff (16 KB)
Attached To
Mode
D8816: Add modern releeph.queryproducts and releeph.querybranches
Attached
Detach File
Event Timeline
Log In to Comment