From 9518a1a9a6420eb2bf9dd0f26ff439cd73e7a6a5 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Tue, 5 Apr 2016 11:21:44 -0700 Subject: [PATCH] Add `badges.edit` and `badges.search` to Conduit API Summary: Ref T10671 Test Plan: Open Conduit application, open `badges.edit` or `badges.search`, create, edit, or query for a badge. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Maniphest Tasks: T10671 Differential Revision: https://secure.phabricator.com/D15622 --- src/__phutil_library_map__.php | 5 +++ .../PhabricatorBadgesEditConduitAPIMethod.php | 19 ++++++++++ ...habricatorBadgesSearchConduitAPIMethod.php | 18 +++++++++ .../editor/PhabricatorBadgesEditEngine.php | 5 +++ .../badges/storage/PhabricatorBadgesBadge.php | 37 ++++++++++++++++++- .../paste/storage/PhabricatorPaste.php | 2 +- 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php create mode 100644 src/applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 99c9c32b55..13e4b98341 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1878,6 +1878,7 @@ phutil_register_library_map(array( 'PhabricatorBadgesCreateCapability' => 'applications/badges/capability/PhabricatorBadgesCreateCapability.php', 'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php', 'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php', + 'PhabricatorBadgesEditConduitAPIMethod' => 'applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php', 'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php', 'PhabricatorBadgesEditEngine' => 'applications/badges/editor/PhabricatorBadgesEditEngine.php', 'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php', @@ -1892,6 +1893,7 @@ phutil_register_library_map(array( 'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php', 'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php', 'PhabricatorBadgesSchemaSpec' => 'applications/badges/storage/PhabricatorBadgesSchemaSpec.php', + 'PhabricatorBadgesSearchConduitAPIMethod' => 'applications/badges/conduit/PhabricatorBadgesSearchConduitAPIMethod.php', 'PhabricatorBadgesSearchEngine' => 'applications/badges/query/PhabricatorBadgesSearchEngine.php', 'PhabricatorBadgesTransaction' => 'applications/badges/storage/PhabricatorBadgesTransaction.php', 'PhabricatorBadgesTransactionComment' => 'applications/badges/storage/PhabricatorBadgesTransactionComment.php', @@ -6247,12 +6249,14 @@ phutil_register_library_map(array( 'PhabricatorTokenReceiverInterface', 'PhabricatorFlaggableInterface', 'PhabricatorDestructibleInterface', + 'PhabricatorConduitResultInterface', ), 'PhabricatorBadgesCommentController' => 'PhabricatorBadgesController', 'PhabricatorBadgesController' => 'PhabricatorController', 'PhabricatorBadgesCreateCapability' => 'PhabricatorPolicyCapability', 'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO', 'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability', + 'PhabricatorBadgesEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'PhabricatorBadgesEditController' => 'PhabricatorBadgesController', 'PhabricatorBadgesEditEngine' => 'PhabricatorEditEngine', 'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController', @@ -6267,6 +6271,7 @@ phutil_register_library_map(array( 'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController', 'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'PhabricatorBadgesSchemaSpec' => 'PhabricatorConfigSchemaSpec', + 'PhabricatorBadgesSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'PhabricatorBadgesSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment', diff --git a/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php b/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php new file mode 100644 index 0000000000..42be0c2ba3 --- /dev/null +++ b/src/applications/badges/conduit/PhabricatorBadgesEditConduitAPIMethod.php @@ -0,0 +1,19 @@ +setKey('name') ->setLabel(pht('Name')) ->setDescription(pht('Badge name.')) + ->setConduitTypeDescription(pht('New badge name.')) ->setTransactionType(PhabricatorBadgesTransaction::TYPE_NAME) ->setValue($object->getName()), id(new PhabricatorTextEditField()) ->setKey('flavor') ->setLabel(pht('Flavor text')) ->setDescription(pht('Short description of the badge.')) + ->setConduitTypeDescription(pht('New badge flavor.')) ->setValue($object->getFlavor()) ->setTransactionType(PhabricatorBadgesTransaction::TYPE_FLAVOR), id(new PhabricatorIconSetEditField()) @@ -100,6 +102,8 @@ final class PhabricatorBadgesEditEngine id(new PhabricatorSelectEditField()) ->setKey('quality') ->setLabel(pht('Quality')) + ->setDescription(pht('Color and rarity of the badge.')) + ->setConduitTypeDescription(pht('New badge quality.')) ->setValue($object->getQuality()) ->setTransactionType(PhabricatorBadgesTransaction::TYPE_QUALITY) ->setOptions(PhabricatorBadgesQuality::getDropdownQualityMap()), @@ -107,6 +111,7 @@ final class PhabricatorBadgesEditEngine ->setKey('description') ->setLabel(pht('Description')) ->setDescription(pht('Badge long description.')) + ->setConduitTypeDescription(pht('New badge description.')) ->setTransactionType(PhabricatorBadgesTransaction::TYPE_DESCRIPTION) ->setValue($object->getDescription()), ); diff --git a/src/applications/badges/storage/PhabricatorBadgesBadge.php b/src/applications/badges/storage/PhabricatorBadgesBadge.php index c5b29df09d..95ceb7a9e8 100644 --- a/src/applications/badges/storage/PhabricatorBadgesBadge.php +++ b/src/applications/badges/storage/PhabricatorBadgesBadge.php @@ -7,7 +7,8 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO PhabricatorSubscribableInterface, PhabricatorTokenReceiverInterface, PhabricatorFlaggableInterface, - PhabricatorDestructibleInterface { + PhabricatorDestructibleInterface, + PhabricatorConduitResultInterface { protected $name; protected $flavor; @@ -49,6 +50,8 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO ->setQuality(PhabricatorBadgesQuality::DEFAULT_QUALITY) ->setCreatorPHID($actor->getPHID()) ->setEditPolicy($edit_policy) + ->setFlavor('') + ->setDescription('') ->setStatus(self::STATUS_ACTIVE); } @@ -190,4 +193,36 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO $this->saveTransaction(); } +/* -( PhabricatorConduitResultInterface )---------------------------------- */ + + + public function getFieldSpecificationsForConduit() { + return array( + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('name') + ->setType('string') + ->setDescription(pht('The name of the badge.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('creatorPHID') + ->setType('phid') + ->setDescription(pht('User PHID of the creator.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('status') + ->setType('string') + ->setDescription(pht('Active or archived status of the badge.')), + ); + } + + public function getFieldValuesForConduit() { + return array( + 'name' => $this->getName(), + 'creatorPHID' => $this->getCreatorPHID(), + 'status' => $this->getStatus(), + ); + } + + public function getConduitSearchAttachments() { + return array(); + } + } diff --git a/src/applications/paste/storage/PhabricatorPaste.php b/src/applications/paste/storage/PhabricatorPaste.php index bc0909cd45..0e8f497936 100644 --- a/src/applications/paste/storage/PhabricatorPaste.php +++ b/src/applications/paste/storage/PhabricatorPaste.php @@ -264,7 +264,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO id(new PhabricatorConduitSearchFieldSpecification()) ->setKey('status') ->setType('string') - ->setDescription(pht('Active or arhived status of the paste.')), + ->setDescription(pht('Active or archived status of the paste.')), ); }