From 98b0b5e62b086ab0479b73353707f7aa1afd0ab6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 29 Mar 2014 09:16:24 -0700 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 28 +++---- .../PhabricatorApplicationReleeph.php | 6 +- .../releeph/controller/ReleephController.php | 4 +- .../project/ReleephProductController.php | 6 +- ...r.php => ReleephProductListController.php} | 22 +++--- ...r.php => ReleephProductViewController.php} | 78 +++++++++++-------- ...ine.php => ReleephProductSearchEngine.php} | 10 +-- 7 files changed, 86 insertions(+), 68 deletions(-) rename src/applications/releeph/controller/project/{ReleephProjectListController.php => ReleephProductListController.php} (76%) rename src/applications/releeph/controller/project/{ReleephProjectViewController.php => ReleephProductViewController.php} (77%) rename src/applications/releeph/query/{ReleephProjectSearchEngine.php => ReleephProductSearchEngine.php} (88%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 31d4a73549..ca1888d40b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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( diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php index 6ed13ab011..d8bfa51f3e 100644 --- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php +++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php @@ -33,12 +33,12 @@ final class PhabricatorApplicationReleeph extends PhabricatorApplication { return array( '/RQ(?P[1-9]\d*)' => 'ReleephRequestViewController', '/releeph/' => array( - '' => 'ReleephProjectListController', + '' => 'ReleephProductListController', 'project/' => array( - '(?:query/(?P[^/]+)/)?' => 'ReleephProjectListController', + '(?:query/(?P[^/]+)/)?' => 'ReleephProductListController', 'create/' => 'ReleephProjectCreateController', '(?P[1-9]\d*)/' => array( - '(?:query/(?P[^/]+)/)?' => 'ReleephProjectViewController', + '(?:query/(?P[^/]+)/)?' => 'ReleephProductViewController', 'edit/' => 'ReleephProjectEditController', 'cutbranch/' => 'ReleephBranchCreateController', 'action/(?P.+)/' => 'ReleephProductActionController', diff --git a/src/applications/releeph/controller/ReleephController.php b/src/applications/releeph/controller/ReleephController.php index 1a2078ef5c..8033668e28 100644 --- a/src/applications/releeph/controller/ReleephController.php +++ b/src/applications/releeph/controller/ReleephController.php @@ -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()); diff --git a/src/applications/releeph/controller/project/ReleephProductController.php b/src/applications/releeph/controller/project/ReleephProductController.php index e14b98e80c..8125eff4a8 100644 --- a/src/applications/releeph/controller/project/ReleephProductController.php +++ b/src/applications/releeph/controller/project/ReleephProductController.php @@ -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(), diff --git a/src/applications/releeph/controller/project/ReleephProjectListController.php b/src/applications/releeph/controller/project/ReleephProductListController.php similarity index 76% rename from src/applications/releeph/controller/project/ReleephProjectListController.php rename to src/applications/releeph/controller/project/ReleephProductListController.php index 8f60723ca7..3651358dbe 100644 --- a/src/applications/releeph/controller/project/ReleephProjectListController.php +++ b/src/applications/releeph/controller/project/ReleephProductListController.php @@ -1,6 +1,6 @@ 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')); diff --git a/src/applications/releeph/controller/project/ReleephProjectViewController.php b/src/applications/releeph/controller/project/ReleephProductViewController.php similarity index 77% rename from src/applications/releeph/controller/project/ReleephProjectViewController.php rename to src/applications/releeph/controller/project/ReleephProductViewController.php index acee8f207e..44fc4fcd4b 100644 --- a/src/applications/releeph/controller/project/ReleephProjectViewController.php +++ b/src/applications/releeph/controller/project/ReleephProductViewController.php @@ -1,8 +1,9 @@ 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( diff --git a/src/applications/releeph/query/ReleephProjectSearchEngine.php b/src/applications/releeph/query/ReleephProductSearchEngine.php similarity index 88% rename from src/applications/releeph/query/ReleephProjectSearchEngine.php rename to src/applications/releeph/query/ReleephProductSearchEngine.php index 2e9685b12f..8269230c02 100644 --- a/src/applications/releeph/query/ReleephProjectSearchEngine.php +++ b/src/applications/releeph/query/ReleephProductSearchEngine.php @@ -1,6 +1,6 @@ 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'), ); }