diff --git a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php index 4703adade5..1c9a66f237 100644 --- a/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php +++ b/src/applications/phurl/controller/PhabricatorPhurlURLViewController.php @@ -1,153 +1,153 @@ getViewer(); $id = $request->getURIData('id'); $timeline = null; $url = id(new PhabricatorPhurlURLQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$url) { return new Aphront404Response(); } $title = $url->getMonogram(); $page_title = $title.' '.$url->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $timeline = $this->buildTransactionTimeline( $url, new PhabricatorPhurlURLTransactionQuery()); $header = $this->buildHeaderView($url); $curtain = $this->buildCurtain($url); $details = $this->buildPropertySectionView($url); $url_error = id(new PHUIInfoView()) ->setErrors(array(pht('This URL is invalid due to a bad protocol.'))) ->setIsHidden($url->isValid()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $add_comment_header = $is_serious ? pht('Add Comment') : pht('More Cowbell'); $draft = PhabricatorDraft::newFromUserAndKey($viewer, $url->getPHID()); $comment_uri = $this->getApplicationURI( '/url/comment/'.$url->getID().'/'); $add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) ->setUser($viewer) ->setObjectPHID($url->getPHID()) ->setDraft($draft) ->setHeaderText($add_comment_header) ->setAction($comment_uri) ->setSubmitButtonName(pht('Add Comment')); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->setMainColumn(array( $url_error, $details, $timeline, $add_comment_form, )); return $this->newPage() ->setTitle($page_title) ->setCrumbs($crumbs) ->setPageObjectPHIDs(array($url->getPHID())) ->appendChild( array( $view, )); } private function buildHeaderView(PhabricatorPhurlURL $url) { $viewer = $this->getViewer(); $icon = 'fa-check'; $color = 'bluegrey'; $status = pht('Active'); $id = $url->getID(); $visit = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Visit URL')) ->setIcon('fa-external-link') ->setHref("u/{$id}") ->setDisabled(!$url->isValid()); $header = id(new PHUIHeaderView()) ->setUser($viewer) ->setHeader($url->getDisplayName()) ->setStatus($icon, $color, $status) ->setPolicyObject($url) ->setHeaderIcon('fa-compress') ->addActionLink($visit); return $header; } private function buildCurtain(PhabricatorPhurlURL $url) { $viewer = $this->getViewer(); $id = $url->getID(); $curtain = $this->newCurtainView($url); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $url, PhabricatorPolicyCapability::CAN_EDIT); $curtain ->addAction( id(new PhabricatorActionView()) - ->setName(pht('Edit')) + ->setName(pht('Edit Phurl')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI("url/edit/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); return $curtain; } private function buildPropertySectionView(PhabricatorPhurlURL $url) { $viewer = $this->getViewer(); $properties = id(new PHUIPropertyListView()) ->setUser($viewer); $properties->addProperty( pht('Original URL'), $url->getLongURL()); $properties->addProperty( pht('Alias'), $url->getAlias()); $description = $url->getDescription(); if (strlen($description)) { $description = new PHUIRemarkupView($viewer, $description); $properties->addSectionHeader(pht('Description')); $properties->addTextContent($description); } return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Details')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($properties); } } diff --git a/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php b/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php index c652cfffdf..db40c263ad 100644 --- a/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php +++ b/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php @@ -1,113 +1,119 @@ setLabel(pht('Created By')) ->setKey('authorPHIDs') ->setDatasource(new PhabricatorPeopleUserFunctionDatasource()), ); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); if ($map['authorPHIDs']) { $query->withAuthorPHIDs($map['authorPHIDs']); } return $query; } protected function getURI($path) { return '/phurl/'.$path; } protected function getBuiltinQueryNames() { $names = array( - 'authored' => pht('Authored'), 'all' => pht('All URLs'), + 'authored' => pht('Authored'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); $viewer = $this->requireViewer(); switch ($query_key) { case 'authored': return $query->setParameter('authorPHIDs', array($viewer->getPHID())); case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $urls, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($urls, 'PhabricatorPhurlURL'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $handles = $viewer->loadHandles(mpull($urls, 'getAuthorPHID')); foreach ($urls as $url) { + $name = $url->getName(); + $item = id(new PHUIObjectItemView()) ->setUser($viewer) ->setObject($url) - ->setHeader($viewer->renderHandle($url->getPHID())); + ->setObjectName('U'.$url->getID()) + ->setHeader($name) + ->setHref('/U'.$url->getID()) + ->addAttribute($url->getAlias()) + ->addAttribute($url->getLongURL()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No URLs found.')); return $result; } protected function getNewUserBody() { $create_button = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Shorten a URL')) ->setHref('/phurl/url/create/') ->setColor(PHUIButtonView::GREEN); $icon = $this->getApplication()->getIcon(); $app_name = $this->getApplication()->getName(); $view = id(new PHUIBigInfoView()) ->setIcon($icon) ->setTitle(pht('Welcome to %s', $app_name)) ->setDescription( pht('Create reusable, memorable, shorter URLs for easy accessibility.')) ->addAction($create_button); return $view; } }