1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Rename more project -> product in Releeph

Summary:
Ref T3549.

  - Renames most "project" in view/list controllers.
  - Moves away from "ProjectController".
  - Modernizes some modern UI.

Test Plan:
  - Viewed product lists.
  - Viewed product detail pages.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3549

Differential Revision: https://secure.phabricator.com/D8635
This commit is contained in:
epriestley 2014-03-29 09:16:24 -07:00
parent c7bcecb9b0
commit 98b0b5e62b
7 changed files with 86 additions and 68 deletions

View file

@ -2518,16 +2518,16 @@ phutil_register_library_map(array(
'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php',
'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php',
'ReleephProductHistoryController' => 'applications/releeph/controller/project/ReleephProductHistoryController.php',
'ReleephProductListController' => 'applications/releeph/controller/project/ReleephProductListController.php',
'ReleephProductSearchEngine' => 'applications/releeph/query/ReleephProductSearchEngine.php',
'ReleephProductTransaction' => 'applications/releeph/storage/ReleephProductTransaction.php',
'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php',
'ReleephProductViewController' => 'applications/releeph/controller/project/ReleephProductViewController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php',
'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php',
'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php',
'ReleephProjectListController' => 'applications/releeph/controller/project/ReleephProjectListController.php',
'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.php',
'ReleephProjectSearchEngine' => 'applications/releeph/query/ReleephProjectSearchEngine.php',
'ReleephProjectViewController' => 'applications/releeph/controller/project/ReleephProjectViewController.php',
'ReleephReasonFieldSpecification' => 'applications/releeph/field/specification/ReleephReasonFieldSpecification.php',
'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php',
'ReleephRequestActionController' => 'applications/releeph/controller/request/ReleephRequestActionController.php',
@ -5493,8 +5493,19 @@ phutil_register_library_map(array(
'ReleephProductController' => 'ReleephController',
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
'ReleephProductHistoryController' => 'ReleephProductController',
'ReleephProductListController' =>
array(
0 => 'ReleephController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine',
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',
'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'ReleephProductViewController' =>
array(
0 => 'ReleephProductController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProject' =>
array(
0 => 'ReleephDAO',
@ -5503,18 +5514,7 @@ phutil_register_library_map(array(
'ReleephProjectController' => 'ReleephController',
'ReleephProjectCreateController' => 'ReleephProjectController',
'ReleephProjectEditController' => 'ReleephProjectController',
'ReleephProjectListController' =>
array(
0 => 'ReleephController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ReleephProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
'ReleephProjectViewController' =>
array(
0 => 'ReleephProjectController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification',
'ReleephRequest' =>
array(

View file

@ -33,12 +33,12 @@ final class PhabricatorApplicationReleeph extends PhabricatorApplication {
return array(
'/RQ(?P<requestID>[1-9]\d*)' => 'ReleephRequestViewController',
'/releeph/' => array(
'' => 'ReleephProjectListController',
'' => 'ReleephProductListController',
'project/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProjectListController',
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductListController',
'create/' => 'ReleephProjectCreateController',
'(?P<projectID>[1-9]\d*)/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProjectViewController',
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductViewController',
'edit/' => 'ReleephProjectEditController',
'cutbranch/' => 'ReleephBranchCreateController',
'action/(?P<action>.+)/' => 'ReleephProductActionController',

View file

@ -22,10 +22,10 @@ abstract class ReleephController extends PhabricatorController {
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('project/create/', pht('Create Project'));
$nav->addFilter('project/create/', pht('Create Product'));
}
id(new ReleephProjectSearchEngine())
id(new ReleephProductSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());

View file

@ -9,6 +9,10 @@ abstract class ReleephProductController extends ReleephController {
return $this;
}
protected function getProduct() {
return $this->product;
}
protected function getProductViewURI(ReleephProject $product) {
return $this->getApplicationURI('project/'.$product->getID().'/');
}
@ -16,7 +20,7 @@ abstract class ReleephProductController extends ReleephController {
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$product = $this->product;
$product = $this->getProduct();
if ($product) {
$crumbs->addTextCrumb(
$product->getName(),

View file

@ -1,6 +1,6 @@
<?php
final class ReleephProjectListController extends ReleephController
final class ReleephProductListController extends ReleephController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
@ -17,34 +17,34 @@ final class ReleephProjectListController extends ReleephController
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new ReleephProjectSearchEngine())
->setSearchEngine(new ReleephProductSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(
array $projects,
array $products,
PhabricatorSavedQuery $query) {
assert_instances_of($projects, 'ReleephProject');
assert_instances_of($products, 'ReleephProject');
$viewer = $this->getRequest()->getUser();
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($projects as $project) {
$id = $project->getID();
foreach ($products as $product) {
$id = $product->getID();
$item = id(new PHUIObjectItemView())
->setHeader($project->getName())
->setHeader($product->getName())
->setHref($this->getApplicationURI("project/{$id}/"));
if (!$project->getIsActive()) {
if (!$product->getIsActive()) {
$item->setDisabled(true);
$item->addIcon('none', pht('Inactive'));
}
$repo = $project->getRepository();
$repo = $product->getRepository();
$item->addAttribute(
phutil_tag(
'a',
@ -53,7 +53,7 @@ final class ReleephProjectListController extends ReleephController
),
'r'.$repo->getCallsign()));
$arc = $project->loadArcanistProject();
$arc = $product->loadArcanistProject();
if ($arc) {
$item->addAttribute($arc->getName());
}
@ -69,7 +69,7 @@ final class ReleephProjectListController extends ReleephController
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Project'))
->setName(pht('Create Product'))
->setHref($this->getApplicationURI('project/create/'))
->setIcon('create'));

View file

@ -1,8 +1,9 @@
<?php
final class ReleephProjectViewController extends ReleephProjectController
final class ReleephProductViewController extends ReleephProductController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $productID;
private $queryKey;
public function shouldAllowPublic() {
@ -10,18 +11,29 @@ final class ReleephProjectViewController extends ReleephProjectController
}
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
$this->productID = idx($data, 'projectID');
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProjectQuery())
->setViewer($viewer)
->withIDs(array($this->productID))
->executeOne();
if (!$product) {
return new Aphront404Response();
}
$this->setProduct($product);
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setPreface($this->renderPreface())
->setSearchEngine(
id(new ReleephBranchSearchEngine())
->setProjectID($this->getReleephProject()->getID()))
->setProjectID($product->getID()))
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
@ -34,8 +46,8 @@ final class ReleephProjectViewController extends ReleephProjectController
$viewer = $this->getRequest()->getUser();
$projects = mpull($branches, 'getProject');
$repo_phids = mpull($projects, 'getRepositoryPHID');
$products = mpull($branches, 'getProject');
$repo_phids = mpull($products, 'getRepositoryPHID');
$repos = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
@ -116,18 +128,19 @@ final class ReleephProjectViewController extends ReleephProjectController
}
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$viewer = $this->getRequest()->getUser();
$product = $this->getProduct();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('project/create/', pht('Create Project'));
$nav->addFilter('project/create/', pht('Create Product'));
}
id(new ReleephBranchSearchEngine())
->setProjectID($this->getReleephProject()->getID())
->setViewer($user)
->setProjectID($product->getID())
->setViewer($viewer)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
@ -138,42 +151,43 @@ final class ReleephProjectViewController extends ReleephProjectController
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$project = $this->getReleephProject();
$crumbs->addAction(
id(new PHUIListItemView())
->setHref($project->getURI('cutbranch'))
->setName(pht('Cut New Branch'))
->setIcon('create'));
$product = $this->getProduct();
if ($product) {
$crumbs->addAction(
id(new PHUIListItemView())
->setHref($product->getURI('cutbranch/'))
->setName(pht('Cut New Branch'))
->setIcon('create'));
}
return $crumbs;
}
private function renderPreface() {
$project = $this->getReleephProject();
$viewer = $this->getRequest()->getUser();
$product = $this->getProduct();
$id = $project->getID();
$id = $product->getID();
$header = id(new PHUIHeaderView())
->setHeader($project->getName());
->setHeader($product->getName())
->setUser($viewer)
->setPolicyObject($product);
if (!$project->getIsActive()) {
$header->addTag(
id(new PHUITagView())
->setType(PHUITagView::TYPE_STATE)
->setBackgroundColor(PHUITagView::COLOR_BLACK)
->setName(pht('Deactivated')));
if ($product->getIsActive()) {
$header->setStatus('oh-ok', '', pht('Active'));
} else {
$header->setStatus('policy-noone', '', pht('Inactive'));
}
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($project)
->setObject($product)
->setObjectURI($this->getRequest()->getRequestURI());
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$project,
$product,
PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = $this->getApplicationURI("project/{$id}/edit/");
@ -181,13 +195,13 @@ final class ReleephProjectViewController extends ReleephProjectController
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Project'))
->setName(pht('Edit Product'))
->setHref($edit_uri)
->setIcon('edit')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
if ($project->getIsActive()) {
if ($product->getIsActive()) {
$status_name = pht('Deactivate Product');
$status_href = "project/{$id}/action/deactivate/";
$status_icon = 'delete';
@ -213,15 +227,15 @@ final class ReleephProjectViewController extends ReleephProjectController
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($project);
->setObject($product);
$properties->addProperty(
pht('Repository'),
$project->getRepository()->getName());
$product->getRepository()->getName());
$properties->setActionList($actions);
$pushers = $project->getPushers();
$pushers = $product->getPushers();
if ($pushers) {
$this->loadHandles($pushers);
$properties->addProperty(

View file

@ -1,6 +1,6 @@
<?php
final class ReleephProjectSearchEngine
final class ReleephProductSearchEngine
extends PhabricatorApplicationSearchEngine {
public function buildSavedQueryFromRequest(AphrontRequest $request) {
@ -31,7 +31,7 @@ final class ReleephProjectSearchEngine
$form->appendChild(
id(new AphrontFormSelectControl())
->setName('active')
->setLabel(pht('Show Projects'))
->setLabel(pht('Show Products'))
->setValue($saved_query->getParameter('active'))
->setOptions($this->getActiveOptions()));
@ -68,9 +68,9 @@ final class ReleephProjectSearchEngine
private function getActiveOptions() {
return array(
'all' => pht('Active and Inactive Projects'),
'active' => pht('Active Projects'),
'inactive' => pht('Inactive Projects'),
'all' => pht('Active and Inactive Products'),
'active' => pht('Active Prodcuts'),
'inactive' => pht('Inactive Products'),
);
}