Don't show workboard action previews if the action won't have any effect

Summary:
Ref T10335. When you (for example) drag a "Resolved" task into a column with "Trigger: change status to resolved.", don't show a hint that the action will "Change status to resolved." since this isn't helpful and is somewhat confusing.

For now, the only visibility operator is "!=" since all current actions are simple field comparisons, but some actions in the future (like "add subscriber" or "remove project") might need other conditions.

Test Plan:
Dragged cards in ways that previously provided useless hints: move from column A to column B on a "Group by Priority" board; drag a resolved task to a "Trigger: change status to as resolved" column. Saw a more accurate preview in both cases.

Drags which actually cause effects still show the effects correctly.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T10335

Differential Revision: https://secure.phabricator.com/D20300
This commit is contained in:
epriestley
2019-03-19 19:29:33 -07:00
parent 5dca1569b5
commit a5b3e33e3c
9 changed files with 83 additions and 22 deletions

View File

@@ -655,6 +655,8 @@ final class PhabricatorProjectBoardViewController
$properties[$task->getPHID()] = array(
'points' => (double)$task->getPoints(),
'status' => $task->getStatus(),
'priority' => (int)$task->getPriority(),
'owner' => $task->getOwnerPHID(),
);
}

View File

@@ -6,6 +6,7 @@ final class PhabricatorProjectDropEffect
private $icon;
private $color;
private $content;
private $conditions = array();
public function setIcon($icon) {
$this->icon = $icon;
@@ -39,7 +40,22 @@ final class PhabricatorProjectDropEffect
'icon' => $this->getIcon(),
'color' => $this->getColor(),
'content' => hsprintf('%s', $this->getContent()),
'conditions' => $this->getConditions(),
);
}
public function addCondition($field, $operator, $value) {
$this->conditions[] = array(
'field' => $field,
'operator' => $operator,
'value' => $value,
);
return $this;
}
public function getConditions() {
return $this->conditions;
}
}

View File

@@ -171,6 +171,7 @@ final class PhabricatorProjectColumnOwnerOrder
$this->newEffect()
->setIcon($owner_icon)
->setColor($owner_color)
->addCondition('owner', '!=', $owner_phid)
->setContent($effect_content));
}

View File

@@ -68,6 +68,7 @@ final class PhabricatorProjectColumnPriorityOrder
$drop_effect = $this->newEffect()
->setIcon($priority_icon)
->setColor($priority_color)
->addCondition('priority', '!=', $priority)
->setContent(
pht(
'Change priority to %s.',

View File

@@ -75,6 +75,7 @@ final class PhabricatorProjectColumnStatusOrder
$drop_effect = $this->newEffect()
->setIcon($status_icon)
->setColor($status_color)
->addCondition('status', '!=', $status_key)
->setContent(
pht(
'Change status to %s.',

View File

@@ -51,6 +51,7 @@ final class PhabricatorProjectTriggerManiphestStatusRule
$this->newEffect()
->setIcon($status_icon)
->setColor($status_color)
->addCondition('status', '!=', $value)
->setContent($content),
);
}