
+ Also change property to needs-review since ‘unreviewed’ was kinda bleh. Change-Id: Ia779e7d50c57315a108777774908b485d856fbce
211 lines
6.1 KiB
HTML
211 lines
6.1 KiB
HTML
<!--
|
|
Copyright (C) 2015 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<link rel="import" href="../bower_components/polymer/polymer.html">
|
|
<link rel="import" href="../styles/gr-change-list-styles.html">
|
|
<link rel="import" href="../behaviors/rest-client-behavior.html">
|
|
<link rel="import" href="gr-account-link.html">
|
|
<link rel="import" href="gr-change-star.html">
|
|
<link rel="import" href="gr-date-formatter.html">
|
|
|
|
<dom-module id="gr-change-list-item">
|
|
<template>
|
|
<style>
|
|
:host {
|
|
display: flex;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
:host([selected]) {
|
|
background-color: #ebf5fb;
|
|
}
|
|
:host([needs-review]) {
|
|
font-weight: bold;
|
|
}
|
|
.cell {
|
|
flex-shrink: 0;
|
|
padding: .3em .5em;
|
|
}
|
|
a {
|
|
color: var(--default-text-color);
|
|
text-decoration: none;
|
|
}
|
|
a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
.positionIndicator {
|
|
visibility: hidden;
|
|
}
|
|
:host([selected]) .positionIndicator {
|
|
visibility: visible;
|
|
}
|
|
.u-monospace {
|
|
font-family: var(--monospace-font-family);
|
|
}
|
|
.u-green {
|
|
color: #388E3C;
|
|
}
|
|
.u-red {
|
|
color: #D32F2F;
|
|
}
|
|
</style>
|
|
<style include="gr-change-list-styles"></style>
|
|
<span class="cell keyboard">
|
|
<span class="positionIndicator">▶</span>
|
|
</span>
|
|
<span class="cell star" hidden$="[[!showStar]]">
|
|
<gr-change-star change="{{change}}"></gr-change-star>
|
|
</span>
|
|
<a class="cell subject" href$="[[changeURL]]">[[change.subject]]</a>
|
|
<span class="cell status">[[_computeChangeStatusString(change)]]</span>
|
|
<span class="cell owner">
|
|
<gr-account-link account="[[change.owner]]"></gr-account-link>
|
|
</span>
|
|
<a class="cell project" href$="[[_computeProjectURL(change.project)]]">[[change.project]]</a>
|
|
<a class="cell branch" href$="[[_computeProjectBranchURL(change.project, change.branch)]]">[[change.branch]]</a>
|
|
<gr-date-formatter class="cell updated" date-str="[[change.updated]]"></gr-date-formatter>
|
|
<span class="cell size u-monospace">
|
|
<span class="u-green"><span>+</span>[[change.insertions]]</span>,
|
|
<span class="u-red"><span>-</span>[[change.deletions]]</span>
|
|
</span>
|
|
<template is="dom-repeat" items="[[labelNames]]" as="labelName">
|
|
<span title$="[[_computeLabelTitle(change, labelName)]]"
|
|
class$="[[_computeLabelClass(change, labelName)]]">[[_computeLabelValue(change, labelName)]]</span>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
(function() {
|
|
'use strict';
|
|
|
|
Polymer({
|
|
is: 'gr-change-list-item',
|
|
|
|
properties: {
|
|
selected: {
|
|
type: Boolean,
|
|
value: false,
|
|
reflectToAttribute: true,
|
|
},
|
|
needsReview: {
|
|
type: Boolean,
|
|
value: false,
|
|
reflectToAttribute: true,
|
|
},
|
|
labelNames: {
|
|
type: Array,
|
|
},
|
|
change: Object,
|
|
changeURL: {
|
|
type: String,
|
|
computed: '_computeChangeURL(change._number)',
|
|
},
|
|
showStar: {
|
|
type: Boolean,
|
|
value: false,
|
|
},
|
|
},
|
|
|
|
behaviors: [
|
|
Gerrit.RESTClientBehavior,
|
|
],
|
|
|
|
_computeChangeURL: function(changeNum) {
|
|
if (!changeNum) { return ''; }
|
|
return '/c/' + changeNum + '/';
|
|
},
|
|
|
|
_computeChangeStatusString: function(change) {
|
|
if (change.status == this.ChangeStatus.MERGED) {
|
|
return 'Merged';
|
|
}
|
|
if (change.mergeable != null && change.mergeable == false) {
|
|
return 'Merge Conflict';
|
|
}
|
|
if (change.status == this.ChangeStatus.DRAFT) {
|
|
return 'Draft';
|
|
}
|
|
if (change.status == this.ChangeStatus.ABANDONED) {
|
|
return 'Abandoned';
|
|
}
|
|
return '';
|
|
},
|
|
|
|
_computeLabelTitle: function(change, labelName) {
|
|
var label = change.labels[labelName];
|
|
if (!label) { return labelName; }
|
|
var significantLabel = label.rejected || label.approved ||
|
|
label.disliked || label.recommended;
|
|
if (significantLabel && significantLabel.name) {
|
|
return labelName + '\nby ' + significantLabel.name;
|
|
}
|
|
return labelName;
|
|
},
|
|
|
|
_computeLabelClass: function(change, labelName) {
|
|
var label = change.labels[labelName];
|
|
// Mimic a Set.
|
|
var classes = {
|
|
'cell': true,
|
|
'label': true,
|
|
};
|
|
if (label) {
|
|
if (label.approved) {
|
|
classes['u-green'] = true;
|
|
}
|
|
if (label.value == 1) {
|
|
classes['u-monospace'] = true;
|
|
classes['u-green'] = true;
|
|
} else if (label.value == -1) {
|
|
classes['u-monospace'] = true;
|
|
classes['u-red'] = true;
|
|
}
|
|
if (label.rejected) {
|
|
classes['u-red'] = true;
|
|
}
|
|
}
|
|
return Object.keys(classes).sort().join(' ');
|
|
},
|
|
|
|
_computeLabelValue: function(change, labelName) {
|
|
var label = change.labels[labelName];
|
|
if (!label) { return ''; }
|
|
if (label.approved) {
|
|
return '✓';
|
|
}
|
|
if (label.rejected) {
|
|
return '✕';
|
|
}
|
|
if (label.value > 0) {
|
|
return '+' + label.value;
|
|
}
|
|
if (label.value < 0) {
|
|
return label.value;
|
|
}
|
|
return '';
|
|
},
|
|
|
|
_computeProjectURL: function(project) {
|
|
return '/projects/' + project + ',dashboards/default';
|
|
},
|
|
|
|
_computeProjectBranchURL: function(project, branch) {
|
|
return '/q/status:open+project:' + project + '+branch:' + branch;
|
|
},
|
|
|
|
});
|
|
})();
|
|
</script>
|
|
</dom-module>
|