1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 06:50:55 +01: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', 'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php',
'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php', 'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php',
'ReleephProductHistoryController' => 'applications/releeph/controller/project/ReleephProductHistoryController.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', 'ReleephProductTransaction' => 'applications/releeph/storage/ReleephProductTransaction.php',
'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php', 'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php',
'ReleephProductViewController' => 'applications/releeph/controller/project/ReleephProductViewController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php', 'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php', 'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php',
'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php', 'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php',
'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php', 'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php',
'ReleephProjectListController' => 'applications/releeph/controller/project/ReleephProjectListController.php',
'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.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', 'ReleephReasonFieldSpecification' => 'applications/releeph/field/specification/ReleephReasonFieldSpecification.php',
'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php', 'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php',
'ReleephRequestActionController' => 'applications/releeph/controller/request/ReleephRequestActionController.php', 'ReleephRequestActionController' => 'applications/releeph/controller/request/ReleephRequestActionController.php',
@ -5493,8 +5493,19 @@ phutil_register_library_map(array(
'ReleephProductController' => 'ReleephController', 'ReleephProductController' => 'ReleephController',
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor', 'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
'ReleephProductHistoryController' => 'ReleephProductController', 'ReleephProductHistoryController' => 'ReleephProductController',
'ReleephProductListController' =>
array(
0 => 'ReleephController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine',
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction', 'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',
'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'ReleephProductViewController' =>
array(
0 => 'ReleephProductController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProject' => 'ReleephProject' =>
array( array(
0 => 'ReleephDAO', 0 => 'ReleephDAO',
@ -5503,18 +5514,7 @@ phutil_register_library_map(array(
'ReleephProjectController' => 'ReleephController', 'ReleephProjectController' => 'ReleephController',
'ReleephProjectCreateController' => 'ReleephProjectController', 'ReleephProjectCreateController' => 'ReleephProjectController',
'ReleephProjectEditController' => 'ReleephProjectController', 'ReleephProjectEditController' => 'ReleephProjectController',
'ReleephProjectListController' =>
array(
0 => 'ReleephController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ReleephProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
'ReleephProjectViewController' =>
array(
0 => 'ReleephProjectController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification',
'ReleephRequest' => 'ReleephRequest' =>
array( array(

View file

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

View file

@ -22,10 +22,10 @@ abstract class ReleephController extends PhabricatorController {
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) { 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) ->setViewer($user)
->addNavigationItems($nav->getMenu()); ->addNavigationItems($nav->getMenu());

View file

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

View file

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

View file

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

View file

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