Reduce code duplication for inline "Undo"
Summary: Ref T2009. This is another almost-identical copy of the row scaffolding, which has the same 1up/2up bugs as the 8 other copies of this code. Turn the "undo" element into an InlineCommentView so we can scaffold it. Then, scaffold it with the same code as everything else. Test Plan: Hit "Undo", swapped from 1up to 2up, hit "undo" again, swapped back, tried left/right, everything rendered with proper scaffolding. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T2009 Differential Revision: https://secure.phabricator.com/D12019
This commit is contained in:
@@ -4,6 +4,7 @@ final class PhabricatorChangesetResponse extends AphrontProxyResponse {
|
||||
|
||||
private $renderedChangeset;
|
||||
private $coverage;
|
||||
private $undoTemplates;
|
||||
|
||||
public function setRenderedChangeset($rendered_changeset) {
|
||||
$this->renderedChangeset = $rendered_changeset;
|
||||
@@ -15,6 +16,11 @@ final class PhabricatorChangesetResponse extends AphrontProxyResponse {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUndoTemplates($undo_templates) {
|
||||
$this->undoTemplates = $undo_templates;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function buildProxy() {
|
||||
return new AphrontAjaxResponse();
|
||||
}
|
||||
@@ -28,6 +34,10 @@ final class PhabricatorChangesetResponse extends AphrontProxyResponse {
|
||||
$content['coverage'] = $this->coverage;
|
||||
}
|
||||
|
||||
if ($this->undoTemplates) {
|
||||
$content['undoTemplates'] = $this->undoTemplates;
|
||||
}
|
||||
|
||||
return $this->getProxy()->setContent($content);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Render the "Undo" action to recover discarded inline comments.
|
||||
*
|
||||
* This extends @{class:PHUIDiffInlineCommentView} so it can use the same
|
||||
* scaffolding code as other kinds of inline comments.
|
||||
*/
|
||||
final class PHUIDiffInlineCommentUndoView
|
||||
extends PHUIDiffInlineCommentView {
|
||||
|
||||
private $isOnRight;
|
||||
|
||||
public function setIsOnRight($is_on_right) {
|
||||
$this->isOnRight = $is_on_right;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsOnRight() {
|
||||
return $this->isOnRight;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$link = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#',
|
||||
'sigil' => 'differential-inline-comment-undo',
|
||||
),
|
||||
pht('Undo'));
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'differential-inline-undo',
|
||||
),
|
||||
array('Changes discarded. ', $link));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user