Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/herald/editor/HeraldWebhookEditEngine.php
12256 views
1
<?php
2
3
final class HeraldWebhookEditEngine
4
extends PhabricatorEditEngine {
5
6
const ENGINECONST = 'herald.webhook';
7
8
public function isEngineConfigurable() {
9
return false;
10
}
11
12
public function getEngineName() {
13
return pht('Webhooks');
14
}
15
16
public function getSummaryHeader() {
17
return pht('Edit Webhook Configurations');
18
}
19
20
public function getSummaryText() {
21
return pht('This engine is used to edit webhooks.');
22
}
23
24
public function getEngineApplicationClass() {
25
return 'PhabricatorHeraldApplication';
26
}
27
28
protected function newEditableObject() {
29
$viewer = $this->getViewer();
30
return HeraldWebhook::initializeNewWebhook($viewer);
31
}
32
33
protected function newObjectQuery() {
34
return new HeraldWebhookQuery();
35
}
36
37
protected function getObjectCreateTitleText($object) {
38
return pht('Create Webhook');
39
}
40
41
protected function getObjectCreateButtonText($object) {
42
return pht('Create Webhook');
43
}
44
45
protected function getObjectEditTitleText($object) {
46
return pht('Edit Webhook: %s', $object->getName());
47
}
48
49
protected function getObjectEditShortText($object) {
50
return pht('Edit Webhook');
51
}
52
53
protected function getObjectCreateShortText() {
54
return pht('Create Webhook');
55
}
56
57
protected function getObjectName() {
58
return pht('Webhook');
59
}
60
61
protected function getEditorURI() {
62
return '/herald/webhook/edit/';
63
}
64
65
protected function getObjectCreateCancelURI($object) {
66
return '/herald/webhook/';
67
}
68
69
protected function getObjectViewURI($object) {
70
return $object->getURI();
71
}
72
73
protected function getCreateNewObjectPolicy() {
74
return $this->getApplication()->getPolicy(
75
HeraldCreateWebhooksCapability::CAPABILITY);
76
}
77
78
protected function buildCustomEditFields($object) {
79
return array(
80
id(new PhabricatorTextEditField())
81
->setKey('name')
82
->setLabel(pht('Name'))
83
->setDescription(pht('Name of the webhook.'))
84
->setTransactionType(HeraldWebhookNameTransaction::TRANSACTIONTYPE)
85
->setIsRequired(true)
86
->setValue($object->getName()),
87
id(new PhabricatorTextEditField())
88
->setKey('uri')
89
->setLabel(pht('URI'))
90
->setDescription(pht('URI for the webhook.'))
91
->setTransactionType(HeraldWebhookURITransaction::TRANSACTIONTYPE)
92
->setIsRequired(true)
93
->setValue($object->getWebhookURI()),
94
id(new PhabricatorSelectEditField())
95
->setKey('status')
96
->setLabel(pht('Status'))
97
->setDescription(pht('Status mode for the webhook.'))
98
->setTransactionType(HeraldWebhookStatusTransaction::TRANSACTIONTYPE)
99
->setOptions(HeraldWebhook::getStatusDisplayNameMap())
100
->setValue($object->getStatus()),
101
102
);
103
}
104
105
}
106
107