From 355142fcbf23d6f307f248f7ad1aba2876d596cc Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 8 Mar 2015 14:00:08 -0700 Subject: [PATCH] Reduce code duplication on comment editing UI Summary: Ref T2009. This has two more copies of the scaffolding. Test Plan: Created, edited, deleted, replied to inline comments. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T2009 Differential Revision: https://secure.phabricator.com/D12018 --- .../PhabricatorInlineCommentController.php | 25 +++++++++++------ .../view/PHUIDiffInlineCommentEditView.php | 27 +------------------ .../differential/changeset-view.css | 7 ----- 3 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php index 4aa0a7d6ee..749a66098b 100644 --- a/src/infrastructure/diff/PhabricatorInlineCommentController.php +++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php @@ -130,8 +130,10 @@ abstract class PhabricatorInlineCommentController $this->renderTextArea( nonempty($text, $inline->getContent()))); + $view = $this->buildScaffoldForView($edit_dialog); + return id(new AphrontAjaxResponse()) - ->setContent($edit_dialog->render()); + ->setContent($view->render()); case 'create': $text = $this->getCommentText(); @@ -184,8 +186,10 @@ abstract class PhabricatorInlineCommentController $text_area = $this->renderTextArea($this->getCommentText()); $edit_dialog->appendChild($text_area); + $view = $this->buildScaffoldForView($edit_dialog); + return id(new AphrontAjaxResponse()) - ->setContent($edit_dialog->render()); + ->setContent($view->render()); } } @@ -276,12 +280,7 @@ abstract class PhabricatorInlineCommentController ->setHandles($handles) ->setEditable(true); - $renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey( - $this->getRenderer()); - - $view = $renderer->getRowScaffoldForInline($view); - $view = id(new PHUIDiffInlineCommentTableScaffold()) - ->addRowScaffold($view); + $view = $this->buildScaffoldForView($view); return id(new AphrontAjaxResponse()) ->setContent( @@ -300,4 +299,14 @@ abstract class PhabricatorInlineCommentController ->setDisableFullScreen(true); } + private function buildScaffoldForView(PHUIDiffInlineCommentView $view) { + $renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey( + $this->getRenderer()); + + $view = $renderer->getRowScaffoldForInline($view); + + return id(new PHUIDiffInlineCommentTableScaffold()) + ->addRowScaffold($view); + } + } diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php index 47710a85e0..da89f79079 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php @@ -104,32 +104,7 @@ final class PHUIDiffInlineCommentEditView $this->renderBody(), )); - if ($this->renderer == '1up') { - $cells = array( - phutil_tag('th', array()), - phutil_tag('th', array()), - phutil_tag( - 'td', - array('colspan' => 3, 'class' => 'right3'), - $content), - ); - } else { - $cells = array( - phutil_tag('th', array()), - phutil_tag( - 'td', - array('class' => 'left'), - $this->onRight ? null : $content), - phutil_tag('th', array()), - phutil_tag( - 'td', - array('colspan' => 3, 'class' => 'right3'), - $this->onRight ? $content : null), - ); - } - - $row = phutil_tag('tr', array('class' => 'inline-comment-splint'), $cells); - return phutil_tag('table', array(), $row); + return $content; } private function renderInputs() { diff --git a/webroot/rsrc/css/application/differential/changeset-view.css b/webroot/rsrc/css/application/differential/changeset-view.css index 5c3c33e5c0..b302f8b23b 100644 --- a/webroot/rsrc/css/application/differential/changeset-view.css +++ b/webroot/rsrc/css/application/differential/changeset-view.css @@ -423,13 +423,6 @@ td.cov-I { text-decoration: none; } -/* Create a wide band of color behind the inline edit interface so it is easy - to find by skimming the page while scrolling. -*/ -tr.inline-comment-splint { - background: #f9f1d5; -} - tr.differential-inline-hidden { display: none; }