@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modernize "legalpad" typeahead datasource

Summary: Ref T4420. Modernize legalpad.

Test Plan:
- Used typeahead in Herald rules.
- Used typeahead in Policy dialog.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4420

Differential Revision: https://secure.phabricator.com/D9876

+62 -33
+2
src/__phutil_library_map__.php
··· 864 864 'LegalpadDocument' => 'applications/legalpad/storage/LegalpadDocument.php', 865 865 'LegalpadDocumentBody' => 'applications/legalpad/storage/LegalpadDocumentBody.php', 866 866 'LegalpadDocumentCommentController' => 'applications/legalpad/controller/LegalpadDocumentCommentController.php', 867 + 'LegalpadDocumentDatasource' => 'applications/legalpad/typeahead/LegalpadDocumentDatasource.php', 867 868 'LegalpadDocumentDoneController' => 'applications/legalpad/controller/LegalpadDocumentDoneController.php', 868 869 'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php', 869 870 'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php', ··· 3629 3630 1 => 'PhabricatorMarkupInterface', 3630 3631 ), 3631 3632 'LegalpadDocumentCommentController' => 'LegalpadController', 3633 + 'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource', 3632 3634 'LegalpadDocumentDoneController' => 'LegalpadController', 3633 3635 'LegalpadDocumentEditController' => 'LegalpadController', 3634 3636 'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor',
+18 -13
src/applications/herald/controller/HeraldRuleController.php
··· 588 588 $template = new AphrontTokenizerTemplateView(); 589 589 $template = $template->render(); 590 590 591 + $sources = array( 592 + 'repository' => new DiffusionRepositoryDatasource(), 593 + 'legaldocuments' => new LegalpadDocumentDatasource(), 594 + ); 595 + 596 + $sources = mpull($sources, 'getDatasourceURI'); 597 + $sources += array( 598 + 'email' => '/typeahead/common/mailable/', 599 + 'user' => '/typeahead/common/accounts/', 600 + 'package' => '/typeahead/common/packages/', 601 + 'project' => '/typeahead/common/projects/', 602 + 'userorproject' => '/typeahead/common/accountsorprojects/', 603 + 'buildplan' => '/typeahead/common/buildplans/', 604 + 'taskpriority' => '/typeahead/common/taskpriority/', 605 + 'arcanistprojects' => '/typeahead/common/arcanistprojects/', 606 + ); 607 + 591 608 return array( 592 - 'source' => array( 593 - 'email' => '/typeahead/common/mailable/', 594 - 'user' => '/typeahead/common/accounts/', 595 - 'repository' => 596 - id(new DiffusionRepositoryDatasource())->getDatasourceURI(), 597 - 'package' => '/typeahead/common/packages/', 598 - 'project' => '/typeahead/common/projects/', 599 - 'userorproject' => '/typeahead/common/accountsorprojects/', 600 - 'buildplan' => '/typeahead/common/buildplans/', 601 - 'taskpriority' => '/typeahead/common/taskpriority/', 602 - 'arcanistprojects' => '/typeahead/common/arcanistprojects/', 603 - 'legaldocuments' => '/typeahead/common/legalpaddocuments/', 604 - ), 609 + 'source' => $sources, 605 610 'username' => $this->getRequest()->getUser()->getUserName(), 606 611 'icons' => mpull($handles, 'getTypeIcon', 'getPHID'), 607 612 'markup' => $template,
+5 -2
src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
··· 12 12 return pht('Legalpad Document'); 13 13 } 14 14 15 + public function getTypeIcon() { 16 + return 'fa-file-text-o'; 17 + } 18 + 15 19 public function newObject() { 16 20 return new LegalpadDocument(); 17 21 } ··· 33 37 foreach ($handles as $phid => $handle) { 34 38 $document = $objects[$phid]; 35 39 $name = $document->getDocumentBody()->getTitle(); 36 - $handle->setName($name); 37 - $handle->setFullName($document->getMonogram().' '.$name); 40 + $handle->setName($document->getMonogram().' '.$name); 38 41 $handle->setURI('/'.$document->getMonogram()); 39 42 } 40 43 }
+33
src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getPlaceholderText() { 7 + return pht('Type a document name...'); 8 + } 9 + 10 + public function getDatasourceApplicationClass() { 11 + return 'PhabricatorApplicationLegalpad'; 12 + } 13 + 14 + public function loadResults() { 15 + $viewer = $this->getViewer(); 16 + $raw_query = $this->getRawQuery(); 17 + 18 + $results = array(); 19 + 20 + $documents = id(new LegalpadDocumentQuery()) 21 + ->setViewer($viewer) 22 + ->execute(); 23 + foreach ($documents as $document) { 24 + $results[] = id(new PhabricatorTypeaheadResult()) 25 + ->setPHID($document->getPHID()) 26 + ->setIcon('fa-file-text-o') 27 + ->setName($document->getMonogram().' '.$document->getTitle()); 28 + } 29 + 30 + return $results; 31 + } 32 + 33 + }
+4 -2
src/applications/policy/rule/PhabricatorPolicyRuleLegalpadSignature.php
··· 40 40 } 41 41 42 42 public function getValueControlTemplate() { 43 + $datasource = new LegalpadDocumentDatasource(); 44 + 43 45 return array( 44 46 'markup' => new AphrontTokenizerTemplateView(), 45 - 'uri' => '/typeahead/common/legalpaddocuments/', 46 - 'placeholder' => pht('Type a document title...'), 47 + 'uri' => $datasource->getDatasourceURI(), 48 + 'placeholder' => $datasource->getPlaceholderText(), 47 49 ); 48 50 } 49 51
-16
src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
··· 34 34 $need_jump_objects = false; 35 35 $need_build_plans = false; 36 36 $need_task_priority = false; 37 - $need_legalpad_documents = false; 38 37 switch ($this->type) { 39 38 case 'mainsearch': 40 39 $need_users = true; ··· 87 86 break; 88 87 case 'taskpriority': 89 88 $need_task_priority = true; 90 - break; 91 - case 'legalpaddocuments': 92 - $need_legalpad_documents = true; 93 89 break; 94 90 } 95 91 ··· 236 232 $results[] = id(new PhabricatorTypeaheadResult()) 237 233 ->setPHID($value) 238 234 ->setName($name); 239 - } 240 - } 241 - 242 - if ($need_legalpad_documents) { 243 - $documents = id(new LegalpadDocumentQuery()) 244 - ->setViewer($viewer) 245 - ->execute(); 246 - foreach ($documents as $document) { 247 - $results[] = id(new PhabricatorTypeaheadResult()) 248 - ->setPHID($document->getPHID()) 249 - ->setIcon('fa-file-text-o') 250 - ->setName($document->getMonogram().' '.$document->getTitle()); 251 235 } 252 236 } 253 237