From feca8fbdece3ca631db09a03450dd969937bd920 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 13 Nov 2015 07:06:59 +1100 Subject: [PATCH] Use monograms for Herald URIs Summary: I think `HeraldRule`s are the only objects which have monograms but are not accesible via `/{$monogram}`. This diff changes the `/herald/rule/{$id}` URI to `/{$monogram}`. Test Plan: Clicked a bunch of links in Herald to ensure there were no dead links. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14469 --- .../application/PhabricatorHeraldApplication.php | 2 +- .../herald/controller/HeraldDisableController.php | 2 +- .../herald/controller/HeraldRuleController.php | 4 ++-- .../herald/controller/HeraldRuleViewController.php | 2 +- src/applications/herald/phid/HeraldRulePHIDType.php | 10 +++++----- .../herald/query/HeraldRuleSearchEngine.php | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/applications/herald/application/PhabricatorHeraldApplication.php b/src/applications/herald/application/PhabricatorHeraldApplication.php index e3537d9722..bef94b6ac4 100644 --- a/src/applications/herald/application/PhabricatorHeraldApplication.php +++ b/src/applications/herald/application/PhabricatorHeraldApplication.php @@ -47,10 +47,10 @@ final class PhabricatorHeraldApplication extends PhabricatorApplication { public function getRoutes() { return array( + '/H(?P[1-9]\d*)' => 'HeraldRuleViewController', '/herald/' => array( '(?:query/(?P[^/]+)/)?' => 'HeraldRuleListController', 'new/' => 'HeraldNewController', - 'rule/(?P[1-9]\d*)/' => 'HeraldRuleViewController', 'edit/(?:(?P[1-9]\d*)/)?' => 'HeraldRuleController', 'disable/(?P[1-9]\d*)/(?P\w+)/' => 'HeraldDisableController', diff --git a/src/applications/herald/controller/HeraldDisableController.php b/src/applications/herald/controller/HeraldDisableController.php index 054f30e7d3..bdbefa55ea 100644 --- a/src/applications/herald/controller/HeraldDisableController.php +++ b/src/applications/herald/controller/HeraldDisableController.php @@ -25,7 +25,7 @@ final class HeraldDisableController extends HeraldController { HeraldManageGlobalRulesCapability::CAPABILITY); } - $view_uri = $this->getApplicationURI("rule/{$id}/"); + $view_uri = '/'.$rule->getMonogram(); $is_disable = ($action === 'disable'); diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 37a583c7ef..510113b0de 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -22,7 +22,7 @@ final class HeraldRuleController extends HeraldController { if (!$rule) { return new Aphront404Response(); } - $cancel_uri = $this->getApplicationURI("rule/{$id}/"); + $cancel_uri = '/'.$rule->getMonogram(); } else { $new_uri = $this->getApplicationURI('new/'); @@ -128,7 +128,7 @@ final class HeraldRuleController extends HeraldController { list($e_name, $errors) = $this->saveRule($adapter, $rule, $request); if (!$errors) { $id = $rule->getID(); - $uri = $this->getApplicationURI("rule/{$id}/"); + $uri = '/'.$rule->getMonogram(); return id(new AphrontRedirectResponse())->setURI($uri); } } diff --git a/src/applications/herald/controller/HeraldRuleViewController.php b/src/applications/herald/controller/HeraldRuleViewController.php index f6ec235a9e..2063ebcc2f 100644 --- a/src/applications/herald/controller/HeraldRuleViewController.php +++ b/src/applications/herald/controller/HeraldRuleViewController.php @@ -67,7 +67,7 @@ final class HeraldRuleViewController extends HeraldController { $view = id(new PhabricatorActionListView()) ->setUser($viewer) ->setObject($rule) - ->setObjectURI($this->getApplicationURI("rule/{$id}/")); + ->setObjectURI('/'.$rule->getMonogram()); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, diff --git a/src/applications/herald/phid/HeraldRulePHIDType.php b/src/applications/herald/phid/HeraldRulePHIDType.php index f8d5c25db4..34c6d80c5f 100644 --- a/src/applications/herald/phid/HeraldRulePHIDType.php +++ b/src/applications/herald/phid/HeraldRulePHIDType.php @@ -32,12 +32,12 @@ final class HeraldRulePHIDType extends PhabricatorPHIDType { foreach ($handles as $phid => $handle) { $rule = $objects[$phid]; - $id = $rule->getID(); - $name = $rule->getName(); + $monogram = $rule->getMonogram(); + $name = $rule->getName(); - $handle->setName("H{$id}"); - $handle->setFullName("H{$id} {$name}"); - $handle->setURI("/herald/rule/{$id}/"); + $handle->setName($monogram); + $handle->setFullName("{$monogram} {$name}"); + $handle->setURI("/{$monogram}"); } } diff --git a/src/applications/herald/query/HeraldRuleSearchEngine.php b/src/applications/herald/query/HeraldRuleSearchEngine.php index 04b7a5d852..ad4c9a7ad2 100644 --- a/src/applications/herald/query/HeraldRuleSearchEngine.php +++ b/src/applications/herald/query/HeraldRuleSearchEngine.php @@ -173,12 +173,12 @@ final class HeraldRuleSearchEngine extends PhabricatorApplicationSearchEngine { $list = id(new PHUIObjectItemListView()) ->setUser($viewer); foreach ($rules as $rule) { - $id = $rule->getID(); + $monogram = $rule->getMonogram(); $item = id(new PHUIObjectItemView()) - ->setObjectName("H{$id}") + ->setObjectName($monogram) ->setHeader($rule->getName()) - ->setHref($this->getApplicationURI("rule/{$id}/")); + ->setHref("/{$monogram}"); if ($rule->isPersonalRule()) { $item->addIcon('fa-user', pht('Personal Rule'));