3 final class PhabricatorConfigTransaction
4 extends PhabricatorApplicationTransaction
{
6 const TYPE_EDIT
= 'config:edit';
8 public function getApplicationName() {
12 public function getApplicationTransactionType() {
13 return PhabricatorConfigConfigPHIDType
::TYPECONST
;
16 public function getTitle() {
17 $author_phid = $this->getAuthorPHID();
19 $old = $this->getOldValue();
20 $new = $this->getNewValue();
22 switch ($this->getTransactionType()) {
25 // TODO: After T2213 show the actual values too; for now, we don't
26 // have the tools to do it without making a bit of a mess of it.
28 $old_del = idx($old, 'deleted');
29 $new_del = idx($new, 'deleted');
30 if ($old_del && !$new_del) {
32 '%s created this configuration entry.',
33 $this->renderHandleLink($author_phid));
34 } else if (!$old_del && $new_del) {
36 '%s deleted this configuration entry.',
37 $this->renderHandleLink($author_phid));
38 } else if ($old_del && $new_del) {
41 '%s deleted this configuration entry (again?).',
42 $this->renderHandleLink($author_phid));
45 '%s edited this configuration entry.',
46 $this->renderHandleLink($author_phid));
51 return parent
::getTitle();
54 public function getTitleForFeed() {
55 $author_phid = $this->getAuthorPHID();
57 $old = $this->getOldValue();
58 $new = $this->getNewValue();
60 switch ($this->getTransactionType()) {
62 $old_del = idx($old, 'deleted');
63 $new_del = idx($new, 'deleted');
64 if ($old_del && !$new_del) {
67 $this->renderHandleLink($author_phid),
68 $this->getObject()->getConfigKey());
69 } else if (!$old_del && $new_del) {
72 $this->renderHandleLink($author_phid),
73 $this->getObject()->getConfigKey());
74 } else if ($old_del && $new_del) {
77 '%s deleted %s (again?).',
78 $this->renderHandleLink($author_phid),
79 $this->getObject()->getConfigKey());
83 $this->renderHandleLink($author_phid),
84 $this->getObject()->getConfigKey());
89 return parent
::getTitle();
93 public function getIcon() {
94 switch ($this->getTransactionType()) {
99 return parent
::getIcon();
102 public function hasChangeDetails() {
103 switch ($this->getTransactionType()) {
104 case self
::TYPE_EDIT
:
107 return parent
::hasChangeDetails();
110 public function renderChangeDetails(PhabricatorUser
$viewer) {
111 $old = $this->getOldValue();
112 $new = $this->getNewValue();
114 if ($old['deleted']) {
117 $old_text = PhabricatorConfigJSON
::prettyPrintJSON($old['value']);
120 if ($new['deleted']) {
123 $new_text = PhabricatorConfigJSON
::prettyPrintJSON($new['value']);
126 return $this->renderTextCorpusChangeDetails(
132 public function getColor() {
133 $old = $this->getOldValue();
134 $new = $this->getNewValue();
136 switch ($this->getTransactionType()) {
137 case self
::TYPE_EDIT
:
138 $old_del = idx($old, 'deleted');
139 $new_del = idx($new, 'deleted');
141 if ($old_del && !$new_del) {
142 return PhabricatorTransactions
::COLOR_GREEN
;
143 } else if (!$old_del && $new_del) {
144 return PhabricatorTransactions
::COLOR_RED
;
146 return PhabricatorTransactions
::COLOR_BLUE
;