Merge "Add a copy icon to make copy change id and subject easier"

This commit is contained in:
Tao Zhou
2020-01-13 13:15:35 +00:00
committed by Gerrit Code Review
3 changed files with 34 additions and 2 deletions

View File

@@ -194,8 +194,6 @@ limitations under the License.
max-height: 36em;
overflow: hidden;
}
#relatedChanges {
}
#relatedChanges.collapsed {
margin-bottom: var(--spacing-l);
max-height: var(--relation-chain-max-height, 2em);
@@ -391,10 +389,15 @@ limitations under the License.
change="{{_change}}"
on-toggle-star="_handleToggleStar"
hidden$="[[!_loggedIn]]"></gr-change-star>
<a aria-label$="[[_computeChangePermalinkAriaLabel(_change._number)]]"
href$="[[_computeChangeUrl(_change)]]">[[_change._number]]</a>
<span class="changeNumberColon">:&nbsp;</span>
<span class="headerSubject">[[_change.subject]]</span>
<gr-copy-clipboard
hide-input
text="[[_computeCopyTextForTitle(_change)]]">
</gr-copy-clipboard>
</div><!-- end headerTitle -->
<div class="commitActions" hidden$="[[!_loggedIn]]">
<gr-change-actions

View File

@@ -1597,6 +1597,17 @@
return collapsed ? '\u25bc Show more' : '\u25b2 Show less';
}
/**
* Returns the text to be copied when
* click the copy icon next to change subject
*
* @param {!Object} change
*/
_computeCopyTextForTitle(change) {
return `${change._number}: ${change.subject}` +
` | https://${location.host}${this._computeChangeUrl(change)}`;
}
_toggleCommitCollapsed() {
this._commitCollapsed = !this._commitCollapsed;
if (this._commitCollapsed) {

View File

@@ -803,6 +803,24 @@ limitations under the License.
assert.deepEqual(commit, {commit: 2});
});
test('_computeCopyTextForTitle', () => {
const change = {
_number: 123,
subject: 'test subject',
revisions: {
rev1: {_number: 1},
rev3: {_number: 3},
},
current_revision: 'rev3',
};
sandbox.stub(Gerrit.Nav, 'getUrlForChange')
.returns('/change/123');
assert.equal(
element._computeCopyTextForTitle(change),
'123: test subject | https://localhost:8081/change/123'
);
});
test('get latest revision', () => {
let change = {
revisions: {