Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
| <?php | <?php | ||||
| final class PHUIDiffInlineCommentDetailView | final class PHUIDiffInlineCommentDetailView | ||||
| extends PHUIDiffInlineCommentView { | extends PHUIDiffInlineCommentView { | ||||
| private $inlineComment; | |||||
| private $handles; | private $handles; | ||||
| private $markupEngine; | private $markupEngine; | ||||
| private $editable; | private $editable; | ||||
| private $preview; | private $preview; | ||||
| private $allowReply; | private $allowReply; | ||||
| private $renderer; | |||||
| private $canMarkDone; | private $canMarkDone; | ||||
| private $objectOwnerPHID; | private $objectOwnerPHID; | ||||
| public function setInlineComment(PhabricatorInlineCommentInterface $comment) { | |||||
| $this->inlineComment = $comment; | |||||
| return $this; | |||||
| } | |||||
| public function isHidden() { | public function isHidden() { | ||||
| return $this->inlineComment->isHidden(); | return $this->getInlineComment()->isHidden(); | ||||
| } | } | ||||
| public function setHandles(array $handles) { | public function setHandles(array $handles) { | ||||
| assert_instances_of($handles, 'PhabricatorObjectHandle'); | assert_instances_of($handles, 'PhabricatorObjectHandle'); | ||||
| $this->handles = $handles; | $this->handles = $handles; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| Show All 12 Lines | public function setPreview($preview) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setAllowReply($allow_reply) { | public function setAllowReply($allow_reply) { | ||||
| $this->allowReply = $allow_reply; | $this->allowReply = $allow_reply; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setRenderer($renderer) { | |||||
| $this->renderer = $renderer; | |||||
| return $this; | |||||
| } | |||||
| public function getRenderer() { | |||||
| return $this->renderer; | |||||
| } | |||||
| public function setCanMarkDone($can_mark_done) { | public function setCanMarkDone($can_mark_done) { | ||||
| $this->canMarkDone = $can_mark_done; | $this->canMarkDone = $can_mark_done; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getCanMarkDone() { | public function getCanMarkDone() { | ||||
| return $this->canMarkDone; | return $this->canMarkDone; | ||||
| } | } | ||||
| public function setObjectOwnerPHID($phid) { | public function setObjectOwnerPHID($phid) { | ||||
| $this->objectOwnerPHID = $phid; | $this->objectOwnerPHID = $phid; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getObjectOwnerPHID() { | public function getObjectOwnerPHID() { | ||||
| return $this->objectOwnerPHID; | return $this->objectOwnerPHID; | ||||
| } | } | ||||
| public function getAnchorName() { | public function getAnchorName() { | ||||
| $inline = $this->inlineComment; | $inline = $this->getInlineComment(); | ||||
| if ($inline->getID()) { | if ($inline->getID()) { | ||||
| return 'inline-'.$inline->getID(); | return 'inline-'.$inline->getID(); | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function getScaffoldCellID() { | public function getScaffoldCellID() { | ||||
| $anchor = $this->getAnchorName(); | $anchor = $this->getAnchorName(); | ||||
| if ($anchor) { | if ($anchor) { | ||||
| return 'anchor-'.$anchor; | return 'anchor-'.$anchor; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function render() { | public function render() { | ||||
| require_celerity_resource('phui-inline-comment-view-css'); | require_celerity_resource('phui-inline-comment-view-css'); | ||||
| $inline = $this->inlineComment; | $inline = $this->getInlineComment(); | ||||
| $classes = array( | $classes = array( | ||||
| 'differential-inline-comment', | 'differential-inline-comment', | ||||
| ); | ); | ||||
| $is_fixed = false; | |||||
| switch ($inline->getFixedState()) { | |||||
| case PhabricatorInlineCommentInterface::STATE_DONE: | |||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | |||||
| $is_fixed = true; | |||||
| break; | |||||
| } | |||||
| $is_draft_done = false; | |||||
| switch ($inline->getFixedState()) { | |||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | |||||
| case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | |||||
| $is_draft_done = true; | |||||
| break; | |||||
| } | |||||
| $is_synthetic = false; | $is_synthetic = false; | ||||
| if ($inline->getSyntheticAuthor()) { | if ($inline->getSyntheticAuthor()) { | ||||
| $is_synthetic = true; | $is_synthetic = true; | ||||
| } | } | ||||
| $metadata = array( | $metadata = $this->getInlineCommentMetadata(); | ||||
| 'id' => $inline->getID(), | |||||
| 'phid' => $inline->getPHID(), | |||||
| 'changesetID' => $inline->getChangesetID(), | |||||
| 'number' => $inline->getLineNumber(), | |||||
| 'length' => $inline->getLineLength(), | |||||
| 'isNewFile' => (bool)$inline->getIsNewFile(), | |||||
| 'on_right' => $this->getIsOnRight(), | |||||
| 'original' => $inline->getContent(), | |||||
| 'replyToCommentPHID' => $inline->getReplyToCommentPHID(), | |||||
| 'isDraft' => $inline->isDraft(), | |||||
| 'isFixed' => $is_fixed, | |||||
| 'isGhost' => $inline->getIsGhost(), | |||||
| 'isSynthetic' => $is_synthetic, | |||||
| 'isDraftDone' => $is_draft_done, | |||||
| ); | |||||
| $sigil = 'differential-inline-comment'; | $sigil = 'differential-inline-comment'; | ||||
| if ($this->preview) { | if ($this->preview) { | ||||
| $sigil = $sigil.' differential-inline-comment-preview'; | $sigil = $sigil.' differential-inline-comment-preview'; | ||||
| } | } | ||||
| $classes = array( | $classes = array( | ||||
| 'differential-inline-comment', | 'differential-inline-comment', | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | if ($viewer_phid == $inline->getAuthorPHID()) { | ||||
| if ($inline->isDraft()) { | if ($inline->isDraft()) { | ||||
| $mark_done = true; | $mark_done = true; | ||||
| } | } | ||||
| } | } | ||||
| if (!$is_synthetic) { | if (!$is_synthetic) { | ||||
| $draft_state = false; | $draft_state = false; | ||||
| switch ($inline->getFixedState()) { | switch ($inline->getFixedState()) { | ||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | case PhabricatorInlineComment::STATE_DRAFT: | ||||
| $is_done = $mark_done; | $is_done = $mark_done; | ||||
| $draft_state = true; | $draft_state = true; | ||||
| break; | break; | ||||
| case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | case PhabricatorInlineComment::STATE_UNDRAFT: | ||||
| $is_done = !$mark_done; | $is_done = !$mark_done; | ||||
| $draft_state = true; | $draft_state = true; | ||||
| break; | break; | ||||
| case PhabricatorInlineCommentInterface::STATE_DONE: | case PhabricatorInlineComment::STATE_DONE: | ||||
| $is_done = true; | $is_done = true; | ||||
| break; | break; | ||||
| default: | default: | ||||
| case PhabricatorInlineCommentInterface::STATE_UNDONE: | case PhabricatorInlineComment::STATE_UNDONE: | ||||
| $is_done = false; | $is_done = false; | ||||
| break; | break; | ||||
| } | } | ||||
| // If you don't have permission to mark the comment as "Done", you also | // If you don't have permission to mark the comment as "Done", you also | ||||
| // can not see the draft state. | // can not see the draft state. | ||||
| if (!$mark_done) { | if (!$mark_done) { | ||||
| $draft_state = false; | $draft_state = false; | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (!$is_synthetic) { | ||||
| $icon, | $icon, | ||||
| $label, | $label, | ||||
| )); | )); | ||||
| } | } | ||||
| } | } | ||||
| $content = $this->markupEngine->getOutput( | $content = $this->markupEngine->getOutput( | ||||
| $inline, | $inline, | ||||
| PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | PhabricatorInlineComment::MARKUP_FIELD_BODY); | ||||
| if ($this->preview) { | if ($this->preview) { | ||||
| $anchor = null; | $anchor = null; | ||||
| } else { | } else { | ||||
| $anchor = phutil_tag( | $anchor = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'name' => $anchor_name, | 'name' => $anchor_name, | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | public function render() { | ||||
| return array( | return array( | ||||
| $anchor, | $anchor, | ||||
| $markup, | $markup, | ||||
| $summary, | $summary, | ||||
| ); | ); | ||||
| } | } | ||||
| private function canHide() { | private function canHide() { | ||||
| $inline = $this->inlineComment; | $inline = $this->getInlineComment(); | ||||
| if ($inline->isDraft()) { | if ($inline->isDraft()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (!$inline->getID()) { | if (!$inline->getID()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| Show All 14 Lines | |||||