Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | 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 render() { | public function render() { | ||||
| require_celerity_resource('phui-inline-comment-view-css'); | |||||
| $inline = $this->inlineComment; | $inline = $this->inlineComment; | ||||
| $start = $inline->getLineNumber(); | $classes = array( | ||||
| $length = $inline->getLineLength(); | 'differential-inline-comment', | ||||
| if ($length) { | ); | ||||
| $end = $start + $length; | |||||
| $line = 'Lines '.number_format($start).'-'.number_format($end); | |||||
| } else { | |||||
| $line = 'Line '.number_format($start); | |||||
| } | |||||
| $metadata = array( | $metadata = array( | ||||
| 'id' => $inline->getID(), | 'id' => $inline->getID(), | ||||
| 'phid' => $inline->getPHID(), | 'phid' => $inline->getPHID(), | ||||
| 'changesetID' => $inline->getChangesetID(), | 'changesetID' => $inline->getChangesetID(), | ||||
| 'number' => $inline->getLineNumber(), | 'number' => $inline->getLineNumber(), | ||||
| 'length' => $inline->getLineLength(), | 'length' => $inline->getLineLength(), | ||||
| 'isNewFile' => (bool)$inline->getIsNewFile(), | 'isNewFile' => (bool)$inline->getIsNewFile(), | ||||
| Show All 16 Lines | public function render() { | ||||
| $links = array(); | $links = array(); | ||||
| $is_synthetic = false; | $is_synthetic = false; | ||||
| if ($inline->getSyntheticAuthor()) { | if ($inline->getSyntheticAuthor()) { | ||||
| $is_synthetic = true; | $is_synthetic = true; | ||||
| } | } | ||||
| $is_draft = false; | $draft_text = null; | ||||
| if ($inline->isDraft() && !$is_synthetic) { | if (!$is_synthetic) { | ||||
| $links[] = pht('Not Submitted Yet'); | // This display is controlled by CSS | ||||
| $is_draft = true; | $draft_text = id(new PHUITagView()) | ||||
| ->setType(PHUITagView::TYPE_SHADE) | |||||
| ->setName(pht('Unsubmitted')) | |||||
| ->setSlimShady(true) | |||||
| ->setShade(PHUITagView::COLOR_RED) | |||||
| ->addClass('mml inline-draft-text'); | |||||
| } | } | ||||
| // I think this is unused | |||||
| // TODO: This stuff is nonfinal, just making it do something. | |||||
| if ($inline->getHasReplies()) { | if ($inline->getHasReplies()) { | ||||
| $links[] = pht('Has Reply'); | $classes[] = 'inline-comment-has-reply'; | ||||
| $classes[] = 'inline-has-reply'; | |||||
| } | } | ||||
| // I think this is unused | |||||
| if ($inline->getReplyToCommentPHID()) { | if ($inline->getReplyToCommentPHID()) { | ||||
| $links[] = pht('Is Reply'); | $classes[] = 'inline-comment-is-reply'; | ||||
| } | |||||
| // Might break? | |||||
| if ($this->getCanMarkDone()) { | |||||
| $classes[] = 'viewer-is-diff-author'; | |||||
| } | } | ||||
| $action_buttons = new PHUIButtonBarView(); | |||||
| $action_buttons->addClass('mml'); | |||||
| $nextprev = null; | |||||
| if (!$this->preview) { | if (!$this->preview) { | ||||
| $links[] = javelin_tag( | $nextprev = new PHUIButtonBarView(); | ||||
| 'a', | $nextprev->addClass('mml'); | ||||
| array( | $up = id(new PHUIButtonView()) | ||||
| 'href' => '#', | ->setTag('a') | ||||
| 'mustcapture' => true, | ->setColor(PHUIButtonView::SIMPLE) | ||||
| 'sigil' => 'differential-inline-prev', | ->setTooltip(pht('Previous')) | ||||
| ), | ->setIconFont('fa-chevron-up') | ||||
| pht('Previous')); | ->addSigil('differential-inline-prev') | ||||
| ->setMustCapture(true); | |||||
| $down = id(new PHUIButtonView()) | |||||
| ->setTag('a') | |||||
| ->setColor(PHUIButtonView::SIMPLE) | |||||
| ->setTooltip(pht('Next')) | |||||
| ->setIconFont('fa-chevron-down') | |||||
| ->addSigil('differential-inline-next') | |||||
| ->setMustCapture(true); | |||||
| $links[] = javelin_tag( | $nextprev->addButton($up); | ||||
| 'a', | $nextprev->addButton($down); | ||||
| array( | |||||
| 'href' => '#', | |||||
| 'mustcapture' => true, | |||||
| 'sigil' => 'differential-inline-next', | |||||
| ), | |||||
| pht('Next')); | |||||
| if ($this->allowReply) { | if ($this->allowReply) { | ||||
| if (!$is_synthetic) { | if (!$is_synthetic) { | ||||
| // NOTE: No product reason why you can't reply to these, but the reply | // NOTE: No product reason why you can't reply to these, but the reply | ||||
| // mechanism currently sends the inline comment ID to the server, not | // mechanism currently sends the inline comment ID to the server, not | ||||
| // file/line information, and synthetic comments don't have an inline | // file/line information, and synthetic comments don't have an inline | ||||
| // comment ID. | // comment ID. | ||||
| $links[] = javelin_tag( | $reply_button = id(new PHUIButtonView()) | ||||
| 'a', | ->setTag('a') | ||||
| array( | ->setColor(PHUIButtonView::SIMPLE) | ||||
| 'href' => '#', | ->setIconFont('fa-reply') | ||||
| 'mustcapture' => true, | ->setTooltip(pht('Reply')) | ||||
| 'sigil' => 'differential-inline-reply', | ->addSigil('differential-inline-reply') | ||||
| ), | ->setMustCapture(true); | ||||
| pht('Reply')); | $action_buttons->addButton($reply_button); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $anchor_name = 'inline-'.$inline->getID(); | $anchor_name = 'inline-'.$inline->getID(); | ||||
| if ($this->editable && !$this->preview) { | if ($this->editable && !$this->preview) { | ||||
| $links[] = javelin_tag( | $edit_button = id(new PHUIButtonView()) | ||||
| 'a', | ->setTag('a') | ||||
| array( | ->setColor(PHUIButtonView::SIMPLE) | ||||
| 'href' => '#', | ->setIconFont('fa-pencil') | ||||
| 'mustcapture' => true, | ->setTooltip(pht('Edit')) | ||||
| 'sigil' => 'differential-inline-edit', | ->addSigil('differential-inline-edit') | ||||
| ), | ->setMustCapture(true); | ||||
| pht('Edit')); | $action_buttons->addButton($edit_button); | ||||
| $links[] = javelin_tag( | |||||
| 'a', | $delete_button = id(new PHUIButtonView()) | ||||
| array( | ->setTag('a') | ||||
| 'href' => '#', | ->setColor(PHUIButtonView::SIMPLE) | ||||
| 'mustcapture' => true, | ->setIconFont('fa-trash-o') | ||||
| 'sigil' => 'differential-inline-delete', | ->setTooltip(pht('Delete')) | ||||
| ), | ->addSigil('differential-inline-delete') | ||||
| pht('Delete')); | ->setMustCapture(true); | ||||
| $action_buttons->addButton($delete_button); | |||||
| } else if ($this->preview) { | } else if ($this->preview) { | ||||
| $links[] = javelin_tag( | $links[] = javelin_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'class' => 'button simple', | |||||
| 'meta' => array( | 'meta' => array( | ||||
| 'anchor' => $anchor_name, | 'anchor' => $anchor_name, | ||||
| ), | ), | ||||
| 'sigil' => 'differential-inline-preview-jump', | 'sigil' => 'differential-inline-preview-jump', | ||||
| ), | ), | ||||
| pht('Not Visible')); | pht('Not Visible')); | ||||
| $links[] = javelin_tag( | |||||
| 'a', | $delete_button = id(new PHUIButtonView()) | ||||
| array( | ->setTag('a') | ||||
| 'href' => '#', | ->setColor(PHUIButtonView::SIMPLE) | ||||
| 'mustcapture' => true, | ->setTooltip(pht('Delete')) | ||||
| 'sigil' => 'differential-inline-delete', | ->setIconFont('fa-trash-o') | ||||
| ), | ->addSigil('differential-inline-delete') | ||||
| pht('Delete')); | ->setMustCapture(true); | ||||
| $action_buttons->addButton($delete_button); | |||||
| } | } | ||||
| $done_button = null; | |||||
| if (!$is_synthetic) { | if (!$is_synthetic) { | ||||
| $draft_state = false; | $draft_state = false; | ||||
| switch ($inline->getFixedState()) { | switch ($inline->getFixedState()) { | ||||
| case PhabricatorInlineCommentInterface::STATE_DRAFT: | case PhabricatorInlineCommentInterface::STATE_DRAFT: | ||||
| $is_done = ($this->getCanMarkDone()); | $is_done = ($this->getCanMarkDone()); | ||||
| $draft_state = true; | $draft_state = true; | ||||
| break; | break; | ||||
| case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | case PhabricatorInlineCommentInterface::STATE_UNDRAFT: | ||||
| Show All 12 Lines | if (!$is_synthetic) { | ||||
| if ($is_done) { | if ($is_done) { | ||||
| $classes[] = 'inline-is-done'; | $classes[] = 'inline-is-done'; | ||||
| } | } | ||||
| if ($draft_state) { | if ($draft_state) { | ||||
| $classes[] = 'inline-state-is-draft'; | $classes[] = 'inline-state-is-draft'; | ||||
| } | } | ||||
| $links[] = javelin_tag( | $done_input = javelin_tag( | ||||
| 'input', | 'input', | ||||
| array( | array( | ||||
| 'type' => 'checkbox', | 'type' => 'checkbox', | ||||
| 'checked' => ($is_done ? 'checked' : null), | 'checked' => ($is_done ? 'checked' : null), | ||||
| 'disabled' => ($this->getCanMarkDone() ? null : 'disabled'), | 'disabled' => ($this->getCanMarkDone() ? null : 'disabled'), | ||||
| 'class' => 'differential-inline-done', | 'class' => 'differential-inline-done', | ||||
| 'sigil' => 'differential-inline-done', | 'sigil' => 'differential-inline-done', | ||||
| )); | )); | ||||
| } | $done_button = phutil_tag( | ||||
| 'label', | |||||
| if ($links) { | array( | ||||
| $links = phutil_tag( | 'class' => 'differential-inline-done-label '. | ||||
| 'span', | ($this->getCanMarkDone() ? null : 'done-is-disabled'), | ||||
| array('class' => 'differential-inline-comment-links'), | ), | ||||
| phutil_implode_html(" \xC2\xB7 ", $links)); | array( | ||||
| } else { | $done_input, | ||||
| $links = null; | pht('Done'), | ||||
| )); | |||||
| } | } | ||||
| $content = $this->markupEngine->getOutput( | $content = $this->markupEngine->getOutput( | ||||
| $inline, | $inline, | ||||
| PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); | PhabricatorInlineCommentInterface::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, | ||||
| 'id' => $anchor_name, | 'id' => $anchor_name, | ||||
| 'class' => 'differential-inline-comment-anchor', | 'class' => 'differential-inline-comment-anchor', | ||||
| ), | ), | ||||
| ''); | ''); | ||||
| } | } | ||||
| if ($is_draft) { | if ($inline->isDraft() && !$is_synthetic) { | ||||
| $classes[] = 'differential-inline-comment-unsaved-draft'; | $classes[] = 'differential-inline-comment-unsaved-draft'; | ||||
| } | } | ||||
| if ($is_synthetic) { | if ($is_synthetic) { | ||||
| $classes[] = 'differential-inline-comment-synthetic'; | $classes[] = 'differential-inline-comment-synthetic'; | ||||
| } | } | ||||
| $classes = implode(' ', $classes); | $classes = implode(' ', $classes); | ||||
| $author_owner = null; | |||||
| if ($is_synthetic) { | if ($is_synthetic) { | ||||
| $author = $inline->getSyntheticAuthor(); | $author = $inline->getSyntheticAuthor(); | ||||
| } else { | } else { | ||||
| $author = $handles[$inline->getAuthorPHID()]->getName(); | $author = $handles[$inline->getAuthorPHID()]->getName(); | ||||
| if ($inline->getAuthorPHID() == $this->objectOwnerPHID) { | |||||
| $author_owner = id(new PHUITagView()) | |||||
| ->setType(PHUITagView::TYPE_SHADE) | |||||
| ->setName(pht('Author')) | |||||
| ->setSlimShady(true) | |||||
| ->setShade(PHUITagView::COLOR_YELLOW) | |||||
| ->addClass('mml'); | |||||
| } | } | ||||
| } | |||||
| $group_left = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'class' => 'inline-head-left', | |||||
| ), | |||||
| array( | |||||
| $author, | |||||
| $author_owner, | |||||
| $draft_text, | |||||
| )); | |||||
| $line = phutil_tag( | $group_right = phutil_tag( | ||||
| 'span', | 'div', | ||||
| array('class' => 'differential-inline-comment-line'), | array( | ||||
| $line); | 'class' => 'inline-head-right', | ||||
| ), | |||||
| array( | |||||
| $anchor, | |||||
| $links, | |||||
| $nextprev, | |||||
| $action_buttons, | |||||
| $done_button, | |||||
| )); | |||||
| $markup = javelin_tag( | $markup = javelin_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => $classes, | 'class' => $classes, | ||||
| 'sigil' => $sigil, | 'sigil' => $sigil, | ||||
| 'meta' => $metadata, | 'meta' => $metadata, | ||||
| ), | ), | ||||
| array( | array( | ||||
| phutil_tag_div('differential-inline-comment-head', array( | phutil_tag_div('differential-inline-comment-head grouped', array( | ||||
| $anchor, | $group_left, | ||||
| $links, | $group_right, | ||||
| ' ', | |||||
| $line, | |||||
| ' ', | |||||
| $author, | |||||
| )), | )), | ||||
| phutil_tag_div( | phutil_tag_div( | ||||
| 'differential-inline-comment-content', | 'differential-inline-comment-content', | ||||
| phutil_tag_div('phabricator-remarkup', $content)), | phutil_tag_div('phabricator-remarkup', $content)), | ||||
| )); | )); | ||||
| return $markup; | return $markup; | ||||
| } | } | ||||
| } | } | ||||