Merge changes I4f278748,I0f26b6df,If6b772c5,Ia8658605,Id3acdad1, ...
* changes:
NoSuchCheckerException: Remove unused constructors
Checker: Remove unused builder(CheckerUuid) method
Test that checker with invalid query is treated as not required for combined check state
PostCheck: Move into api package
CheckerRef: Add private constructor
Test that checker refs are only protected in the All-Projects project
Support 'is:inprogress' operator in pending checks query
Support 'is:<state>' operator in pending checks query
Rename ListPendingChecks to QueryPendingChecks
Change List Pending Checks REST endpoint to accept a query as input
diff --git a/gr-checks/BUILD b/gr-checks/BUILD
index e2dd6bd..e8f2e82 100644
--- a/gr-checks/BUILD
+++ b/gr-checks/BUILD
@@ -10,7 +10,7 @@
polygerrit_plugin(
name = "gr-checks",
app = "gr-checks.html",
- plugin_name = "checks",
+ plugin_name = "checks-pg",
externs = ["externs.js"],
srcs = glob([
"*.html",
diff --git a/gr-checks/gr-checks-all-statuses.js b/gr-checks/gr-checks-all-statuses.js
index 9f76441..17a7bee 100644
--- a/gr-checks/gr-checks-all-statuses.js
+++ b/gr-checks/gr-checks-all-statuses.js
@@ -1,72 +1,64 @@
(function() {
-'use strict';
+ 'use strict';
-window.Gerrit = (window.Gerrit || {});
-window.Gerrit.Checks = (window.Gerrit.Checks || {});
+ window.Gerrit = (window.Gerrit || {});
+ window.Gerrit.Checks = (window.Gerrit.Checks || {});
-// Prevent redefinition.
-if (window.Gerrit.Checks.Statuses) return;
+ // Prevent redefinition.
+ if (window.Gerrit.Checks.Statuses) return;
-const Statuses = {
- // non-terminal statuses
- STATUS_UNKNOWN: 'STATUS_UNKNOWN',
- QUEUING: 'QUEUING',
- QUEUED: 'QUEUED',
- WORKING: 'WORKING',
+ const Statuses = {
+ // non-terminal statuses
+ NOT_STARTED: 'NOT_STARTED',
+ SCHEDULED: 'SCHEDULED',
+ RUNNING: 'RUNNING',
- // terminal statuses
- SUCCESS: 'SUCCESS',
- FAILURE: 'FAILURE',
- INTERNAL_ERROR: 'INTERNAL_ERROR',
- TIMEOUT: 'TIMEOUT',
- CANCELLED: 'CANCELLED',
-};
+ // terminal statuses
+ SUCCESSFUL: 'SUCCESSFUL',
+ FAILED: 'FAILED',
+ NOT_RELEVANT: 'NOT_RELEVANT',
+ };
+ function isStatus(status, includedStatuses) {
+ return includedStatuses.includes(status);
+ }
-function isStatus(status, includedStatuses) {
- return includedStatuses.includes(status);
-}
+ function isUnevaluated(status) {
+ return isStatus(status, [Statuses.NOT_STARTED, Statuses.NOT_RELEVANT]);
+ }
+ function isInProgress(status) {
+ return isStatus(status, [Statuses.SCHEDULED, Statuses.RUNNING]);
+ }
-function isUnevaluated(status) {
- return isStatus(status, [Statuses.STATUS_UNKNOWN, Statuses.CANCELLED]);
-}
+ function isSuccessful(status) {
+ return isStatus(status, [Statuses.SUCCESSFUL]);
+ }
-function isInProgress(status) {
- return isStatus(
- status, [Statuses.QUEUING, Statuses.QUEUED, Statuses.WORKING]);
-}
+ function isFailed(status) {
+ return isStatus(status, [Statuses.FAILED]);
+ }
-function isSuccessful(status) {
- return isStatus(status, [Statuses.SUCCESS]);
-}
-
-function isFailed(status) {
- return isStatus(
- status, [Statuses.FAILURE, Statuses.INTERNAL_ERROR, Statuses.TIMEOUT]);
-}
-
-
-function statusClass(status) {
- if (isUnevaluated(status)) {
+ function statusClass(status) {
+ if (isUnevaluated(status)) {
+ return 'unevaluated';
+ }
+ if (isInProgress(status)) {
+ return 'in-progress';
+ }
+ if (isSuccessful(status)) {
+ return 'successful';
+ }
+ if (isFailed(status)) {
+ return 'failed';
+ }
return 'unevaluated';
}
- if (isInProgress(status)) {
- return 'in-progress';
- }
- if (isSuccessful(status)) {
- return 'successful';
- }
- if (isFailed(status)) {
- return 'failed';
- }
- return 'unevaluated';
-}
-window.Gerrit.Checks.Statuses = Statuses;
-window.Gerrit.Checks.isUnevaluated = isUnevaluated;
-window.Gerrit.Checks.isInProgress = isInProgress;
-window.Gerrit.Checks.isSuccessful = isSuccessful;
-window.Gerrit.Checks.isFailed = isFailed;
-window.Gerrit.Checks.statusClass = statusClass;
+ window.Gerrit.Checks.Statuses = Statuses;
+ window.Gerrit.Checks.isUnevaluated = isUnevaluated;
+ window.Gerrit.Checks.isInProgress = isInProgress;
+ window.Gerrit.Checks.isSuccessful = isSuccessful;
+ window.Gerrit.Checks.isFailed = isFailed;
+ window.Gerrit.Checks.statusClass = statusClass;
})();
diff --git a/gr-checks/gr-checks-chip-view.js b/gr-checks/gr-checks-chip-view.js
index 415bc1f..778f87d 100644
--- a/gr-checks/gr-checks-chip-view.js
+++ b/gr-checks/gr-checks-chip-view.js
@@ -1,124 +1,114 @@
(function() {
-'use strict';
-const Statuses = window.Gerrit.Checks.Statuses;
+ 'use strict';
+ const Statuses = window.Gerrit.Checks.Statuses;
-const StatusPriorityOrder = [
- Statuses.INTERNAL_ERROR, Statuses.TIMEOUT, Statuses.FAILURE,
- Statuses.STATUS_UNKNOWN, Statuses.CANCELLED, Statuses.QUEUED,
- Statuses.QUEUING, Statuses.WORKING, Statuses.SUCCESS
-];
+ const StatusPriorityOrder = [
+ Statuses.FAILED,
+ Statuses.SCHEDULED,
+ Statuses.RUNNING,
+ Statuses.SUCCESSFUL,
+ Statuses.NOT_STARTED,
+ Statuses.NOT_RELEVANT,
+ ];
-const HumanizedStatuses = {
- // non-terminal statuses
- STATUS_UNKNOWN: 'unevaluated',
- QUEUING: 'in progress',
- QUEUED: 'in progress',
- WORKING: 'in progress',
+ const HumanizedStatuses = {
+ // non-terminal statuses
+ NOT_STARTED: 'in progress',
+ NOT_RELEVANT: 'not relevant',
+ SCHEDULED: 'in progress',
+ RUNNING: 'in progress',
- // terminal statuses
- SUCCESS: 'successful',
- FAILURE: 'failed',
- INTERNAL_ERROR: 'failed',
- TIMEOUT: 'failed',
- CANCELLED: 'unevaluated',
-};
+ // terminal statuses
+ SUCCESSFUL: 'successful',
+ FAILED: 'failed',
+ };
+ const Defs = {};
+ /**
+ * @typedef {{
+ * _number: number,
+ * }}
+ */
+ Defs.Change;
+ /**
+ * @typedef {{
+ * _number: number,
+ * }}
+ */
+ Defs.Revision;
-const Defs = {};
-/**
- * @typedef {{
- * revisions: !Object<string, !Object>,
- * }}
- */
-Defs.Change;
+ function computeCheckStatuses(checks) {
+ return checks.reduce((accum, check) => {
+ accum[check.state] || (accum[check.state] = 0);
+ accum[check.state]++;
+ return accum;
+ }, {total: checks.length});
+ }
-/**
- * @param {!Defs.Change} change The current CL.
- * @param {!Object} revision The current patchset.
- * @return {string|undefined}
- */
-function currentRevisionSha(change, revision) {
- return Object.keys(change.revisions)
- .find(sha => change.revisions[sha] === revision);
-}
+ Polymer({
+ is: 'gr-checks-chip-view',
-function computeCheckStatuses(checks) {
- return checks.reduce((accum, check) => {
- accum[check.state] || (accum[check.state] = 0);
- accum[check.state]++;
- return accum;
- }, {total: checks.length});
-}
-
-Polymer({
- is: 'gr-checks-chip-view',
-
- properties: {
- revision: Object,
- change: Object,
- // TODO(brohlfs): Implement getChecks based on new Rest APIs.
- /** @type {function(string, (string|undefined)): !Promise<!Object>} */
- getChecks: Function,
- _checkStatuses: Object,
- _hasChecks: Boolean,
- _status: {type: String, computed: '_computeStatus(_checkStatuses)'},
- _statusString: {
- type: String,
- computed: '_computeStatusString(_status, _checkStatuses)'
+ properties: {
+ revision: Object,
+ change: Object,
+ /** @type {function(number, number): !Promise<!Object>} */
+ getChecks: Function,
+ _checkStatuses: Object,
+ _hasChecks: Boolean,
+ _status: {type: String, computed: '_computeStatus(_checkStatuses)'},
+ _statusString: {
+ type: String,
+ computed: '_computeStatusString(_status, _checkStatuses)',
+ },
+ _chipClasses: {type: String, computed: '_computeChipClass(_status)'},
},
- _chipClasses: {type: String, computed: '_computeChipClass(_status)'},
- },
- observers: [
- '_fetchChecks(change, revision, getChecks)',
- ],
+ observers: [
+ '_fetchChecks(change, revision, getChecks)',
+ ],
- /**
- * @param {!Defs.Change} change The current CL.
- * @param {!Object} revision The current patchset.
- * @param {function(string, (string|undefined)): !Promise<!Object>}
- * getChecks function to get checks.
- */
- _fetchChecks(change, revision, getChecks) {
- const repository = change['project'];
- const gitSha = currentRevisionSha(change, revision);
+ /**
+ * @param {!Defs.Change} change
+ * @param {!Defs.Revision} revision
+ * @param {function(number, number): !Promise<!Object>} getChecks
+ */
+ _fetchChecks(change, revision, getChecks) {
+ getChecks(change._number, revision._number).then(checks => {
+ this.set('_hasChecks', checks.length > 0);
+ if (checks.length > 0) {
+ this.set(
+ '_checkStatuses', computeCheckStatuses(checks));
+ }
+ });
+ },
- getChecks(repository, gitSha).then(checks => {
- this.set('_hasChecks', checks.length > 0);
- if (checks.length > 0) {
- this.set(
- '_checkStatuses', computeCheckStatuses(checks));
- }
- });
- },
+ /**
+ * @param {!Object} checkStatuses The number of checks in each status.
+ * @return {string}
+ */
+ _computeStatus(checkStatuses) {
+ return StatusPriorityOrder.find(
+ status => checkStatuses[status] > 0) ||
+ Statuses.STATUS_UNKNOWN;
+ },
- /**
- * @param {!Object} checkStatuses The number of checks in each status.
- * @return {string}
- */
- _computeStatus(checkStatuses) {
- return StatusPriorityOrder.find(
- status => checkStatuses[status] > 0) ||
- Statuses.STATUS_UNKNOWN;
- },
+ /**
+ * @param {string} status The overall status of the checks.
+ * @param {!Object} checkStatuses The number of checks in each status.
+ * @return {string}
+ */
+ _computeStatusString(status, checkStatuses) {
+ if (checkStatuses.total === 0) return 'No checks';
+ return `${checkStatuses[status]} of ${
+ checkStatuses.total} checks ${HumanizedStatuses[status]}`;
+ },
- /**
- * @param {string} status The overall status of the checks.
- * @param {!Object} checkStatuses The number of checks in each status.
- * @return {string}
- */
- _computeStatusString(status, checkStatuses) {
- if (checkStatuses.total === 0) return 'No checks';
- return `${checkStatuses[status]} of ${
- checkStatuses.total} checks ${HumanizedStatuses[status]}`;
- },
-
- /**
- * @param {string} status The overall status of the checks.
- * @return {string}
- */
- _computeChipClass(status) {
- return `chip ${window.Gerrit.Checks.statusClass(status)}`;
- },
-});
+ /**
+ * @param {string} status The overall status of the checks.
+ * @return {string}
+ */
+ _computeChipClass(status) {
+ return `chip ${window.Gerrit.Checks.statusClass(status)}`;
+ },
+ });
})();
diff --git a/gr-checks/gr-checks-chip-view_test.html b/gr-checks/gr-checks-chip-view_test.html
index fb1c67a..e8decce 100644
--- a/gr-checks/gr-checks-chip-view_test.html
+++ b/gr-checks/gr-checks-chip-view_test.html
@@ -19,7 +19,7 @@
logUrl: 'http://example.com/test-log-url',
startTime: "2019-02-06T22:25:19.269Z",
finishTime: "2019-02-06T22:25:44.574Z",
- status: 'SUCCESS',
+ status: 'SUCCESSFUL',
};
const CHECK2 = {
@@ -27,7 +27,7 @@
logUrl: 'http://example.com/test-log-url',
startTime: "2019-02-06T22:25:19.269Z",
finishTime: "2019-02-06T22:25:44.574Z",
- status: 'FAILURE',
+ status: 'FAILED',
};
suite('gr-checks-chip-view tests', () => {
@@ -44,13 +44,11 @@
element = fixture('basic', {
getChecks: getChecksSpy,
change: {
- 'project': 'test-repository',
- 'revisions': {
- 'first-sha': "test-revision",
- 'second-sha': "test-revision2",
- }
+ '_number': 314,
},
- revision: 'test-revision2',
+ revision: {
+ '_number': 271,
+ },
});
flush(done);
});
@@ -64,7 +62,7 @@
suite('builds chip contents', () => {
test('queries the checks', () => {
assert.isTrue(getChecksSpy.called);
- assert.isTrue(getChecksSpy.calledWith('test-repository', 'second-sha'));
+ assert.isTrue(getChecksSpy.calledWith(314, 271));
});
test('renders the text of failed checks', () => {
diff --git a/gr-checks/gr-checks-configure-link.html b/gr-checks/gr-checks-configure-link.html
deleted file mode 100644
index 23cbb6e..0000000
--- a/gr-checks/gr-checks-configure-link.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<dom-module id="gr-checks-configure-link">
- <template>
- <style>
- iron-icon {
- height: 1.2rem;
- margin-right: 4px;
- width: 1.2rem;
- }
- </style>
- <a href$="[[configurePath]]">
- <gr-button link no-uppercase>
- <iron-icon icon="gr-icons:settings"></iron-icon>
- Configure checks
- </gr-button>
- </a>
- </template>
- <script src="gr-checks-configure-link.js"></script>
-</dom-module>
diff --git a/gr-checks/gr-checks-configure-link.js b/gr-checks/gr-checks-configure-link.js
deleted file mode 100644
index 0eb1571..0000000
--- a/gr-checks/gr-checks-configure-link.js
+++ /dev/null
@@ -1,11 +0,0 @@
-(function() {
-'use strict';
-
-Polymer({
- is: 'gr-checks-configure-link',
-
- properties: {
- configurePath: String,
- },
-});
-})();
diff --git a/gr-checks/gr-checks-configure-link_test.html b/gr-checks/gr-checks-configure-link_test.html
deleted file mode 100644
index 3c8f314..0000000
--- a/gr-checks/gr-checks-configure-link_test.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE html>
-<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
-<script src="imports.js"></script>
-<script src="webcomponentsjs/webcomponents-lite.js"></script>
-<link rel="import" href="polymer/polymer.html">
-
-<title>gr-checks-configure-link</title>
-<link rel="import" href="webcomponent_lib/gr-checks-configure-link.html">
-
-<test-fixture id="basic">
- <template is="dom-template">
- <gr-checks-configure-link configure-path="[[configurePath]]"></gr-checks-configure-link>
- </template>
-</test-fixture>
-
-<script>
- suite('gr-checks-configure-link tests', () => {
- let element;
- let sandbox;
-
- setup((done) => {
- sandbox = sinon.sandbox.create();
- element = fixture('basic', {
- configurePath: 'http://example.com/test-configure',
- });
- flush(done);
- });
-
- teardown(() => { sandbox.restore(); });
-
- test('renders the link to configure a check', () => {
- const configureLink = element.$$('a');
- assert.equal(configureLink.getAttribute('href'), 'http://example.com/test-configure');
- assert.equal(configureLink.textContent.trim(), 'Configure checks');
- });
- });
-</script>
diff --git a/gr-checks/gr-checks-item.html b/gr-checks/gr-checks-item.html
index 436f65b..9037772 100644
--- a/gr-checks/gr-checks-item.html
+++ b/gr-checks/gr-checks-item.html
@@ -20,12 +20,12 @@
}
</style>
- <td>[[_checkerDescription]]</td>
+ <td>[[check.checker_name]]</td>
<td><!-- required for merge--></td>
<td>
<gr-checks-status show-text status="[[check.state]]"></gr-checks-status>
</td>
- <td>Check System</td>
+ <td><!--Check System--></td>
<td>[[_startTime]]</td>
<td>[[_duration]]</td>
<td>
diff --git a/gr-checks/gr-checks-item.js b/gr-checks/gr-checks-item.js
index 272f82c..7777f75 100644
--- a/gr-checks/gr-checks-item.js
+++ b/gr-checks/gr-checks-item.js
@@ -4,12 +4,20 @@
const Defs = {};
/**
* @typedef {{
- * id: string,
- * projectId: string,
- * checkerId: string,
- * startTime: string,
- * finishTime: string,
- * }}
+ * project: string,
+ * change_number: number,
+ * patch_set_id: number,
+ * checker_uuid: string,
+ * state: string,
+ * url: string,
+ * started: string,
+ * finished: string,
+ * created: string,
+ * updated: string,
+ * checker_name: string,
+ * checker_status: string,
+ * blocking: Array<Object>,
+ * }}
*/
Defs.Check;
@@ -17,12 +25,10 @@
is: 'gr-checks-item',
properties: {
+ /** @type {Defs.Check} */
check: Object,
/** @type {function(string): !Promise<!Object>} */
- getChecker: Function,
- /** @type {function(string): !Promise<!Object>} */
retryCheck: Function,
- _checkerDescription: String,
_startTime: {
type: String,
computed: '_computeStartTime(check)',
@@ -33,29 +39,12 @@
},
},
- observers: [
- '_updateCheckerName(check, getChecker)',
- ],
-
- /**
- * @param {!Defs.Check} check
- * @param {function(string): !Promise<!Object>} getChecker
- */
- _updateCheckerName(check, getChecker) {
- const checkerId = check.checker_uuid;
- getChecker(checkerId).then(
- checker => checker && checker.description || checkerId,
- () => checkerId).then(checkerDescription => {
- this.set('_checkerDescription', checkerDescription);
- });
- },
-
/**
* @param {!Defs.Check} check
* @return {string}
*/
_computeStartTime(check) {
- return moment(check.created).format('l');
+ return moment(check.started).format('LTS');
},
/**
@@ -63,8 +52,8 @@
* @return {string}
*/
_computeDuration(check) {
- const startTime = moment(check.created);
- const finishTime = moment(check.updated);
+ const startTime = moment(check.started);
+ const finishTime = check.finished ? moment(check.finished) : moment();
return generateDurationString(
moment.duration(finishTime.diff(startTime)));
},
@@ -87,25 +76,25 @@
}
const durationSegments = [];
- if (duration.seconds()) {
- durationSegments.push(`${duration.seconds()} sec`);
- }
- if (duration.minutes()) {
- durationSegments.push(`${duration.minutes()} min`);
- }
- if (duration.hours()) {
- const hours = pluralize(duration.hours(), 'hour', 'hours');
- durationSegments.push(`${duration.hours()} ${hours}`);
+ if (duration.months()) {
+ const months = pluralize(duration.months(), 'month', 'months');
+ durationSegments.push(`${duration.months()} ${months}`);
}
if (duration.days()) {
const days = pluralize(duration.days(), 'day', 'days');
durationSegments.push(`${duration.days()} ${days}`);
}
- if (duration.months()) {
- const months = pluralize(duration.months(), 'month', 'months');
- durationSegments.push(`${duration.months()} ${months}`);
+ if (duration.hours()) {
+ const hours = pluralize(duration.hours(), 'hour', 'hours');
+ durationSegments.push(`${duration.hours()} ${hours}`);
}
- return durationSegments.join(' ');
+ if (duration.minutes()) {
+ durationSegments.push(`${duration.minutes()} min`);
+ }
+ if (duration.seconds()) {
+ durationSegments.push(`${duration.seconds()} sec`);
+ }
+ return durationSegments.slice(0, 2).join(' ');
}
/**
diff --git a/gr-checks/gr-checks-item_test.html b/gr-checks/gr-checks-item_test.html
index 0495d52..ef133aa 100644
--- a/gr-checks/gr-checks-item_test.html
+++ b/gr-checks/gr-checks-item_test.html
@@ -11,7 +11,6 @@
<template is="dom-template">
<gr-checks-item
check="{{check}}"
- get-checker="[[getChecker]]"
retry-check="[[retryCheck]]">
</gr-checks-item>
</template>
@@ -21,24 +20,14 @@
suite('gr-checks-item tests', () => {
let element;
let sandbox;
- let getCheckerSpy;
- let resolveGetChecker;
- let rejectGetChecker;
let retryCheckSpy;
setup((done) => {
sandbox = sinon.sandbox.create();
- const getCheckerPromise = new Promise((resolve, reject) => {
- resolveGetChecker = resolve;
- rejectGetChecker = reject;
- });
- getCheckerSpy = sinon.stub();
- getCheckerSpy.returns(getCheckerPromise);
retryCheckSpy = sinon.stub();
retryCheckSpy.returns(Promise.resolve());
element = fixture('basic', {
- getChecker: getCheckerSpy,
retryCheck: retryCheckSpy,
check: {
checkId: 'test-check-id',
@@ -52,51 +41,6 @@
teardown(() => { sandbox.restore(); });
- suite('checker name', () => {
- test('calls getChecker', () => {
- assert.isTrue(getCheckerSpy.called);
- assert.isTrue(getCheckerSpy.calledWith('test-check-id'));
- });
-
- function assertCheckerText(text) {
- const name = element.$$('td:nth-child(1)');
- assert.equal(name.textContent.trim(), text);
- }
-
- suite('on success', () => {
- setup(done => {
- resolveGetChecker({description: 'test checker name'});
- flush(done);
- });
-
- test('renders the checker name on success', () => {
- assertCheckerText('test checker name');
- });
- });
-
- suite('on empty response', () => {
- setup(done => {
- resolveGetChecker();
- flush(done);
- });
-
- test('renders the id when there is no description', () => {
- assertCheckerText('test-check-id');
- });
- });
-
- suite('on error', () => {
- setup(done => {
- rejectGetChecker(new Error('broken'));
- flush(done);
- });
-
- test('renders the id when the call fails', () => {
- assertCheckerText('test-check-id');
- });
- });
- });
-
test('renders the status', () => {
const status = element.$$('td:nth-child(3) > gr-checks-status');
assert.exists(status);
diff --git a/gr-checks/gr-checks-status.html b/gr-checks/gr-checks-status.html
index ef4a02a..ba5eef0 100644
--- a/gr-checks/gr-checks-status.html
+++ b/gr-checks/gr-checks-status.html
@@ -29,7 +29,7 @@
</style>
<span class$="[[_className]]">
<template is="dom-if" if="[[_isUnevaluated(status)]]">
- <i>⏹</i>
+ <i>⏹</i>
<template is="dom-if" if="[[showText]]">
<span>
Unevaluated
diff --git a/gr-checks/gr-checks-status_test.html b/gr-checks/gr-checks-status_test.html
index 19957a3..6f6a98c 100644
--- a/gr-checks/gr-checks-status_test.html
+++ b/gr-checks/gr-checks-status_test.html
@@ -56,9 +56,8 @@
});
}
- testStatus('successful', 'Successful', ['SUCCESS']);
- testStatus('failed', 'Failed', ['FAILURE', 'INTERNAL_ERROR', 'TIMEOUT']);
- testStatus('in-progress', 'In progress', ['QUEUING', 'QUEUED', 'WORKING']);
- testStatus('unevaluated', 'Unevaluated', ['STATUS_UNKNOWN', 'CANCELLED']);
+ testStatus('successful', 'Successful', ['SUCCESSFUL']);
+ testStatus('failed', 'Failed', ['FAILED']);
+ testStatus('in-progress', 'In progress', ['NOT_STARTED', 'SCHEDULED', 'RUNNING']);
});
</script>
diff --git a/gr-checks/gr-checks-view.html b/gr-checks/gr-checks-view.html
index 5f1b94e..b4efaa4 100644
--- a/gr-checks/gr-checks-view.html
+++ b/gr-checks/gr-checks-view.html
@@ -70,8 +70,6 @@
<div class="no-content">
<h2>No checks ran for this code review</h2>
<p>Configure checkers to view the results here.</p>
- <gr-checks-configure-link configure-path="[[configurePath]]">
- </gr-checks-configure-link>
</div>
</template>
@@ -79,16 +77,12 @@
<div class="no-content">
<h2>Code review checks not configured</h2>
<p>Configure checkers to view the results here.</p>
- <gr-checks-configure-link configure-path="[[configurePath]]">
- </gr-checks-configure-link>
</div>
</template>
<template is="dom-if" if="[[_hasResults(_status)]]">
<header>
<h3>Latest checks for Patchset [[revision._number]]</h3>
- <gr-checks-configure-link configure-path="[[configurePath]]">
- </gr-checks-configure-link>
</header>
<table>
@@ -97,7 +91,7 @@
<th class="topHeader">Name</th>
<th class="topHeader"><!-- required for merge --></th>
<th class="topHeader">Status</th>
- <th class="topHeader">Checking system</th>
+ <th class="topHeader"><!--Checking system--></th>
<th class="topHeader">Started</th>
<th class="topHeader">Duration</th>
<th class="topHeader"><!-- actions --></th>
@@ -105,7 +99,7 @@
</thead>
<tbody>
<template is="dom-repeat" items="[[_checks]]" as="check">
- <gr-checks-item check="[[check]]" retry-check="[[retryCheck]]" get-checker="[[getChecker]]"></gr-checks-item>
+ <gr-checks-item check="[[check]]" retry-check="[[retryCheck]]"></gr-checks-item>
</template>
</tbody>
</table>
diff --git a/gr-checks/gr-checks-view.js b/gr-checks/gr-checks-view.js
index 3f53f61..7bee91a 100644
--- a/gr-checks/gr-checks-view.js
+++ b/gr-checks/gr-checks-view.js
@@ -1,103 +1,86 @@
(function() {
-'use strict';
+ 'use strict';
-const Defs = {};
-/**
- * @typedef {{
- * revisions: !Object<string, !Object>,
- * }}
- */
-Defs.Change;
-
-/**
- * @param {!Defs.Change} change The current CL.
- * @param {!Object} revision The current patchset.
- * @return {string|undefined}
- */
-function currentRevisionSha(change, revision) {
- return Object.keys(change.revisions)
- .find(sha => change.revisions[sha] === revision);
-}
-
-const LoadingStatus = {
- LOADING: 0,
- EMPTY: 1,
- RESULTS: 2,
- NOT_CONFIGURED: 3,
-};
-
-Polymer({
- is: 'gr-checks-view',
-
- properties: {
- revision: Object,
- change: Object,
- // TODO(brohlfs): Implement getChecks based on Checks Rest API.
- /** @type {function(string, (string|undefined)): !Promise<!Object>} */
- getChecks: Function,
- // TODO(brohlfs): Implement isConfigured based on Checks Rest API.
- /** @type {function(string): !Promise<!Object>} */
- isConfigured: Function,
- // TODO(brohlfs): Implement getChecker based on Checks Rest API.
- /** @type {function(string, string): !Promise<!Object>} */
- getChecker: Function,
- // TODO(brohlfs): Implement retryCheck based on Checks Rest API.
- /** @type {function(string, string): !Promise<!Object>} */
- retryCheck: Function,
- // TODO(brohlfs): Implement configurePath based on Checks Rest API.
- // The url path to configure checkers.
- configurePath: String,
- _checks: Object,
- _status: {
- type: Object,
- value: LoadingStatus.LOADING,
- },
- },
-
- observers: [
- '_fetchChecks(change, revision, getChecks)',
- ],
-
+ const Defs = {};
/**
- * @param {!Defs.Change} change The current CL.
- * @param {!Object} revision The current patchset.
- * @param {function(string, (string|undefined)): !Promise<!Object>}
- * getChecks function to get checks.
+ * @typedef {{
+ * _number: number,
+ * }}
*/
- _fetchChecks(change, revision, getChecks) {
- const repository = change['project'];
- const gitSha = currentRevisionSha(change, revision);
+ Defs.Change;
+ /**
+ * @typedef {{
+ * _number: number,
+ * }}
+ */
+ Defs.Revision;
- getChecks(repository, gitSha).then(checks => {
- if (checks && checks.length) {
- this.set('_checks', checks);
- this.set('_status', LoadingStatus.RESULTS);
- } else {
- this._checkConfigured();
- }
- });
- },
+ const LoadingStatus = {
+ LOADING: 0,
+ EMPTY: 1,
+ RESULTS: 2,
+ NOT_CONFIGURED: 3,
+ };
- _checkConfigured() {
- const repository = this.change['project'];
- this.isConfigured(repository).then(configured => {
- const status =
- configured ? LoadingStatus.EMPTY : LoadingStatus.NOT_CONFIGURED;
- this.set('_status', status);
- });
- },
+ Polymer({
+ is: 'gr-checks-view',
- _isLoading(status) {
- return status === LoadingStatus.LOADING;
- },
- _isEmpty(status) {
- return status === LoadingStatus.EMPTY;
- },
- _hasResults(status) {
- return status === LoadingStatus.RESULTS;
- },
- _isNotConfigured(status) {
- return status === LoadingStatus.NOT_CONFIGURED;
- },
-});
+ properties: {
+ revision: Object,
+ change: Object,
+ /** @type {function(number, number): !Promise<!Object>} */
+ getChecks: Function,
+ /** @type {function(string): !Promise<Boolean>} */
+ isConfigured: Function,
+ /** @type {function(string, string): !Promise<!Object>} */
+ retryCheck: Function,
+ _checks: Object,
+ _status: {
+ type: Object,
+ value: LoadingStatus.LOADING,
+ },
+ },
+
+ observers: [
+ '_fetchChecks(change, revision, getChecks)',
+ ],
+
+ /**
+ * @param {!Defs.Change} change
+ * @param {!Defs.Revision} revision
+ * @param {function(number, number): !Promise<!Object>} getChecks
+ */
+ _fetchChecks(change, revision, getChecks) {
+ getChecks(change._number, revision._number).then(checks => {
+ if (checks && checks.length) {
+ this.set('_checks', checks);
+ this.set('_status', LoadingStatus.RESULTS);
+ } else {
+ this._checkConfigured();
+ }
+ });
+ },
+
+ _checkConfigured() {
+ const repository = this.change['project'];
+ this.isConfigured(repository).then(configured => {
+ const status =
+ configured ? LoadingStatus.EMPTY : LoadingStatus.NOT_CONFIGURED;
+ this.set('_status', status);
+ });
+ },
+
+ _isLoading(status) {
+ return status === LoadingStatus.LOADING;
+ },
+ _isEmpty(status) {
+ return status === LoadingStatus.EMPTY;
+ },
+ _hasResults(status) {
+ return status === LoadingStatus.RESULTS;
+ },
+ _isNotConfigured(status) {
+ return status === LoadingStatus.NOT_CONFIGURED;
+ },
+ });
})();
diff --git a/gr-checks/gr-checks-view_test.html b/gr-checks/gr-checks-view_test.html
index 6affa9c..6607e66 100644
--- a/gr-checks/gr-checks-view_test.html
+++ b/gr-checks/gr-checks-view_test.html
@@ -12,10 +12,8 @@
<gr-checks-view
change="[[change]]"
revision="[[revision]]"
- configure-path="[[configurePath]]"
get-checks="[[getChecks]]"
is-configured="[[isConfigured]]"
- get-checker="[[getChecker]]"
retry-check="[[retryCheck]]">
</gr-checks-view>
</template>
@@ -49,7 +47,6 @@
let sandbox;
let getChecksSpy;
let getChecksResolve;
- let getCheckerSpy;
let retryCheckSpy;
let isConfiguredSpy;
let isConfiguredResolve;
@@ -69,17 +66,13 @@
});
isConfiguredSpy.returns(isConfiguredPromise);
- getCheckerSpy = sinon.stub();
- getCheckerSpy.returns(Promise.resolve({description: 'test checker name'}));
retryCheckSpy = sinon.stub();
retryCheckSpy.returns(Promise.resolve());
element = fixture('basic', {
- getChecker: getCheckerSpy,
retryCheck: retryCheckSpy,
getChecks: getChecksSpy,
isConfigured: isConfiguredSpy,
- configurePath: 'http://example.com/test-configure',
change: {
'project': 'test-repository',
'revisions': {
@@ -124,11 +117,6 @@
const header = element.$$('h2');
assert.equal(header.textContent.trim(), 'Code review checks not configured');
});
-
- test('renders the link to configure a check', () => {
- const configureLink = element.$$('gr-checks-configure-link');
- assert.exists(configureLink);
- });
});
suite('no checks ran', () => {
@@ -141,11 +129,6 @@
const header = element.$$('h2');
assert.equal(header.textContent.trim(), 'No checks ran for this code review');
});
-
- test('renders the link to configure a check', () => {
- const configureLink = element.$$('gr-checks-configure-link');
- assert.exists(configureLink);
- });
});
});
@@ -164,11 +147,6 @@
assert.equal(header.textContent.trim(), 'Latest checks for Patchset 3');
});
- test('renders the link to configure a check', () => {
- const configureLink = element.$$('header > gr-checks-configure-link');
- assert.exists(configureLink);
- });
-
test('renders a table of all the checks', () => {
const tbody = element.$$('table > tbody');
assert.lengthOf(tbody.querySelectorAll('gr-checks-item'), 3)
diff --git a/gr-checks/gr-checks.html b/gr-checks/gr-checks.html
index 4efdf97..cc4f6ca 100644
--- a/gr-checks/gr-checks.html
+++ b/gr-checks/gr-checks.html
@@ -5,24 +5,42 @@
<link rel="import" href="gr-checks-change-list-item-cell-view.html">
<link rel="import" href="gr-checks-change-list-header-view.html">
<link rel="import" href="gr-checks-change-view-tab-header-view.html">
-<link rel="import" href="gr-checks-configure-link.html">
<dom-module id="gr-checks">
<script>
Gerrit.install(plugin => {
- plugin.registerDynamicCustomComponent(
- 'change-list-header',
- 'gr-checks-change-list-header-view');
- plugin.registerDynamicCustomComponent(
- 'change-list-item-cell',
- 'gr-checks-change-list-item-cell-view');
+
+ const getChecks = (change, revision) => {
+ return plugin.restApi().get(
+ '/changes/' + change + '/revisions/' + revision + '/checks?o=CHECKER');
+ };
+
+ // TODO(brohlfs): Enable this dashboard column when search queries start
+ // returning checks.
+ // plugin.registerDynamicCustomComponent(
+ // 'change-list-header',
+ // 'gr-checks-change-list-header-view');
+ // plugin.registerDynamicCustomComponent(
+ // 'change-list-item-cell',
+ // 'gr-checks-change-list-item-cell-view');
+ plugin.registerCustomComponent(
+ 'commit-container',
+ 'gr-checks-chip-view').onAttached(
+ view => {
+ view['getChecks'] = getChecks;
+ });
plugin.registerDynamicCustomComponent(
'change-view-tab-header',
'gr-checks-change-view-tab-header-view');
plugin.registerDynamicCustomComponent(
'change-view-tab-content',
'gr-checks-view').onAttached(
- view => console.log('gr-checks-view attached'));
+ view => {
+ view['isConfigured'] = (repository) => Promise.resolve(true);
+ // TODO(brohlfs): Implement retry.
+ view['retryCheck'] = (buildId) => undefined;
+ view['getChecks'] = getChecks;
+ });
});
</script>
</dom-module>