From d56a37b636739d467bfc65112db7d9de2f97d0ab Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 11 Apr 2018 07:11:28 -0700 Subject: [PATCH] Allow Almanac Bindings to be enabled/disabled via API and support the "properties" attachment Summary: Depends on D19340. Ref T12414. Ref T13120. See T12414 for some discussion about direction here. Since I think retaining "enabled/disabled" as a simple flag is reasonable, expose it via the API for readers and writers. Also expose binding properties. Test Plan: - Searched for bindings and properties with "alamanc.binding.search". - Enabled and disabled bindings with "almanac.binding.edit". Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13120, T12414 Differential Revision: https://secure.phabricator.com/D19341 --- .../almanac/editor/AlmanacBindingEditEngine.php | 13 +++++++++++++ src/applications/almanac/storage/AlmanacBinding.php | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/applications/almanac/editor/AlmanacBindingEditEngine.php b/src/applications/almanac/editor/AlmanacBindingEditEngine.php index dfcd9dedcd..07a9e36e9e 100644 --- a/src/applications/almanac/editor/AlmanacBindingEditEngine.php +++ b/src/applications/almanac/editor/AlmanacBindingEditEngine.php @@ -152,6 +152,19 @@ final class AlmanacBindingEditEngine ->setConduitDescription(pht('Set the interface to bind.')) ->setConduitTypeDescription(pht('Interface PHID.')) ->setValue($object->getInterfacePHID()), + id(new PhabricatorBoolEditField()) + ->setKey('disabled') + ->setLabel(pht('Disabled')) + ->setIsConduitOnly(true) + ->setTransactionType( + AlmanacBindingDisableTransaction::TRANSACTIONTYPE) + ->setDescription(pht('Disable or enable the binding.')) + ->setConduitDescription(pht('Disable or enable the binding.')) + ->setConduitTypeDescription(pht('True to disable the binding.')) + ->setValue($object->getIsDisabled()) + ->setOptions( + pht('Enable Binding'), + pht('Disable Binding')), ); } diff --git a/src/applications/almanac/storage/AlmanacBinding.php b/src/applications/almanac/storage/AlmanacBinding.php index 1641120900..be70a5ecdc 100644 --- a/src/applications/almanac/storage/AlmanacBinding.php +++ b/src/applications/almanac/storage/AlmanacBinding.php @@ -244,6 +244,10 @@ final class AlmanacBinding ->setKey('interfacePHID') ->setType('phid') ->setDescription(pht('The interface the service is bound to.')), + id(new PhabricatorConduitSearchFieldSpecification()) + ->setKey('disabled') + ->setType('bool') + ->setDescription(pht('Interface status.')), ); } @@ -252,11 +256,15 @@ final class AlmanacBinding 'servicePHID' => $this->getServicePHID(), 'devicePHID' => $this->getDevicePHID(), 'interfacePHID' => $this->getInterfacePHID(), + 'disabled' => (bool)$this->getIsDisabled(), ); } public function getConduitSearchAttachments() { - return array(); + return array( + id(new AlmanacPropertiesSearchEngineAttachment()) + ->setAttachmentKey('properties'), + ); } }