@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.

Fully modularize Herald field values

Summary: Ref T8726. This gets rid of all the `VALUE_*` constants and lets Fields provide arbitrary typeaheads without upstream/JS changes.

Test Plan: Used all tokenizers. Used "Another Herald Rule". Grepped for all removed constants.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

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

+261 -401
+11 -11
resources/celerity/map.php
··· 382 382 'rsrc/js/application/doorkeeper/behavior-doorkeeper-tag.js' => 'e5822781', 383 383 'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58', 384 384 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 385 - 'rsrc/js/application/herald/HeraldRuleEditor.js' => '797e4876', 385 + 'rsrc/js/application/herald/HeraldRuleEditor.js' => '6c2dffcc', 386 386 'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec', 387 387 'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3', 388 388 'rsrc/js/application/maniphest/behavior-batch-editor.js' => '782ab6e7', ··· 538 538 'global-drag-and-drop-css' => '697324ad', 539 539 'harbormaster-css' => '49d64eb4', 540 540 'herald-css' => '826075fa', 541 - 'herald-rule-editor' => '797e4876', 541 + 'herald-rule-editor' => '6c2dffcc', 542 542 'herald-test-css' => '778b008e', 543 543 'inline-comment-summary-css' => '51efda3a', 544 544 'javelin-aphlict' => '5359e785', ··· 1338 1338 'javelin-install', 1339 1339 'javelin-util', 1340 1340 ), 1341 + '6c2dffcc' => array( 1342 + 'multirow-row-manager', 1343 + 'javelin-install', 1344 + 'javelin-util', 1345 + 'javelin-dom', 1346 + 'javelin-stratcom', 1347 + 'javelin-json', 1348 + 'phabricator-prefab', 1349 + ), 1341 1350 '6c53634d' => array( 1342 1351 'javelin-install', 1343 1352 'javelin-event', ··· 1415 1424 '7927a7d3' => array( 1416 1425 'javelin-behavior', 1417 1426 'javelin-quicksand', 1418 - ), 1419 - '797e4876' => array( 1420 - 'multirow-row-manager', 1421 - 'javelin-install', 1422 - 'javelin-util', 1423 - 'javelin-dom', 1424 - 'javelin-stratcom', 1425 - 'javelin-json', 1426 - 'phabricator-prefab', 1427 1427 ), 1428 1428 '7a68dda3' => array( 1429 1429 'owners-path-editor',
+2
src/__phutil_library_map__.php
··· 1057 1057 'HeraldSubscribersField' => 'applications/subscriptions/herald/HeraldSubscribersField.php', 1058 1058 'HeraldTestConsoleController' => 'applications/herald/controller/HeraldTestConsoleController.php', 1059 1059 'HeraldTextFieldValue' => 'applications/herald/value/HeraldTextFieldValue.php', 1060 + 'HeraldTokenizerFieldValue' => 'applications/herald/value/HeraldTokenizerFieldValue.php', 1060 1061 'HeraldTransactionQuery' => 'applications/herald/query/HeraldTransactionQuery.php', 1061 1062 'HeraldTranscript' => 'applications/herald/storage/transcript/HeraldTranscript.php', 1062 1063 'HeraldTranscriptController' => 'applications/herald/controller/HeraldTranscriptController.php', ··· 4664 4665 'HeraldSubscribersField' => 'HeraldField', 4665 4666 'HeraldTestConsoleController' => 'HeraldController', 4666 4667 'HeraldTextFieldValue' => 'HeraldFieldValue', 4668 + 'HeraldTokenizerFieldValue' => 'HeraldFieldValue', 4667 4669 'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 4668 4670 'HeraldTranscript' => array( 4669 4671 'HeraldDAO',
+2 -2
src/applications/differential/herald/DifferentialDiffAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php
··· 19 19 return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectOrUserDatasource(); 30 24 } 31 25 32 26 }
+2 -8
src/applications/differential/herald/DifferentialDiffRepositoryHeraldField.php
··· 23 23 return self::STANDARD_PHID_NULLABLE; 24 24 } 25 25 26 - public function getHeraldFieldValueType($condition) { 27 - switch ($condition) { 28 - case HeraldAdapter::CONDITION_EXISTS: 29 - case HeraldAdapter::CONDITION_NOT_EXISTS: 30 - return HeraldAdapter::VALUE_NONE; 31 - default: 32 - return HeraldAdapter::VALUE_REPOSITORY; 33 - } 26 + protected function getDatasource() { 27 + return new DiffusionRepositoryDatasource(); 34 28 } 35 29 36 30 }
+2 -8
src/applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php
··· 24 24 return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 - public function getHeraldFieldValueType($condition) { 28 - switch ($condition) { 29 - case HeraldAdapter::CONDITION_EXISTS: 30 - case HeraldAdapter::CONDITION_NOT_EXISTS: 31 - return HeraldAdapter::VALUE_NONE; 32 - default: 33 - return HeraldAdapter::VALUE_PROJECT; 34 - } 27 + protected function getDatasource() { 28 + return new PhabricatorProjectDatasource(); 35 29 } 36 30 37 31 }
+2 -2
src/applications/differential/herald/DifferentialRevisionAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php
··· 19 19 return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 31 25 32 26 }
+2 -8
src/applications/differential/herald/DifferentialRevisionPackageHeraldField.php
··· 18 18 return self::STANDARD_PHID_LIST; 19 19 } 20 20 21 - public function getHeraldFieldValueType($condition) { 22 - switch ($condition) { 23 - case HeraldAdapter::CONDITION_EXISTS: 24 - case HeraldAdapter::CONDITION_NOT_EXISTS: 25 - return HeraldAdapter::VALUE_NONE; 26 - default: 27 - return HeraldAdapter::VALUE_OWNERS_PACKAGE; 28 - } 21 + protected function getDatasource() { 22 + return new PhabricatorOwnersPackageDatasource(); 29 23 } 30 24 31 25 }
+2 -8
src/applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php
··· 23 23 return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 - public function getHeraldFieldValueType($condition) { 27 - switch ($condition) { 28 - case HeraldAdapter::CONDITION_EXISTS: 29 - case HeraldAdapter::CONDITION_NOT_EXISTS: 30 - return HeraldAdapter::VALUE_NONE; 31 - default: 32 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 33 - } 26 + protected function getDatasource() { 27 + return new PhabricatorProjectOrUserDatasource(); 34 28 } 35 29 36 30 }
+2 -8
src/applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php
··· 23 23 return self::STANDARD_PHID_NULLABLE; 24 24 } 25 25 26 - public function getHeraldFieldValueType($condition) { 27 - switch ($condition) { 28 - case HeraldAdapter::CONDITION_EXISTS: 29 - case HeraldAdapter::CONDITION_NOT_EXISTS: 30 - return HeraldAdapter::VALUE_NONE; 31 - default: 32 - return HeraldAdapter::VALUE_REPOSITORY; 33 - } 26 + protected function getDatasource() { 27 + return new DiffusionRepositoryDatasource(); 34 28 } 35 29 36 30 }
+2 -8
src/applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php
··· 24 24 return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 - public function getHeraldFieldValueType($condition) { 28 - switch ($condition) { 29 - case HeraldAdapter::CONDITION_EXISTS: 30 - case HeraldAdapter::CONDITION_NOT_EXISTS: 31 - return HeraldAdapter::VALUE_NONE; 32 - default: 33 - return HeraldAdapter::VALUE_PROJECT; 34 - } 27 + protected function getDatasource() { 28 + return new PhabricatorProjectDatasource(); 35 29 } 36 30 37 31 }
+2 -8
src/applications/differential/herald/DifferentialRevisionReviewersHeraldField.php
··· 17 17 return self::STANDARD_PHID_LIST; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorProjectOrUserDatasource(); 28 22 } 29 23 30 24 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+1 -1
src/applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php
··· 20 20 } 21 21 22 22 public function getHeraldFieldValueType($condition) { 23 - return HeraldAdapter::VALUE_NONE; 23 + return new HeraldEmptyFieldValue(); 24 24 } 25 25 26 26 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php
··· 22 22 return self::STANDARD_PHID_LIST; 23 23 } 24 24 25 - public function getHeraldFieldValueType($condition) { 26 - switch ($condition) { 27 - case HeraldAdapter::CONDITION_EXISTS: 28 - case HeraldAdapter::CONDITION_NOT_EXISTS: 29 - return HeraldAdapter::VALUE_NONE; 30 - default: 31 - return HeraldAdapter::VALUE_OWNERS_PACKAGE; 32 - } 25 + protected function getDatasource() { 26 + return new PhabricatorOwnersPackageDatasource(); 33 27 } 34 28 35 29 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitPackageHeraldField.php
··· 18 18 return self::STANDARD_PHID_LIST; 19 19 } 20 20 21 - public function getHeraldFieldValueType($condition) { 22 - switch ($condition) { 23 - case HeraldAdapter::CONDITION_EXISTS: 24 - case HeraldAdapter::CONDITION_NOT_EXISTS: 25 - return HeraldAdapter::VALUE_NONE; 26 - default: 27 - return HeraldAdapter::VALUE_OWNERS_PACKAGE; 28 - } 21 + protected function getDatasource() { 22 + return new PhabricatorOwnersPackageDatasource(); 29 23 } 30 24 31 25 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php
··· 24 24 return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 - public function getHeraldFieldValueType($condition) { 28 - switch ($condition) { 29 - case HeraldAdapter::CONDITION_EXISTS: 30 - case HeraldAdapter::CONDITION_NOT_EXISTS: 31 - return HeraldAdapter::VALUE_NONE; 32 - default: 33 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 34 - } 27 + protected function getDatasource() { 28 + return new PhabricatorProjectOrUserDatasource(); 35 29 } 36 30 37 31 }
+2 -2
src/applications/diffusion/herald/DiffusionCommitRepositoryHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_REPOSITORY; 20 + protected function getDatasource() { 21 + return new DiffusionRepositoryDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitRepositoryProjectsHeraldField.php
··· 19 19 return self::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 31 25 32 26 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitReviewerHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php
··· 23 23 return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 - public function getHeraldFieldValueType($condition) { 27 - switch ($condition) { 28 - case HeraldAdapter::CONDITION_EXISTS: 29 - case HeraldAdapter::CONDITION_NOT_EXISTS: 30 - return HeraldAdapter::VALUE_NONE; 31 - default: 32 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 33 - } 26 + protected function getDatasource() { 27 + return new PhabricatorProjectOrUserDatasource(); 34 28 } 35 29 36 30 }
+2 -8
src/applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php
··· 24 24 return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 - public function getHeraldFieldValueType($condition) { 28 - switch ($condition) { 29 - case HeraldAdapter::CONDITION_EXISTS: 30 - case HeraldAdapter::CONDITION_NOT_EXISTS: 31 - return HeraldAdapter::VALUE_NONE; 32 - default: 33 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 34 - } 27 + protected function getDatasource() { 28 + return new PhabricatorProjectOrUserDatasource(); 35 29 } 36 30 37 31 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php
··· 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+3 -8
src/applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php
··· 19 19 return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 25 + 31 26 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php
··· 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_REPOSITORY; 20 + protected function getDatasource() { 21 + return new DiffusionRepositoryDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php
··· 19 19 return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 31 25 32 26 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php
··· 23 23 return self::STANDARD_PHID_LIST; 24 24 } 25 25 26 - public function getHeraldFieldValueType($condition) { 27 - switch ($condition) { 28 - case HeraldAdapter::CONDITION_EXISTS: 29 - case HeraldAdapter::CONDITION_NOT_EXISTS: 30 - return HeraldAdapter::VALUE_NONE; 31 - default: 32 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 33 - } 26 + protected function getDatasource() { 27 + return new PhabricatorProjectOrUserDatasource(); 34 28 } 35 29 36 30 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php
··· 24 24 return self::STANDARD_PHID_LIST; 25 25 } 26 26 27 - public function getHeraldFieldValueType($condition) { 28 - switch ($condition) { 29 - case HeraldAdapter::CONDITION_EXISTS: 30 - case HeraldAdapter::CONDITION_NOT_EXISTS: 31 - return HeraldAdapter::VALUE_NONE; 32 - default: 33 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 34 - } 27 + protected function getDatasource() { 28 + return new PhabricatorProjectOrUserDatasource(); 35 29 } 36 30 37 31 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitRefPusherHeraldField.php
··· 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+3 -8
src/applications/diffusion/herald/DiffusionPreCommitRefPusherProjectsHeraldField.php
··· 19 19 return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 25 + 31 26 }
+2 -2
src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryHeraldField.php
··· 17 17 return HeraldField::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_REPOSITORY; 20 + protected function getDatasource() { 21 + return new DiffusionRepositoryDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/diffusion/herald/DiffusionPreCommitRefRepositoryProjectsHeraldField.php
··· 19 19 return HeraldField::STANDARD_PHID_LIST; 20 20 } 21 21 22 - public function getHeraldFieldValueType($condition) { 23 - switch ($condition) { 24 - case HeraldAdapter::CONDITION_EXISTS: 25 - case HeraldAdapter::CONDITION_NOT_EXISTS: 26 - return HeraldAdapter::VALUE_NONE; 27 - default: 28 - return HeraldAdapter::VALUE_PROJECT; 29 - } 22 + protected function getDatasource() { 23 + return new PhabricatorProjectDatasource(); 30 24 } 31 25 32 26 }
+26 -24
src/applications/herald/adapter/HeraldAdapter.php
··· 41 41 const ACTION_BLOCK = 'block'; 42 42 const ACTION_REQUIRE_SIGNATURE = 'signature'; 43 43 44 - const VALUE_NONE = 'none'; 45 - const VALUE_EMAIL = 'email'; 46 - const VALUE_USER = 'user'; 47 - const VALUE_RULE = 'rule'; 48 - const VALUE_REPOSITORY = 'repository'; 49 - const VALUE_OWNERS_PACKAGE = 'package'; 50 - const VALUE_PROJECT = 'project'; 51 - const VALUE_USER_OR_PROJECT = 'userorproject'; 52 - const VALUE_BUILD_PLAN = 'buildplan'; 53 - const VALUE_TASK_PRIORITY = 'taskpriority'; 54 - const VALUE_TASK_STATUS = 'taskstatus'; 55 - const VALUE_LEGAL_DOCUMENTS = 'legaldocuments'; 56 - const VALUE_APPLICATION_EMAIL = 'applicationemail'; 57 - const VALUE_SPACE = 'space'; 58 - 59 44 private $contentSource; 60 45 private $isNewObject; 61 46 private $applicationEmail; ··· 761 746 case self::ACTION_ASSIGN_TASK: 762 747 case self::ACTION_ADD_REVIEWERS: 763 748 case self::ACTION_ADD_BLOCKING_REVIEWERS: 764 - return self::VALUE_NONE; 749 + return new HeraldEmptyFieldValue(); 765 750 case self::ACTION_FLAG: 766 751 return $this->buildFlagColorFieldValue(); 767 752 case self::ACTION_ADD_PROJECTS: 768 753 case self::ACTION_REMOVE_PROJECTS: 769 - return self::VALUE_PROJECT; 754 + return $this->buildTokenizerFieldValue( 755 + new PhabricatorProjectDatasource()); 770 756 } 771 757 } else { 772 758 switch ($action) { 773 759 case self::ACTION_ADD_CC: 774 760 case self::ACTION_REMOVE_CC: 775 761 case self::ACTION_EMAIL: 776 - return self::VALUE_EMAIL; 762 + return $this->buildTokenizerFieldValue( 763 + new PhabricatorMetaMTAMailableDatasource()); 777 764 case self::ACTION_NOTHING: 778 - return self::VALUE_NONE; 765 + return new HeraldEmptyFieldValue(); 779 766 case self::ACTION_ADD_PROJECTS: 780 767 case self::ACTION_REMOVE_PROJECTS: 781 - return self::VALUE_PROJECT; 768 + return $this->buildTokenizerFieldValue( 769 + new PhabricatorProjectDatasource()); 782 770 case self::ACTION_FLAG: 783 771 return $this->buildFlagColorFieldValue(); 784 772 case self::ACTION_ASSIGN_TASK: 785 - return self::VALUE_USER; 773 + return $this->buildTokenizerFieldValue( 774 + new PhabricatorPeopleDatasource()); 786 775 case self::ACTION_AUDIT: 787 776 case self::ACTION_ADD_REVIEWERS: 788 777 case self::ACTION_ADD_BLOCKING_REVIEWERS: 789 - return self::VALUE_USER_OR_PROJECT; 778 + return $this->buildTokenizerFieldValue( 779 + new PhabricatorProjectOrUserDatasource()); 790 780 case self::ACTION_APPLY_BUILD_PLANS: 791 - return self::VALUE_BUILD_PLAN; 781 + return $this->buildTokenizerFieldValue( 782 + new HarbormasterBuildPlanDatasource()); 792 783 case self::ACTION_REQUIRE_SIGNATURE: 793 - return self::VALUE_LEGAL_DOCUMENTS; 784 + return $this->buildTokenizerFieldValue( 785 + new LegalpadDocumentDatasource()); 794 786 case self::ACTION_BLOCK: 795 787 return new HeraldTextFieldValue(); 796 788 } ··· 809 801 ->setKey('flag.color') 810 802 ->setOptions(PhabricatorFlagColor::getColorNameMap()) 811 803 ->setDefault(PhabricatorFlagColor::COLOR_BLUE); 804 + } 805 + 806 + private function buildTokenizerFieldValue( 807 + PhabricatorTypeaheadDatasource $datasource) { 808 + 809 + $key = 'action.'.get_class($datasource); 810 + 811 + return id(new HeraldTokenizerFieldValue()) 812 + ->setKey($key) 813 + ->setDatasource($datasource); 812 814 } 813 815 814 816 /* -( Repetition )--------------------------------------------------------- */
+6 -31
src/applications/herald/controller/HeraldRuleController.php
··· 458 458 $condition); 459 459 460 460 if ($value_key instanceof HeraldFieldValue) { 461 + $value_key->setViewer($this->getViewer()); 462 + 461 463 $spec = $value_key->getControlSpecificationDictionary(); 462 464 $value_key = $value_key->getFieldValueKey(); 463 465 $config_info['valueMap'][$value_key] = $spec; ··· 479 481 } 480 482 481 483 if ($value_key instanceof HeraldFieldValue) { 484 + $value_key->setViewer($this->getViewer()); 485 + 482 486 $spec = $value_key->getControlSpecificationDictionary(); 483 487 $value_key = $value_key->getFieldValueKey(); 484 488 $config_info['valueMap'][$value_key] = $spec; ··· 493 497 'root' => 'herald-rule-edit-form', 494 498 'conditions' => (object)$serial_conditions, 495 499 'actions' => (object)$serial_actions, 496 - 'template' => $this->buildTokenizerTemplates($handles) + array( 500 + 'template' => $this->buildTokenizerTemplates() + array( 497 501 'rules' => $all_rules, 498 502 ), 499 503 'info' => $config_info, ··· 576 580 } 577 581 578 582 579 - protected function buildTokenizerTemplates(array $handles) { 583 + protected function buildTokenizerTemplates() { 580 584 $template = new AphrontTokenizerTemplateView(); 581 585 $template = $template->render(); 582 - 583 - $sources = array( 584 - 'repository' => new DiffusionRepositoryDatasource(), 585 - 'legaldocuments' => new LegalpadDocumentDatasource(), 586 - 'taskpriority' => new ManiphestTaskPriorityDatasource(), 587 - 'taskstatus' => new ManiphestTaskStatusDatasource(), 588 - 'buildplan' => new HarbormasterBuildPlanDatasource(), 589 - 'package' => new PhabricatorOwnersPackageDatasource(), 590 - 'project' => new PhabricatorProjectDatasource(), 591 - 'user' => new PhabricatorPeopleDatasource(), 592 - 'email' => new PhabricatorMetaMTAMailableDatasource(), 593 - 'userorproject' => new PhabricatorProjectOrUserDatasource(), 594 - 'applicationemail' => new PhabricatorMetaMTAApplicationEmailDatasource(), 595 - 'space' => new PhabricatorSpacesNamespaceDatasource(), 596 - ); 597 - 598 - foreach ($sources as $key => $source) { 599 - $source->setViewer($this->getViewer()); 600 - 601 - $sources[$key] = array( 602 - 'uri' => $source->getDatasourceURI(), 603 - 'placeholder' => $source->getPlaceholderText(), 604 - 'browseURI' => $source->getBrowseURI(), 605 - ); 606 - } 607 - 608 586 return array( 609 - 'source' => $sources, 610 - 'username' => $this->getRequest()->getUser()->getUserName(), 611 - 'icons' => mpull($handles, 'getTypeIcon', 'getPHID'), 612 587 'markup' => $template, 613 588 ); 614 589 }
+1 -1
src/applications/herald/field/HeraldAlwaysField.php
··· 19 19 } 20 20 21 21 public function getHeraldFieldValueType($condition) { 22 - return HeraldAdapter::VALUE_NONE; 22 + return new HeraldEmptyFieldValue(); 23 23 } 24 24 25 25 public function supportsObject($object) {
+5 -2
src/applications/herald/field/HeraldAnotherRuleField.php
··· 24 24 } 25 25 26 26 public function getHeraldFieldValueType($condition) { 27 - return HeraldAdapter::VALUE_RULE; 27 + // NOTE: This is a bit magical because we don't currently have a reasonable 28 + // way to populate it from here. 29 + return id(new HeraldSelectFieldValue()) 30 + ->setKey(self::FIELDCONST) 31 + ->setOptions(array()); 28 32 } 29 - 30 33 31 34 }
+20 -1
src/applications/herald/field/HeraldField.php
··· 20 20 throw new PhutilMethodNotImplementedException(); 21 21 } 22 22 23 + protected function getDatasource() { 24 + throw new PhutilMethodNotImplementedException(); 25 + } 26 + 23 27 public function getHeraldFieldConditions() { 24 28 $standard_type = $this->getHeraldFieldStandardType(); 25 29 switch ($standard_type) { ··· 91 95 case self::STANDARD_TEXT_LIST: 92 96 case self::STANDARD_TEXT_MAP: 93 97 return new HeraldTextFieldValue(); 98 + case self::STANDARD_PHID: 99 + case self::STANDARD_PHID_NULLABLE: 100 + case self::STANDARD_PHID_LIST: 101 + switch ($condition) { 102 + case HeraldAdapter::CONDITION_EXISTS: 103 + case HeraldAdapter::CONDITION_NOT_EXISTS: 104 + return new HeraldEmptyFieldValue(); 105 + default: 106 + return id(new HeraldTokenizerFieldValue()) 107 + ->setKey($this->getHeraldFieldName()) 108 + ->setDatasource($this->getDatasource()); 109 + } 110 + break; 111 + 94 112 } 95 113 96 114 throw new Exception( ··· 113 131 114 132 $value_type = $this->getHeraldFieldValueType($condition); 115 133 if ($value_type instanceof HeraldFieldValue) { 116 - return $value_type->renderValue($viewer, $value); 134 + $value_type->setViewer($viewer); 135 + return $value_type->renderFieldValue($value); 117 136 } 118 137 119 138 // TODO: While this is less of a mess than it used to be, it would still
+1 -1
src/applications/herald/value/HeraldEmptyFieldValue.php
··· 11 11 return self::CONTROL_NONE; 12 12 } 13 13 14 - public function renderValue(PhabricatorUser $viewer, $value) { 14 + public function renderFieldValue($value) { 15 15 return null; 16 16 } 17 17
+13 -1
src/applications/herald/value/HeraldFieldValue.php
··· 2 2 3 3 abstract class HeraldFieldValue extends Phobject { 4 4 5 + private $viewer; 6 + 5 7 const CONTROL_NONE = 'herald.control.none'; 6 8 const CONTROL_TEXT = 'herald.control.text'; 7 9 const CONTROL_SELECT = 'herald.control.select'; ··· 9 11 10 12 abstract public function getFieldValueKey(); 11 13 abstract public function getControlType(); 12 - abstract public function renderValue(PhabricatorUser $viewer, $value); 14 + abstract public function renderFieldValue($value); 15 + 16 + public function setViewer(PhabricatorUser $viewer) { 17 + $this->viewer = $viewer; 18 + return $this; 19 + } 20 + 21 + public function getViewer() { 22 + return $this->viewer; 23 + } 13 24 14 25 final public function getControlSpecificationDictionary() { 15 26 return array( 27 + 'key' => $this->getFieldValueKey(), 16 28 'control' => $this->getControlType(), 17 29 'template' => $this->getControlTemplate(), 18 30 );
+1 -1
src/applications/herald/value/HeraldSelectFieldValue.php
··· 56 56 ); 57 57 } 58 58 59 - public function renderValue(PhabricatorUser $viewer, $value) { 59 + public function renderFieldValue($value) { 60 60 $options = $this->getOptions(); 61 61 return idx($options, $value, $value); 62 62 }
+1 -1
src/applications/herald/value/HeraldTextFieldValue.php
··· 12 12 } 13 13 14 14 15 - public function renderValue(PhabricatorUser $viewer, $value) { 15 + public function renderFieldValue($value) { 16 16 return $value; 17 17 } 18 18
+60
src/applications/herald/value/HeraldTokenizerFieldValue.php
··· 1 + <?php 2 + 3 + final class HeraldTokenizerFieldValue 4 + extends HeraldFieldValue { 5 + 6 + private $key; 7 + private $datasource; 8 + 9 + public function setKey($key) { 10 + $this->key = $key; 11 + return $this; 12 + } 13 + 14 + public function getKey() { 15 + return $this->key; 16 + } 17 + 18 + public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { 19 + $this->datasource = $datasource; 20 + return $this; 21 + } 22 + 23 + public function getDatasource() { 24 + return $this->datasource; 25 + } 26 + 27 + public function getFieldValueKey() { 28 + if ($this->getKey() === null) { 29 + throw new PhutilInvalidStateException('setKey'); 30 + } 31 + return 'tokenizer.'.$this->getKey(); 32 + } 33 + 34 + public function getControlType() { 35 + return self::CONTROL_TOKENIZER; 36 + } 37 + 38 + protected function getControlTemplate() { 39 + if ($this->getDatasource() === null) { 40 + throw new PhutilInvalidStateException('setDatasource'); 41 + } 42 + 43 + $datasource = $this->getDatasource(); 44 + $datasource->setViewer($this->getViewer()); 45 + 46 + return array( 47 + 'tokenizer' => array( 48 + 'datasourceURI' => $datasource->getDatasourceURI(), 49 + 'browseURI' => $datasource->getBrowseURI(), 50 + 'placeholder' => $datasource->getPlaceholderText(), 51 + ), 52 + ); 53 + } 54 + 55 + public function renderFieldValue($value) { 56 + $viewer = $this->getViewer(); 57 + return $viewer->renderHandleList((array)$value)->setAsInline(true); 58 + } 59 + 60 + }
+2 -8
src/applications/maniphest/herald/ManiphestTaskAssigneeHeraldField.php
··· 17 17 return self::STANDARD_PHID_NULLABLE; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - switch ($condition) { 22 - case HeraldAdapter::CONDITION_EXISTS: 23 - case HeraldAdapter::CONDITION_NOT_EXISTS: 24 - return HeraldAdapter::VALUE_NONE; 25 - default: 26 - return HeraldAdapter::VALUE_USER; 27 - } 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 28 22 } 29 23 30 24 }
+2 -2
src/applications/maniphest/herald/ManiphestTaskAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+2 -2
src/applications/maniphest/herald/ManiphestTaskPriorityHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TASK_PRIORITY; 20 + protected function getDatasource() { 21 + return new ManiphestTaskPriorityDatasource(); 22 22 } 23 23 24 24 public function renderConditionValue(
+2 -2
src/applications/maniphest/herald/ManiphestTaskStatusHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_TASK_STATUS; 20 + protected function getDatasource() { 21 + return new ManiphestTaskStatusDatasource(); 22 22 } 23 23 24 24 public function renderConditionValue(
+2 -8
src/applications/metamta/herald/PhabricatorMetaMTAApplicationEmailHeraldField.php
··· 28 28 return self::STANDARD_PHID_LIST; 29 29 } 30 30 31 - public function getHeraldFieldValueType($condition) { 32 - switch ($condition) { 33 - case HeraldAdapter::CONDITION_EXISTS: 34 - case HeraldAdapter::CONDITION_NOT_EXISTS: 35 - return HeraldAdapter::VALUE_NONE; 36 - default: 37 - return HeraldAdapter::VALUE_APPLICATION_EMAIL; 38 - } 31 + protected function getDatasource() { 32 + return new PhabricatorMetaMTAApplicationEmailDatasource(); 39 33 } 40 34 41 35 }
+2 -2
src/applications/pholio/herald/PholioMockAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+2 -2
src/applications/phriction/herald/PhrictionDocumentAuthorHeraldField.php
··· 17 17 return self::STANDARD_PHID; 18 18 } 19 19 20 - public function getHeraldFieldValueType($condition) { 21 - return HeraldAdapter::VALUE_USER; 20 + protected function getDatasource() { 21 + return new PhabricatorPeopleDatasource(); 22 22 } 23 23 24 24 }
+2 -8
src/applications/project/herald/HeraldProjectsField.php
··· 22 22 return self::STANDARD_PHID_LIST; 23 23 } 24 24 25 - public function getHeraldFieldValueType($condition) { 26 - switch ($condition) { 27 - case HeraldAdapter::CONDITION_EXISTS: 28 - case HeraldAdapter::CONDITION_NOT_EXISTS: 29 - return HeraldAdapter::VALUE_NONE; 30 - default: 31 - return HeraldAdapter::VALUE_PROJECT; 32 - } 25 + protected function getDatasource() { 26 + return new PhabricatorProjectDatasource(); 33 27 } 34 28 35 29 }
+2 -2
src/applications/spaces/herald/HeraldSpaceField.php
··· 20 20 return self::STANDARD_PHID; 21 21 } 22 22 23 - public function getHeraldFieldValueType($condition) { 24 - return HeraldAdapter::VALUE_SPACE; 23 + protected function getDatasource() { 24 + return new PhabricatorSpacesNamespaceDatasource(); 25 25 } 26 26 27 27 }
+2 -8
src/applications/subscriptions/herald/HeraldSubscribersField.php
··· 21 21 return self::STANDARD_PHID_LIST; 22 22 } 23 23 24 - public function getHeraldFieldValueType($condition) { 25 - switch ($condition) { 26 - case HeraldAdapter::CONDITION_EXISTS: 27 - case HeraldAdapter::CONDITION_NOT_EXISTS: 28 - return HeraldAdapter::VALUE_NONE; 29 - default: 30 - return HeraldAdapter::VALUE_USER_OR_PROJECT; 31 - } 24 + protected function getDatasource() { 25 + return new PhabricatorProjectOrUserDatasource(); 32 26 } 33 27 34 28 }
+3 -1
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
··· 41 41 } 42 42 43 43 public function getHeraldFieldValueType($condition) { 44 - return HeraldAdapter::VALUE_USER; 44 + return id(new HeraldTokenizerFieldValue()) 45 + ->setKey('custom.'.$this->getFieldKey()) 46 + ->setDatasource(new PhabricatorPeopleDatasource()); 45 47 } 46 48 47 49 }
+22 -59
webroot/rsrc/js/application/herald/HeraldRuleEditor.js
··· 200 200 return node; 201 201 }, 202 202 203 - _buildStandardInput: function(spec) { 203 + _buildInput : function(type) { 204 + var spec = this._config.info.valueMap[type]; 205 + 204 206 var input; 205 207 var get_fn; 206 208 var set_fn; ··· 216 218 set_fn = function(v) { input.value = v; }; 217 219 break; 218 220 case 'herald.control.select': 219 - input = this._renderSelect(spec.template.options); 221 + var options; 222 + 223 + // NOTE: This is a hacky special case for "Another Herald Rule", 224 + // which we don't currently generate normal options for. 225 + 226 + if (spec.key == 'select.rule') { 227 + options = this._config.template.rules; 228 + } else { 229 + options = spec.template.options; 230 + } 231 + 232 + input = this._renderSelect(options); 220 233 get_fn = function() { return input.value; }; 221 234 set_fn = function(v) { input.value = v; }; 222 235 if (spec.template.default) { ··· 224 237 } 225 238 break; 226 239 case 'herald.control.tokenizer': 227 - var tokenizer = this._newTokenizer(spec.template.tokenizer, true); 240 + var tokenizer = this._newTokenizer(spec.template.tokenizer); 228 241 input = tokenizer[0]; 229 242 get_fn = tokenizer[1]; 230 243 set_fn = tokenizer[2]; ··· 237 250 return [input, get_fn, set_fn]; 238 251 }, 239 252 240 - _buildInput : function(type) { 241 - if (this._config.info.valueMap[type]) { 242 - return this._buildStandardInput(this._config.info.valueMap[type]); 243 - } 244 - 245 - var input; 246 - var get_fn; 247 - var set_fn; 248 - switch (type) { 249 - case 'rule': 250 - input = this._renderSelect(this._config.template.rules); 251 - get_fn = function() { return input.value; }; 252 - set_fn = function(v) { input.value = v; }; 253 - break; 254 - case 'email': 255 - case 'user': 256 - case 'repository': 257 - case 'tag': 258 - case 'package': 259 - case 'project': 260 - case 'userorproject': 261 - case 'buildplan': 262 - case 'taskpriority': 263 - case 'taskstatus': 264 - case 'legaldocuments': 265 - case 'applicationemail': 266 - case 'space': 267 - var tokenizer = this._newTokenizer(type); 268 - input = tokenizer[0]; 269 - get_fn = tokenizer[1]; 270 - set_fn = tokenizer[2]; 271 - break; 272 - default: 273 - input = JX.$N('input', {type: 'text'}); 274 - get_fn = function() { return input.value; }; 275 - set_fn = function(v) { input.value = v; }; 276 - break; 277 - } 278 - 279 - return [input, get_fn, set_fn]; 280 - }, 281 - 282 253 _renderValueInputForRow : function(row_id) { 283 254 var cond = this._config.conditions[row_id]; 284 255 var type = this._config.info.values[cond[0]][cond[1]]; ··· 303 274 return node; 304 275 }, 305 276 306 - _newTokenizer : function(type, is_config) { 307 - var tokenizerConfig; 308 - 309 - if (is_config) { 310 - tokenizerConfig = type; 311 - } else { 312 - tokenizerConfig = { 313 - src : this._config.template.source[type].uri, 314 - placeholder: this._config.template.source[type].placeholder, 315 - browseURI: this._config.template.source[type].browseURI, 316 - icons : this._config.template.icons, 317 - username : this._config.username 318 - }; 319 - } 277 + _newTokenizer : function(spec) { 278 + var tokenizerConfig = { 279 + src: spec.datasourceURI, 280 + placeholder: spec.placeholder, 281 + browseURI: spec.browseURI 282 + }; 320 283 321 284 var build = JX.Prefab.newTokenizerFromTemplate( 322 285 this._config.template.markup,