mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Show a trigger rule summary on the rule view page
Summary: Ref T5474. When you view the main page for a rule, show what the rule does before you actually edit it. Test Plan: Viewed a real trigger, then faked invalid/unknown rules: {F6300211} {F6300212} {F6300213} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T5474 Differential Revision: https://secure.phabricator.com/D20303
This commit is contained in:
parent
ff128e1b32
commit
614f39b806
6 changed files with 123 additions and 1 deletions
|
@ -21,6 +21,7 @@ final class PhabricatorProjectTriggerViewController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$rules_view = $this->newRulesView($trigger);
|
||||
$columns_view = $this->newColumnsView($trigger);
|
||||
|
||||
$title = $trigger->getObjectName();
|
||||
|
@ -40,6 +41,7 @@ final class PhabricatorProjectTriggerViewController
|
|||
->setCurtain($curtain)
|
||||
->setMainColumn(
|
||||
array(
|
||||
$rules_view,
|
||||
$columns_view,
|
||||
$timeline,
|
||||
));
|
||||
|
@ -139,6 +141,48 @@ final class PhabricatorProjectTriggerViewController
|
|||
->setTable($table_view);
|
||||
}
|
||||
|
||||
private function newRulesView(PhabricatorProjectTrigger $trigger) {
|
||||
$viewer = $this->getViewer();
|
||||
$rules = $trigger->getTriggerRules();
|
||||
|
||||
$rows = array();
|
||||
foreach ($rules as $rule) {
|
||||
$value = $rule->getRecord()->getValue();
|
||||
|
||||
$rows[] = array(
|
||||
$rule->getRuleViewIcon($value),
|
||||
$rule->getRuleViewLabel(),
|
||||
$rule->getRuleViewDescription($value),
|
||||
);
|
||||
}
|
||||
|
||||
$table_view = id(new AphrontTableView($rows))
|
||||
->setNoDataString(pht('This trigger has no rules.'))
|
||||
->setHeaders(
|
||||
array(
|
||||
null,
|
||||
pht('Rule'),
|
||||
pht('Action'),
|
||||
))
|
||||
->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
'pri',
|
||||
'wide',
|
||||
));
|
||||
|
||||
$header_view = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Trigger Rules'))
|
||||
->setSubheader(
|
||||
pht(
|
||||
'When a card is dropped into a column that uses this trigger, '.
|
||||
'these actions will be taken.'));
|
||||
|
||||
return id(new PHUIObjectBoxView())
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||
->setHeader($header_view)
|
||||
->setTable($table_view);
|
||||
}
|
||||
private function newCurtain(PhabricatorProjectTrigger $trigger) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
|
|
|
@ -174,7 +174,8 @@ final class PhabricatorProjectTrigger
|
|||
}
|
||||
|
||||
$rule = id(new PhabricatorProjectTriggerInvalidRule())
|
||||
->setRecord($record);
|
||||
->setRecord($record)
|
||||
->setException($ex);
|
||||
}
|
||||
|
||||
$trigger_rules[] = $rule;
|
||||
|
|
|
@ -5,6 +5,17 @@ final class PhabricatorProjectTriggerInvalidRule
|
|||
|
||||
const TRIGGERTYPE = 'invalid';
|
||||
|
||||
private $exception;
|
||||
|
||||
public function setException(Exception $exception) {
|
||||
$this->exception = $exception;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getException() {
|
||||
return $this->exception;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return pht(
|
||||
'Invalid rule (of type "%s").',
|
||||
|
@ -59,4 +70,30 @@ final class PhabricatorProjectTriggerInvalidRule
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getRuleViewLabel() {
|
||||
return pht('Invalid Rule');
|
||||
}
|
||||
|
||||
public function getRuleViewDescription($value) {
|
||||
$record = $this->getRecord();
|
||||
$type = $record->getType();
|
||||
|
||||
$exception = $this->getException();
|
||||
if ($exception) {
|
||||
return pht(
|
||||
'This rule (of type "%s") is invalid: %s',
|
||||
$type,
|
||||
$exception->getMessage());
|
||||
} else {
|
||||
return pht(
|
||||
'This rule (of type "%s") is invalid.',
|
||||
$type);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRuleViewIcon($value) {
|
||||
return id(new PHUIIconView())
|
||||
->setIcon('fa-exclamation-triangle', 'red');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,4 +77,25 @@ final class PhabricatorProjectTriggerManiphestStatusRule
|
|||
);
|
||||
}
|
||||
|
||||
public function getRuleViewLabel() {
|
||||
return pht('Change Status');
|
||||
}
|
||||
|
||||
public function getRuleViewDescription($value) {
|
||||
$status_name = ManiphestTaskStatus::getTaskStatusName($value);
|
||||
|
||||
return pht(
|
||||
'Change task status to %s.',
|
||||
phutil_tag('strong', array(), $status_name));
|
||||
}
|
||||
|
||||
public function getRuleViewIcon($value) {
|
||||
$status_icon = ManiphestTaskStatus::getStatusIcon($value);
|
||||
$status_color = ManiphestTaskStatus::getStatusColor($value);
|
||||
|
||||
return id(new PHUIIconView())
|
||||
->setIcon($status_icon, $status_color);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ abstract class PhabricatorProjectTriggerRule
|
|||
|
||||
abstract public function getDescription();
|
||||
abstract public function getSelectControlName();
|
||||
abstract public function getRuleViewLabel();
|
||||
abstract public function getRuleViewDescription($value);
|
||||
abstract public function getRuleViewIcon($value);
|
||||
abstract protected function assertValidRuleValue($value);
|
||||
abstract protected function newDropTransactions($object, $value);
|
||||
abstract protected function newDropEffects($value);
|
||||
|
|
|
@ -58,4 +58,20 @@ final class PhabricatorProjectTriggerUnknownRule
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getRuleViewLabel() {
|
||||
return pht('Unknown Rule');
|
||||
}
|
||||
|
||||
public function getRuleViewDescription($value) {
|
||||
return pht(
|
||||
'This is an unknown rule of type "%s". An administrator may have '.
|
||||
'edited or removed an extension which implements this rule type.',
|
||||
$this->getRecord()->getType());
|
||||
}
|
||||
|
||||
public function getRuleViewIcon($value) {
|
||||
return id(new PHUIIconView())
|
||||
->setIcon('fa-question-circle', 'yellow');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue