Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | $classes = array( | ||||
'differential-inline-comment', | 'differential-inline-comment', | ||||
); | ); | ||||
$is_synthetic = false; | $is_synthetic = false; | ||||
if ($inline->getSyntheticAuthor()) { | if ($inline->getSyntheticAuthor()) { | ||||
$is_synthetic = true; | $is_synthetic = true; | ||||
} | } | ||||
$is_preview = $this->preview; | |||||
$metadata = $this->getInlineCommentMetadata(); | $metadata = $this->getInlineCommentMetadata(); | ||||
$sigil = 'differential-inline-comment'; | $sigil = 'differential-inline-comment'; | ||||
if ($this->preview) { | if ($is_preview) { | ||||
$sigil = $sigil.' differential-inline-comment-preview'; | $sigil = $sigil.' differential-inline-comment-preview'; | ||||
} | } | ||||
$classes = array( | $classes = array( | ||||
'differential-inline-comment', | 'differential-inline-comment', | ||||
); | ); | ||||
$content = $inline->getContent(); | $content = $inline->getContent(); | ||||
Show All 38 Lines | if ($ghost) { | ||||
'class' => 'ghost-icon', | 'class' => 'ghost-icon', | ||||
'href' => $ghost['href'], | 'href' => $ghost['href'], | ||||
'target' => '_blank', | 'target' => '_blank', | ||||
), | ), | ||||
$ghost_icon); | $ghost_icon); | ||||
$classes[] = 'inline-comment-ghost'; | $classes[] = 'inline-comment-ghost'; | ||||
} | } | ||||
// I think this is unused | |||||
if ($inline->getHasReplies()) { | |||||
$classes[] = 'inline-comment-has-reply'; | |||||
} | |||||
if ($inline->getReplyToCommentPHID()) { | if ($inline->getReplyToCommentPHID()) { | ||||
$classes[] = 'inline-comment-is-reply'; | $classes[] = 'inline-comment-is-reply'; | ||||
} | } | ||||
$viewer_phid = $this->getUser()->getPHID(); | $viewer_phid = $this->getUser()->getPHID(); | ||||
$owner_phid = $this->getObjectOwnerPHID(); | $owner_phid = $this->getObjectOwnerPHID(); | ||||
if ($viewer_phid) { | if ($viewer_phid) { | ||||
if ($viewer_phid == $owner_phid) { | if ($viewer_phid == $owner_phid) { | ||||
$classes[] = 'viewer-is-object-owner'; | $classes[] = 'viewer-is-object-owner'; | ||||
} | } | ||||
} | } | ||||
$anchor_name = $this->getAnchorName(); | $anchor_name = $this->getAnchorName(); | ||||
$action_buttons = array(); | $action_buttons = array(); | ||||
$menu_items = array(); | |||||
$can_reply = | if ($this->editable && !$is_preview) { | ||||
(!$this->editable) && | $menu_items[] = array( | ||||
(!$this->preview) && | 'label' => pht('Edit Comment'), | ||||
($this->allowReply) && | 'icon' => 'fa-pencil', | ||||
'action' => 'edit', | |||||
// NOTE: No product reason why you can't reply to synthetic comments, | 'key' => 'e', | ||||
// but the reply mechanism currently sends the inline comment ID to the | ); | ||||
// server, not file/line information, and synthetic comments don't have | |||||
// an inline comment ID. | |||||
(!$is_synthetic); | |||||
if ($can_reply) { | |||||
$action_buttons[] = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setIcon('fa-reply') | |||||
->setTooltip(pht('Reply')) | |||||
->addSigil('differential-inline-reply') | |||||
->setMustCapture(true) | |||||
->setAuralLabel(pht('Reply')); | |||||
} | |||||
if ($this->editable && !$this->preview) { | |||||
$action_buttons[] = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setIcon('fa-pencil') | |||||
->setTooltip(pht('Edit')) | |||||
->addSigil('differential-inline-edit') | |||||
->setMustCapture(true) | |||||
->setAuralLabel(pht('Edit')); | |||||
$action_buttons[] = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setIcon('fa-trash-o') | |||||
->setTooltip(pht('Delete')) | |||||
->addSigil('differential-inline-delete') | |||||
->setMustCapture(true) | |||||
->setAuralLabel(pht('Delete')); | |||||
} else if ($this->preview) { | $menu_items[] = array( | ||||
'label' => pht('Delete Comment'), | |||||
'icon' => 'fa-trash-o', | |||||
'action' => 'delete', | |||||
); | |||||
} else if ($is_preview) { | |||||
$links[] = javelin_tag( | $links[] = javelin_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => 'inline-button-divider pml msl', | 'class' => 'inline-button-divider pml msl', | ||||
'meta' => array( | 'meta' => array( | ||||
'inlineCommentID' => $inline->getID(), | 'inlineCommentID' => $inline->getID(), | ||||
), | ), | ||||
'sigil' => 'differential-inline-preview-jump', | 'sigil' => 'differential-inline-preview-jump', | ||||
), | ), | ||||
pht('View')); | pht('View')); | ||||
$action_buttons[] = id(new PHUIButtonView()) | $action_buttons[] = id(new PHUIButtonView()) | ||||
->setTag('a') | ->setTag('a') | ||||
->setTooltip(pht('Delete')) | ->setTooltip(pht('Delete')) | ||||
->setIcon('fa-trash-o') | ->setIcon('fa-trash-o') | ||||
->addSigil('differential-inline-delete') | ->addSigil('differential-inline-delete') | ||||
->setMustCapture(true) | ->setMustCapture(true) | ||||
->setAuralLabel(pht('Delete')); | ->setAuralLabel(pht('Delete')); | ||||
} | } | ||||
if (!$this->preview && $this->canHide()) { | if (!$is_preview && $this->canHide()) { | ||||
$action_buttons[] = id(new PHUIButtonView()) | $menu_items[] = array( | ||||
->setTag('a') | 'label' => pht('Collapse'), | ||||
->setTooltip(pht('Collapse')) | 'icon' => 'fa-times', | ||||
->setIcon('fa-times') | 'action' => 'collapse', | ||||
->addSigil('hide-inline') | 'key' => 'q', | ||||
->setMustCapture(true) | ); | ||||
->setAuralLabel(pht('Collapse')); | } | ||||
$can_reply = | |||||
(!$this->editable) && | |||||
(!$is_preview) && | |||||
($this->allowReply) && | |||||
// NOTE: No product reason why you can't reply to synthetic comments, | |||||
// but the reply mechanism currently sends the inline comment ID to the | |||||
// server, not file/line information, and synthetic comments don't have | |||||
// an inline comment ID. | |||||
(!$is_synthetic); | |||||
if ($can_reply) { | |||||
$menu_items[] = array( | |||||
'label' => pht('Reply to Comment'), | |||||
'icon' => 'fa-reply', | |||||
'action' => 'reply', | |||||
'key' => 'r', | |||||
); | |||||
$menu_items[] = array( | |||||
'label' => pht('Quote Comment'), | |||||
'icon' => 'fa-quote-left', | |||||
'action' => 'quote', | |||||
'key' => 'R', | |||||
); | |||||
} | } | ||||
$done_button = null; | $done_button = null; | ||||
$mark_done = $this->getCanMarkDone(); | $mark_done = $this->getCanMarkDone(); | ||||
// Allow users to mark their own draft inlines as "Done". | // Allow users to mark their own draft inlines as "Done". | ||||
if ($viewer_phid == $inline->getAuthorPHID()) { | if ($viewer_phid == $inline->getAuthorPHID()) { | ||||
Show All 31 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'; | ||||
} | } | ||||
if ($mark_done && !$this->preview) { | if ($mark_done && !$is_preview) { | ||||
$done_input = javelin_tag( | $done_input = javelin_tag( | ||||
'input', | 'input', | ||||
array( | array( | ||||
'type' => 'checkbox', | 'type' => 'checkbox', | ||||
'checked' => ($is_done ? 'checked' : null), | 'checked' => ($is_done ? 'checked' : null), | ||||
'class' => 'differential-inline-done', | 'class' => 'differential-inline-done', | ||||
'sigil' => 'differential-inline-done', | 'sigil' => 'differential-inline-done', | ||||
)); | )); | ||||
Show All 27 Lines | if (!$is_synthetic) { | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
$content = $this->markupEngine->getOutput( | $content = $this->markupEngine->getOutput( | ||||
$inline, | $inline, | ||||
PhabricatorInlineComment::MARKUP_FIELD_BODY); | PhabricatorInlineComment::MARKUP_FIELD_BODY); | ||||
if ($this->preview) { | if ($is_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', | ||||
Show All 20 Lines | if ($is_synthetic) { | ||||
->setName(pht('Author')) | ->setName(pht('Author')) | ||||
->setSlimShady(true) | ->setSlimShady(true) | ||||
->setColor(PHUITagView::COLOR_YELLOW) | ->setColor(PHUITagView::COLOR_YELLOW) | ||||
->addClass('mml'); | ->addClass('mml'); | ||||
} | } | ||||
} | } | ||||
$actions = null; | $actions = null; | ||||
if ($action_buttons) { | if ($action_buttons || $menu_items) { | ||||
$actions = new PHUIButtonBarView(); | $actions = new PHUIButtonBarView(); | ||||
$actions->setBorderless(true); | $actions->setBorderless(true); | ||||
$actions->addClass('inline-button-divider'); | $actions->addClass('inline-button-divider'); | ||||
foreach ($action_buttons as $button) { | foreach ($action_buttons as $button) { | ||||
$actions->addButton($button); | $actions->addButton($button); | ||||
} | } | ||||
if (!$is_preview) { | |||||
$menu_button = id(new PHUIButtonView()) | |||||
->setTag('a') | |||||
->setColor(PHUIButtonView::GREY) | |||||
->setDropdown(true) | |||||
->setAuralLabel(pht('Inline Actions')) | |||||
->addSigil('inline-action-dropdown'); | |||||
$actions->addButton($menu_button); | |||||
} | |||||
} | } | ||||
$group_left = phutil_tag( | $group_left = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'inline-head-left', | 'class' => 'inline-head-left', | ||||
), | ), | ||||
array( | array( | ||||
Show All 14 Lines | $group_right = phutil_tag( | ||||
$actions, | $actions, | ||||
)); | )); | ||||
$snippet = id(new PhutilUTF8StringTruncator()) | $snippet = id(new PhutilUTF8StringTruncator()) | ||||
->setMaximumGlyphs(96) | ->setMaximumGlyphs(96) | ||||
->truncateString($inline->getContent()); | ->truncateString($inline->getContent()); | ||||
$metadata['snippet'] = pht('%s: %s', $author, $snippet); | $metadata['snippet'] = pht('%s: %s', $author, $snippet); | ||||
$metadata['menuItems'] = $menu_items; | |||||
$markup = javelin_tag( | $markup = javelin_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => $classes, | 'class' => $classes, | ||||
'sigil' => $sigil, | 'sigil' => $sigil, | ||||
'meta' => $metadata, | 'meta' => $metadata, | ||||
), | ), | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |