Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15367462
D12019.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D12019.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1139,6 +1139,7 @@
'PHUIDiffInlineCommentEditView' => 'infrastructure/diff/view/PHUIDiffInlineCommentEditView.php',
'PHUIDiffInlineCommentRowScaffold' => 'infrastructure/diff/view/PHUIDiffInlineCommentRowScaffold.php',
'PHUIDiffInlineCommentTableScaffold' => 'infrastructure/diff/view/PHUIDiffInlineCommentTableScaffold.php',
+ 'PHUIDiffInlineCommentUndoView' => 'infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php',
'PHUIDiffInlineCommentView' => 'infrastructure/diff/view/PHUIDiffInlineCommentView.php',
'PHUIDiffOneUpInlineCommentRowScaffold' => 'infrastructure/diff/view/PHUIDiffOneUpInlineCommentRowScaffold.php',
'PHUIDiffTwoUpInlineCommentRowScaffold' => 'infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php',
@@ -4371,6 +4372,7 @@
'PHUIDiffInlineCommentEditView' => 'PHUIDiffInlineCommentView',
'PHUIDiffInlineCommentRowScaffold' => 'AphrontView',
'PHUIDiffInlineCommentTableScaffold' => 'AphrontView',
+ 'PHUIDiffInlineCommentUndoView' => 'PHUIDiffInlineCommentView',
'PHUIDiffInlineCommentView' => 'AphrontView',
'PHUIDiffOneUpInlineCommentRowScaffold' => 'PHUIDiffInlineCommentRowScaffold',
'PHUIDiffTwoUpInlineCommentRowScaffold' => 'PHUIDiffInlineCommentRowScaffold',
diff --git a/src/applications/differential/controller/DifferentialChangesetViewController.php b/src/applications/differential/controller/DifferentialChangesetViewController.php
--- a/src/applications/differential/controller/DifferentialChangesetViewController.php
+++ b/src/applications/differential/controller/DifferentialChangesetViewController.php
@@ -217,7 +217,8 @@
return id(new PhabricatorChangesetResponse())
->setRenderedChangeset($parser->renderChangeset())
- ->setCoverage($coverage);
+ ->setCoverage($coverage)
+ ->setUndoTemplates($parser->getRenderer()->renderUndoTemplates());
}
$diff = $changeset->getDiff();
diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetRenderer.php
@@ -600,4 +600,19 @@
return array($old, $new);
}
+ public function renderUndoTemplates() {
+ $views = array(
+ 'l' => id(new PHUIDiffInlineCommentUndoView())->setIsOnRight(false),
+ 'r' => id(new PHUIDiffInlineCommentUndoView())->setIsOnRight(true),
+ );
+
+ foreach ($views as $key => $view) {
+ $scaffold = $this->getRowScaffoldForInline($view);
+ $views[$key] = id(new PHUIDiffInlineCommentTableScaffold())
+ ->addRowScaffold($scaffold);
+ }
+
+ return $views;
+ }
+
}
diff --git a/src/applications/differential/view/DifferentialChangesetDetailView.php b/src/applications/differential/view/DifferentialChangesetDetailView.php
--- a/src/applications/differential/view/DifferentialChangesetDetailView.php
+++ b/src/applications/differential/view/DifferentialChangesetDetailView.php
@@ -208,6 +208,9 @@
$icon = id(new PHUIIconView())
->setIconFont($display_icon);
+ $renderer = DifferentialChangesetHTMLRenderer::getHTMLRendererByKey(
+ $this->getRenderer());
+
return javelin_tag(
'div',
array(
@@ -224,6 +227,7 @@
'ref' => $this->getRenderingRef(),
'autoload' => $this->getAutoload(),
'loaded' => $this->getLoaded(),
+ 'undoTemplates' => $renderer->renderUndoTemplates(),
),
'class' => $class,
'id' => $id,
@@ -252,4 +256,5 @@
));
}
+
}
diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php
--- a/src/applications/differential/view/DifferentialChangesetListView.php
+++ b/src/applications/differential/view/DifferentialChangesetListView.php
@@ -123,6 +123,7 @@
'collapsed' => pht('This file content has been collapsed.'),
),
));
+
Javelin::initBehavior(
'differential-dropdown-menus',
array(
@@ -230,11 +231,8 @@
$this->initBehavior('differential-comment-jump', array());
if ($this->inlineURI) {
- $undo_templates = $this->renderUndoTemplates();
-
Javelin::initBehavior('differential-edit-inline-comments', array(
'uri' => $this->inlineURI,
- 'undo_templates' => $undo_templates,
'stage' => 'differential-review-stage',
));
}
@@ -257,44 +255,6 @@
return $object_box;
}
- /**
- * Render the "Undo" markup for the inline comment undo feature.
- */
- private function renderUndoTemplates() {
- $link = javelin_tag(
- 'a',
- array(
- 'href' => '#',
- 'sigil' => 'differential-inline-comment-undo',
- ),
- pht('Undo'));
-
- $div = phutil_tag(
- 'div',
- array(
- 'class' => 'differential-inline-undo',
- ),
- array('Changes discarded. ', $link));
-
- return array(
- 'l' => phutil_tag('table', array(),
- phutil_tag('tr', array(), array(
- phutil_tag('th', array()),
- phutil_tag('td', array(), $div),
- phutil_tag('th', array()),
- phutil_tag('td', array('colspan' => 3)),
- ))),
-
- 'r' => phutil_tag('table', array(),
- phutil_tag('tr', array(), array(
- phutil_tag('th', array()),
- phutil_tag('td', array()),
- phutil_tag('th', array()),
- phutil_tag('td', array('colspan' => 3), $div),
- ))),
- );
- }
-
private function renderViewOptionsDropdown(
DifferentialChangesetDetailView $detail,
$ref,
diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php
--- a/src/applications/diffusion/controller/DiffusionDiffController.php
+++ b/src/applications/diffusion/controller/DiffusionDiffController.php
@@ -130,6 +130,7 @@
$parser->setMask($mask);
return id(new PhabricatorChangesetResponse())
- ->setRenderedChangeset($parser->renderChangeset());
+ ->setRenderedChangeset($parser->renderChangeset())
+ ->setUndoTemplates($parser->getRenderer()->renderUndoTemplates());
}
}
diff --git a/src/infrastructure/diff/PhabricatorChangesetResponse.php b/src/infrastructure/diff/PhabricatorChangesetResponse.php
--- a/src/infrastructure/diff/PhabricatorChangesetResponse.php
+++ b/src/infrastructure/diff/PhabricatorChangesetResponse.php
@@ -4,6 +4,7 @@
private $renderedChangeset;
private $coverage;
+ private $undoTemplates;
public function setRenderedChangeset($rendered_changeset) {
$this->renderedChangeset = $rendered_changeset;
@@ -15,6 +16,11 @@
return $this;
}
+ public function setUndoTemplates($undo_templates) {
+ $this->undoTemplates = $undo_templates;
+ return $this;
+ }
+
protected function buildProxy() {
return new AphrontAjaxResponse();
}
@@ -28,6 +34,10 @@
$content['coverage'] = $this->coverage;
}
+ if ($this->undoTemplates) {
+ $content['undoTemplates'] = $this->undoTemplates;
+ }
+
return $this->getProxy()->setContent($content);
}
diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php
@@ -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));
+ }
+
+}
diff --git a/webroot/rsrc/css/application/differential/changeset-view.css b/webroot/rsrc/css/application/differential/changeset-view.css
--- a/webroot/rsrc/css/application/differential/changeset-view.css
+++ b/webroot/rsrc/css/application/differential/changeset-view.css
@@ -379,10 +379,12 @@
.differential-inline-undo {
padding: 4px;
text-align: center;
- background: #ffeeaa;
+ background: {$lightyellow};
+ border: 1px solid {$yellow};
margin: 3px 0 1px;
- font: 12px;
- color: 444444;
+ color: {$darkgreytext};
+ font: {$basefont};
+ font-size: 12px;
}
.differential-inline-undo a {
diff --git a/webroot/rsrc/js/application/differential/ChangesetViewManager.js b/webroot/rsrc/js/application/differential/ChangesetViewManager.js
--- a/webroot/rsrc/js/application/differential/ChangesetViewManager.js
+++ b/webroot/rsrc/js/application/differential/ChangesetViewManager.js
@@ -38,6 +38,7 @@
_renderer: null,
_highlight: null,
_encoding: null,
+ _undoTemplates: null,
/**
@@ -193,6 +194,8 @@
var root = target.parentNode;
this._moveRows(table, root, target);
root.removeChild(target);
+
+ this._onchangesetresponse(response);
},
_moveRows: function(src, dst, before) {
@@ -256,6 +259,10 @@
return (JX.Device.getDevice() == 'desktop') ? '2up' : '1up';
},
+ getUndoTemplates: function() {
+ return this._undoTemplates;
+ },
+
setEncoding: function(encoding) {
this._encoding = encoding;
return this;
@@ -333,6 +340,12 @@
this._stabilize = false;
}
+ this._onchangesetresponse(response);
+ },
+
+ _onchangesetresponse: function(response) {
+ // Code shared by autoload and context responses.
+
if (response.coverage) {
for (var k in response.coverage) {
try {
@@ -342,6 +355,10 @@
}
}
}
+
+ if (response.undoTemplates) {
+ this._undoTemplates = response.undoTemplates;
+ }
},
_getContentFrame: function() {
diff --git a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
--- a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
+++ b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js
@@ -243,7 +243,7 @@
var view = JX.ChangesetViewManager.getForNode(root);
editor = new JX.DifferentialInlineCommentEditor(config.uri)
- .setTemplates(config.undo_templates)
+ .setTemplates(view.getUndoTemplates())
.setOperation('new')
.setChangesetID(changeset)
.setLineNumber(o)
@@ -335,7 +335,7 @@
var view = JX.ChangesetViewManager.getForNode(changeset_root);
editor = new JX.DifferentialInlineCommentEditor(config.uri)
- .setTemplates(config.undo_templates)
+ .setTemplates(view.getUndoTemplates())
.setOperation(op)
.setID(data.id)
.setChangesetID(data.changesetID)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 6:51 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7261264
Default Alt Text
D12019.diff (11 KB)
Attached To
Mode
D12019: Reduce code duplication for inline "Undo"
Attached
Detach File
Event Timeline
Log In to Comment