3 final class HeraldWebhookEditEngine
4 extends PhabricatorEditEngine
{
6 const ENGINECONST
= 'herald.webhook';
8 public function isEngineConfigurable() {
12 public function getEngineName() {
13 return pht('Webhooks');
16 public function getSummaryHeader() {
17 return pht('Edit Webhook Configurations');
20 public function getSummaryText() {
21 return pht('This engine is used to edit webhooks.');
24 public function getEngineApplicationClass() {
25 return 'PhabricatorHeraldApplication';
28 protected function newEditableObject() {
29 $viewer = $this->getViewer();
30 return HeraldWebhook
::initializeNewWebhook($viewer);
33 protected function newObjectQuery() {
34 return new HeraldWebhookQuery();
37 protected function getObjectCreateTitleText($object) {
38 return pht('Create Webhook');
41 protected function getObjectCreateButtonText($object) {
42 return pht('Create Webhook');
45 protected function getObjectEditTitleText($object) {
46 return pht('Edit Webhook: %s', $object->getName());
49 protected function getObjectEditShortText($object) {
50 return pht('Edit Webhook');
53 protected function getObjectCreateShortText() {
54 return pht('Create Webhook');
57 protected function getObjectName() {
58 return pht('Webhook');
61 protected function getEditorURI() {
62 return '/herald/webhook/edit/';
65 protected function getObjectCreateCancelURI($object) {
66 return '/herald/webhook/';
69 protected function getObjectViewURI($object) {
70 return $object->getURI();
73 protected function getCreateNewObjectPolicy() {
74 return $this->getApplication()->getPolicy(
75 HeraldCreateWebhooksCapability
::CAPABILITY
);
78 protected function buildCustomEditFields($object) {
80 id(new PhabricatorTextEditField())
82 ->setLabel(pht('Name'))
83 ->setDescription(pht('Name of the webhook.'))
84 ->setTransactionType(HeraldWebhookNameTransaction
::TRANSACTIONTYPE
)
86 ->setValue($object->getName()),
87 id(new PhabricatorTextEditField())
89 ->setLabel(pht('URI'))
90 ->setDescription(pht('URI for the webhook.'))
91 ->setTransactionType(HeraldWebhookURITransaction
::TRANSACTIONTYPE
)
93 ->setValue($object->getWebhookURI()),
94 id(new PhabricatorSelectEditField())
96 ->setLabel(pht('Status'))
97 ->setDescription(pht('Status mode for the webhook.'))
98 ->setTransactionType(HeraldWebhookStatusTransaction
::TRANSACTIONTYPE
)
99 ->setOptions(HeraldWebhook
::getStatusDisplayNameMap())
100 ->setValue($object->getStatus()),