Merge "Add optional file link to gr-comment-thread"
This commit is contained in:
@@ -15,20 +15,16 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
|
<link rel="import" href="../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.html">
|
||||||
|
<link rel="import" href="../../../styles/shared-styles.html">
|
||||||
|
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||||
<link rel="import" href="../../shared/gr-storage/gr-storage.html">
|
<link rel="import" href="../../shared/gr-storage/gr-storage.html">
|
||||||
<link rel="import" href="../gr-diff-comment/gr-diff-comment.html">
|
<link rel="import" href="../gr-diff-comment/gr-diff-comment.html">
|
||||||
<link rel="import" href="../../../styles/shared-styles.html">
|
|
||||||
|
|
||||||
<dom-module id="gr-diff-comment-thread">
|
<dom-module id="gr-diff-comment-thread">
|
||||||
<template>
|
<template>
|
||||||
<style include="shared-styles">
|
<style include="shared-styles">
|
||||||
:host {
|
|
||||||
border: 1px solid #bbb;
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 1px;
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
gr-button {
|
gr-button {
|
||||||
margin-left: .5em;
|
margin-left: .5em;
|
||||||
--gr-button-color: #212121;
|
--gr-button-color: #212121;
|
||||||
@@ -39,6 +35,10 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
#container {
|
#container {
|
||||||
background-color: #fcfad6;
|
background-color: #fcfad6;
|
||||||
|
border: 1px solid #bbb;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 1px;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
#container.unresolved {
|
#container.unresolved {
|
||||||
background-color: #fcfaa6;
|
background-color: #fcfaa6;
|
||||||
@@ -52,7 +52,22 @@ limitations under the License.
|
|||||||
margin: auto 0;
|
margin: auto 0;
|
||||||
padding: .5em .7em;
|
padding: .5em .7em;
|
||||||
}
|
}
|
||||||
|
.pathInfo {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
.descriptionText {
|
||||||
|
margin-left: .5rem;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<template is="dom-if" if="[[showFilePath]]">
|
||||||
|
<div class="pathInfo">
|
||||||
|
<a href$="[[_getDiffUrlForComment(projectName, changeNum, path, patchNum)]]">[[_computeDisplayPath(path)]]</a>
|
||||||
|
<span class="descriptionText">Patchset [[patchNum]]</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<div id="container" class$="[[_computeHostClass(unresolved)]]">
|
<div id="container" class$="[[_computeHostClass(unresolved)]]">
|
||||||
<template id="commentList" is="dom-repeat" items="[[_orderedComments]]"
|
<template id="commentList" is="dom-repeat" items="[[_orderedComments]]"
|
||||||
as="comment">
|
as="comment">
|
||||||
|
|||||||
@@ -58,6 +58,16 @@
|
|||||||
value: null,
|
value: null,
|
||||||
},
|
},
|
||||||
rootId: String,
|
rootId: String,
|
||||||
|
/**
|
||||||
|
* If this is true, the comment thread also needs to have the change and
|
||||||
|
* line properties property set
|
||||||
|
*/
|
||||||
|
showFilePath: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
/** Necessary only if showFilePath is true */
|
||||||
|
lineNum: Number,
|
||||||
unresolved: {
|
unresolved: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
notify: true,
|
notify: true,
|
||||||
@@ -71,6 +81,7 @@
|
|||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
Gerrit.KeyboardShortcutBehavior,
|
Gerrit.KeyboardShortcutBehavior,
|
||||||
|
Gerrit.PathListBehavior,
|
||||||
],
|
],
|
||||||
|
|
||||||
listeners: {
|
listeners: {
|
||||||
@@ -117,6 +128,17 @@
|
|||||||
this.push('comments', draft);
|
this.push('comments', draft);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getDiffUrlForComment(projectName, changeNum, path, patchNum) {
|
||||||
|
return Gerrit.Nav.getUrlForDiffById(changeNum,
|
||||||
|
projectName, path, patchNum,
|
||||||
|
null, this.lineNum);
|
||||||
|
},
|
||||||
|
|
||||||
|
_computeDisplayPath(path) {
|
||||||
|
const lineString = this.lineNum ? `#${this.lineNum}` : '';
|
||||||
|
return this.computeDisplayPath(path) + lineString;
|
||||||
|
},
|
||||||
|
|
||||||
_getLoggedIn() {
|
_getLoggedIn() {
|
||||||
return this.$.restAPI.getLoggedIn();
|
return this.$.restAPI.getLoggedIn();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -170,6 +170,35 @@ limitations under the License.
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('optionally show file path', () => {
|
||||||
|
// Path info doesn't exist when showFilePath is false. Because it's in a
|
||||||
|
// dom-if it is not yet in the dom.
|
||||||
|
assert.isNotOk(element.$$('.pathInfo'));
|
||||||
|
|
||||||
|
sandbox.stub(Gerrit.Nav, 'getUrlForDiffById');
|
||||||
|
element.changeNum = 123;
|
||||||
|
element.projectName = 'test project';
|
||||||
|
element.path = 'path/to/file';
|
||||||
|
element.patchNum = 3;
|
||||||
|
element.lineNum = 5;
|
||||||
|
element.showFilePath = true;
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
assert.isOk(element.$$('.pathInfo'));
|
||||||
|
assert.notEqual(getComputedStyle(element.$$('.pathInfo')).display,
|
||||||
|
'none');
|
||||||
|
assert.isTrue(Gerrit.Nav.getUrlForDiffById.lastCall.calledWithExactly(
|
||||||
|
element.changeNum, element.projectName, element.path,
|
||||||
|
element.patchNum, null, element.lineNum));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('_computeDisplayPath', () => {
|
||||||
|
const path = 'path/to/file';
|
||||||
|
assert.equal(element._computeDisplayPath(path), 'path/to/file');
|
||||||
|
|
||||||
|
element.lineNum = 5;
|
||||||
|
assert.equal(element._computeDisplayPath(path), 'path/to/file#5');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
suite('comment action tests', () => {
|
suite('comment action tests', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user