Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / config / storage / PhabricatorConfigTransaction.php
blob94272bfb1a5c8c9561726bd56c486120cd28637d
1 <?php
3 final class PhabricatorConfigTransaction
4 extends PhabricatorApplicationTransaction {
6 const TYPE_EDIT = 'config:edit';
8 public function getApplicationName() {
9 return 'config';
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()) {
23 case self::TYPE_EDIT:
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) {
31 return pht(
32 '%s created this configuration entry.',
33 $this->renderHandleLink($author_phid));
34 } else if (!$old_del && $new_del) {
35 return pht(
36 '%s deleted this configuration entry.',
37 $this->renderHandleLink($author_phid));
38 } else if ($old_del && $new_del) {
39 // This is a bug.
40 return pht(
41 '%s deleted this configuration entry (again?).',
42 $this->renderHandleLink($author_phid));
43 } else {
44 return pht(
45 '%s edited this configuration entry.',
46 $this->renderHandleLink($author_phid));
48 break;
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()) {
61 case self::TYPE_EDIT:
62 $old_del = idx($old, 'deleted');
63 $new_del = idx($new, 'deleted');
64 if ($old_del && !$new_del) {
65 return pht(
66 '%s created %s.',
67 $this->renderHandleLink($author_phid),
68 $this->getObject()->getConfigKey());
69 } else if (!$old_del && $new_del) {
70 return pht(
71 '%s deleted %s.',
72 $this->renderHandleLink($author_phid),
73 $this->getObject()->getConfigKey());
74 } else if ($old_del && $new_del) {
75 // This is a bug.
76 return pht(
77 '%s deleted %s (again?).',
78 $this->renderHandleLink($author_phid),
79 $this->getObject()->getConfigKey());
80 } else {
81 return pht(
82 '%s edited %s.',
83 $this->renderHandleLink($author_phid),
84 $this->getObject()->getConfigKey());
86 break;
89 return parent::getTitle();
93 public function getIcon() {
94 switch ($this->getTransactionType()) {
95 case self::TYPE_EDIT:
96 return 'fa-pencil';
99 return parent::getIcon();
102 public function hasChangeDetails() {
103 switch ($this->getTransactionType()) {
104 case self::TYPE_EDIT:
105 return true;
107 return parent::hasChangeDetails();
110 public function renderChangeDetails(PhabricatorUser $viewer) {
111 $old = $this->getOldValue();
112 $new = $this->getNewValue();
114 if ($old['deleted']) {
115 $old_text = '';
116 } else {
117 $old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);
120 if ($new['deleted']) {
121 $new_text = '';
122 } else {
123 $new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
126 return $this->renderTextCorpusChangeDetails(
127 $viewer,
128 $old_text,
129 $new_text);
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;
145 } else {
146 return PhabricatorTransactions::COLOR_BLUE;
148 break;