mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
953ff197bf
Summary: Ref T603. Ref T1279. Further improves transaction and policy support for Herald. - Instead of deleting rules (which wipes out history and can't be undone) allow them to be disabled. - Track disables with transactions. - Gate disables with policy controls. - Show policy and status information in the headers. - Show transaction history on rule detail screens. - Remove the delete controller. - Support disabled queries in the ApplicationSearch. Test Plan: - Enabled and disabled rules. - Searched for enabled/disabled rules. - Verified disabled rules don't activate. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1279, T603 Differential Revision: https://secure.phabricator.com/D7247
92 lines
1.9 KiB
PHP
92 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class HeraldRuleTransaction
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
const TYPE_EDIT = 'herald:edit';
|
|
const TYPE_DISABLE = 'herald:disable';
|
|
|
|
public function getApplicationName() {
|
|
return 'herald';
|
|
}
|
|
|
|
public function getApplicationTransactionType() {
|
|
return HeraldPHIDTypeRule::TYPECONST;
|
|
}
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
return new HeraldRuleTransactionComment();
|
|
}
|
|
|
|
public function getColor() {
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_DISABLE:
|
|
if ($new) {
|
|
return 'red';
|
|
} else {
|
|
return 'green';
|
|
}
|
|
}
|
|
|
|
return parent::getColor();
|
|
}
|
|
|
|
public function getActionName() {
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_DISABLE:
|
|
if ($new) {
|
|
return pht('Disabled');
|
|
} else {
|
|
return pht('Enabled');
|
|
}
|
|
}
|
|
|
|
return parent::getActionName();
|
|
}
|
|
|
|
public function getIcon() {
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_DISABLE:
|
|
if ($new) {
|
|
return 'disable';
|
|
} else {
|
|
return 'enable';
|
|
}
|
|
}
|
|
|
|
return parent::getIcon();
|
|
}
|
|
|
|
|
|
public function getTitle() {
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$old = $this->getOldValue();
|
|
$new = $this->getNewValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
case self::TYPE_DISABLE:
|
|
if ($new) {
|
|
return pht(
|
|
'%s disabled this rule.',
|
|
$this->renderHandleLink($author_phid));
|
|
} else {
|
|
return pht(
|
|
'%s enabled this rule.',
|
|
$this->renderHandleLink($author_phid));
|
|
}
|
|
}
|
|
|
|
return parent::getTitle();
|
|
}
|
|
|
|
}
|