1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 06:50:55 +01:00

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
This commit is contained in:
epriestley 2015-03-08 14:00:08 -07:00
parent 082b7f95e6
commit 355142fcbf
3 changed files with 18 additions and 41 deletions

View file

@ -130,8 +130,10 @@ abstract class PhabricatorInlineCommentController
$this->renderTextArea( $this->renderTextArea(
nonempty($text, $inline->getContent()))); nonempty($text, $inline->getContent())));
$view = $this->buildScaffoldForView($edit_dialog);
return id(new AphrontAjaxResponse()) return id(new AphrontAjaxResponse())
->setContent($edit_dialog->render()); ->setContent($view->render());
case 'create': case 'create':
$text = $this->getCommentText(); $text = $this->getCommentText();
@ -184,8 +186,10 @@ abstract class PhabricatorInlineCommentController
$text_area = $this->renderTextArea($this->getCommentText()); $text_area = $this->renderTextArea($this->getCommentText());
$edit_dialog->appendChild($text_area); $edit_dialog->appendChild($text_area);
$view = $this->buildScaffoldForView($edit_dialog);
return id(new AphrontAjaxResponse()) return id(new AphrontAjaxResponse())
->setContent($edit_dialog->render()); ->setContent($view->render());
} }
} }
@ -276,12 +280,7 @@ abstract class PhabricatorInlineCommentController
->setHandles($handles) ->setHandles($handles)
->setEditable(true); ->setEditable(true);
$renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey( $view = $this->buildScaffoldForView($view);
$this->getRenderer());
$view = $renderer->getRowScaffoldForInline($view);
$view = id(new PHUIDiffInlineCommentTableScaffold())
->addRowScaffold($view);
return id(new AphrontAjaxResponse()) return id(new AphrontAjaxResponse())
->setContent( ->setContent(
@ -300,4 +299,14 @@ abstract class PhabricatorInlineCommentController
->setDisableFullScreen(true); ->setDisableFullScreen(true);
} }
private function buildScaffoldForView(PHUIDiffInlineCommentView $view) {
$renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey(
$this->getRenderer());
$view = $renderer->getRowScaffoldForInline($view);
return id(new PHUIDiffInlineCommentTableScaffold())
->addRowScaffold($view);
}
} }

View file

@ -104,32 +104,7 @@ final class PHUIDiffInlineCommentEditView
$this->renderBody(), $this->renderBody(),
)); ));
if ($this->renderer == '1up') { return $content;
$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);
} }
private function renderInputs() { private function renderInputs() {

View file

@ -423,13 +423,6 @@ td.cov-I {
text-decoration: none; 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 { tr.differential-inline-hidden {
display: none; display: none;
} }