Skip to content

Commit 355142f

Browse files
author
epriestley
committed
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
1 parent 082b7f9 commit 355142f

File tree

3 files changed

+18
-41
lines changed

3 files changed

+18
-41
lines changed

src/infrastructure/diff/PhabricatorInlineCommentController.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ public function processRequest() {
130130
$this->renderTextArea(
131131
nonempty($text, $inline->getContent())));
132132

133+
$view = $this->buildScaffoldForView($edit_dialog);
134+
133135
return id(new AphrontAjaxResponse())
134-
->setContent($edit_dialog->render());
136+
->setContent($view->render());
135137
case 'create':
136138
$text = $this->getCommentText();
137139

@@ -184,8 +186,10 @@ public function processRequest() {
184186
$text_area = $this->renderTextArea($this->getCommentText());
185187
$edit_dialog->appendChild($text_area);
186188

189+
$view = $this->buildScaffoldForView($edit_dialog);
190+
187191
return id(new AphrontAjaxResponse())
188-
->setContent($edit_dialog->render());
192+
->setContent($view->render());
189193
}
190194
}
191195

@@ -276,12 +280,7 @@ private function buildRenderedCommentResponse(
276280
->setHandles($handles)
277281
->setEditable(true);
278282

279-
$renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey(
280-
$this->getRenderer());
281-
282-
$view = $renderer->getRowScaffoldForInline($view);
283-
$view = id(new PHUIDiffInlineCommentTableScaffold())
284-
->addRowScaffold($view);
283+
$view = $this->buildScaffoldForView($view);
285284

286285
return id(new AphrontAjaxResponse())
287286
->setContent(
@@ -300,4 +299,14 @@ private function renderTextArea($text) {
300299
->setDisableFullScreen(true);
301300
}
302301

302+
private function buildScaffoldForView(PHUIDiffInlineCommentView $view) {
303+
$renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey(
304+
$this->getRenderer());
305+
306+
$view = $renderer->getRowScaffoldForInline($view);
307+
308+
return id(new PHUIDiffInlineCommentTableScaffold())
309+
->addRowScaffold($view);
310+
}
311+
303312
}

src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,32 +104,7 @@ public function render() {
104104
$this->renderBody(),
105105
));
106106

107-
if ($this->renderer == '1up') {
108-
$cells = array(
109-
phutil_tag('th', array()),
110-
phutil_tag('th', array()),
111-
phutil_tag(
112-
'td',
113-
array('colspan' => 3, 'class' => 'right3'),
114-
$content),
115-
);
116-
} else {
117-
$cells = array(
118-
phutil_tag('th', array()),
119-
phutil_tag(
120-
'td',
121-
array('class' => 'left'),
122-
$this->onRight ? null : $content),
123-
phutil_tag('th', array()),
124-
phutil_tag(
125-
'td',
126-
array('colspan' => 3, 'class' => 'right3'),
127-
$this->onRight ? $content : null),
128-
);
129-
}
130-
131-
$row = phutil_tag('tr', array('class' => 'inline-comment-splint'), $cells);
132-
return phutil_tag('table', array(), $row);
107+
return $content;
133108
}
134109

135110
private function renderInputs() {

webroot/rsrc/css/application/differential/changeset-view.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,6 @@ td.cov-I {
423423
text-decoration: none;
424424
}
425425

426-
/* Create a wide band of color behind the inline edit interface so it is easy
427-
to find by skimming the page while scrolling.
428-
*/
429-
tr.inline-comment-splint {
430-
background: #f9f1d5;
431-
}
432-
433426
tr.differential-inline-hidden {
434427
display: none;
435428
}

0 commit comments

Comments
 (0)