Show Repo and Branch in one line when small enough

Change-Id: I5c811f7885567bb62767c0a2493346de55cd8130
This commit is contained in:
Ben Rohlfs
2020-01-24 11:59:01 +01:00
parent 23c87e1b79
commit 2b6b9dc884
2 changed files with 41 additions and 24 deletions

View File

@@ -207,22 +207,35 @@ limitations under the License.
max-reviewers-displayed="3"></gr-reviewer-list>
</span>
</section>
<section>
<span class="title">Repo</span>
<span class="value">
<a href$="[[_computeProjectURL(change.project)]]">
<gr-limited-text limit="40" text="[[change.project]]"></gr-limited-text>
</a>
</span>
</section>
<section>
<span class="title">Branch</span>
<span class="value">
<a href$="[[_computeBranchURL(change.project, change.branch)]]">
<gr-limited-text limit="40" text="[[change.branch]]"></gr-limited-text>
</a>
</span>
</section>
<template is="dom-if"
if="[[_computeShowRepoBranchTogether(change.project, change.branch)]]">
<section>
<span class="title">Repo Branch</span>
<span class="value">
<a href$="[[_computeProjectUrl(change.project)]]">[[change.project]]</a>
<a href$="[[_computeBranchUrl(change.project, change.branch)]]">[[change.branch]]</a>
</span>
</section>
</template>
<template is="dom-if"
if="[[!_computeShowRepoBranchTogether(change.project, change.branch)]]">
<section>
<span class="title">Repo</span>
<span class="value">
<a href$="[[_computeProjectUrl(change.project)]]">
<gr-limited-text limit="40" text="[[change.project]]"></gr-limited-text>
</a>
</span>
</section>
<section>
<span class="title">Branch</span>
<span class="value">
<a href$="[[_computeBranchUrl(change.project, change.branch)]]">
<gr-limited-text limit="40" text="[[change.branch]]"></gr-limited-text>
</a>
</span>
</section>
</template>
<section>
<span class="title">[[_computeParentsLabel(_currentParents)]]</span>
<span class="value">
@@ -252,7 +265,7 @@ limitations under the License.
<gr-linked-chip
text="[[change.topic]]"
limit="40"
href="[[_computeTopicURL(change.topic)]]"
href="[[_computeTopicUrl(change.topic)]]"
removable="[[!_topicReadOnly]]"
on-remove="_handleTopicRemoved"></gr-linked-chip>
</template>
@@ -274,7 +287,7 @@ limitations under the License.
<section>
<span class="title">Cherry pick of</span>
<span class="value">
<a href$="[[_computeCherryPickOfURL(change.cherry_pick_of_change, change.cherry_pick_of_patch_set, change.project)]]">
<a href$="[[_computeCherryPickOfUrl(change.cherry_pick_of_change, change.cherry_pick_of_patch_set, change.project)]]">
<gr-limited-text
text="[[change.cherry_pick_of_change]],[[change.cherry_pick_of_patch_set]]"
limit="40">
@@ -294,7 +307,7 @@ limitations under the License.
<gr-linked-chip
class="hashtagChip"
text="[[item]]"
href="[[_computeHashtagURL(item)]]"
href="[[_computeHashtagUrl(item)]]"
removable="[[!_hashtagReadOnly]]"
on-remove="_handleHashtagRemoved">
</gr-linked-chip>

View File

@@ -351,26 +351,30 @@
return [msg + ':'].concat(key.problems).join('\n');
}
_computeProjectURL(project) {
_computeShowRepoBranchTogether(repo, branch) {
return !!repo && !!branch && repo.length + branch.length < 40;
}
_computeProjectUrl(project) {
return Gerrit.Nav.getUrlForProjectChanges(project);
}
_computeBranchURL(project, branch) {
_computeBranchUrl(project, branch) {
if (!this.change || !this.change.status) return '';
return Gerrit.Nav.getUrlForBranch(branch, project,
this.change.status == this.ChangeStatus.NEW ? 'open' :
this.change.status.toLowerCase());
}
_computeCherryPickOfURL(change, patchset, project) {
_computeCherryPickOfUrl(change, patchset, project) {
return Gerrit.Nav.getUrlForChangeById(change, project, patchset);
}
_computeTopicURL(topic) {
_computeTopicUrl(topic) {
return Gerrit.Nav.getUrlForTopic(topic);
}
_computeHashtagURL(hashtag) {
_computeHashtagUrl(hashtag) {
return Gerrit.Nav.getUrlForHashtag(hashtag);
}