2013-01-01 18:14:41 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
|
|
|
const TYPE_EDIT = 'config:edit';
|
|
|
|
|
|
|
|
public function getApplicationName() {
|
|
|
|
return 'config';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
2014-07-24 08:05:46 +10:00
|
|
|
return PhabricatorConfigConfigPHIDType::TYPECONST;
|
2013-01-01 18:14:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_EDIT:
|
|
|
|
|
|
|
|
// TODO: After T2213 show the actual values too; for now, we don't
|
|
|
|
// have the tools to do it without making a bit of a mess of it.
|
|
|
|
|
|
|
|
$old_del = idx($old, 'deleted');
|
|
|
|
$new_del = idx($new, 'deleted');
|
|
|
|
if ($old_del && !$new_del) {
|
|
|
|
return pht(
|
|
|
|
'%s created this configuration entry.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else if (!$old_del && $new_del) {
|
|
|
|
return pht(
|
|
|
|
'%s deleted this configuration entry.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else if ($old_del && $new_del) {
|
|
|
|
// This is a bug.
|
|
|
|
return pht(
|
|
|
|
'%s deleted this configuration entry (again?).',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s edited this configuration entry.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2015-01-02 08:45:43 -08:00
|
|
|
public function getTitleForFeed() {
|
2015-01-01 06:51:44 -08:00
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_EDIT:
|
|
|
|
$old_del = idx($old, 'deleted');
|
|
|
|
$new_del = idx($new, 'deleted');
|
|
|
|
if ($old_del && !$new_del) {
|
|
|
|
return pht(
|
|
|
|
'%s created %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getObject()->getConfigKey());
|
|
|
|
} else if (!$old_del && $new_del) {
|
|
|
|
return pht(
|
|
|
|
'%s deleted %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getObject()->getConfigKey());
|
|
|
|
} else if ($old_del && $new_del) {
|
|
|
|
// This is a bug.
|
|
|
|
return pht(
|
|
|
|
'%s deleted %s (again?).',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getObject()->getConfigKey());
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s edited %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getObject()->getConfigKey());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2013-01-01 18:14:41 -08:00
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_EDIT:
|
2014-04-22 08:25:54 -07:00
|
|
|
return 'fa-pencil';
|
2013-01-01 18:14:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
2013-02-17 06:37:02 -08:00
|
|
|
public function hasChangeDetails() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_EDIT:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return parent::hasChangeDetails();
|
|
|
|
}
|
|
|
|
|
2013-03-04 12:54:20 -08:00
|
|
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
2013-02-17 06:37:02 -08:00
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
if ($old['deleted']) {
|
|
|
|
$old_text = '';
|
|
|
|
} else {
|
2013-03-04 18:07:47 -08:00
|
|
|
$old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);
|
2013-02-17 06:37:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($new['deleted']) {
|
|
|
|
$new_text = '';
|
|
|
|
} else {
|
2013-03-04 18:07:47 -08:00
|
|
|
$new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
|
2013-02-17 06:37:02 -08:00
|
|
|
}
|
|
|
|
|
Allow CustomField to provide ApplicationTransaction change details
Summary:
Ref T3886. Ref T418. For fields like "Summary" and "Test Plan" where changes can't be summarized in one line, allow CustomField to provide a "(Show Details)" link and render a diff.
Also consolidate some of the existing copy/paste, and simplify this featuer slightly now that we've move to dialogs.
Test Plan:
{F115918}
- Viewed "description"-style field changes in phlux, pholio, legalpad, maniphest, differential, ponder (questions), ponder (answers), and repositories.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T3886, T418
Differential Revision: https://secure.phabricator.com/D8284
2014-02-21 11:53:04 -08:00
|
|
|
return $this->renderTextCorpusChangeDetails(
|
|
|
|
$viewer,
|
|
|
|
$old_text,
|
|
|
|
$new_text);
|
2013-02-17 06:37:02 -08:00
|
|
|
}
|
|
|
|
|
2013-01-01 18:14:41 -08:00
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_EDIT:
|
|
|
|
$old_del = idx($old, 'deleted');
|
|
|
|
$new_del = idx($new, 'deleted');
|
|
|
|
|
|
|
|
if ($old_del && !$new_del) {
|
|
|
|
return PhabricatorTransactions::COLOR_GREEN;
|
|
|
|
} else if (!$old_del && $new_del) {
|
|
|
|
return PhabricatorTransactions::COLOR_RED;
|
|
|
|
} else {
|
|
|
|
return PhabricatorTransactions::COLOR_BLUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|