Merge "Show file weblinks (e.g. gitles) in diff view"
This commit is contained in:
@@ -132,7 +132,7 @@ limitations under the License.
|
||||
<span class="value">
|
||||
<template is="dom-if" if="[[_showWebLink]]">
|
||||
<a target="_blank"
|
||||
href$="[[_webLink]]">[[_computeShortHash(commitInfo)]]</a>
|
||||
href$="[[_webLink]]">[[_computeShortHash(commitInfo)]]</a>
|
||||
</template>
|
||||
<template is="dom-if" if="[[!_showWebLink]]">
|
||||
[[_computeShortHash(commitInfo)]]
|
||||
|
||||
@@ -40,7 +40,7 @@ limitations under the License.
|
||||
|
||||
test('single line', function() {
|
||||
assert(element.message == null);
|
||||
element.commitInfo = { message: "one line commit" };
|
||||
element.commitInfo = { message: 'one line commit' };
|
||||
console.log(element.message);
|
||||
var expected = 'Revert of one line commit\n\n' +
|
||||
'Reason for revert: <INSERT REASONING HERE>\n\n' +
|
||||
@@ -51,7 +51,7 @@ limitations under the License.
|
||||
|
||||
test('multi line', function() {
|
||||
assert(element.message == null);
|
||||
element.commitInfo = { message: "many lines\ncommit\n\nmessage\n" };
|
||||
element.commitInfo = { message: 'many lines\ncommit\n\nmessage\n' };
|
||||
console.log(element.message);
|
||||
var expected = 'Revert of many lines\n\n' +
|
||||
'Reason for revert: <INSERT REASONING HERE>\n\n' +
|
||||
|
||||
@@ -172,6 +172,7 @@ limitations under the License.
|
||||
path="[[_path]]"
|
||||
change-num="[[_changeNum]]"
|
||||
patch-range="[[_patchRange]]"
|
||||
files-weblinks="[[_filesWeblinks]]"
|
||||
available-patches="[[_computeAvailablePatches(_change.revisions)]]">
|
||||
</gr-patch-range-select>
|
||||
<div>
|
||||
@@ -199,10 +200,12 @@ limitations under the License.
|
||||
on-save="_handlePrefsSave"
|
||||
on-cancel="_handlePrefsCancel"></gr-diff-preferences>
|
||||
</gr-overlay>
|
||||
<gr-diff id="diff"
|
||||
<gr-diff
|
||||
id="diff"
|
||||
project="[[_change.project]]"
|
||||
commit="[[_change.current_revision]]"
|
||||
is-image-diff="{{_isImageDiff}}"
|
||||
files-weblinks="{{_filesWeblinks}}"
|
||||
change-num="[[_changeNum]]"
|
||||
patch-range="[[_patchRange]]"
|
||||
path="[[_path]]"
|
||||
|
||||
@@ -81,9 +81,10 @@
|
||||
_userPrefs: Object,
|
||||
_diffMode: {
|
||||
type: String,
|
||||
computed: '_getDiffViewMode(changeViewState.diffMode, _userPrefs)'
|
||||
computed: '_getDiffViewMode(changeViewState.diffMode, _userPrefs)',
|
||||
},
|
||||
_isImageDiff: Boolean,
|
||||
_filesWeblinks: Object,
|
||||
},
|
||||
|
||||
behaviors: [
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
computed: '_computeIsImageDiff(_diff)',
|
||||
notify: true,
|
||||
},
|
||||
filesWeblinks: {
|
||||
type: Object,
|
||||
value: function() { return {}; },
|
||||
notify: true,
|
||||
},
|
||||
|
||||
_loggedIn: {
|
||||
type: Boolean,
|
||||
@@ -353,7 +358,13 @@
|
||||
this.patchRange.basePatchNum,
|
||||
this.patchRange.patchNum,
|
||||
this.path,
|
||||
this._handleGetDiffError.bind(this));
|
||||
this._handleGetDiffError.bind(this)).then(function(diff) {
|
||||
this.filesWeblinks = {
|
||||
meta_a: diff.meta_a && diff.meta_a.web_links,
|
||||
meta_b: diff.meta_b && diff.meta_b.web_links,
|
||||
};
|
||||
return diff;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_getDiffComments: function() {
|
||||
|
||||
@@ -56,6 +56,27 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('loads files weblinks', function(done) {
|
||||
var diffStub = sinon.stub(element.$.restAPI, 'getDiff').returns(
|
||||
Promise.resolve({
|
||||
meta_a: {
|
||||
web_links: 'foo',
|
||||
},
|
||||
meta_b: {
|
||||
web_links: 'bar',
|
||||
},
|
||||
}));
|
||||
element.patchRange = {};
|
||||
element._getDiff().then(function() {
|
||||
assert.deepEqual(element.filesWeblinks, {
|
||||
meta_a: 'foo',
|
||||
meta_b: 'bar',
|
||||
});
|
||||
done();
|
||||
});
|
||||
diffStub.restore();
|
||||
});
|
||||
|
||||
test('remove comment', function() {
|
||||
element._comments = {
|
||||
meta: {
|
||||
|
||||
@@ -38,6 +38,12 @@ limitations under the License.
|
||||
</template>
|
||||
</select>
|
||||
</span>
|
||||
<span is="dom-if" if="[[filesWeblinks.meta_a]]">
|
||||
<template is="dom-repeat" items="[[filesWeblinks.meta_a]]" as="weblink">
|
||||
<a target="_blank"
|
||||
href$="[[weblink.url]]">[[weblink.name]]</a>
|
||||
</template>
|
||||
</span>
|
||||
→
|
||||
<span class="patchRange">
|
||||
<select id="rightPatchSelect" on-change="_handlePatchChange">
|
||||
@@ -47,6 +53,12 @@ limitations under the License.
|
||||
disabled$="[[_computeRightDisabled(patchNum, patchRange)]]">[[patchNum]]</option>
|
||||
</template>
|
||||
</select>
|
||||
<span is="dom-if" if="[[filesWeblinks.meta_b]]">
|
||||
<template is="dom-repeat" items="[[filesWeblinks.meta_b]]" as="weblink">
|
||||
<a target="_blank"
|
||||
href$="[[weblink.url]]">[[weblink.name]]</a>
|
||||
</template>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<script src="gr-patch-range-select.js"></script>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
properties: {
|
||||
availablePatches: Array,
|
||||
changeNum: String,
|
||||
filesWeblinks: Object,
|
||||
patchRange: Object,
|
||||
path: String,
|
||||
},
|
||||
|
||||
@@ -89,5 +89,28 @@ limitations under the License.
|
||||
rightSelectEl.value = '3';
|
||||
element.fire('change', {}, {node: leftSelectEl});
|
||||
});
|
||||
|
||||
test('filesWeblinks', function() {
|
||||
element.filesWeblinks = {
|
||||
meta_a: [
|
||||
{
|
||||
name: 'foo',
|
||||
url: 'f.oo',
|
||||
}
|
||||
],
|
||||
meta_b: [
|
||||
{
|
||||
name: 'bar',
|
||||
url: 'ba.r',
|
||||
}
|
||||
],
|
||||
};
|
||||
flushAsynchronousOperations();
|
||||
var domApi = Polymer.dom(element.root);
|
||||
assert.equal(
|
||||
domApi.querySelector('a[href="f.oo"]').textContent, 'foo');
|
||||
assert.equal(
|
||||
domApi.querySelector('a[href="ba.r"]').textContent, 'bar');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user