Fix task hovercards showing a "Not Editable" state

Summary:
Ref T13269. These cards really have three states:

  - Editable: shows a pencil icon edit button.
  - You Do Not Have Permission To Edit This: shows a "no editing" icon in red.
  - Hovecard: shouldn't show anything.

However, the "hovercard" and "no permission" states are currently the same state, so when I made the "no permission" state more obvious that made the hovercard go all weird.

Make these states explicitly separate states.

Test Plan:
Looked at a...

  - Editable card on workboard: edit state.
  - No permission card on workboard: no permission state.
  - Any hovercard: "not editable, this is a hovercard" state.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13269

Differential Revision: https://secure.phabricator.com/D20330
This commit is contained in:
epriestley 2019-03-26 15:27:05 -07:00
parent b328af0a1b
commit 4485482fd4
3 changed files with 31 additions and 19 deletions

View file

@ -47,8 +47,7 @@ final class ManiphestHovercardEngineExtension
$card = id(new ProjectBoardTaskCard()) $card = id(new ProjectBoardTaskCard())
->setViewer($viewer) ->setViewer($viewer)
->setTask($task) ->setTask($task);
->setCanEdit(false);
$owner_phid = $task->getOwnerPHID(); $owner_phid = $task->getOwnerPHID();
if ($owner_phid) { if ($owner_phid) {

View file

@ -56,6 +56,7 @@ final class PhabricatorBoardRenderingEngine extends Phobject {
$card = id(new ProjectBoardTaskCard()) $card = id(new ProjectBoardTaskCard())
->setViewer($viewer) ->setViewer($viewer)
->setTask($object) ->setTask($object)
->setShowEditControls(true)
->setCanEdit($this->getCanEdit($phid)); ->setCanEdit($this->getCanEdit($phid));
$owner_phid = $object->getOwnerPHID(); $owner_phid = $object->getOwnerPHID();

View file

@ -6,6 +6,7 @@ final class ProjectBoardTaskCard extends Phobject {
private $projectHandles; private $projectHandles;
private $task; private $task;
private $owner; private $owner;
private $showEditControls;
private $canEdit; private $canEdit;
private $coverImageFile; private $coverImageFile;
private $hideArchivedProjects; private $hideArchivedProjects;
@ -70,6 +71,15 @@ final class ProjectBoardTaskCard extends Phobject {
return $this->canEdit; return $this->canEdit;
} }
public function setShowEditControls($show_edit_controls) {
$this->showEditControls = $show_edit_controls;
return $this;
}
public function getShowEditControls() {
return $this->showEditControls;
}
public function getItem() { public function getItem() {
$task = $this->getTask(); $task = $this->getTask();
$owner = $this->getOwner(); $owner = $this->getOwner();
@ -89,24 +99,26 @@ final class ProjectBoardTaskCard extends Phobject {
->setDisabled($task->isClosed()) ->setDisabled($task->isClosed())
->setBarColor($bar_color); ->setBarColor($bar_color);
if ($can_edit) { if ($this->getShowEditControls()) {
$card if ($can_edit) {
->addSigil('draggable-card') $card
->addClass('draggable-card'); ->addSigil('draggable-card')
$edit_icon = 'fa-pencil'; ->addClass('draggable-card');
} else { $edit_icon = 'fa-pencil';
$card } else {
->addClass('not-editable') $card
->addClass('undraggable-card'); ->addClass('not-editable')
$edit_icon = 'fa-lock red'; ->addClass('undraggable-card');
} $edit_icon = 'fa-lock red';
}
$card->addAction( $card->addAction(
id(new PHUIListItemView()) id(new PHUIListItemView())
->setName(pht('Edit')) ->setName(pht('Edit'))
->setIcon($edit_icon) ->setIcon($edit_icon)
->addSigil('edit-project-card') ->addSigil('edit-project-card')
->setHref('/maniphest/task/edit/'.$task->getID().'/')); ->setHref('/maniphest/task/edit/'.$task->getID().'/'));
}
if ($owner) { if ($owner) {
$card->addHandleIcon($owner, $owner->getName()); $card->addHandleIcon($owner, $owner->getName());