Files
phabricator/src/applications/spaces/view/PHUISpacesNamespaceContextView.php
epriestley 739bdeccab Improve some Spaces behaviors
Summary:
Ref T8449. Try out some more subtle behaviors:

  - Make the "Space" control part of the policy control, so the UI shows "Visible To: [Space][Policy]". I think this helps make the role of spaces more clear. It also makes them easier to implement.
  - Don't show the default space in headers: instead, show nothing.
  - If the user has access to only one space, pretend spaces don't exist (no edit controls, no header stuff).

This might be confusing, but I think most of the time it will all align fairly well with user expectation.

Test Plan:
  - Viewed a list of pastes (saw Space with non-default space, no space with default space, no space with user in only one space).
  - Viewed a paste (saw Space with non-default space, saw no space with default space, saw no space with user in only one space).
  - Edited spaces on objects (control as privileged user, no control as locked user).
  - Created a new paste in a space (got space select as privileged user, no select as locked user).

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8449

Differential Revision: https://secure.phabricator.com/D13229
2015-06-10 15:52:18 -07:00

50 lines
1.0 KiB
PHP

<?php
final class PHUISpacesNamespaceContextView extends AphrontView {
private $object;
public function setObject($object) {
$this->object = $object;
return $this;
}
public function getObject() {
return $this->object;
}
public function render() {
$object = $this->getObject();
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
if (!$space_phid) {
return null;
}
// If the viewer can't see spaces, pretend they don't exist.
$viewer = $this->getUser();
if (!PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) {
return null;
}
// If this is the default space, don't show a space label.
$default = PhabricatorSpacesNamespaceQuery::getDefaultSpace();
if ($default) {
if ($default->getPHID() == $space_phid) {
return null;
}
}
return phutil_tag(
'span',
array(
'class' => 'spaces-name',
),
array(
$viewer->renderHandle($space_phid),
' | ',
));
}
}