Make "public" pastes meaningfully visible to logged-out users
Summary: - Introduce `shouldAllowPublic()`, indicating that logged-out users are OK in a controller if the install is configured to permit public policies. - Make Paste views and lists allow public users. - Make UI do sensible things with respect to disabling links, etc. - Improve behavior of "you need to login" with respect to policy exceptions and Ajax requests. Test Plan: Looked at "public" paste, saw all unavailable UI disabled, clicked it, got appropraite prompts. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D3502
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
abstract class PhabricatorPasteController extends PhabricatorController {
|
||||
|
||||
public function buildSideNavView(PhabricatorPaste $paste = null) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('filter/')));
|
||||
|
||||
@@ -28,11 +30,18 @@ abstract class PhabricatorPasteController extends PhabricatorController {
|
||||
}
|
||||
|
||||
$nav->addLabel('Create');
|
||||
$nav->addFilter('edit', 'New Paste', $this->getApplicationURI());
|
||||
$nav->addFilter(
|
||||
'edit',
|
||||
'New Paste',
|
||||
$this->getApplicationURI(),
|
||||
$relative = false,
|
||||
$class = ($user->isLoggedIn() ? null : 'disabled'));
|
||||
|
||||
$nav->addSpacer();
|
||||
$nav->addLabel('Pastes');
|
||||
$nav->addFilter('my', 'My Pastes');
|
||||
if ($user->isLoggedIn()) {
|
||||
$nav->addFilter('my', 'My Pastes');
|
||||
}
|
||||
$nav->addFilter('all', 'All Pastes');
|
||||
|
||||
return $nav;
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||
|
||||
public function shouldRequireLogin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private $filter;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private $id;
|
||||
private $handles;
|
||||
|
||||
@@ -98,6 +102,8 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
$paste,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$can_fork = $user->isLoggedIn();
|
||||
|
||||
return id(new PhabricatorActionListView())
|
||||
->setUser($user)
|
||||
->setObject($paste)
|
||||
@@ -105,6 +111,8 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Fork This Paste'))
|
||||
->setIcon('fork')
|
||||
->setDisabled(!$can_fork)
|
||||
->setWorkflow(!$can_fork)
|
||||
->setHref($this->getApplicationURI('?parent='.$paste->getID())))
|
||||
->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
|
||||
Reference in New Issue
Block a user