2012-08-15 19:45:06 +02:00
|
|
|
<?php
|
|
|
|
|
2015-05-12 15:55:46 +02:00
|
|
|
final class PHUIHeaderView extends AphrontTagView {
|
2013-09-17 18:12:37 +02:00
|
|
|
|
2013-09-24 17:42:04 +02:00
|
|
|
const PROPERTY_STATUS = 1;
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
private $objectName;
|
|
|
|
private $header;
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
private $tags = array();
|
2013-07-10 01:23:22 +02:00
|
|
|
private $image;
|
2014-05-08 23:21:32 +02:00
|
|
|
private $imageURL = null;
|
2013-07-10 01:23:22 +02:00
|
|
|
private $subheader;
|
2015-05-18 19:00:15 +02:00
|
|
|
private $headerIcon;
|
2013-09-05 21:29:07 +02:00
|
|
|
private $noBackground;
|
|
|
|
private $bleedHeader;
|
2015-05-31 17:36:44 +02:00
|
|
|
private $tall;
|
2013-09-19 20:56:58 +02:00
|
|
|
private $properties = array();
|
2013-12-03 17:34:04 +01:00
|
|
|
private $actionLinks = array();
|
2014-02-16 18:25:29 +01:00
|
|
|
private $buttonBar = null;
|
2013-09-19 20:56:58 +02:00
|
|
|
private $policyObject;
|
Add setEpoch for PHUIHeaderView, use in all Documents
Summary: Sets a consistent last update time in the header of PHUIDocuments, Legalpad, Diviner, Phriction. I'm not set on the exact language, just that there is consistency, feel free to suggest changes.
Test Plan:
Test Legalpad, Diviner, Phriction.
{F368270}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12384
2015-04-13 03:08:09 +02:00
|
|
|
private $epoch;
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
private $actionIcons = array();
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
public function setHeader($header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setObjectName($object_name) {
|
|
|
|
$this->objectName = $object_name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-05 21:29:07 +02:00
|
|
|
public function setNoBackground($nada) {
|
|
|
|
$this->noBackground = $nada;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-05-31 17:36:44 +02:00
|
|
|
public function setTall($tall) {
|
|
|
|
$this->tall = $tall;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-14 23:09:52 +01:00
|
|
|
public function addTag(PHUITagView $tag) {
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
$this->tags[] = $tag;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-07-10 01:23:22 +02:00
|
|
|
public function setImage($uri) {
|
|
|
|
$this->image = $uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-05-08 23:21:32 +02:00
|
|
|
public function setImageURL($url) {
|
|
|
|
$this->imageURL = $url;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-07-10 01:23:22 +02:00
|
|
|
public function setSubheader($subheader) {
|
|
|
|
$this->subheader = $subheader;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-05 21:29:07 +02:00
|
|
|
public function setBleedHeader($bleed) {
|
|
|
|
$this->bleedHeader = $bleed;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:00:15 +02:00
|
|
|
public function setHeaderIcon($icon) {
|
|
|
|
$this->headerIcon = $icon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:56:58 +02:00
|
|
|
public function setPolicyObject(PhabricatorPolicyInterface $object) {
|
|
|
|
$this->policyObject = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
public function addProperty($property, $value) {
|
|
|
|
$this->properties[$property] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-12-03 17:34:04 +01:00
|
|
|
public function addActionLink(PHUIButtonView $button) {
|
|
|
|
$this->actionLinks[] = $button;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
public function addActionIcon(PHUIIconView $action) {
|
|
|
|
$this->actionIcons[] = $action;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-02-16 18:25:29 +01:00
|
|
|
public function setButtonBar(PHUIButtonBarView $bb) {
|
|
|
|
$this->buttonBar = $bb;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-10-07 02:10:29 +02:00
|
|
|
public function setStatus($icon, $color, $name) {
|
|
|
|
$header_class = 'phui-header-status';
|
|
|
|
|
|
|
|
if ($color) {
|
2014-05-19 01:10:54 +02:00
|
|
|
$icon = $icon.' '.$color;
|
2013-10-07 02:10:29 +02:00
|
|
|
$header_class = $header_class.'-'.$color;
|
|
|
|
}
|
|
|
|
|
|
|
|
$img = id(new PHUIIconView())
|
2014-05-19 01:10:54 +02:00
|
|
|
->setIconFont($icon);
|
2013-10-07 02:10:29 +02:00
|
|
|
|
|
|
|
$tag = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => "{$header_class} plr",
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$img,
|
|
|
|
$name,
|
|
|
|
));
|
|
|
|
|
|
|
|
return $this->addProperty(self::PROPERTY_STATUS, $tag);
|
|
|
|
}
|
|
|
|
|
Add setEpoch for PHUIHeaderView, use in all Documents
Summary: Sets a consistent last update time in the header of PHUIDocuments, Legalpad, Diviner, Phriction. I'm not set on the exact language, just that there is consistency, feel free to suggest changes.
Test Plan:
Test Legalpad, Diviner, Phriction.
{F368270}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12384
2015-04-13 03:08:09 +02:00
|
|
|
public function setEpoch($epoch) {
|
|
|
|
$age = time() - $epoch;
|
|
|
|
$age = floor($age / (60 * 60 * 24));
|
|
|
|
if ($age < 1) {
|
|
|
|
$when = pht('Today');
|
|
|
|
} else if ($age == 1) {
|
|
|
|
$when = pht('Yesterday');
|
|
|
|
} else {
|
|
|
|
$when = pht('%d Days Ago', $age);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->setStatus('fa-clock-o bluegrey', null, pht('Updated %s', $when));
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-05-12 15:55:46 +02:00
|
|
|
protected function getTagName() {
|
|
|
|
return 'div';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagAttributes() {
|
2013-09-17 18:12:37 +02:00
|
|
|
require_celerity_resource('phui-header-view-css');
|
2012-08-15 19:45:06 +02:00
|
|
|
|
2013-07-10 14:11:08 +02:00
|
|
|
$classes = array();
|
2013-09-17 18:12:37 +02:00
|
|
|
$classes[] = 'phui-header-shell';
|
2013-07-10 14:11:08 +02:00
|
|
|
|
2013-09-05 21:29:07 +02:00
|
|
|
if ($this->noBackground) {
|
2013-09-17 18:12:37 +02:00
|
|
|
$classes[] = 'phui-header-no-backgound';
|
2013-09-05 21:29:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->bleedHeader) {
|
2013-09-18 23:57:34 +02:00
|
|
|
$classes[] = 'phui-bleed-header';
|
2013-09-05 21:29:07 +02:00
|
|
|
}
|
|
|
|
|
2015-05-31 17:36:44 +02:00
|
|
|
if ($this->properties || $this->policyObject ||
|
|
|
|
$this->subheader || $this->tall) {
|
2013-09-17 18:12:37 +02:00
|
|
|
$classes[] = 'phui-header-tall';
|
|
|
|
}
|
|
|
|
|
2015-05-12 15:55:46 +02:00
|
|
|
return array(
|
|
|
|
'class' => $classes,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
2013-07-10 01:23:22 +02:00
|
|
|
$image = null;
|
|
|
|
if ($this->image) {
|
|
|
|
$image = phutil_tag(
|
2014-05-08 23:21:32 +02:00
|
|
|
($this->imageURL ? 'a' : 'span'),
|
2013-07-10 01:23:22 +02:00
|
|
|
array(
|
2014-05-08 23:21:32 +02:00
|
|
|
'href' => $this->imageURL,
|
2013-09-17 18:12:37 +02:00
|
|
|
'class' => 'phui-header-image',
|
2013-07-10 01:23:22 +02:00
|
|
|
'style' => 'background-image: url('.$this->image.')',
|
|
|
|
),
|
2014-05-08 23:21:32 +02:00
|
|
|
' ');
|
2013-07-10 01:23:22 +02:00
|
|
|
}
|
|
|
|
|
2015-06-05 23:20:25 +02:00
|
|
|
$viewer = $this->getUser();
|
2015-01-14 01:10:57 +01:00
|
|
|
|
2015-05-22 17:22:25 +02:00
|
|
|
$left = array();
|
|
|
|
$right = array();
|
2015-01-14 01:10:57 +01:00
|
|
|
|
2015-06-05 23:20:25 +02:00
|
|
|
if ($viewer) {
|
2015-06-10 16:44:58 +02:00
|
|
|
$left[] = id(new PHUISpacesNamespaceContextView())
|
2015-06-05 23:20:25 +02:00
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($this->policyObject);
|
|
|
|
}
|
2015-06-05 19:42:49 +02:00
|
|
|
|
|
|
|
if ($this->objectName) {
|
2015-06-10 16:44:58 +02:00
|
|
|
$left[] = array(
|
2015-06-05 19:42:49 +02:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/'.$this->objectName,
|
|
|
|
),
|
|
|
|
$this->objectName),
|
|
|
|
' ',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-01-14 01:10:57 +01:00
|
|
|
if ($this->actionLinks) {
|
|
|
|
$actions = array();
|
|
|
|
foreach ($this->actionLinks as $button) {
|
|
|
|
$button->setColor(PHUIButtonView::SIMPLE);
|
|
|
|
$button->addClass(PHUI::MARGIN_SMALL_LEFT);
|
|
|
|
$button->addClass('phui-header-action-link');
|
|
|
|
$actions[] = $button;
|
|
|
|
}
|
2015-05-22 17:22:25 +02:00
|
|
|
$right[] = phutil_tag(
|
2015-01-14 01:10:57 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-action-links',
|
|
|
|
),
|
|
|
|
$actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->buttonBar) {
|
2015-05-22 17:22:25 +02:00
|
|
|
$right[] = phutil_tag(
|
2015-01-14 01:10:57 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-action-links',
|
|
|
|
),
|
|
|
|
$this->buttonBar);
|
|
|
|
}
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
|
2015-05-18 19:00:15 +02:00
|
|
|
if ($this->actionIcons || $this->tags) {
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
$action_list = array();
|
2015-05-18 19:00:15 +02:00
|
|
|
if ($this->actionIcons) {
|
|
|
|
foreach ($this->actionIcons as $icon) {
|
|
|
|
$action_list[] = phutil_tag(
|
|
|
|
'li',
|
|
|
|
array(
|
2015-05-31 16:54:48 +02:00
|
|
|
'class' => 'phui-header-action-icon',
|
2015-05-18 19:00:15 +02:00
|
|
|
),
|
|
|
|
$icon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($this->tags) {
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
$action_list[] = phutil_tag(
|
|
|
|
'li',
|
|
|
|
array(
|
2015-05-31 16:54:48 +02:00
|
|
|
'class' => 'phui-header-action-tag',
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
),
|
2015-05-18 19:00:15 +02:00
|
|
|
array_interleave(' ', $this->tags));
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
}
|
2015-05-22 17:22:25 +02:00
|
|
|
$right[] = phutil_tag(
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
'ul',
|
|
|
|
array(
|
2015-05-31 16:54:48 +02:00
|
|
|
'class' => 'phui-header-action-list',
|
[Redesign] Convert Dashboard Panels to ObjectBox
Summary: Moves Dashboard Panels to use PHUIObjectBoxView and PHUIHeaderView
Test Plan:
Tested the most common dashboards, Differential, Maniphest, Projects, Feed, Audit. Some edge cases (Legalpad, Macro) still are in progress. Tested laying out a new Dashboard, removing panels, moving panels.
{F406170}
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T8099
Differential Revision: https://secure.phabricator.com/D12873
2015-05-17 16:05:14 +02:00
|
|
|
),
|
|
|
|
$action_list);
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:00:15 +02:00
|
|
|
if ($this->headerIcon) {
|
|
|
|
$icon = id(new PHUIIconView())
|
|
|
|
->setIconFont($this->headerIcon);
|
2015-05-22 17:22:25 +02:00
|
|
|
$left[] = $icon;
|
2015-05-18 19:00:15 +02:00
|
|
|
}
|
2015-05-31 17:36:44 +02:00
|
|
|
$left[] = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-header',
|
|
|
|
),
|
|
|
|
$this->header);
|
2012-08-15 19:45:06 +02:00
|
|
|
|
2013-07-10 01:23:22 +02:00
|
|
|
if ($this->subheader) {
|
2015-05-22 17:22:25 +02:00
|
|
|
$left[] = phutil_tag(
|
2013-07-10 01:23:22 +02:00
|
|
|
'div',
|
|
|
|
array(
|
2013-09-17 18:12:37 +02:00
|
|
|
'class' => 'phui-header-subheader',
|
2013-07-10 01:23:22 +02:00
|
|
|
),
|
|
|
|
$this->subheader);
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:56:58 +02:00
|
|
|
if ($this->properties || $this->policyObject) {
|
2013-09-17 18:12:37 +02:00
|
|
|
$property_list = array();
|
|
|
|
foreach ($this->properties as $type => $property) {
|
|
|
|
switch ($type) {
|
2013-09-24 17:42:04 +02:00
|
|
|
case self::PROPERTY_STATUS:
|
2013-09-17 18:12:37 +02:00
|
|
|
$property_list[] = $property;
|
|
|
|
break;
|
|
|
|
default:
|
2015-05-22 09:27:56 +02:00
|
|
|
throw new Exception(pht('Incorrect Property Passed'));
|
2013-09-17 18:12:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:56:58 +02:00
|
|
|
if ($this->policyObject) {
|
2013-09-27 17:43:41 +02:00
|
|
|
$property_list[] = $this->renderPolicyProperty($this->policyObject);
|
2013-09-19 20:56:58 +02:00
|
|
|
}
|
|
|
|
|
2015-05-22 17:22:25 +02:00
|
|
|
$left[] = phutil_tag(
|
2013-09-17 18:12:37 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-subheader',
|
|
|
|
),
|
|
|
|
$property_list);
|
|
|
|
}
|
|
|
|
|
2015-05-22 17:22:25 +02:00
|
|
|
// We here at @phabricator
|
|
|
|
$header_image = null;
|
|
|
|
if ($image) {
|
|
|
|
$header_image = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-col1',
|
|
|
|
),
|
|
|
|
$image);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All really love
|
|
|
|
$header_left = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-col2',
|
|
|
|
),
|
|
|
|
$left);
|
|
|
|
|
|
|
|
// Tables and Pokemon.
|
|
|
|
$header_right = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-col3',
|
|
|
|
),
|
|
|
|
$right);
|
|
|
|
|
|
|
|
$header_row = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-row',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$header_image,
|
|
|
|
$header_left,
|
|
|
|
$header_right,
|
|
|
|
));
|
|
|
|
|
|
|
|
return phutil_tag(
|
|
|
|
'h1',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-header-view',
|
|
|
|
),
|
|
|
|
$header_row);
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 17:43:41 +02:00
|
|
|
private function renderPolicyProperty(PhabricatorPolicyInterface $object) {
|
2015-06-05 19:42:49 +02:00
|
|
|
$viewer = $this->getUser();
|
|
|
|
|
|
|
|
$policies = PhabricatorPolicyQuery::loadPolicies($viewer, $object);
|
2012-08-15 19:45:06 +02:00
|
|
|
|
2013-09-27 17:43:41 +02:00
|
|
|
$view_capability = PhabricatorPolicyCapability::CAN_VIEW;
|
|
|
|
$policy = idx($policies, $view_capability);
|
|
|
|
if (!$policy) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-06-17 20:25:19 +02:00
|
|
|
// If an object is in a Space with a strictly stronger (more restrictive)
|
|
|
|
// policy, we show the more restrictive policy. This better aligns the
|
|
|
|
// UI hint with the actual behavior.
|
|
|
|
|
|
|
|
// NOTE: We'll do this even if the viewer has access to only one space, and
|
|
|
|
// show them information about the existence of spaces if they click
|
|
|
|
// through.
|
2015-06-22 20:46:59 +02:00
|
|
|
$use_space_policy = false;
|
2015-06-17 20:25:19 +02:00
|
|
|
if ($object instanceof PhabricatorSpacesInterface) {
|
|
|
|
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID(
|
|
|
|
$object);
|
|
|
|
|
|
|
|
$spaces = PhabricatorSpacesNamespaceQuery::getViewerSpaces($viewer);
|
|
|
|
$space = idx($spaces, $space_phid);
|
|
|
|
if ($space) {
|
|
|
|
$space_policies = PhabricatorPolicyQuery::loadPolicies(
|
|
|
|
$viewer,
|
|
|
|
$space);
|
|
|
|
$space_policy = idx($space_policies, $view_capability);
|
|
|
|
if ($space_policy) {
|
|
|
|
if ($space_policy->isStrongerThan($policy)) {
|
|
|
|
$policy = $space_policy;
|
2015-06-22 20:46:59 +02:00
|
|
|
$use_space_policy = true;
|
2015-06-17 20:25:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 20:46:59 +02:00
|
|
|
$container_classes = array();
|
|
|
|
$container_classes[] = 'policy-header-callout';
|
2013-09-27 17:43:41 +02:00
|
|
|
$phid = $object->getPHID();
|
|
|
|
|
2015-06-22 20:46:59 +02:00
|
|
|
// If we're going to show the object policy, try to determine if the object
|
|
|
|
// policy differs from the default policy. If it does, we'll call it out
|
|
|
|
// as changed.
|
|
|
|
if (!$use_space_policy) {
|
|
|
|
$default_policy = PhabricatorPolicyQuery::getDefaultPolicyForObject(
|
|
|
|
$viewer,
|
|
|
|
$object,
|
|
|
|
$view_capability);
|
|
|
|
if ($default_policy) {
|
|
|
|
if ($default_policy->getPHID() != $policy->getPHID()) {
|
|
|
|
$container_classes[] = 'policy-adjusted';
|
|
|
|
if ($default_policy->isStrongerThan($policy)) {
|
|
|
|
// The policy has strictly been weakened. For example, the
|
|
|
|
// default might be "All Users" and the current policy is "Public".
|
|
|
|
$container_classes[] = 'policy-adjusted-weaker';
|
|
|
|
} else if ($policy->isStrongerThan($default_policy)) {
|
|
|
|
// The policy has strictly been strengthened, and is now more
|
|
|
|
// restrictive than the default. For example, "All Users" has
|
|
|
|
// been replaced with "No One".
|
|
|
|
$container_classes[] = 'policy-adjusted-stronger';
|
|
|
|
} else {
|
|
|
|
// The policy has been adjusted but not strictly strengthened
|
|
|
|
// or weakened. For example, "Members of X" has been replaced with
|
|
|
|
// "Members of Y".
|
|
|
|
$container_classes[] = 'policy-adjusted-different';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:43:41 +02:00
|
|
|
$icon = id(new PHUIIconView())
|
2014-05-19 01:10:54 +02:00
|
|
|
->setIconFont($policy->getIcon().' bluegrey');
|
2013-09-27 17:43:41 +02:00
|
|
|
|
|
|
|
$link = javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
2013-09-29 00:55:38 +02:00
|
|
|
'class' => 'policy-link',
|
2013-09-27 17:43:41 +02:00
|
|
|
'href' => '/policy/explain/'.$phid.'/'.$view_capability.'/',
|
|
|
|
'sigil' => 'workflow',
|
|
|
|
),
|
2013-10-14 23:17:25 +02:00
|
|
|
$policy->getShortName());
|
2013-09-27 17:43:41 +02:00
|
|
|
|
2015-06-22 20:46:59 +02:00
|
|
|
return phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $container_classes),
|
|
|
|
),
|
|
|
|
array($icon, $link));
|
2013-09-27 17:43:41 +02:00
|
|
|
}
|
2015-06-05 19:42:49 +02:00
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|