2014-02-03 19:52:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDashboardTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
|
|
|
const TYPE_NAME = 'dashboard:name';
|
2016-12-13 19:52:19 +01:00
|
|
|
const TYPE_ICON = 'dashboard:icon';
|
2015-07-23 23:22:56 +02:00
|
|
|
const TYPE_STATUS = 'dashboard:status';
|
2014-05-16 04:12:40 +02:00
|
|
|
const TYPE_LAYOUT_MODE = 'dashboard:layoutmode';
|
2014-02-03 19:52:15 +01:00
|
|
|
|
|
|
|
public function getApplicationName() {
|
|
|
|
return 'dashboard';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
2014-07-24 00:05:46 +02:00
|
|
|
return PhabricatorDashboardDashboardPHIDType::TYPECONST;
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$author_link = $this->renderHandleLink($author_phid);
|
|
|
|
|
|
|
|
$type = $this->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case self::TYPE_NAME:
|
|
|
|
if (!strlen($old)) {
|
|
|
|
return pht(
|
|
|
|
'%s created this dashboard.',
|
|
|
|
$author_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s renamed this dashboard from "%s" to "%s".',
|
|
|
|
$author_link,
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
2015-07-23 23:22:56 +02:00
|
|
|
break;
|
2016-12-13 19:52:19 +01:00
|
|
|
case self::TYPE_ICON:
|
|
|
|
if (!strlen($old)) {
|
|
|
|
return pht(
|
|
|
|
'%s set the dashboard icon.',
|
|
|
|
$author_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s changed this dashboard icon from "%s" to "%s".',
|
|
|
|
$author_link,
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
break;
|
2015-07-23 23:22:56 +02:00
|
|
|
case self::TYPE_STATUS:
|
|
|
|
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
|
|
|
|
return pht(
|
2017-02-09 23:17:54 +01:00
|
|
|
'%s activated this dashboard.',
|
2015-07-23 23:22:56 +02:00
|
|
|
$author_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
2017-02-09 23:17:54 +01:00
|
|
|
'%s archived this dashboard.',
|
2015-07-23 23:22:56 +02:00
|
|
|
$author_link);
|
|
|
|
}
|
|
|
|
break;
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2015-01-02 17:45:43 +01:00
|
|
|
public function getTitleForFeed() {
|
2014-02-03 19:52:15 +01:00
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$author_link = $this->renderHandleLink($author_phid);
|
|
|
|
$object_link = $this->renderHandleLink($object_phid);
|
|
|
|
|
|
|
|
$type = $this->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case self::TYPE_NAME:
|
|
|
|
if (!strlen($old)) {
|
|
|
|
return pht(
|
|
|
|
'%s created dashboard %s.',
|
|
|
|
$author_link,
|
|
|
|
$object_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s renamed dashboard %s from "%s" to "%s".',
|
|
|
|
$author_link,
|
|
|
|
$object_link,
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
2015-07-23 23:22:56 +02:00
|
|
|
break;
|
2016-12-13 19:52:19 +01:00
|
|
|
case self::TYPE_ICON:
|
|
|
|
if (!strlen($old)) {
|
|
|
|
return pht(
|
|
|
|
'%s set dashboard icon for %s.',
|
|
|
|
$author_link,
|
|
|
|
$object_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s set the dashboard icon on %s from "%s" to "%s".',
|
|
|
|
$author_link,
|
|
|
|
$object_link,
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
break;
|
2015-07-23 23:22:56 +02:00
|
|
|
case self::TYPE_STATUS:
|
|
|
|
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
|
|
|
|
return pht(
|
|
|
|
'%s activated dashboard %s.',
|
|
|
|
$author_link,
|
|
|
|
$object_link);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s archived dashboard %s.',
|
|
|
|
$author_link,
|
|
|
|
$object_link);
|
|
|
|
}
|
|
|
|
break;
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|
|
|
|
|
2015-01-02 17:45:43 +01:00
|
|
|
return parent::getTitleForFeed();
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_NAME:
|
|
|
|
if (!strlen($old)) {
|
|
|
|
return PhabricatorTransactions::COLOR_GREEN;
|
|
|
|
}
|
|
|
|
break;
|
2015-07-23 23:22:56 +02:00
|
|
|
case self::TYPE_STATUS:
|
|
|
|
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
|
|
|
|
return PhabricatorTransactions::COLOR_GREEN;
|
|
|
|
} else {
|
|
|
|
return PhabricatorTransactions::COLOR_INDIGO;
|
|
|
|
}
|
|
|
|
break;
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getColor();
|
|
|
|
}
|
2014-05-16 04:12:40 +02:00
|
|
|
|
2015-07-23 23:22:56 +02:00
|
|
|
public function getIcon() {
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_NAME:
|
|
|
|
return 'fa-pencil';
|
|
|
|
break;
|
|
|
|
case self::TYPE_STATUS:
|
|
|
|
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
|
|
|
|
return 'fa-check';
|
|
|
|
} else {
|
|
|
|
return 'fa-ban';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case self::TYPE_LAYOUT_MODE:
|
|
|
|
return 'fa-columns';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
2014-05-16 04:12:40 +02:00
|
|
|
public function shouldHide() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_LAYOUT_MODE:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return parent::shouldHide();
|
|
|
|
}
|
2014-02-03 19:52:15 +01:00
|
|
|
}
|