Path: blob/master/src/applications/config/storage/PhabricatorConfigTransaction.php
12256 views
<?php12final class PhabricatorConfigTransaction3extends PhabricatorApplicationTransaction {45const TYPE_EDIT = 'config:edit';67public function getApplicationName() {8return 'config';9}1011public function getApplicationTransactionType() {12return PhabricatorConfigConfigPHIDType::TYPECONST;13}1415public function getTitle() {16$author_phid = $this->getAuthorPHID();1718$old = $this->getOldValue();19$new = $this->getNewValue();2021switch ($this->getTransactionType()) {22case self::TYPE_EDIT:2324// TODO: After T2213 show the actual values too; for now, we don't25// have the tools to do it without making a bit of a mess of it.2627$old_del = idx($old, 'deleted');28$new_del = idx($new, 'deleted');29if ($old_del && !$new_del) {30return pht(31'%s created this configuration entry.',32$this->renderHandleLink($author_phid));33} else if (!$old_del && $new_del) {34return pht(35'%s deleted this configuration entry.',36$this->renderHandleLink($author_phid));37} else if ($old_del && $new_del) {38// This is a bug.39return pht(40'%s deleted this configuration entry (again?).',41$this->renderHandleLink($author_phid));42} else {43return pht(44'%s edited this configuration entry.',45$this->renderHandleLink($author_phid));46}47break;48}4950return parent::getTitle();51}5253public function getTitleForFeed() {54$author_phid = $this->getAuthorPHID();5556$old = $this->getOldValue();57$new = $this->getNewValue();5859switch ($this->getTransactionType()) {60case self::TYPE_EDIT:61$old_del = idx($old, 'deleted');62$new_del = idx($new, 'deleted');63if ($old_del && !$new_del) {64return pht(65'%s created %s.',66$this->renderHandleLink($author_phid),67$this->getObject()->getConfigKey());68} else if (!$old_del && $new_del) {69return pht(70'%s deleted %s.',71$this->renderHandleLink($author_phid),72$this->getObject()->getConfigKey());73} else if ($old_del && $new_del) {74// This is a bug.75return pht(76'%s deleted %s (again?).',77$this->renderHandleLink($author_phid),78$this->getObject()->getConfigKey());79} else {80return pht(81'%s edited %s.',82$this->renderHandleLink($author_phid),83$this->getObject()->getConfigKey());84}85break;86}8788return parent::getTitle();89}909192public function getIcon() {93switch ($this->getTransactionType()) {94case self::TYPE_EDIT:95return 'fa-pencil';96}9798return parent::getIcon();99}100101public function hasChangeDetails() {102switch ($this->getTransactionType()) {103case self::TYPE_EDIT:104return true;105}106return parent::hasChangeDetails();107}108109public function renderChangeDetails(PhabricatorUser $viewer) {110$old = $this->getOldValue();111$new = $this->getNewValue();112113if ($old['deleted']) {114$old_text = '';115} else {116$old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);117}118119if ($new['deleted']) {120$new_text = '';121} else {122$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);123}124125return $this->renderTextCorpusChangeDetails(126$viewer,127$old_text,128$new_text);129}130131public function getColor() {132$old = $this->getOldValue();133$new = $this->getNewValue();134135switch ($this->getTransactionType()) {136case self::TYPE_EDIT:137$old_del = idx($old, 'deleted');138$new_del = idx($new, 'deleted');139140if ($old_del && !$new_del) {141return PhabricatorTransactions::COLOR_GREEN;142} else if (!$old_del && $new_del) {143return PhabricatorTransactions::COLOR_RED;144} else {145return PhabricatorTransactions::COLOR_BLUE;146}147break;148}149}150151}152153154