Don't show a "Manage" button in Legalpad if the user is signing a TOS document

Summary:
When a TOS-like Legalpad document is marked "Require this document to use Phabricator", the login prompt shows a "Manage" button, but that button doesn't work.

When we're presenting a document as a session gate, don't show "Manage".

Test Plan: Viewed a required document during a session gate (no "Manage" button) and normally (saw "Manage" button).

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20312
This commit is contained in:
epriestley
2019-03-22 09:32:13 -07:00
parent 930cc7a6dd
commit b081053e26
2 changed files with 21 additions and 2 deletions

View File

@@ -608,6 +608,7 @@ abstract class PhabricatorController extends AphrontController {
$this->setCurrentApplication($application); $this->setCurrentApplication($application);
$controller = new LegalpadDocumentSignController(); $controller = new LegalpadDocumentSignController();
$controller->setIsSessionGate(true);
return $this->delegateToController($controller); return $this->delegateToController($controller);
} }

View File

@@ -2,6 +2,8 @@
final class LegalpadDocumentSignController extends LegalpadController { final class LegalpadDocumentSignController extends LegalpadController {
private $isSessionGate;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
@@ -10,6 +12,15 @@ final class LegalpadDocumentSignController extends LegalpadController {
return true; return true;
} }
public function setIsSessionGate($is_session_gate) {
$this->isSessionGate = $is_session_gate;
return $this;
}
public function getIsSessionGate() {
return $this->isSessionGate;
}
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$viewer = $request->getUser(); $viewer = $request->getUser();
@@ -251,8 +262,14 @@ final class LegalpadDocumentSignController extends LegalpadController {
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader($title) ->setHeader($title)
->setUser($viewer) ->setUser($viewer)
->setEpoch($content_updated) ->setEpoch($content_updated);
->addActionLink(
// If we're showing the user this document because it's required to use
// Phabricator and they haven't signed it, don't show the "Manage" button,
// since it won't work.
$is_gate = $this->getIsSessionGate();
if (!$is_gate) {
$header->addActionLink(
id(new PHUIButtonView()) id(new PHUIButtonView())
->setTag('a') ->setTag('a')
->setIcon('fa-pencil') ->setIcon('fa-pencil')
@@ -260,6 +277,7 @@ final class LegalpadDocumentSignController extends LegalpadController {
->setHref($manage_uri) ->setHref($manage_uri)
->setDisabled(!$can_edit) ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)); ->setWorkflow(!$can_edit));
}
$preamble_box = null; $preamble_box = null;
if (strlen($document->getPreamble())) { if (strlen($document->getPreamble())) {