2016-03-04 17:48:22 -05:00
|
|
|
|
// Copyright (C) 2016 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.
|
|
|
|
|
(function() {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2017-07-11 14:50:51 -07:00
|
|
|
|
const ERR_REVIEW_STATUS = 'Couldn’t change file review status.';
|
2017-09-14 09:45:50 -07:00
|
|
|
|
const MSG_LOADING_BLAME = 'Loading blame...';
|
|
|
|
|
const MSG_LOADED_BLAME = 'Blame loaded';
|
2017-07-11 14:50:51 -07:00
|
|
|
|
|
2017-07-26 09:32:03 -07:00
|
|
|
|
const PARENT = 'PARENT';
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const DiffSides = {
|
2016-06-20 14:38:33 -07:00
|
|
|
|
LEFT: 'left',
|
|
|
|
|
RIGHT: 'right',
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-06 17:02:17 -08:00
|
|
|
|
const DiffViewMode = {
|
|
|
|
|
SIDE_BY_SIDE: 'SIDE_BY_SIDE',
|
|
|
|
|
UNIFIED: 'UNIFIED_DIFF',
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-04 17:48:22 -05:00
|
|
|
|
Polymer({
|
|
|
|
|
is: 'gr-diff-view',
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fired when the title of the page should change.
|
|
|
|
|
*
|
|
|
|
|
* @event title-change
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-06 14:50:53 -08:00
|
|
|
|
/**
|
|
|
|
|
* Fired when user tries to navigate away while comments are pending save.
|
|
|
|
|
*
|
|
|
|
|
* @event show-alert
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-04 17:48:22 -05:00
|
|
|
|
properties: {
|
|
|
|
|
/**
|
|
|
|
|
* URL params passed from the router.
|
|
|
|
|
*/
|
|
|
|
|
params: {
|
|
|
|
|
type: Object,
|
|
|
|
|
observer: '_paramsChanged',
|
|
|
|
|
},
|
|
|
|
|
keyEventTarget: {
|
|
|
|
|
type: Object,
|
2017-05-16 14:38:48 -07:00
|
|
|
|
value() { return document.body; },
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
2017-08-11 16:32:47 -07:00
|
|
|
|
/**
|
|
|
|
|
* @type {{ diffMode: (string|undefined) }}
|
|
|
|
|
*/
|
2016-03-04 17:48:22 -05:00
|
|
|
|
changeViewState: {
|
|
|
|
|
type: Object,
|
|
|
|
|
notify: true,
|
2017-05-16 14:38:48 -07:00
|
|
|
|
value() { return {}; },
|
2017-07-12 12:47:14 -07:00
|
|
|
|
observer: '_changeViewStateChanged',
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
2017-10-12 11:35:18 -07:00
|
|
|
|
/** @type {?} */
|
2016-03-04 17:48:22 -05:00
|
|
|
|
_patchRange: Object,
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
/** @type {?} */
|
|
|
|
|
_commitRange: Object,
|
2017-08-11 16:32:47 -07:00
|
|
|
|
/**
|
|
|
|
|
* @type {{
|
|
|
|
|
* subject: string,
|
|
|
|
|
* project: string,
|
|
|
|
|
* revisions: string,
|
|
|
|
|
* }}
|
|
|
|
|
*/
|
2016-03-04 17:48:22 -05:00
|
|
|
|
_change: Object,
|
2017-11-06 15:36:10 -08:00
|
|
|
|
/** @type {?} */
|
Update gr-comment-api
Previously, nested components (that are never standalone) were making
their own requests for comments, creating unecessary duplicate API
requests.
Some requests were made to the rest API directly (for example,
gr-change-view requested comments this way), and some were through the
gr-comment-api, which also helped handle comment manipulation and
reorganization.
Instead of ad-hoc comment requesting, move all comment requests to the
top level (standalone) component, and use an object prototype to
generate _changeComments as a property on gr-comment-api. This is an
immutable object that can be passed to the inner components
(file list, etc), and includes the methods needed to manipulate
comments into the forms
necessary.
When a child component needs to trigger a refresh of the comments, fire
an event that the parent event handles (see gr-file-list l.867).
Bug: Issue 6953
Change-Id: Ic4b6cf16520baae65d8cf956c311a60f2a70a2e1
2017-11-02 16:07:13 -07:00
|
|
|
|
_changeComments: Object,
|
2016-03-04 17:48:22 -05:00
|
|
|
|
_changeNum: String,
|
|
|
|
|
_diff: Object,
|
2017-11-07 15:49:55 -08:00
|
|
|
|
// An array specifically formatted to be used in a gr-dropdown-list
|
|
|
|
|
// element for selected a file to view.
|
|
|
|
|
_formattedFiles: {
|
|
|
|
|
type: Array,
|
2017-11-09 11:53:33 -08:00
|
|
|
|
computed: '_formatFilesForDropdown(_fileList, _patchRange.patchNum, ' +
|
|
|
|
|
'_changeComments)',
|
2017-11-07 15:49:55 -08:00
|
|
|
|
},
|
|
|
|
|
// An sorted array of files, as returned by the rest API.
|
2016-03-04 17:48:22 -05:00
|
|
|
|
_fileList: {
|
|
|
|
|
type: Array,
|
2017-05-16 14:38:48 -07:00
|
|
|
|
value() { return []; },
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
_path: {
|
|
|
|
|
type: String,
|
|
|
|
|
observer: '_pathChanged',
|
|
|
|
|
},
|
2018-01-30 16:17:13 -08:00
|
|
|
|
_fileNum: {
|
|
|
|
|
type: Number,
|
|
|
|
|
computed: '_computeFileNum(_path, _formattedFiles)',
|
|
|
|
|
},
|
2016-03-04 17:48:22 -05:00
|
|
|
|
_loggedIn: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
},
|
2016-04-23 23:18:43 -04:00
|
|
|
|
_loading: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
},
|
|
|
|
|
_prefs: Object,
|
2016-06-08 12:37:31 -07:00
|
|
|
|
_localPrefs: Object,
|
2016-05-29 18:12:56 +02:00
|
|
|
|
_projectConfig: Object,
|
2016-05-05 16:53:38 -07:00
|
|
|
|
_userPrefs: Object,
|
|
|
|
|
_diffMode: {
|
|
|
|
|
type: String,
|
2016-08-03 13:16:36 -07:00
|
|
|
|
computed: '_getDiffViewMode(changeViewState.diffMode, _userPrefs)',
|
2016-05-05 16:53:38 -07:00
|
|
|
|
},
|
2016-05-23 17:18:43 -07:00
|
|
|
|
_isImageDiff: Boolean,
|
2016-08-03 13:16:36 -07:00
|
|
|
|
_filesWeblinks: Object,
|
2017-01-18 17:10:51 -08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-02-06 14:50:53 -08:00
|
|
|
|
* Map of paths in the current change and patch range that have comments
|
2017-01-18 17:10:51 -08:00
|
|
|
|
* or drafts or robot comments.
|
|
|
|
|
*/
|
|
|
|
|
_commentMap: Object,
|
|
|
|
|
|
2017-07-26 09:32:03 -07:00
|
|
|
|
_commentsForDiff: Object,
|
|
|
|
|
|
2017-01-18 17:10:51 -08:00
|
|
|
|
/**
|
|
|
|
|
* Object to contain the path of the next and previous file in the current
|
|
|
|
|
* change and patch range that has comments.
|
|
|
|
|
*/
|
|
|
|
|
_commentSkips: {
|
|
|
|
|
type: Object,
|
|
|
|
|
computed: '_computeCommentSkips(_commentMap, _fileList, _path)',
|
|
|
|
|
},
|
2017-06-19 14:50:09 -07:00
|
|
|
|
_panelFloatingDisabled: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
value: () => { return window.PANEL_FLOATING_DISABLED; },
|
|
|
|
|
},
|
2018-01-23 17:15:38 -08:00
|
|
|
|
_editMode: {
|
2017-08-08 14:04:54 -07:00
|
|
|
|
type: Boolean,
|
2018-01-23 17:15:38 -08:00
|
|
|
|
computed: '_computeEditMode(_patchRange.*)',
|
2017-08-08 14:04:54 -07:00
|
|
|
|
},
|
2017-09-14 09:45:50 -07:00
|
|
|
|
_isBlameSupported: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
},
|
|
|
|
|
_isBlameLoaded: Boolean,
|
|
|
|
|
_isBlameLoading: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
value: false,
|
|
|
|
|
},
|
2017-09-26 09:59:33 -07:00
|
|
|
|
_allPatchSets: {
|
|
|
|
|
type: Array,
|
|
|
|
|
computed: 'computeAllPatchSets(_change, _change.revisions.*)',
|
|
|
|
|
},
|
2017-11-08 15:33:48 -08:00
|
|
|
|
_revisionInfo: {
|
|
|
|
|
type: Object,
|
|
|
|
|
computed: '_getRevisionInfo(_change)',
|
|
|
|
|
},
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
behaviors: [
|
|
|
|
|
Gerrit.KeyboardShortcutBehavior,
|
2017-07-21 14:07:48 -07:00
|
|
|
|
Gerrit.PatchSetBehavior,
|
2017-09-12 14:15:44 -07:00
|
|
|
|
Gerrit.PathListBehavior,
|
2016-10-21 11:01:08 -07:00
|
|
|
|
Gerrit.RESTClientBehavior,
|
2016-04-05 16:06:57 -04:00
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
observers: [
|
|
|
|
|
'_getProjectConfig(_change.project)',
|
2016-05-11 14:31:49 -04:00
|
|
|
|
'_getFiles(_changeNum, _patchRange.*)',
|
2018-02-07 11:37:22 -08:00
|
|
|
|
'_setReviewedObserver(_loggedIn, params.*, _prefs)',
|
2016-03-04 17:48:22 -05:00
|
|
|
|
],
|
|
|
|
|
|
2016-11-15 17:01:15 -08:00
|
|
|
|
keyBindings: {
|
|
|
|
|
'esc': '_handleEscKey',
|
|
|
|
|
'shift+left': '_handleShiftLeftKey',
|
|
|
|
|
'shift+right': '_handleShiftRightKey',
|
|
|
|
|
'up k': '_handleUpKey',
|
|
|
|
|
'down j': '_handleDownKey',
|
|
|
|
|
'c': '_handleCKey',
|
|
|
|
|
'[': '_handleLeftBracketKey',
|
|
|
|
|
']': '_handleRightBracketKey',
|
|
|
|
|
'n shift+n': '_handleNKey',
|
|
|
|
|
'p shift+p': '_handlePKey',
|
|
|
|
|
'a shift+a': '_handleAKey',
|
|
|
|
|
'u': '_handleUKey',
|
|
|
|
|
',': '_handleCommaKey',
|
2018-02-06 17:02:17 -08:00
|
|
|
|
'm': '_handleMKey',
|
2018-02-20 13:13:27 -08:00
|
|
|
|
'r': '_handleRKey',
|
2016-11-15 17:01:15 -08:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
attached() {
|
|
|
|
|
this._getLoggedIn().then(loggedIn => {
|
2016-03-29 14:06:39 -04:00
|
|
|
|
this._loggedIn = loggedIn;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-05-17 09:46:00 -07:00
|
|
|
|
|
2017-09-14 09:45:50 -07:00
|
|
|
|
this.$.restAPI.getConfig().then(config => {
|
|
|
|
|
this._isBlameSupported = config.change.allow_blame;
|
|
|
|
|
});
|
|
|
|
|
|
2016-05-17 09:46:00 -07:00
|
|
|
|
this.$.cursor.push('diffs', this.$.diff);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getLoggedIn() {
|
2016-03-29 14:06:39 -04:00
|
|
|
|
return this.$.restAPI.getLoggedIn();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getProjectConfig(project) {
|
2016-04-05 16:06:57 -04:00
|
|
|
|
return this.$.restAPI.getProjectConfig(project).then(
|
2017-05-16 14:38:48 -07:00
|
|
|
|
config => {
|
2016-04-05 16:06:57 -04:00
|
|
|
|
this._projectConfig = config;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-04-05 16:06:57 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getChangeDetail(changeNum) {
|
2017-07-24 15:06:07 -07:00
|
|
|
|
return this.$.restAPI.getDiffChangeDetail(changeNum).then(change => {
|
|
|
|
|
this._change = change;
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
return change;
|
2017-07-24 15:06:07 -07:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2017-04-25 23:48:05 +02:00
|
|
|
|
_getChangeEdit(changeNum) {
|
|
|
|
|
return this.$.restAPI.getChangeEdit(this._changeNum);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getFiles(changeNum, patchRangeRecord) {
|
|
|
|
|
const patchRange = patchRangeRecord.base;
|
2016-04-14 17:52:07 -04:00
|
|
|
|
return this.$.restAPI.getChangeFilePathsAsSpeciallySortedArray(
|
2017-05-16 14:38:48 -07:00
|
|
|
|
changeNum, patchRange).then(files => {
|
2016-04-14 17:52:07 -04:00
|
|
|
|
this._fileList = files;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-04-05 16:06:57 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getDiffPreferences() {
|
2016-05-03 18:11:00 -04:00
|
|
|
|
return this.$.restAPI.getDiffPreferences();
|
2016-04-23 23:18:43 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getPreferences() {
|
2016-05-05 16:53:38 -07:00
|
|
|
|
return this.$.restAPI.getPreferences();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getWindowWidth() {
|
2016-10-07 17:22:16 -07:00
|
|
|
|
return window.innerWidth;
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleReviewedChange(e) {
|
2016-03-04 17:48:22 -05:00
|
|
|
|
this._setReviewed(Polymer.dom(e).rootTarget.checked);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_setReviewed(reviewed) {
|
2018-01-23 17:15:38 -08:00
|
|
|
|
if (this._editMode) { return; }
|
2016-03-04 17:48:22 -05:00
|
|
|
|
this.$.reviewed.checked = reviewed;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
this._saveReviewedState(reviewed).catch(err => {
|
2017-07-11 14:50:51 -07:00
|
|
|
|
this.fire('show-alert', {message: ERR_REVIEW_STATUS});
|
2016-03-04 17:48:22 -05:00
|
|
|
|
throw err;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_saveReviewedState(reviewed) {
|
2016-04-05 16:06:57 -04:00
|
|
|
|
return this.$.restAPI.saveFileReviewed(this._changeNum,
|
|
|
|
|
this._patchRange.patchNum, this._path, reviewed);
|
|
|
|
|
},
|
|
|
|
|
|
2018-02-20 13:13:27 -08:00
|
|
|
|
_handleRKey(e) {
|
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
|
|
|
|
this.modifierPressed(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._setReviewed(!this.$.reviewed.checked);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleEscKey(e) {
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
|
|
|
|
this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.diff.displayLine = false;
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleShiftLeftKey(e) {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.cursor.moveLeft();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleShiftRightKey(e) {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.cursor.moveRight();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleUpKey(e) {
|
2017-01-18 17:10:51 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
if (e.detail.keyboardEvent.shiftKey &&
|
|
|
|
|
e.detail.keyboardEvent.keyCode === 75) { // 'K'
|
|
|
|
|
this._moveToPreviousFileWithComment();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.diff.displayLine = true;
|
|
|
|
|
this.$.cursor.moveUp();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleDownKey(e) {
|
2017-01-18 17:10:51 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
if (e.detail.keyboardEvent.shiftKey &&
|
|
|
|
|
e.detail.keyboardEvent.keyCode === 74) { // 'J'
|
|
|
|
|
this._moveToNextFileWithComment();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.diff.displayLine = true;
|
|
|
|
|
this.$.cursor.moveDown();
|
2016-09-27 15:57:56 -07:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_moveToPreviousFileWithComment() {
|
2018-01-10 15:18:32 -08:00
|
|
|
|
if (!this._commentSkips) { return; }
|
|
|
|
|
|
|
|
|
|
// If there is no previous diff with comments, then return to the change
|
|
|
|
|
// view.
|
|
|
|
|
if (!this._commentSkips.previous) {
|
|
|
|
|
this._navToChangeView();
|
|
|
|
|
return;
|
2017-01-18 17:10:51 -08:00
|
|
|
|
}
|
2018-01-10 15:18:32 -08:00
|
|
|
|
|
|
|
|
|
Gerrit.Nav.navigateToDiff(this._change, this._commentSkips.previous,
|
|
|
|
|
this._patchRange.patchNum, this._patchRange.basePatchNum);
|
2017-01-18 17:10:51 -08:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_moveToNextFileWithComment() {
|
2018-01-10 15:18:32 -08:00
|
|
|
|
if (!this._commentSkips) { return; }
|
|
|
|
|
|
|
|
|
|
// If there is no next diff with comments, then return to the change view.
|
|
|
|
|
if (!this._commentSkips.next) {
|
|
|
|
|
this._navToChangeView();
|
|
|
|
|
return;
|
2017-01-18 17:10:51 -08:00
|
|
|
|
}
|
2018-01-10 15:18:32 -08:00
|
|
|
|
|
|
|
|
|
Gerrit.Nav.navigateToDiff(this._change, this._commentSkips.next,
|
|
|
|
|
this._patchRange.patchNum, this._patchRange.basePatchNum);
|
2017-01-18 17:10:51 -08:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleCKey(e) {
|
2016-10-10 17:10:10 -07:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.$.diff.isRangeSelected()) { return; }
|
2016-11-28 15:16:21 -08:00
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
2016-11-15 17:01:15 -08:00
|
|
|
|
e.preventDefault();
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const line = this.$.cursor.getTargetLineElement();
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (line) {
|
|
|
|
|
this.$.diff.addDraftAtLine(line);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleLeftBracketKey(e) {
|
2017-05-24 13:49:02 -07:00
|
|
|
|
// Check for meta key to avoid overriding native chrome shortcut.
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
2017-05-24 13:49:02 -07:00
|
|
|
|
this.getKeyboardEvent(e).metaKey) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._navToFile(this._path, this._fileList, -1);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleRightBracketKey(e) {
|
2017-05-24 13:49:02 -07:00
|
|
|
|
// Check for meta key to avoid overriding native chrome shortcut.
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
2017-05-24 13:49:02 -07:00
|
|
|
|
this.getKeyboardEvent(e).metaKey) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._navToFile(this._path, this._fileList, 1);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleNKey(e) {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (e.detail.keyboardEvent.shiftKey) {
|
|
|
|
|
this.$.cursor.moveToNextCommentThread();
|
|
|
|
|
} else {
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
this.$.cursor.moveToNextChunk();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handlePKey(e) {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (e.detail.keyboardEvent.shiftKey) {
|
|
|
|
|
this.$.cursor.moveToPreviousCommentThread();
|
|
|
|
|
} else {
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
this.$.cursor.moveToPreviousChunk();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleAKey(e) {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
|
|
|
|
|
|
|
|
|
if (e.detail.keyboardEvent.shiftKey) { // Hide left diff.
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$.diff.toggleLeftDiff();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.modifierPressed(e)) { return; }
|
|
|
|
|
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (!this._loggedIn) { return; }
|
|
|
|
|
|
|
|
|
|
this.set('changeViewState.showReplyDialog', true);
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._navToChangeView();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleUKey(e) {
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
|
|
|
|
this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this._navToChangeView();
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleCommaKey(e) {
|
2016-12-07 18:02:34 -08:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
|
|
|
|
this.modifierPressed(e)) { return; }
|
2016-11-15 17:01:15 -08:00
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
2017-04-19 12:06:43 -07:00
|
|
|
|
this.$.diffPreferences.open();
|
2016-11-15 17:01:15 -08:00
|
|
|
|
},
|
|
|
|
|
|
2018-02-06 17:02:17 -08:00
|
|
|
|
_handleMKey(e) {
|
2018-01-13 20:55:22 -07:00
|
|
|
|
if (this.shouldSuppressKeyboardShortcut(e) ||
|
|
|
|
|
this.modifierPressed(e)) { return; }
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
2018-02-06 17:02:17 -08:00
|
|
|
|
if (this._getDiffViewMode() === DiffViewMode.SIDE_BY_SIDE) {
|
2018-02-14 15:58:17 -08:00
|
|
|
|
this.$.modeSelect.setMode(DiffViewMode.UNIFIED);
|
2018-01-13 20:55:22 -07:00
|
|
|
|
} else {
|
2018-02-14 15:58:17 -08:00
|
|
|
|
this.$.modeSelect.setMode(DiffViewMode.SIDE_BY_SIDE);
|
2018-01-13 20:55:22 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_navToChangeView() {
|
2016-11-15 17:01:15 -08:00
|
|
|
|
if (!this._changeNum || !this._patchRange.patchNum) { return; }
|
2017-07-05 21:26:33 -07:00
|
|
|
|
this._navigateToChange(
|
|
|
|
|
this._change,
|
2016-11-15 17:01:15 -08:00
|
|
|
|
this._patchRange,
|
2017-07-05 21:26:33 -07:00
|
|
|
|
this._change && this._change.revisions);
|
2017-03-29 16:33:29 +00:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_navToFile(path, fileList, direction) {
|
2017-07-05 21:26:33 -07:00
|
|
|
|
const newPath = this._getNavLinkPath(path, fileList, direction);
|
|
|
|
|
if (!newPath) { return; }
|
|
|
|
|
|
|
|
|
|
if (newPath.up) {
|
|
|
|
|
this._navigateToChange(
|
|
|
|
|
this._change,
|
|
|
|
|
this._patchRange,
|
|
|
|
|
this._change && this._change.revisions);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
2017-07-05 21:26:33 -07:00
|
|
|
|
Gerrit.Nav.navigateToDiff(this._change, newPath.path,
|
|
|
|
|
this._patchRange.patchNum, this._patchRange.basePatchNum);
|
2016-09-07 17:34:41 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {?string} path The path of the current file being shown.
|
2017-08-11 16:32:47 -07:00
|
|
|
|
* @param {!Array<string>} fileList The list of files in this change and
|
2016-09-07 17:34:41 -04:00
|
|
|
|
* patch range.
|
|
|
|
|
* @param {number} direction Either 1 (next file) or -1 (prev file).
|
|
|
|
|
* @param {(number|boolean)} opt_noUp Whether to return to the change view
|
|
|
|
|
* when advancing the file goes outside the bounds of fileList.
|
|
|
|
|
*
|
|
|
|
|
* @return {?string} The next URL when proceeding in the specified
|
|
|
|
|
* direction.
|
|
|
|
|
*/
|
2017-07-05 21:26:33 -07:00
|
|
|
|
_computeNavLinkURL(change, path, fileList, direction, opt_noUp) {
|
|
|
|
|
const newPath = this._getNavLinkPath(path, fileList, direction, opt_noUp);
|
|
|
|
|
if (!newPath) { return null; }
|
|
|
|
|
|
|
|
|
|
if (newPath.up) {
|
|
|
|
|
return this._getChangePath(
|
|
|
|
|
this._change,
|
|
|
|
|
this._patchRange,
|
|
|
|
|
this._change && this._change.revisions);
|
|
|
|
|
}
|
|
|
|
|
return this._getDiffUrl(this._change, this._patchRange, newPath.path);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gives an object representing the target of navigating either left or
|
|
|
|
|
* right through the change. The resulting object will have one of the
|
|
|
|
|
* following forms:
|
|
|
|
|
* * {path: "<target file path>"} - When another file path should be the
|
|
|
|
|
* result of the navigation.
|
|
|
|
|
* * {up: true} - When the result of navigating should go back to the
|
|
|
|
|
* change view.
|
|
|
|
|
* * null - When no navigation is possible for the given direction.
|
|
|
|
|
*
|
|
|
|
|
* @param {?string} path The path of the current file being shown.
|
2017-08-11 16:32:47 -07:00
|
|
|
|
* @param {!Array<string>} fileList The list of files in this change and
|
2017-07-05 21:26:33 -07:00
|
|
|
|
* patch range.
|
|
|
|
|
* @param {number} direction Either 1 (next file) or -1 (prev file).
|
2017-08-11 16:32:47 -07:00
|
|
|
|
* @param {?number|boolean=} opt_noUp Whether to return to the change view
|
2017-07-05 21:26:33 -07:00
|
|
|
|
* when advancing the file goes outside the bounds of fileList.
|
2017-08-11 16:32:47 -07:00
|
|
|
|
* @return {?Object}
|
2017-07-05 21:26:33 -07:00
|
|
|
|
*/
|
|
|
|
|
_getNavLinkPath(path, fileList, direction, opt_noUp) {
|
2016-09-07 17:34:41 -04:00
|
|
|
|
if (!path || fileList.length === 0) { return null; }
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
let idx = fileList.indexOf(path);
|
2017-01-06 15:31:32 -08:00
|
|
|
|
if (idx === -1) {
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const file = direction > 0 ?
|
|
|
|
|
fileList[0] :
|
|
|
|
|
fileList[fileList.length - 1];
|
2017-07-05 21:26:33 -07:00
|
|
|
|
return {path: file};
|
2017-01-06 15:31:32 -08:00
|
|
|
|
}
|
2016-09-07 17:34:41 -04:00
|
|
|
|
|
|
|
|
|
idx += direction;
|
|
|
|
|
// Redirect to the change view if opt_noUp isn’t truthy and idx falls
|
|
|
|
|
// outside the bounds of [0, fileList.length).
|
2016-03-04 17:48:22 -05:00
|
|
|
|
if (idx < 0 || idx > fileList.length - 1) {
|
2016-09-07 17:34:41 -04:00
|
|
|
|
if (opt_noUp) { return null; }
|
2017-07-05 21:26:33 -07:00
|
|
|
|
return {up: true};
|
2016-03-04 17:48:22 -05:00
|
|
|
|
}
|
2017-07-05 21:26:33 -07:00
|
|
|
|
|
|
|
|
|
return {path: fileList[idx]};
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_paramsChanged(value) {
|
2017-07-17 14:12:16 -07:00
|
|
|
|
if (value.view !== Gerrit.Nav.View.DIFF) { return; }
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
2018-01-19 17:54:50 -08:00
|
|
|
|
this.$.diff.lineOfInterest = this._getLineOfInterest(this.params);
|
2017-08-28 16:42:40 -07:00
|
|
|
|
this._initCursor(this.params);
|
2016-04-23 23:18:43 -04:00
|
|
|
|
|
2016-03-04 17:48:22 -05:00
|
|
|
|
this._changeNum = value.changeNum;
|
|
|
|
|
this._patchRange = {
|
|
|
|
|
patchNum: value.patchNum,
|
2017-07-26 09:32:03 -07:00
|
|
|
|
basePatchNum: value.basePatchNum || PARENT,
|
2016-03-04 17:48:22 -05:00
|
|
|
|
};
|
|
|
|
|
this._path = value.path;
|
|
|
|
|
|
2017-07-26 09:44:27 -07:00
|
|
|
|
// NOTE: This may be called before attachment (e.g. while parentElement is
|
|
|
|
|
// null). Fire title-change in an async so that, if attachment to the DOM
|
|
|
|
|
// has been queued, the event can bubble up to the handler in gr-app.
|
2017-07-25 13:25:43 -07:00
|
|
|
|
this.async(() => {
|
|
|
|
|
this.fire('title-change',
|
2017-09-12 14:15:44 -07:00
|
|
|
|
{title: this.computeTruncatedPath(this._path)});
|
2017-07-25 13:25:43 -07:00
|
|
|
|
});
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
|
|
|
|
// When navigating away from the page, there is a possibility that the
|
|
|
|
|
// patch number is no longer a part of the URL (say when navigating to
|
|
|
|
|
// the top-level change info view) and therefore undefined in `params`.
|
|
|
|
|
if (!this._patchRange.patchNum) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const promises = [];
|
2016-04-23 23:18:43 -04:00
|
|
|
|
|
2016-06-09 16:08:04 -07:00
|
|
|
|
this._localPrefs = this.$.storage.getPreferences();
|
2017-05-16 14:38:48 -07:00
|
|
|
|
promises.push(this._getDiffPreferences().then(prefs => {
|
2016-04-23 23:18:43 -04:00
|
|
|
|
this._prefs = prefs;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
}));
|
2016-04-23 23:18:43 -04:00
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
promises.push(this._getPreferences().then(prefs => {
|
2016-05-05 16:53:38 -07:00
|
|
|
|
this._userPrefs = prefs;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
}));
|
2016-05-05 16:53:38 -07:00
|
|
|
|
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
promises.push(this._getChangeDetail(this._changeNum).then(change => {
|
|
|
|
|
let commit;
|
|
|
|
|
let baseCommit;
|
2018-02-05 12:05:38 -08:00
|
|
|
|
for (const commitSha in change.revisions) {
|
|
|
|
|
if (!change.revisions.hasOwnProperty(commitSha)) continue;
|
|
|
|
|
const revision = change.revisions[commitSha];
|
|
|
|
|
const patchNum = revision._number.toString();
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
if (patchNum === this._patchRange.patchNum) {
|
2018-02-05 12:05:38 -08:00
|
|
|
|
commit = commitSha;
|
|
|
|
|
const commitObj = revision.commit || {};
|
|
|
|
|
const parents = commitObj.parents || [];
|
|
|
|
|
if (this._patchRange.basePatchNum === PARENT && parents.length) {
|
|
|
|
|
baseCommit = parents[parents.length - 1].commit;
|
|
|
|
|
}
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
} else if (patchNum === this._patchRange.basePatchNum) {
|
2018-02-05 12:05:38 -08:00
|
|
|
|
baseCommit = commitSha;
|
Weblinks API for embedded scenario using Gerrit.Nav interface
Gerrit.Nav.setup() now takes a weblinks generator function as a third
parameter. Here's the function signature:
``` js
Gerrit.Nav.setup(navigate, generateUrl, generateWeblinks)
```
Weblinks generator function takes single payload parameter with
`type` property that determines which part of the UI is the consumer of
the weblinks. `type` property can be one of `file`, `change`, or
`patchset`.
For `file` type, payload will also contain string properties:
`repo`, `commit`, `file`.
For `pachset` type, payload will also contain string properties:
`repo`, `commit`.
For `change` type, payload will also contain string properties:
`repo`, `commit`.
If server provides weblinks, those will be passed as `options.weblinks`
property on the main payload object.
Change-Id: I0d9de3a295435304e2b6aad551112440075cf098
2017-11-10 16:03:13 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this._commitRange = {commit, baseCommit};
|
|
|
|
|
}));
|
2016-04-23 23:18:43 -04:00
|
|
|
|
|
2017-07-26 09:32:03 -07:00
|
|
|
|
promises.push(this._loadComments());
|
|
|
|
|
|
2017-04-25 23:48:05 +02:00
|
|
|
|
promises.push(this._getChangeEdit(this._changeNum));
|
|
|
|
|
|
2017-10-09 11:36:19 -07:00
|
|
|
|
this._loading = true;
|
2017-04-25 23:48:05 +02:00
|
|
|
|
Promise.all(promises).then(r => {
|
|
|
|
|
const edit = r[4];
|
|
|
|
|
if (edit) {
|
|
|
|
|
this.set('_change.revisions.' + edit.commit.commit, {
|
|
|
|
|
_number: this.EDIT_NAME,
|
|
|
|
|
basePatchNum: edit.base_patch_set_number,
|
|
|
|
|
commit: edit.commit,
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-02-10 15:12:52 -08:00
|
|
|
|
this._loading = false;
|
2017-07-26 09:32:03 -07:00
|
|
|
|
this.$.diff.comments = this._commentsForDiff;
|
2017-02-10 15:12:52 -08:00
|
|
|
|
this.$.diff.reload();
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-07-12 12:47:14 -07:00
|
|
|
|
_changeViewStateChanged(changeViewState) {
|
2017-06-26 15:13:03 -07:00
|
|
|
|
if (changeViewState.diffMode === null) {
|
|
|
|
|
// If screen size is small, always default to unified view.
|
|
|
|
|
this.$.restAPI.getPreferences().then(prefs => {
|
|
|
|
|
this.set('changeViewState.diffMode', prefs.default_diff_view);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2018-02-07 11:37:22 -08:00
|
|
|
|
_setReviewedObserver(_loggedIn, paramsRecord, _prefs) {
|
2018-01-23 10:33:44 -08:00
|
|
|
|
const params = paramsRecord.base || {};
|
2018-02-07 11:37:22 -08:00
|
|
|
|
if (!_loggedIn || _prefs.manual_review) { return; }
|
|
|
|
|
|
|
|
|
|
if (params.view === Gerrit.Nav.View.DIFF) {
|
2017-06-26 15:13:03 -07:00
|
|
|
|
this._setReviewed(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2016-06-20 14:38:33 -07:00
|
|
|
|
/**
|
2017-08-28 16:42:40 -07:00
|
|
|
|
* If the params specify a diff address then configure the diff cursor.
|
2016-06-20 14:38:33 -07:00
|
|
|
|
*/
|
2017-08-28 16:42:40 -07:00
|
|
|
|
_initCursor(params) {
|
|
|
|
|
if (params.lineNum === undefined) { return; }
|
|
|
|
|
if (params.leftSide) {
|
2016-06-20 14:38:33 -07:00
|
|
|
|
this.$.cursor.side = DiffSides.LEFT;
|
|
|
|
|
} else {
|
|
|
|
|
this.$.cursor.side = DiffSides.RIGHT;
|
|
|
|
|
}
|
2017-08-28 16:42:40 -07:00
|
|
|
|
this.$.cursor.initialLineNumber = params.lineNum;
|
2016-06-20 14:38:33 -07:00
|
|
|
|
},
|
|
|
|
|
|
2018-01-19 17:54:50 -08:00
|
|
|
|
_getLineOfInterest(params) {
|
|
|
|
|
// If there is a line number specified, pass it along to the diff so that
|
|
|
|
|
// it will not get collapsed.
|
|
|
|
|
if (!params.lineNum) { return null; }
|
|
|
|
|
return {number: params.lineNum, leftSide: params.leftSide};
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_pathChanged(path) {
|
2017-06-26 15:13:03 -07:00
|
|
|
|
if (path) {
|
|
|
|
|
this.fire('title-change',
|
2017-09-12 14:15:44 -07:00
|
|
|
|
{title: this.computeTruncatedPath(path)});
|
2017-06-26 15:13:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 17:48:22 -05:00
|
|
|
|
if (this._fileList.length == 0) { return; }
|
|
|
|
|
|
|
|
|
|
this.set('changeViewState.selectedFileIndex',
|
|
|
|
|
this._fileList.indexOf(path));
|
|
|
|
|
},
|
|
|
|
|
|
2017-07-05 21:26:33 -07:00
|
|
|
|
_getDiffUrl(change, patchRange, path) {
|
|
|
|
|
return Gerrit.Nav.getUrlForDiff(change, path, patchRange.patchNum,
|
|
|
|
|
patchRange.basePatchNum);
|
2016-05-11 14:31:49 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_patchRangeStr(patchRange) {
|
|
|
|
|
let patchStr = patchRange.patchNum;
|
2016-03-04 17:48:22 -05:00
|
|
|
|
if (patchRange.basePatchNum != null &&
|
2017-07-26 09:32:03 -07:00
|
|
|
|
patchRange.basePatchNum != PARENT) {
|
2016-03-04 17:48:22 -05:00
|
|
|
|
patchStr = patchRange.basePatchNum + '..' + patchRange.patchNum;
|
|
|
|
|
}
|
2016-05-11 14:31:49 -04:00
|
|
|
|
return patchStr;
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-07-05 21:26:33 -07:00
|
|
|
|
/**
|
|
|
|
|
* When the latest patch of the change is selected (and there is no base
|
|
|
|
|
* patch) then the patch range need not appear in the URL. Return a patch
|
|
|
|
|
* range object with undefined values when a range is not needed.
|
2017-08-11 16:32:47 -07:00
|
|
|
|
*
|
|
|
|
|
* @param {!Object} patchRange
|
|
|
|
|
* @param {!Object} revisions
|
|
|
|
|
* @return {!Object}
|
2017-07-05 21:26:33 -07:00
|
|
|
|
*/
|
|
|
|
|
_getChangeUrlRange(patchRange, revisions) {
|
|
|
|
|
let patchNum = undefined;
|
|
|
|
|
let basePatchNum = undefined;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
let latestPatchNum = -1;
|
2017-07-05 21:26:33 -07:00
|
|
|
|
for (const rev of Object.values(revisions || {})) {
|
2017-05-16 14:38:48 -07:00
|
|
|
|
latestPatchNum = Math.max(latestPatchNum, rev._number);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
}
|
2017-07-26 09:32:03 -07:00
|
|
|
|
if (patchRange.basePatchNum !== PARENT ||
|
2016-05-11 14:31:49 -04:00
|
|
|
|
parseInt(patchRange.patchNum, 10) !== latestPatchNum) {
|
2017-07-05 21:26:33 -07:00
|
|
|
|
patchNum = patchRange.patchNum;
|
|
|
|
|
basePatchNum = patchRange.basePatchNum;
|
2016-03-04 17:48:22 -05:00
|
|
|
|
}
|
2017-07-05 21:26:33 -07:00
|
|
|
|
return {patchNum, basePatchNum};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getChangePath(change, patchRange, revisions) {
|
|
|
|
|
const range = this._getChangeUrlRange(patchRange, revisions);
|
|
|
|
|
return Gerrit.Nav.getUrlForChange(change, range.patchNum,
|
|
|
|
|
range.basePatchNum);
|
|
|
|
|
},
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
2017-07-05 21:26:33 -07:00
|
|
|
|
_navigateToChange(change, patchRange, revisions) {
|
|
|
|
|
const range = this._getChangeUrlRange(patchRange, revisions);
|
|
|
|
|
Gerrit.Nav.navigateToChange(change, range.patchNum, range.basePatchNum);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-07-05 21:26:33 -07:00
|
|
|
|
_computeChangePath(change, patchRangeRecord, revisions) {
|
|
|
|
|
return this._getChangePath(change, patchRangeRecord.base, revisions);
|
2016-05-11 14:31:49 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-11-09 11:53:33 -08:00
|
|
|
|
_formatFilesForDropdown(fileList, patchNum, changeComments) {
|
2017-11-07 15:49:55 -08:00
|
|
|
|
if (!fileList) { return; }
|
|
|
|
|
const dropdownContent = [];
|
|
|
|
|
for (const path of fileList) {
|
|
|
|
|
dropdownContent.push({
|
|
|
|
|
text: this.computeDisplayPath(path),
|
|
|
|
|
mobileText: this.computeTruncatedPath(path),
|
2017-11-13 16:23:08 -08:00
|
|
|
|
value: path,
|
2017-11-09 11:53:33 -08:00
|
|
|
|
bottomText: this._computeCommentString(changeComments, patchNum,
|
|
|
|
|
path),
|
2017-11-07 15:49:55 -08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return dropdownContent;
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-11-09 11:53:33 -08:00
|
|
|
|
_computeCommentString(changeComments, patchNum, path) {
|
|
|
|
|
const unresolvedCount = changeComments.computeUnresolvedNum(patchNum,
|
|
|
|
|
path);
|
|
|
|
|
const commentCount = changeComments.computeCommentCount(patchNum, path);
|
|
|
|
|
const commentString = GrCountStringFormatter.computePluralString(
|
|
|
|
|
commentCount, 'comment');
|
|
|
|
|
const unresolvedString = GrCountStringFormatter.computeString(
|
|
|
|
|
unresolvedCount, 'unresolved');
|
|
|
|
|
|
|
|
|
|
return commentString +
|
|
|
|
|
// Add a space if both comments and unresolved
|
|
|
|
|
(commentString && unresolvedString ? ', ' : '') +
|
|
|
|
|
// Add parentheses around unresolved if it exists.
|
|
|
|
|
(unresolvedString ? `${unresolvedString}` : '');
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_computePrefsButtonHidden(prefs, loggedIn) {
|
2016-04-23 23:18:43 -04:00
|
|
|
|
return !loggedIn || !prefs;
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-07 15:49:55 -08:00
|
|
|
|
_handleFileChange(e) {
|
|
|
|
|
// This is when it gets set initially.
|
|
|
|
|
const path = e.detail.value;
|
|
|
|
|
if (path === this._path) {
|
|
|
|
|
return;
|
2016-03-04 17:48:22 -05:00
|
|
|
|
}
|
2017-11-07 15:49:55 -08:00
|
|
|
|
|
|
|
|
|
Gerrit.Nav.navigateToDiff(this._change, path, this._patchRange.patchNum,
|
|
|
|
|
this._patchRange.basePatchNum);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handleFileTap(e) {
|
2017-04-06 14:24:48 -07:00
|
|
|
|
// async is needed so that that the click event is fired before the
|
|
|
|
|
// dropdown closes (This was a bug for touch devices).
|
2017-05-16 14:38:48 -07:00
|
|
|
|
this.async(() => {
|
2017-04-06 14:24:48 -07:00
|
|
|
|
this.$.dropdown.close();
|
|
|
|
|
}, 1);
|
2016-03-04 17:48:22 -05:00
|
|
|
|
},
|
|
|
|
|
|
2017-10-12 11:35:18 -07:00
|
|
|
|
_handlePatchChange(e) {
|
|
|
|
|
const {basePatchNum, patchNum} = e.detail;
|
|
|
|
|
if (this.patchNumEquals(basePatchNum, this._patchRange.basePatchNum) &&
|
|
|
|
|
this.patchNumEquals(patchNum, this._patchRange.patchNum)) { return; }
|
2017-09-12 16:54:19 -07:00
|
|
|
|
Gerrit.Nav.navigateToDiff(
|
2017-09-26 09:59:33 -07:00
|
|
|
|
this._change, this._path, patchNum, basePatchNum);
|
2017-09-12 16:54:19 -07:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handlePrefsTap(e) {
|
2016-04-23 23:18:43 -04:00
|
|
|
|
e.preventDefault();
|
2017-04-19 12:06:43 -07:00
|
|
|
|
this.$.diffPreferences.open();
|
2016-04-23 23:18:43 -04:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_handlePrefsSave(e) {
|
2016-04-23 23:18:43 -04:00
|
|
|
|
e.stopPropagation();
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const el = Polymer.dom(e).rootTarget;
|
2016-04-23 23:18:43 -04:00
|
|
|
|
el.disabled = true;
|
2016-06-08 12:37:31 -07:00
|
|
|
|
this.$.storage.savePreferences(this._localPrefs);
|
2017-05-16 14:38:48 -07:00
|
|
|
|
this._saveDiffPreferences().then(response => {
|
2016-04-23 23:18:43 -04:00
|
|
|
|
el.disabled = false;
|
2016-05-02 15:59:59 -04:00
|
|
|
|
if (!response.ok) { return response; }
|
|
|
|
|
|
2016-04-23 23:18:43 -04:00
|
|
|
|
this.$.prefsOverlay.close();
|
2017-05-16 14:38:48 -07:00
|
|
|
|
}).catch(err => {
|
2016-05-02 15:59:59 -04:00
|
|
|
|
el.disabled = false;
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2016-04-23 23:18:43 -04:00
|
|
|
|
},
|
|
|
|
|
|
2016-05-05 16:53:38 -07:00
|
|
|
|
/**
|
|
|
|
|
* _getDiffViewMode: Get the diff view (side-by-side or unified) based on
|
|
|
|
|
* the current state.
|
|
|
|
|
*
|
|
|
|
|
* The expected behavior is to use the mode specified in the user's
|
2016-12-09 16:58:31 -08:00
|
|
|
|
* preferences unless they have manually chosen the alternative view or they
|
|
|
|
|
* are on a mobile device. If the user navigates up to the change view, it
|
|
|
|
|
* should clear this choice and revert to the preference the next time a
|
|
|
|
|
* diff is viewed.
|
2016-05-05 16:53:38 -07:00
|
|
|
|
*
|
|
|
|
|
* Use side-by-side if the user is not logged in.
|
|
|
|
|
*
|
2017-08-11 16:32:47 -07:00
|
|
|
|
* @return {string}
|
2016-05-05 16:53:38 -07:00
|
|
|
|
*/
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getDiffViewMode() {
|
2016-05-05 16:53:38 -07:00
|
|
|
|
if (this.changeViewState.diffMode) {
|
|
|
|
|
return this.changeViewState.diffMode;
|
2016-12-09 16:58:31 -08:00
|
|
|
|
} else if (this._userPrefs) {
|
2018-02-14 15:58:17 -08:00
|
|
|
|
this.set('changeViewState.diffMode', this._userPrefs.default_diff_view);
|
|
|
|
|
return this._userPrefs.default_diff_view;
|
2016-12-09 16:58:31 -08:00
|
|
|
|
} else {
|
|
|
|
|
return 'SIDE_BY_SIDE';
|
2016-05-05 16:53:38 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2018-02-14 15:58:17 -08:00
|
|
|
|
_computeModeSelectHideClass(isImageDiff) {
|
|
|
|
|
return isImageDiff ? 'hide' : '';
|
2016-05-23 17:18:43 -07:00
|
|
|
|
},
|
2016-06-20 14:02:42 -07:00
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_onLineSelected(e, detail) {
|
2016-06-20 14:02:42 -07:00
|
|
|
|
this.$.cursor.moveToLineNumber(detail.number, detail.side);
|
2017-08-22 13:37:13 -07:00
|
|
|
|
if (!this._change) { return; }
|
|
|
|
|
const cursorAddress = this.$.cursor.getAddress();
|
2017-09-15 11:55:35 -07:00
|
|
|
|
const number = cursorAddress ? cursorAddress.number : undefined;
|
|
|
|
|
const leftSide = cursorAddress ? cursorAddress.leftSide : undefined;
|
2017-08-22 13:37:13 -07:00
|
|
|
|
const url = Gerrit.Nav.getUrlForDiffById(this._changeNum,
|
|
|
|
|
this._change.project, this._path, this._patchRange.patchNum,
|
2017-09-15 11:55:35 -07:00
|
|
|
|
this._patchRange.basePatchNum, number, leftSide);
|
2017-08-22 13:37:13 -07:00
|
|
|
|
history.replaceState(null, '', url);
|
2016-06-20 14:02:42 -07:00
|
|
|
|
},
|
2016-08-30 12:44:27 -07:00
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_computeDownloadLink(changeNum, patchRange, path) {
|
|
|
|
|
let url = this.changeBaseURL(changeNum, patchRange.patchNum);
|
2016-10-21 11:01:08 -07:00
|
|
|
|
url += '/patch?zip&path=' + encodeURIComponent(path);
|
|
|
|
|
return url;
|
|
|
|
|
},
|
2017-01-18 17:10:51 -08:00
|
|
|
|
|
2017-07-26 09:32:03 -07:00
|
|
|
|
_loadComments() {
|
2017-11-08 12:02:04 -08:00
|
|
|
|
return this.$.commentAPI.loadAll(this._changeNum).then(comments => {
|
|
|
|
|
this._changeComments = comments;
|
Update gr-comment-api
Previously, nested components (that are never standalone) were making
their own requests for comments, creating unecessary duplicate API
requests.
Some requests were made to the rest API directly (for example,
gr-change-view requested comments this way), and some were through the
gr-comment-api, which also helped handle comment manipulation and
reorganization.
Instead of ad-hoc comment requesting, move all comment requests to the
top level (standalone) component, and use an object prototype to
generate _changeComments as a property on gr-comment-api. This is an
immutable object that can be passed to the inner components
(file list, etc), and includes the methods needed to manipulate
comments into the forms
necessary.
When a child component needs to trigger a refresh of the comments, fire
an event that the parent event handles (see gr-file-list l.867).
Bug: Issue 6953
Change-Id: Ic4b6cf16520baae65d8cf956c311a60f2a70a2e1
2017-11-02 16:07:13 -07:00
|
|
|
|
this._commentMap = this._getPaths(this._patchRange);
|
2017-07-26 09:32:03 -07:00
|
|
|
|
|
Update gr-comment-api
Previously, nested components (that are never standalone) were making
their own requests for comments, creating unecessary duplicate API
requests.
Some requests were made to the rest API directly (for example,
gr-change-view requested comments this way), and some were through the
gr-comment-api, which also helped handle comment manipulation and
reorganization.
Instead of ad-hoc comment requesting, move all comment requests to the
top level (standalone) component, and use an object prototype to
generate _changeComments as a property on gr-comment-api. This is an
immutable object that can be passed to the inner components
(file list, etc), and includes the methods needed to manipulate
comments into the forms
necessary.
When a child component needs to trigger a refresh of the comments, fire
an event that the parent event handles (see gr-file-list l.867).
Bug: Issue 6953
Change-Id: Ic4b6cf16520baae65d8cf956c311a60f2a70a2e1
2017-11-02 16:07:13 -07:00
|
|
|
|
this._commentsForDiff = this._getCommentsForPath(this._path,
|
2017-07-26 09:32:03 -07:00
|
|
|
|
this._patchRange, this._projectConfig);
|
2017-05-16 14:38:48 -07:00
|
|
|
|
});
|
2017-01-18 17:10:51 -08:00
|
|
|
|
},
|
|
|
|
|
|
Update gr-comment-api
Previously, nested components (that are never standalone) were making
their own requests for comments, creating unecessary duplicate API
requests.
Some requests were made to the rest API directly (for example,
gr-change-view requested comments this way), and some were through the
gr-comment-api, which also helped handle comment manipulation and
reorganization.
Instead of ad-hoc comment requesting, move all comment requests to the
top level (standalone) component, and use an object prototype to
generate _changeComments as a property on gr-comment-api. This is an
immutable object that can be passed to the inner components
(file list, etc), and includes the methods needed to manipulate
comments into the forms
necessary.
When a child component needs to trigger a refresh of the comments, fire
an event that the parent event handles (see gr-file-list l.867).
Bug: Issue 6953
Change-Id: Ic4b6cf16520baae65d8cf956c311a60f2a70a2e1
2017-11-02 16:07:13 -07:00
|
|
|
|
_getPaths(patchRange) {
|
|
|
|
|
return this._changeComments.getPaths(patchRange);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getCommentsForPath(path, patchRange, projectConfig) {
|
2017-11-09 13:21:11 -08:00
|
|
|
|
return this._changeComments.getCommentsBySideForPath(path, patchRange,
|
Update gr-comment-api
Previously, nested components (that are never standalone) were making
their own requests for comments, creating unecessary duplicate API
requests.
Some requests were made to the rest API directly (for example,
gr-change-view requested comments this way), and some were through the
gr-comment-api, which also helped handle comment manipulation and
reorganization.
Instead of ad-hoc comment requesting, move all comment requests to the
top level (standalone) component, and use an object prototype to
generate _changeComments as a property on gr-comment-api. This is an
immutable object that can be passed to the inner components
(file list, etc), and includes the methods needed to manipulate
comments into the forms
necessary.
When a child component needs to trigger a refresh of the comments, fire
an event that the parent event handles (see gr-file-list l.867).
Bug: Issue 6953
Change-Id: Ic4b6cf16520baae65d8cf956c311a60f2a70a2e1
2017-11-02 16:07:13 -07:00
|
|
|
|
projectConfig);
|
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_getDiffDrafts() {
|
2017-07-31 18:43:21 -07:00
|
|
|
|
return this.$.restAPI.getDiffDrafts(this._changeNum);
|
2017-01-18 17:10:51 -08:00
|
|
|
|
},
|
|
|
|
|
|
2017-05-16 14:38:48 -07:00
|
|
|
|
_computeCommentSkips(commentMap, fileList, path) {
|
|
|
|
|
const skips = {previous: null, next: null};
|
2017-01-18 17:10:51 -08:00
|
|
|
|
if (!fileList.length) { return skips; }
|
2017-05-16 14:38:48 -07:00
|
|
|
|
const pathIndex = fileList.indexOf(path);
|
2017-01-18 17:10:51 -08:00
|
|
|
|
|
|
|
|
|
// Scan backward for the previous file.
|
2017-05-16 14:38:48 -07:00
|
|
|
|
for (let i = pathIndex - 1; i >= 0; i--) {
|
2017-01-18 17:10:51 -08:00
|
|
|
|
if (commentMap[fileList[i]]) {
|
|
|
|
|
skips.previous = fileList[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scan forward for the next file.
|
2017-05-16 14:38:48 -07:00
|
|
|
|
for (let i = pathIndex + 1; i < fileList.length; i++) {
|
2017-01-18 17:10:51 -08:00
|
|
|
|
if (commentMap[fileList[i]]) {
|
|
|
|
|
skips.next = fileList[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return skips;
|
|
|
|
|
},
|
2017-06-19 14:50:09 -07:00
|
|
|
|
|
|
|
|
|
_computeDiffClass(panelFloatingDisabled) {
|
|
|
|
|
if (panelFloatingDisabled) {
|
|
|
|
|
return 'noOverflow';
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-08-08 14:04:54 -07:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {!Object} patchRangeRecord
|
|
|
|
|
*/
|
2018-01-23 17:15:38 -08:00
|
|
|
|
_computeEditMode(patchRangeRecord) {
|
2017-08-08 14:04:54 -07:00
|
|
|
|
const patchRange = patchRangeRecord.base || {};
|
|
|
|
|
return this.patchNumEquals(patchRange.patchNum, this.EDIT_NAME);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-23 17:15:38 -08:00
|
|
|
|
* @param {boolean} editMode
|
2017-08-08 14:04:54 -07:00
|
|
|
|
*/
|
2018-01-23 17:15:38 -08:00
|
|
|
|
_computeContainerClass(editMode) {
|
|
|
|
|
return editMode ? 'editMode' : '';
|
2017-08-08 14:04:54 -07:00
|
|
|
|
},
|
2017-09-14 09:45:50 -07:00
|
|
|
|
|
|
|
|
|
_computeBlameToggleLabel(loaded, loading) {
|
|
|
|
|
if (loaded) { return 'Hide blame'; }
|
|
|
|
|
return 'Show blame';
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load and display blame information if it has not already been loaded.
|
|
|
|
|
* Otherwise hide it.
|
|
|
|
|
*/
|
|
|
|
|
_toggleBlame() {
|
|
|
|
|
if (this._isBlameLoaded) {
|
|
|
|
|
this.$.diff.clearBlame();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._isBlameLoading = true;
|
|
|
|
|
this.fire('show-alert', {message: MSG_LOADING_BLAME});
|
|
|
|
|
this.$.diff.loadBlame()
|
|
|
|
|
.then(() => {
|
|
|
|
|
this._isBlameLoading = false;
|
|
|
|
|
this.fire('show-alert', {message: MSG_LOADED_BLAME});
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
this._isBlameLoading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_computeBlameLoaderClass(isImageDiff, supported) {
|
|
|
|
|
return !isImageDiff && supported ? 'show' : '';
|
|
|
|
|
},
|
2017-11-08 15:33:48 -08:00
|
|
|
|
|
|
|
|
|
_getRevisionInfo(change) {
|
|
|
|
|
return new Gerrit.RevisionInfo(change);
|
|
|
|
|
},
|
2018-01-30 16:17:13 -08:00
|
|
|
|
|
|
|
|
|
_computeFileNum(file, files) {
|
|
|
|
|
return files.findIndex(({value}) => value === file) + 1;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_computeFileNumVisible(file, files) {
|
|
|
|
|
if (!files) { return 'hidden'; }
|
|
|
|
|
const fileNum = this._computeFileNum(file, files);
|
|
|
|
|
if (!isNaN(fileNum) && isFinite(fileNum) && fileNum > 0) {
|
|
|
|
|
return '';
|
|
|
|
|
} else {
|
|
|
|
|
return 'hidden';
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-03-04 17:48:22 -05:00
|
|
|
|
});
|
|
|
|
|
})();
|