diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7afed07307..9ab1c176e3 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -854,6 +854,7 @@ phutil_register_library_map(array( 'JavelinUIExample' => 'applications/uiexample/examples/JavelinUIExample.php', 'JavelinViewExample' => 'applications/uiexample/examples/JavelinViewExample.php', 'JavelinViewExampleServerView' => 'applications/uiexample/examples/JavelinViewExampleServerView.php', + 'LegalpadCapabilityCreateDocuments' => 'applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php', 'LegalpadCapabilityDefaultEdit' => 'applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php', 'LegalpadCapabilityDefaultView' => 'applications/legalpad/capability/LegalpadCapabilityDefaultView.php', 'LegalpadConstants' => 'applications/legalpad/constants/LegalpadConstants.php', @@ -3603,6 +3604,7 @@ phutil_register_library_map(array( 'JavelinUIExample' => 'PhabricatorUIExample', 'JavelinViewExample' => 'PhabricatorUIExample', 'JavelinViewExampleServerView' => 'AphrontView', + 'LegalpadCapabilityCreateDocuments' => 'PhabricatorPolicyCapability', 'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'LegalpadController' => 'PhabricatorController', diff --git a/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php b/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php index 71331779bc..306073c25f 100644 --- a/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php +++ b/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php @@ -69,6 +69,8 @@ final class PhabricatorApplicationLegalpad extends PhabricatorApplication { protected function getCustomCapabilities() { return array( + LegalpadCapabilityCreateDocuments::CAPABILITY => array( + ), LegalpadCapabilityDefaultView::CAPABILITY => array( ), LegalpadCapabilityDefaultEdit::CAPABILITY => array( diff --git a/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php b/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php new file mode 100644 index 0000000000..e231ad35dd --- /dev/null +++ b/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php @@ -0,0 +1,20 @@ +id) { $is_create = true; + $this->requireApplicationCapability( + LegalpadCapabilityCreateDocuments::CAPABILITY); + $document = LegalpadDocument::initializeNewDocument($user); $body = id(new LegalpadDocumentBody()) ->setCreatorPHID($user->getPHID()); @@ -145,14 +148,15 @@ final class LegalpadDocumentEditController extends LegalpadController { $submit = new AphrontFormSubmitControl(); if ($is_create) { $submit->setValue(pht('Create Document')); + $submit->addCancelButton($this->getApplicationURI()); $title = pht('Create Document'); $short = pht('Create'); } else { - $submit->setValue(pht('Update Document')); + $submit->setValue(pht('Edit Document')); $submit->addCancelButton( $this->getApplicationURI('view/'.$document->getID())); - $title = pht('Update Document'); - $short = pht('Update'); + $title = pht('Edit Document'); + $short = pht('Edit'); $crumbs->addTextCrumb( $document->getMonogram(), diff --git a/src/applications/legalpad/controller/LegalpadDocumentListController.php b/src/applications/legalpad/controller/LegalpadDocumentListController.php index a6ccc87c1f..a6ff9b0379 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentListController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentListController.php @@ -25,11 +25,17 @@ final class LegalpadDocumentListController extends LegalpadController { public function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); + $can_create = $this->hasApplicationCapability( + LegalpadCapabilityCreateDocuments::CAPABILITY); + $crumbs->addAction( id(new PHUIListItemView()) ->setName(pht('Create Document')) ->setHref($this->getApplicationURI('create/')) - ->setIcon('fa-plus-square')); + ->setIcon('fa-plus-square') + ->setDisabled(!$can_create) + ->setWorkflow(!$can_create)); + return $crumbs; } diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php b/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php index f7e9b4464b..1c0591c36b 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php @@ -71,6 +71,9 @@ final class LegalpadDocumentSignatureListController extends LegalpadController { $crumbs->addTextCrumb( $this->document->getMonogram(), '/'.$this->document->getMonogram()); + $crumbs->addTextCrumb( + pht('Manage'), + $this->getApplicationURI('view/'.$this->document->getID().'/')); } else { $crumbs->addTextCrumb( pht('Signatures'),