mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-15 08:18:38 +01:00
Summary: See PHI624. Some of the mobile navigation and breadcrumbs in support pacts aren't as good as they could be. In particular, we generally collapse crumbs on mobile to just the first and last crumbs. The first crumb is the application; the last is the current page. On `/PHIxxx` pages, the first crumb isn't very useful since the Support landing page is two levels up: you usually want to go back to the pact, not all the way back to the Support landing page. We also don't need the space since the last crumb (`PHIxxx`) is always small. Allow Support and other similar applications to tailor the crumb behavior more narrowly if they end up in situations like this. Test Plan: - With an additional change to instances (see next diff), viewed a support issue page (`/PHI123`) on mobile and desktop. - Saw a link directly back to the pact on both mobile and desktop. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D19438
133 lines
2.7 KiB
PHP
133 lines
2.7 KiB
PHP
<?php
|
|
|
|
final class PHUICrumbView extends AphrontView {
|
|
|
|
private $name;
|
|
private $href;
|
|
private $icon;
|
|
private $isLastCrumb;
|
|
private $workflow;
|
|
private $aural;
|
|
private $alwaysVisible;
|
|
|
|
public function setAural($aural) {
|
|
$this->aural = $aural;
|
|
return $this;
|
|
}
|
|
|
|
public function getAural() {
|
|
return $this->aural;
|
|
}
|
|
|
|
/**
|
|
* Make this crumb always visible, even on devices where it would normally
|
|
* be hidden.
|
|
*
|
|
* @param bool True to make the crumb always visible.
|
|
* @return this
|
|
*/
|
|
public function setAlwaysVisible($always_visible) {
|
|
$this->alwaysVisible = $always_visible;
|
|
return $this;
|
|
}
|
|
|
|
public function getAlwaysVisible() {
|
|
return $this->alwaysVisible;
|
|
}
|
|
|
|
public function setWorkflow($workflow) {
|
|
$this->workflow = $workflow;
|
|
return $this;
|
|
}
|
|
|
|
public function setName($name) {
|
|
$this->name = $name;
|
|
return $this;
|
|
}
|
|
|
|
public function getName() {
|
|
return $this->name;
|
|
}
|
|
|
|
public function setHref($href) {
|
|
$this->href = $href;
|
|
return $this;
|
|
}
|
|
|
|
public function setIcon($icon) {
|
|
$this->icon = $icon;
|
|
return $this;
|
|
}
|
|
|
|
protected function canAppendChild() {
|
|
return false;
|
|
}
|
|
|
|
public function setIsLastCrumb($is_last_crumb) {
|
|
$this->isLastCrumb = $is_last_crumb;
|
|
return $this;
|
|
}
|
|
|
|
public function render() {
|
|
$classes = array(
|
|
'phui-crumb-view',
|
|
);
|
|
|
|
$aural = null;
|
|
if ($this->aural !== null) {
|
|
$aural = javelin_tag(
|
|
'span',
|
|
array(
|
|
'aural' => true,
|
|
),
|
|
$this->aural);
|
|
}
|
|
|
|
$icon = null;
|
|
if ($this->icon) {
|
|
$classes[] = 'phui-crumb-has-icon';
|
|
$icon = id(new PHUIIconView())
|
|
->setIcon($this->icon);
|
|
}
|
|
|
|
// Surround the crumb name with spaces so that double clicking it only
|
|
// selects the crumb itself.
|
|
$name = array(' ', $this->name);
|
|
|
|
$name = phutil_tag(
|
|
'span',
|
|
array(
|
|
'class' => 'phui-crumb-name',
|
|
),
|
|
$name);
|
|
|
|
// Because of text-overflow and safari, put the second space on the
|
|
// outside of the element.
|
|
$name = array($name, ' ');
|
|
|
|
$divider = null;
|
|
if (!$this->isLastCrumb) {
|
|
$divider = id(new PHUIIconView())
|
|
->setIcon('fa-angle-right')
|
|
->addClass('phui-crumb-divider')
|
|
->addClass('phui-crumb-view');
|
|
} else {
|
|
$classes[] = 'phabricator-last-crumb';
|
|
}
|
|
|
|
if ($this->getAlwaysVisible()) {
|
|
$classes[] = 'phui-crumb-always-visible';
|
|
}
|
|
|
|
$tag = javelin_tag(
|
|
$this->href ? 'a' : 'span',
|
|
array(
|
|
'sigil' => $this->workflow ? 'workflow' : null,
|
|
'href' => $this->href,
|
|
'class' => implode(' ', $classes),
|
|
),
|
|
array($aural, $icon, $name));
|
|
|
|
return array($tag, $divider);
|
|
}
|
|
}
|