1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Update Phurl to PHUITwoColumnView

Summary: Cleaner UI, moved visit to be button.

Test Plan: Make a phurl about cats, click on it.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15385
This commit is contained in:
Chad Little 2016-03-08 19:53:44 +00:00 committed by chad
parent fe01949a5c
commit e3a97e31a0

View file

@ -24,24 +24,20 @@ final class PhabricatorPhurlURLViewController
$title = $url->getMonogram(); $title = $url->getMonogram();
$page_title = $title.' '.$url->getName(); $page_title = $title.' '.$url->getName();
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, $url->getURI()); $crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
$timeline = $this->buildTransactionTimeline( $timeline = $this->buildTransactionTimeline(
$url, $url,
new PhabricatorPhurlURLTransactionQuery()); new PhabricatorPhurlURLTransactionQuery());
$header = $this->buildHeaderView($url); $header = $this->buildHeaderView($url);
$actions = $this->buildActionView($url); $curtain = $this->buildCurtain($url);
$properties = $this->buildPropertyView($url); $details = $this->buildPropertySectionView($url);
$properties->setActionList($actions);
$url_error = id(new PHUIInfoView()) $url_error = id(new PHUIInfoView())
->setErrors(array(pht('This URL is invalid due to a bad protocol.'))) ->setErrors(array(pht('This URL is invalid due to a bad protocol.')))
->setIsHidden($url->isValid()); ->setIsHidden($url->isValid());
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties)
->setInfoView($url_error);
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$add_comment_header = $is_serious $add_comment_header = $is_serious
@ -58,71 +54,80 @@ final class PhabricatorPhurlURLViewController
->setAction($comment_uri) ->setAction($comment_uri)
->setSubmitButtonName(pht('Add Comment')); ->setSubmitButtonName(pht('Add Comment'));
return $this->buildApplicationPage( $view = id(new PHUITwoColumnView())
array( ->setHeader($header)
$crumbs, ->setCurtain($curtain)
$box, ->setMainColumn(array(
$url_error,
$details,
$timeline, $timeline,
$add_comment_form, $add_comment_form,
),
array(
'title' => $page_title,
'pageObjects' => array($url->getPHID()),
)); ));
return $this->newPage()
->setTitle($page_title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($url->getPHID()))
->appendChild(
array(
$view,
));
} }
private function buildHeaderView(PhabricatorPhurlURL $url) { private function buildHeaderView(PhabricatorPhurlURL $url) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$icon = 'fa-compress'; $icon = 'fa-check';
$color = 'green'; $color = 'bluegrey';
$status = pht('Active'); $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()) $header = id(new PHUIHeaderView())
->setUser($viewer) ->setUser($viewer)
->setHeader($url->getDisplayName()) ->setHeader($url->getDisplayName())
->setStatus($icon, $color, $status) ->setStatus($icon, $color, $status)
->setPolicyObject($url); ->setPolicyObject($url)
->setHeaderIcon('fa-compress')
->addActionLink($visit);
return $header; return $header;
} }
private function buildActionView(PhabricatorPhurlURL $url) { private function buildCurtain(PhabricatorPhurlURL $url) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$id = $url->getID(); $id = $url->getID();
$actions = id(new PhabricatorActionListView()) $curtain = $this->newCurtainView($url);
->setUser($viewer)
->setObject($url);
$can_edit = PhabricatorPolicyFilter::hasCapability( $can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer, $viewer,
$url, $url,
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
$actions $curtain
->addAction( ->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setName(pht('Edit')) ->setName(pht('Edit'))
->setIcon('fa-pencil') ->setIcon('fa-pencil')
->setHref($this->getApplicationURI("url/edit/{$id}/")) ->setHref($this->getApplicationURI("url/edit/{$id}/"))
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)) ->setWorkflow(!$can_edit));
->addAction(
id(new PhabricatorActionView())
->setName(pht('Visit URL'))
->setIcon('fa-external-link')
->setHref("u/{$id}")
->setDisabled(!$url->isValid()));
return $actions; return $curtain;
} }
private function buildPropertyView(PhabricatorPhurlURL $url) { private function buildPropertySectionView(PhabricatorPhurlURL $url) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView()) $properties = id(new PHUIPropertyListView())
->setUser($viewer) ->setUser($viewer);
->setObject($url);
$properties->addProperty( $properties->addProperty(
pht('Original URL'), pht('Original URL'),
@ -132,18 +137,17 @@ final class PhabricatorPhurlURLViewController
pht('Alias'), pht('Alias'),
$url->getAlias()); $url->getAlias());
$properties->invokeWillRenderEvent();
$description = $url->getDescription(); $description = $url->getDescription();
if (strlen($description)) { if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description); $description = new PHUIRemarkupView($viewer, $description);
$properties->addSectionHeader( $properties->addSectionHeader(pht('Description'));
pht('Description'),
PHUIPropertyListView::ICON_SUMMARY);
$properties->addTextContent($description); $properties->addTextContent($description);
} }
return $properties; return id(new PHUIObjectBoxView())
->setHeaderText(pht('DETAILS'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($properties);
} }
} }