2012-12-07 13:35:17 -08:00
|
|
|
<?php
|
|
|
|
|
2015-01-23 11:35:09 -08:00
|
|
|
final class PHUICrumbView extends AphrontView {
|
2012-12-07 13:35:17 -08:00
|
|
|
|
|
|
|
private $name;
|
|
|
|
private $href;
|
|
|
|
private $icon;
|
|
|
|
private $isLastCrumb;
|
2013-05-24 10:50:18 -07:00
|
|
|
private $workflow;
|
2014-05-01 08:55:45 -07:00
|
|
|
private $aural;
|
2018-05-09 11:25:08 -07:00
|
|
|
private $alwaysVisible;
|
2014-05-01 08:55:45 -07:00
|
|
|
|
|
|
|
public function setAural($aural) {
|
|
|
|
$this->aural = $aural;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAural() {
|
|
|
|
return $this->aural;
|
|
|
|
}
|
2013-05-24 10:50:18 -07:00
|
|
|
|
2018-05-09 11:25:08 -07:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2013-05-24 10:50:18 -07:00
|
|
|
public function setWorkflow($workflow) {
|
|
|
|
$this->workflow = $workflow;
|
|
|
|
return $this;
|
|
|
|
}
|
2012-12-07 13:35:17 -08:00
|
|
|
|
|
|
|
public function setName($name) {
|
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-01-25 17:07:07 -08:00
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-12 17:50:42 -08:00
|
|
|
}
|
|
|
|
|
2012-12-07 13:35:17 -08:00
|
|
|
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(
|
2015-01-23 11:35:09 -08:00
|
|
|
'phui-crumb-view',
|
2012-12-07 13:35:17 -08:00
|
|
|
);
|
|
|
|
|
2014-05-01 08:55:45 -07:00
|
|
|
$aural = null;
|
|
|
|
if ($this->aural !== null) {
|
|
|
|
$aural = javelin_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'aural' => true,
|
|
|
|
),
|
|
|
|
$this->aural);
|
|
|
|
}
|
|
|
|
|
2012-12-07 13:35:17 -08:00
|
|
|
$icon = null;
|
|
|
|
if ($this->icon) {
|
2015-01-23 11:35:09 -08:00
|
|
|
$classes[] = 'phui-crumb-has-icon';
|
2015-01-26 08:27:54 -08:00
|
|
|
$icon = id(new PHUIIconView())
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon($this->icon);
|
2012-12-07 13:35:17 -08:00
|
|
|
}
|
|
|
|
|
2016-02-12 11:10:04 -08:00
|
|
|
// Surround the crumb name with spaces so that double clicking it only
|
|
|
|
// selects the crumb itself.
|
2017-03-08 17:52:57 -08:00
|
|
|
$name = array(' ', $this->name);
|
2016-02-12 11:10:04 -08:00
|
|
|
|
2013-01-25 17:07:07 -08:00
|
|
|
$name = phutil_tag(
|
2012-12-07 13:35:17 -08:00
|
|
|
'span',
|
|
|
|
array(
|
2015-01-23 11:35:09 -08:00
|
|
|
'class' => 'phui-crumb-name',
|
2012-12-07 13:35:17 -08:00
|
|
|
),
|
2016-02-12 11:10:04 -08:00
|
|
|
$name);
|
2012-12-07 13:35:17 -08:00
|
|
|
|
2017-03-08 17:52:57 -08:00
|
|
|
// Because of text-overflow and safari, put the second space on the
|
|
|
|
// outside of the element.
|
|
|
|
$name = array($name, ' ');
|
|
|
|
|
2012-12-07 13:35:17 -08:00
|
|
|
$divider = null;
|
|
|
|
if (!$this->isLastCrumb) {
|
2015-01-26 08:27:54 -08:00
|
|
|
$divider = id(new PHUIIconView())
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon('fa-angle-right')
|
2015-01-26 08:27:54 -08:00
|
|
|
->addClass('phui-crumb-divider')
|
|
|
|
->addClass('phui-crumb-view');
|
2013-03-26 13:15:15 -07:00
|
|
|
} else {
|
|
|
|
$classes[] = 'phabricator-last-crumb';
|
2012-12-07 13:35:17 -08:00
|
|
|
}
|
|
|
|
|
2018-05-09 11:25:08 -07:00
|
|
|
if ($this->getAlwaysVisible()) {
|
|
|
|
$classes[] = 'phui-crumb-always-visible';
|
|
|
|
}
|
|
|
|
|
2015-01-26 08:27:54 -08:00
|
|
|
$tag = javelin_tag(
|
2012-12-07 13:35:17 -08:00
|
|
|
$this->href ? 'a' : 'span',
|
2013-05-24 10:50:18 -07:00
|
|
|
array(
|
|
|
|
'sigil' => $this->workflow ? 'workflow' : null,
|
|
|
|
'href' => $this->href,
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
),
|
2015-01-26 08:27:54 -08:00
|
|
|
array($aural, $icon, $name));
|
|
|
|
|
|
|
|
return array($tag, $divider);
|
2012-12-07 13:35:17 -08:00
|
|
|
}
|
|
|
|
}
|