launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #16471
[Merge] lp:~cprov/launchpad/previewdiff-promotion into lp:launchpad
Celso Providelo has proposed merging lp:~cprov/launchpad/previewdiff-promotion into lp:launchpad.
Requested reviews:
William Grant (wgrant)
For more details, see:
https://code.launchpad.net/~cprov/launchpad/previewdiff-promotion/+merge/208187
Changes to promote PreviewDiff as 1st-class API entities (individual URLs, sane lookup and extra attributes).
--
https://code.launchpad.net/~cprov/launchpad/previewdiff-promotion/+merge/208187
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/app/javascript/comment.js'
--- lib/lp/app/javascript/comment.js 2014-01-17 04:10:34 +0000
+++ lib/lp/app/javascript/comment.js 2014-02-25 17:02:23 +0000
@@ -385,10 +385,9 @@
}
if (this.publish_inline_comments &&
this.publish_inline_comments.get('checked')) {
- var ns = Y.lp.code.branchmergeproposal.inlinecomments;
- config.parameters.inline_comments = ns.inlinecomments;
- config.parameters.diff_timestamp = (
- LP.cache.preview_diff_timestamps.slice(-1)[0]);
+ var ic = Y.lp.code.branchmergeproposal.inlinecomments;
+ config.parameters.inline_comments = ic.inlinecomments;
+ config.parameters.previewdiff_id = ic.current_previewdiff_id;
}
this.get('lp_client').named_post(
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2014-01-17 17:01:53 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2014-02-25 17:02:23 +0000
@@ -461,10 +461,17 @@
except WrongBranchMergeProposal:
return None
- @stepto("+preview-diff")
- def preview_diff(self):
- """Step to the preview diff."""
- return self.context.preview_diff
+ @stepthrough("+preview-diff")
+ def traverse_preview_diff(self, id):
+ """Navigate to a PreviewDiff through its BMP."""
+ try:
+ id = int(id)
+ except ValueError:
+ return None
+ try:
+ return self.context.getPreviewDiff(id)
+ except WrongBranchMergeProposal:
+ return None
@stepthrough('+review')
def review(self, id):
@@ -631,15 +638,14 @@
self.context).event_key
if getFeatureFlag("code.inline_diff_comments.enabled"):
cache.objects['inline_diff_comments'] = True
- cache.objects['preview_diff_timestamps'] = [
- pd.date_created for pd in self.context.preview_diffs]
+ cache.objects['previewdiff_ids'] = [
+ pd.id for pd in self.context.preview_diffs]
if self.context.preview_diff:
cache.objects['published_inline_comments'] = (
- self.context.getInlineComments(
- self.preview_diff.date_created))
+ self.context.getInlineComments(self.preview_diff.id))
cache.objects['draft_inline_comments'] = (
self.context.getDraftInlineComments(
- self.preview_diff.date_created, self.user))
+ self.preview_diff.id, self.user))
else:
cache.objects['published_inline_comments'] = []
cache.objects['draft_inline_comments'] = []
=== modified file 'lib/lp/code/browser/codereviewcomment.py'
--- lib/lp/code/browser/codereviewcomment.py 2014-01-21 14:58:22 +0000
+++ lib/lp/code/browser/codereviewcomment.py 2014-02-25 17:02:23 +0000
@@ -285,17 +285,16 @@
vote = data.get('vote')
review_type = data.get('review_type')
inline_comments = {}
- diff_timestamp = None
+ previewdiff_id = None
if (getFeatureFlag('code.inline_diff_comments.enabled') and
data.get('publish_inline_comments')):
- diff_timestamp = self.previewdiff.date_created
+ previewdiff_id = self.previewdiff.id
inline_comments = (
- self.branch_merge_proposal.getDraftInlineComments(
- diff_timestamp))
+ self.branch_merge_proposal.getDraftInlineComments(diff_id))
comment = self.branch_merge_proposal.createComment(
self.user, subject=None, content=data['comment'],
parent=self.reply_to, vote=vote, review_type=review_type,
- diff_timestamp=diff_timestamp, inline_comments=inline_comments)
+ previewdiff_id=previewdiff_id, inline_comments=inline_comments)
@property
def next_url(self):
=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml 2014-02-25 06:42:01 +0000
+++ lib/lp/code/browser/configure.zcml 2014-02-25 17:02:23 +0000
@@ -827,7 +827,7 @@
<browser:url
for="lp.code.interfaces.diff.IPreviewDiff"
- path_expression="string:+preview-diff"
+ path_expression="string:+preview-diff/${id}"
attribute_to_parent="branch_merge_proposal"
rootsite="code" />
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2014-01-18 04:52:02 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2014-02-25 17:02:23 +0000
@@ -174,7 +174,11 @@
next_preview_diff_job = Attribute(
'The next BranchMergeProposalJob that will update a preview diff.')
- preview_diffs = Attribute('All preview diffs for this merge proposal.')
+ preview_diffs = exported(
+ CollectionField(
+ title=_("All preview diffs for this merge proposal."),
+ value_type=Reference(schema=IPreviewDiff),
+ readonly=True))
preview_diff = exported(
Reference(
@@ -545,14 +549,14 @@
subject=Text(), content=Text(),
vote=Choice(vocabulary=CodeReviewVote), review_type=Text(),
parent=Reference(schema=Interface),
- diff_timestamp=Datetime(),
+ previewdiff_id=Int(),
inline_comments=Dict(key_type=TextLine(), value_type=Text()))
@call_with(owner=REQUEST_USER)
# ICodeReviewComment supplied as Interface to avoid circular imports.
@export_factory_operation(Interface, [])
def createComment(owner, subject, content=None, vote=None,
review_type=None, parent=None,
- diff_timestamp=None, inline_comments=None):
+ previewdiff_id=None, inline_comments=None):
"""Create an ICodeReviewComment associated with this merge proposal.
:param owner: The person who the message is from.
@@ -561,8 +565,7 @@
unspecified, the text of the merge proposal is used.
:param parent: The previous CodeReviewComment in the thread. If
unspecified, the root message is used.
- :param diff_timestamp: the context diff creation timestamp which
- will be used to retrive the actual `PreviewDiff` register.
+ :param previewdiff_id: the inline comments PreviewDiff ID context.
:param inline_comments: a dictionary containing the draft inline
comments keyed by the diff line number.
"""
@@ -579,42 +582,50 @@
@export_read_operation()
@operation_parameters(
- diff_timestamp=Datetime())
+ previewdiff_id=Int())
@operation_for_version('devel')
- def getInlineComments(diff_timestamp):
+ def getInlineComments(previewdiff_id):
"""Return a list of inline comments related to this MP.
- The return value is a list of 4-tuples representing published and
- draft inline comments.
+ The return value is an list of dictionaries (objects), each one
+ representing a comment with 'line_number', 'person', 'text' and
+ 'date' attributes.
- :param diff_timestamp: The timestamp of the target `PreviewDiff`.
+ :param previewdiff_id: The ID of the target `PreviewDiff`.
"""
@export_read_operation()
@operation_parameters(
- diff_timestamp=Datetime())
+ previewdiff_id=Int())
@call_with(person=REQUEST_USER)
@operation_for_version('devel')
- def getDraftInlineComments(diff_timestamp, person):
- """Return a list of draft inline comments related to this MP.
-
- The return value is a list of 4-tuples representing published and
- draft inline comments.
-
- :param diff_timestamp: The timestamp of the target `PreviewDiff`.
+ def getDraftInlineComments(previewdiff_id, person):
+ """Return the draft inline comments related to this MP.
+
+ The return value is a dictionary (object) where the keys are the
+ diff lines and their values are the actual draft comment created
+ by the given person.
+
+ :param previewdiff_id: The ID of the target `PreviewDiff`.
:param person: The `IPerson` owner of the draft comments.
"""
+ def getPreviewDiff(id):
+ """Return the preview diff with the given id.
+
+ :param id: The id of the target `PreviewDiff`.
+ """
+
@export_write_operation()
@operation_parameters(
- diff_timestamp=Datetime(),
+ previewdiff_id=Int(),
comments=Dict(key_type=TextLine(), value_type=Text()))
@call_with(person=REQUEST_USER)
@operation_for_version('devel')
- def saveDraftInlineComment(diff_timestamp, person, comments):
+ def saveDraftInlineComment(previewdiff_id, person, comments):
"""Save `ICodeReviewInlineCommentDraft`
- :param diff_timestamp: The timestamp of the target `PreviewDiff`.
+ :param previewdiff_id: The ID of the target `PreviewDiff`.
:param person: The `IPerson` making the comments.
:param comments: The comments.
"""
=== modified file 'lib/lp/code/interfaces/diff.py'
--- lib/lp/code/interfaces/diff.py 2013-05-08 05:08:51 +0000
+++ lib/lp/code/interfaces/diff.py 2014-02-25 17:02:23 +0000
@@ -34,6 +34,11 @@
class IDiff(Interface):
"""A diff that is stored in the Library."""
+ id = exported(
+ Int(
+ title=_('DB ID'), required=True, readonly=True,
+ description=_("The tracking number for this diff.")))
+
text = Text(
title=_('Textual contents of a diff.'), readonly=True,
description=_("The text may be cut off at a defined maximum size."))
@@ -86,7 +91,7 @@
trying to determine the effective changes of landing the source branch on
the target branch.
"""
- export_as_webservice_entry(publish_web_link=False)
+ export_as_webservice_entry()
source_revision_id = exported(
TextLine(
@@ -124,8 +129,10 @@
Interface, readonly=True,
title=_('The branch merge proposal that diff relates to.')))
- date_created = Datetime(
- title=_("When this diff was created."), readonly=True)
+ date_created = exported(
+ Datetime(
+ title=_('Date Created'), required=False, readonly=True,
+ description=_("When this diff was created.")))
stale = exported(
Bool(readonly=True, description=_(
@@ -133,5 +140,10 @@
'compared to the tip revisions of the source, target, and '
'possibly prerequisite branches.')))
+ displayname = exported(
+ TextLine(
+ title=_('DisplayName'), required=False, readonly=True,
+ description=_('PreviewDiff displayname.')))
+
def getFileByName(filename):
"""Return the file under +files with specified name."""
=== modified file 'lib/lp/code/javascript/branchmergeproposal.inlinecomments.js'
--- lib/lp/code/javascript/branchmergeproposal.inlinecomments.js 2014-01-21 04:51:48 +0000
+++ lib/lp/code/javascript/branchmergeproposal.inlinecomments.js 2014-02-25 17:02:23 +0000
@@ -12,7 +12,9 @@
// Grab the namespace in order to be able to expose the connect methods.
var namespace = Y.namespace('lp.code.branchmergeproposal.inlinecomments');
-namespace.inlinecomments = {};
+namespace.inlinecomments = null;
+
+namespace.current_previewdiff_id = null;
namespace.lp_client = new Y.lp.client.Launchpad();
@@ -46,6 +48,9 @@
handle_widget_button = function(saved, comment) {
if (saved === false) {
handling_request = false;
+ if (namespace.inlinecomments[line_number] === undefined) {
+ header_row.remove(true);
+ }
return;
}
@@ -55,10 +60,9 @@
header_row.remove(true);
content_row.remove(true);
}
- var diff_timestamp = LP.cache.preview_diff_timestamps.slice(-1)[0];
var config = {
parameters: {
- diff_timestamp: diff_timestamp,
+ previewdiff_id: namespace.current_previewdiff_id,
comments: namespace.inlinecomments
}
};
@@ -139,6 +143,9 @@
line.next().remove();
line.remove();
});
+
+ namespace.inlinecomments = {};
+
// Display published inline comments.
// [{'line_number': <lineno>, 'person': <IPerson> 'text': <comment>,
// 'date': <timestamp>}, ...]
@@ -160,14 +167,18 @@
};
-namespace.setup_inline_comments = function() {
- if (LP.cache.inline_diff_comments === true) {
- // Add the double-click handler for each row in the diff. This needs
- // to be done first since populating existing published and draft
- // comments may add more rows.
- namespace.add_doubleclick_handler();
- namespace.populate_existing_comments();
+namespace.setup_inline_comments = function(previewdiff_id) {
+ if (LP.cache.inline_diff_comments !== true) {
+ return;
}
+ // Store the current preview_diff ID locally.
+ namespace.current_previewdiff_id = previewdiff_id;
+ // Add the double-click handler for each row in the diff. This needs
+ // to be done first since populating existing published and draft
+ // comments may add more rows.
+ namespace.add_doubleclick_handler();
+ namespace.populate_existing_comments();
+
};
}, '0.1', {requires: ['event', 'io', 'node', 'widget', 'lp.client',
=== modified file 'lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js'
--- lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js 2014-01-21 04:51:48 +0000
+++ lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js 2014-02-25 17:02:23 +0000
@@ -14,8 +14,9 @@
// Loads testing values into LP.cache.
LP.cache.published_inline_comments = [];
LP.cache.draft_inline_comments = {};
- LP.cache.preview_diff_timestamps = ['2014-01-01 10:00'];
+ LP.cache.preview_diff_ids = [1];
LP.cache.inline_diff_comments = true;
+ module.current_previewdiff_id = 1;
},
tearDown: function () {},
@@ -120,10 +121,13 @@
called = true;
};
module.add_doubleclick_handler = add_doubleclick_handler;
+ module.current_previewdiff_id = null
LP.cache.inline_diff_comments = false;
module.setup_inline_comments();
+
Y.Assert.isFalse(called);
+ Y.Assert.isNull(module.current_previewdiff_id);
},
test_feature_flag: function() {
@@ -132,9 +136,12 @@
called = true;
};
module.add_doubleclick_handler = add_doubleclick_handler;
-
- module.setup_inline_comments();
+ module.current_previewdiff_id = null
+
+ module.setup_inline_comments(1);
+
Y.Assert.isTrue(called);
+ Y.Assert.areEqual(1, module.current_previewdiff_id);
}
}));
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2014-01-17 16:10:34 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2014-02-25 17:02:23 +0000
@@ -752,7 +752,7 @@
def createComment(self, owner, subject, content=None, vote=None,
review_type=None, parent=None, _date_created=DEFAULT,
- diff_timestamp=None, inline_comments=None,
+ previewdiff_id=None, inline_comments=None,
_notify_listeners=True):
"""See `IBranchMergeProposal`."""
#:param _date_created: The date the message was created. Provided
@@ -788,10 +788,10 @@
if getFeatureFlag("code.inline_diff_comments.enabled"):
if inline_comments:
- assert diff_timestamp is not None, (
- 'Inline comments must be associated with a previewdiff '
- 'timestamp.')
- previewdiff = self._getPreviewDiffByTimestamp(diff_timestamp)
+ assert previewdiff_id is not None, (
+ 'Inline comments must be associated with a '
+ 'previewdiff ID.')
+ previewdiff = self.getPreviewDiff(previewdiff_id)
getUtility(ICodeReviewInlineCommentSet).ensureDraft(
previewdiff, owner, inline_comments)
getUtility(ICodeReviewInlineCommentSet).publishDraft(
@@ -799,24 +799,6 @@
return comment
- def _getPreviewDiffByTimestamp(self, diff_timestamp):
- """Return a `PreviewDiff` created on the given timestamp.
-
- Looks for a `PreviewDiff` for this merge proposal created exactly
- on the given timestamp. If it could not be found `DiffNotFound`
- is raised.
- """
- previewdiff = IStore(PreviewDiff).find(
- PreviewDiff,
- PreviewDiff.branch_merge_proposal_id == self.id,
- PreviewDiff.date_created == diff_timestamp).one()
- if not previewdiff:
- raise DiffNotFound(
- "Could not locate a preview diff with a timestamp of "
- "%s" % (diff_timestamp))
-
- return previewdiff
-
def getUsersVoteReference(self, user, review_type=None):
"""Get the existing vote reference for the given user."""
# Lower case the review type.
@@ -906,23 +888,31 @@
code_review_message, original_email))
return code_review_message
- def getInlineComments(self, diff_timestamp):
+ def getInlineComments(self, previewdiff_id):
"""See `IBranchMergeProposal`."""
- previewdiff = self._getPreviewDiffByTimestamp(diff_timestamp)
+ previewdiff = self.getPreviewDiff(previewdiff_id)
return getUtility(ICodeReviewInlineCommentSet).getPublished(
previewdiff)
- def getDraftInlineComments(self, diff_timestamp, person):
+ def getDraftInlineComments(self, previewdiff_id, person):
"""See `IBranchMergeProposal`."""
- previewdiff = self._getPreviewDiffByTimestamp(diff_timestamp)
+ previewdiff = self.getPreviewDiff(previewdiff_id)
return getUtility(ICodeReviewInlineCommentSet).getDraft(
previewdiff, person)
- def saveDraftInlineComment(self, diff_timestamp, person, comments):
+ def getPreviewDiff(self, id):
+ """See `IBranchMergeProposal`."""
+ previewdiff = IStore(self).find(
+ PreviewDiff, PreviewDiff.id == id).one()
+ if previewdiff.branch_merge_proposal != self:
+ raise WrongBranchMergeProposal
+ return previewdiff
+
+ def saveDraftInlineComment(self, previewdiff_id, person, comments):
"""See `IBranchMergeProposal`."""
if not getFeatureFlag("code.inline_diff_comments.enabled"):
return
- previewdiff = self._getPreviewDiffByTimestamp(diff_timestamp)
+ previewdiff = self.getPreviewDiff(previewdiff_id)
getUtility(ICodeReviewInlineCommentSet).ensureDraft(
previewdiff, person, comments)
=== modified file 'lib/lp/code/model/diff.py'
--- lib/lp/code/model/diff.py 2013-05-14 14:30:09 +0000
+++ lib/lp/code/model/diff.py 2014-02-25 17:02:23 +0000
@@ -371,6 +371,17 @@
conflicts = Unicode()
@property
+ def displayname(self):
+ """See `IPreviewDiff`."""
+ bmp = self.branch_merge_proposal
+ source_branch = bmp.source_branch.getBranchRevision(
+ revision_id=self.source_revision_id).sequence
+ target_branch = bmp.target_branch.getBranchRevision(
+ revision_id=self.target_revision_id).sequence
+
+ return u'r{0} into r{1}'.format(source_revno, target_revno)
+
+ @property
def has_conflicts(self):
return self.conflicts is not None and self.conflicts != ''
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py 2014-01-30 15:04:06 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2014-02-25 17:02:23 +0000
@@ -717,6 +717,32 @@
self.vote.id)
+class TestMergeProposalGetPreviewDiff(TestCaseWithFactory):
+ """Tests for `BranchMergeProposal.getPreviewDiff`."""
+
+ layer = LaunchpadFunctionalLayer
+
+ def setUp(self):
+ TestCaseWithFactory.setUp(self, user='foo.bar@xxxxxxxxxxxxx')
+ self.mp_one = self.factory.makeBranchMergeProposal()
+ self.mp_two = self.factory.makeBranchMergeProposal()
+ self.preview_diff = self.mp_one.updatePreviewDiff(
+ u'Some diff', u"source_id", u"target_id")
+ transaction.commit()
+
+ def test_getPreviewDiff(self):
+ """We can get a preview-diff."""
+ self.assertEqual(
+ self.preview_diff,
+ self.mp_one.getPreviewDiff(self.preview_diff.id))
+
+ def test_getPreviewDiffWrongBranchMergeProposal(self):
+ """An error is raised if the given id does not match the MP."""
+ self.assertRaises(
+ WrongBranchMergeProposal,
+ self.mp_two.getPreviewDiff, self.preview_diff.id)
+
+
class TestMergeProposalNotification(TestCaseWithFactory):
"""Test that events are created when merge proposals are manipulated"""
=== modified file 'lib/lp/code/model/tests/test_diff.py'
--- lib/lp/code/model/tests/test_diff.py 2012-12-26 01:32:19 +0000
+++ lib/lp/code/model/tests/test_diff.py 2014-02-25 17:02:23 +0000
@@ -341,6 +341,10 @@
prerequisite_revision_id = u'rev-c'
if content is None:
content = ''.join(unified_diff('', 'content'))
+ self.factory.makeBranchRevision(
+ branch=mp.source_branch, revision_id='rev-a', sequence=10)
+ self.factory.makeBranchRevision(
+ branch=mp.target_branch, revision_id='rev-b', sequence=1)
mp.updatePreviewDiff(
content, u'rev-a', u'rev-b',
prerequisite_revision_id=prerequisite_revision_id)
@@ -359,7 +363,8 @@
# canonical_url of the merge proposal itself.
mp = self._createProposalWithPreviewDiff()
self.assertEqual(
- canonical_url(mp) + '/+preview-diff',
+ '{0}/+preview-diff/{1}'.format(
+ canonical_url(mp), mp.preview_diff.id),
canonical_url(mp.preview_diff))
def test_empty_diff(self):
@@ -367,6 +372,7 @@
# branches will be empty.
mp = self._createProposalWithPreviewDiff(content='')
preview = mp.preview_diff
+ self.assertEqual('r10 into r1', preview.displayname)
self.assertIs(None, preview.diff_text)
self.assertEqual(0, preview.diff_lines_count)
self.assertEqual(mp, preview.branch_merge_proposal)
=== modified file 'lib/lp/code/stories/branches/xx-branchmergeproposals.txt'
--- lib/lp/code/stories/branches/xx-branchmergeproposals.txt 2013-05-09 01:26:05 +0000
+++ lib/lp/code/stories/branches/xx-branchmergeproposals.txt 2014-02-25 17:02:23 +0000
@@ -625,15 +625,21 @@
u'Preview Diff\nDownload diff\n1\n...Fake Diff\u1010'
There is also a link to the diff URL, which is the preview diff URL plus
-"+files/preview.diff". It redirects to the file in the restricted librarian.
+"+files/preview.diff". It redirects logged in users to the file in the
+restricted librarian.
- >>> from lazr.uri import URI
>>> link = get_review_diff().find('a')
+ >>> print extract_text(link)
+ Download diff
+
>>> print link['href']
- http.../+preview-diff/+files/preview.diff
- >>> print http(
- ... """GET %s HTTP/1.1
- ... """ % URI(link['href']).path)
+ http://.../+preview-diff/.../+files/preview.diff
+
+ >>> from lazr.uri import URI
+ >>> print http(r"""
+ ... GET %s HTTP/1.1
+ ... Authorization: Basic no-priv@xxxxxxxxxxxxx:test
+ ... """ % URI(link['href']).path)
HTTP/1.1 303 See Other
...
Location: https://...restricted.../...txt?token=...
=== modified file 'lib/lp/code/stories/webservice/xx-branchmergeproposal.txt'
--- lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2013-02-05 22:56:33 +0000
+++ lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2014-02-25 17:02:23 +0000
@@ -58,6 +58,7 @@
merged_revno: None
prerequisite_branch_link: u'http://api.launchpad.dev/devel/~...'
preview_diff_link: None
+ preview_diffs_collection_link: u'http://.../preview_diffs'
private: False
queue_position: None
queue_status: u'Needs review'
@@ -156,6 +157,7 @@
merged_revno: None
prerequisite_branch_link: None
preview_diff_link: None
+ preview_diffs_collection_link: u'http://.../preview_diffs'
private: False
queue_position: None
queue_status: u'Work in progress'
=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt 2014-01-18 04:52:02 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt 2014-02-25 17:02:23 +0000
@@ -202,26 +202,23 @@
Y.on('load', function() {
var logged_in = LP.links['me'] !== undefined;
-
+ var ic = Y.lp.code.branchmergeproposal.inlinecomments;
if (logged_in) {
var comment = new Y.lp.app.comment.CodeReviewComment();
comment.render();
comment._add_comment_success = function () {
var lp_client = new Y.lp.client.Launchpad();
- var ns = Y.lp.code.branchmergeproposal.inlinecomments;
- var diff_timestamp = (
- LP.cache.preview_diff_timestamps.slice(-1)[0]);
var config = {
on: {
success: function (r) {
LP.cache.published_inline_comments = r;
LP.cache.draft_inline_comments = null;
- ns.populate_existing_comments();
+ ic.populate_existing_comments();
},
},
parameters: {
- diff_timestamp: diff_timestamp,
+ previewdiff_id: ic.current_previewdiff_id,
}
};
lp_client.named_get(
@@ -259,7 +256,9 @@
'.expander-content',
false,
Y.lp.code.branch.revisionexpander.bmp_diff_loader);
- Y.lp.code.branchmergeproposal.inlinecomments.setup_inline_comments();
+ var previewdiff_id = LP.cache.previewdiff_ids.slice(-1)[0];
+ var ic = Y.lp.code.branchmergeproposal.inlinecomments;
+ ic.setup_inline_comments(previewdiff_id);
});
});
<tal:script replace="structure string:</script>" />
Follow ups