Update eslint version and eslint rules
Legacy indent rules doesn't handle all cases. As a result there are different indents in .js files. This commit update eslint rules and add autofix for incorrect indents. It is expected that fix should be run after converting to class-based elements. Change-Id: I9d37a3d4319e2af71ddb93100a6791b8ddb7de79
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
"description": "Gerrit Code Review",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.16.0",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-config-google": "^0.13.0",
|
||||
"eslint-plugin-html": "^5.0.5",
|
||||
"eslint-plugin-html": "^6.0.0",
|
||||
"fried-twinkie": "^0.2.2",
|
||||
"polylint": "^2.10.4",
|
||||
"typescript": "^2.x.x",
|
||||
@@ -16,6 +16,7 @@
|
||||
"start": "polygerrit-ui/run-server.sh",
|
||||
"test": "WCT_HEADLESS_MODE=1 WCT_ARGS='--verbose -l chrome' ./polygerrit-ui/app/run_test.sh",
|
||||
"eslint": "./node_modules/eslint/bin/eslint.js --ignore-pattern 'bower_components/' --ignore-pattern 'gr-linked-text' --ignore-pattern 'scripts/vendor' --ext .html,.js polygerrit-ui/app || exit 0",
|
||||
"eslintfix": "./node_modules/eslint/bin/eslint.js --fix --ignore-pattern 'bower_components/' --ignore-pattern 'gr-linked-text' --ignore-pattern 'scripts/vendor' --ext .html,.js polygerrit-ui/app || exit 0",
|
||||
"test-template": "./polygerrit-ui/app/run_template_test.sh",
|
||||
"polylint": "bazel test polygerrit-ui/app:polylint_test"
|
||||
},
|
||||
|
||||
@@ -25,27 +25,35 @@
|
||||
"block-spacing": ["error", "always"],
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||
"camelcase": "off",
|
||||
"comma-dangle": ["error", "always-multiline"],
|
||||
"comma-dangle": ["error", {
|
||||
"arrays": "always-multiline",
|
||||
"objects": "always-multiline",
|
||||
"imports": "always-multiline",
|
||||
"exports": "always-multiline",
|
||||
"functions": "never"
|
||||
}],
|
||||
"eol-last": "off",
|
||||
"indent": "off",
|
||||
"indent-legacy": ["error", 2, {
|
||||
"indent": ["error", 2, {
|
||||
"MemberExpression": 2,
|
||||
"FunctionDeclaration": {"body": 1, "parameters": 2},
|
||||
"FunctionExpression": {"body": 1, "parameters": 2},
|
||||
"CallExpression": {"arguments": 2},
|
||||
"CallExpression": {"arguments": 2 },
|
||||
"ArrayExpression": 1,
|
||||
"ObjectExpression": 1,
|
||||
"SwitchCase": 1
|
||||
}],
|
||||
"keyword-spacing": ["error", { "after": true, "before": true }],
|
||||
"lines-between-class-members": ["error", "always"],
|
||||
"max-len": [
|
||||
"error",
|
||||
80,
|
||||
2,
|
||||
{"ignoreComments": true}
|
||||
],
|
||||
"new-cap": ["error", { "capIsNewExceptions": ["Polymer"] }],
|
||||
"new-cap": ["error", { "capIsNewExceptions": ["Polymer", "LegacyElementMixin", "GestureEventListeners", "LegacyDataMixin"] }],
|
||||
"no-console": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"no-redeclare": "off",
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
{
|
||||
@@ -61,6 +69,19 @@
|
||||
"no-useless-escape": "off",
|
||||
"no-var": "error",
|
||||
"object-shorthand": ["error", "always"],
|
||||
"padding-line-between-statements": [
|
||||
"error",
|
||||
{
|
||||
"blankLine": "always",
|
||||
"prev": "class",
|
||||
"next": "*"
|
||||
},
|
||||
{
|
||||
"blankLine": "always",
|
||||
"prev": "*",
|
||||
"next": "class"
|
||||
}
|
||||
],
|
||||
"prefer-arrow-callback": "error",
|
||||
"prefer-const": "error",
|
||||
"prefer-spread": "error",
|
||||
|
||||
@@ -56,7 +56,7 @@ limitations under the License.
|
||||
cachedPromise = undefined;
|
||||
},
|
||||
},
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.BaseUrlBehavior,
|
||||
];
|
||||
})(window);
|
||||
</script>
|
||||
|
||||
@@ -56,8 +56,8 @@ limitations under the License.
|
||||
return 0;
|
||||
},
|
||||
},
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.URLEncodingBehavior,
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.URLEncodingBehavior,
|
||||
];
|
||||
})(window);
|
||||
</script>
|
||||
|
||||
@@ -124,8 +124,8 @@ limitations under the License.
|
||||
// 2 -> 3, 3 -> 5, etc.
|
||||
// Map an edit to the patchNum of parent*2... I.e. edit on 2 -> 4.
|
||||
const num = r => r._number === Gerrit.PatchSetBehavior.EDIT_NAME ?
|
||||
2 * editParent :
|
||||
2 * (r._number - 1) + 1;
|
||||
2 * editParent :
|
||||
2 * (r._number - 1) + 1;
|
||||
return revisions.sort((a, b) => num(b) - num(a));
|
||||
},
|
||||
|
||||
|
||||
@@ -240,8 +240,8 @@ limitations under the License.
|
||||
|
||||
test('directory view', () => {
|
||||
const {
|
||||
NEXT_FILE, NEXT_LINE, GO_TO_OPENED_CHANGES, SEARCH,
|
||||
SAVE_COMMENT,
|
||||
NEXT_FILE, NEXT_LINE, GO_TO_OPENED_CHANGES, SEARCH,
|
||||
SAVE_COMMENT,
|
||||
} = kb.Shortcut;
|
||||
const {DIFFS, EVERYWHERE, NAVIGATION} = kb.ShortcutSection;
|
||||
const {GO_KEY, ShortcutManager} = kb;
|
||||
|
||||
@@ -175,7 +175,7 @@ limitations under the License.
|
||||
return this.changeStatuses(change).join(', ');
|
||||
},
|
||||
},
|
||||
Gerrit.BaseUrlBehavior,
|
||||
Gerrit.BaseUrlBehavior,
|
||||
];
|
||||
})(window);
|
||||
</script>
|
||||
|
||||
@@ -224,8 +224,8 @@
|
||||
|
||||
editRefInput() {
|
||||
return Polymer.dom(this.root).querySelector(Polymer.Element ?
|
||||
'iron-input.editRefInput' :
|
||||
'input[is=iron-input].editRefInput');
|
||||
'iron-input.editRefInput' :
|
||||
'input[is=iron-input].editRefInput');
|
||||
},
|
||||
|
||||
editReference() {
|
||||
|
||||
@@ -206,8 +206,9 @@ limitations under the License.
|
||||
id: 'administrateServer',
|
||||
value: {},
|
||||
};
|
||||
assert.equal(element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
assert.equal(
|
||||
element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
element.capabilities[permission.id].name);
|
||||
|
||||
name = 'refs/for/*';
|
||||
@@ -216,8 +217,9 @@ limitations under the License.
|
||||
value: {},
|
||||
};
|
||||
|
||||
assert.equal(element._computePermissionName(
|
||||
name, permission, element.permissionValues, element.capabilities),
|
||||
assert.equal(
|
||||
element._computePermissionName(
|
||||
name, permission, element.permissionValues, element.capabilities),
|
||||
element.permissionValues[permission.id].name);
|
||||
|
||||
name = 'refs/for/*';
|
||||
@@ -228,8 +230,9 @@ limitations under the License.
|
||||
},
|
||||
};
|
||||
|
||||
assert.equal(element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
assert.equal(
|
||||
element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
'Label Code-Review');
|
||||
|
||||
permission = {
|
||||
@@ -239,8 +242,9 @@ limitations under the License.
|
||||
},
|
||||
};
|
||||
|
||||
assert.equal(element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
assert.equal(
|
||||
element._computePermissionName(name, permission,
|
||||
element.permissionValues, element.capabilities),
|
||||
'Label Code-Review(On Behalf Of)');
|
||||
});
|
||||
|
||||
|
||||
@@ -120,11 +120,11 @@
|
||||
return;
|
||||
}
|
||||
this._groups = Object.keys(groups)
|
||||
.map(key => {
|
||||
const group = groups[key];
|
||||
group.name = key;
|
||||
return group;
|
||||
});
|
||||
.map(key => {
|
||||
const group = groups[key];
|
||||
group.name = key;
|
||||
return group;
|
||||
});
|
||||
this._loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -105,23 +105,23 @@
|
||||
.then(res => {
|
||||
this._filteredLinks = res.links;
|
||||
this._breadcrumbParentName = res.expandedSection ?
|
||||
res.expandedSection.name : '';
|
||||
res.expandedSection.name : '';
|
||||
|
||||
if (!res.expandedSection) {
|
||||
this._subsectionLinks = [];
|
||||
return;
|
||||
}
|
||||
this._subsectionLinks = [res.expandedSection]
|
||||
.concat(res.expandedSection.children).map(section => {
|
||||
return {
|
||||
text: !section.detailType ? 'Home' : section.name,
|
||||
value: section.view + (section.detailType || ''),
|
||||
view: section.view,
|
||||
url: section.url,
|
||||
detailType: section.detailType,
|
||||
parent: this._groupId || this._repoName || '',
|
||||
};
|
||||
});
|
||||
.concat(res.expandedSection.children).map(section => {
|
||||
return {
|
||||
text: !section.detailType ? 'Home' : section.name,
|
||||
value: section.view + (section.detailType || ''),
|
||||
view: section.view,
|
||||
url: section.url,
|
||||
detailType: section.detailType,
|
||||
parent: this._groupId || this._repoName || '',
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -107,21 +107,21 @@
|
||||
}
|
||||
return this.$.restAPI.getRepoBranches(
|
||||
input, this.repoName, SUGGESTIONS_LIMIT).then(response => {
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
});
|
||||
},
|
||||
|
||||
_formatBooleanString(config) {
|
||||
|
||||
@@ -141,15 +141,15 @@
|
||||
_handleSavingGroupMember() {
|
||||
return this.$.restAPI.saveGroupMembers(this._groupName,
|
||||
this._groupMemberSearchId).then(config => {
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
this.$.restAPI.getGroupMembers(this._groupName).then(members => {
|
||||
this._groupMembers = members;
|
||||
});
|
||||
this._groupMemberSearchName = '';
|
||||
this._groupMemberSearchId = '';
|
||||
});
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
this.$.restAPI.getGroupMembers(this._groupName).then(members => {
|
||||
this._groupMembers = members;
|
||||
});
|
||||
this._groupMemberSearchName = '';
|
||||
this._groupMemberSearchId = '';
|
||||
});
|
||||
},
|
||||
|
||||
_handleDeleteConfirm() {
|
||||
@@ -239,24 +239,24 @@
|
||||
if (input.length === 0) { return Promise.resolve([]); }
|
||||
return this.$.restAPI.getSuggestedAccounts(
|
||||
input, SUGGESTIONS_LIMIT).then(accounts => {
|
||||
const accountSuggestions = [];
|
||||
let nameAndEmail;
|
||||
if (!accounts) { return []; }
|
||||
for (const key in accounts) {
|
||||
if (!accounts.hasOwnProperty(key)) { continue; }
|
||||
if (accounts[key].email !== undefined) {
|
||||
nameAndEmail = accounts[key].name +
|
||||
const accountSuggestions = [];
|
||||
let nameAndEmail;
|
||||
if (!accounts) { return []; }
|
||||
for (const key in accounts) {
|
||||
if (!accounts.hasOwnProperty(key)) { continue; }
|
||||
if (accounts[key].email !== undefined) {
|
||||
nameAndEmail = accounts[key].name +
|
||||
' <' + accounts[key].email + '>';
|
||||
} else {
|
||||
nameAndEmail = accounts[key].name;
|
||||
}
|
||||
accountSuggestions.push({
|
||||
name: nameAndEmail,
|
||||
value: accounts[key]._account_id,
|
||||
});
|
||||
}
|
||||
return accountSuggestions;
|
||||
} else {
|
||||
nameAndEmail = accounts[key].name;
|
||||
}
|
||||
accountSuggestions.push({
|
||||
name: nameAndEmail,
|
||||
value: accounts[key]._account_id,
|
||||
});
|
||||
}
|
||||
return accountSuggestions;
|
||||
});
|
||||
},
|
||||
|
||||
_getGroupSuggestions(input) {
|
||||
|
||||
@@ -169,10 +169,10 @@ limitations under the License.
|
||||
.querySelectorAll('.nameColumn a')[0].href, includedGroups[0].url);
|
||||
assert.equal(Polymer.dom(element.root)
|
||||
.querySelectorAll('.nameColumn a')[1].href,
|
||||
'https://test/site/group/url');
|
||||
'https://test/site/group/url');
|
||||
assert.equal(Polymer.dom(element.root)
|
||||
.querySelectorAll('.nameColumn a')[2].href,
|
||||
'https://test/site/group/url');
|
||||
'https://test/site/group/url');
|
||||
});
|
||||
|
||||
test('save members correctly', () => {
|
||||
|
||||
@@ -172,15 +172,15 @@
|
||||
}
|
||||
return this.$.restAPI.saveGroupOwner(this.groupId,
|
||||
owner).then(config => {
|
||||
this._owner = false;
|
||||
});
|
||||
this._owner = false;
|
||||
});
|
||||
},
|
||||
|
||||
_handleSaveDescription() {
|
||||
return this.$.restAPI.saveGroupDescription(this.groupId,
|
||||
this._groupConfig.description).then(config => {
|
||||
this._description = false;
|
||||
});
|
||||
this._description = false;
|
||||
});
|
||||
},
|
||||
|
||||
_handleSaveOptions() {
|
||||
@@ -190,8 +190,8 @@
|
||||
|
||||
return this.$.restAPI.saveGroupOptions(this.groupId,
|
||||
options).then(config => {
|
||||
this._options = false;
|
||||
});
|
||||
this._options = false;
|
||||
});
|
||||
},
|
||||
|
||||
_handleConfigName() {
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
|
||||
_computeGroupName(groups, groupId) {
|
||||
return groups && groups[groupId] && groups[groupId].name ?
|
||||
groups[groupId].name : groupId;
|
||||
groups[groupId].name : groupId;
|
||||
},
|
||||
|
||||
_getGroupSuggestions() {
|
||||
|
||||
@@ -92,11 +92,11 @@
|
||||
return;
|
||||
}
|
||||
this._plugins = Object.keys(plugins)
|
||||
.map(key => {
|
||||
const plugin = plugins[key];
|
||||
plugin.name = key;
|
||||
return plugin;
|
||||
});
|
||||
.map(key => {
|
||||
const plugin = plugins[key];
|
||||
plugin.name = key;
|
||||
return plugin;
|
||||
});
|
||||
this._loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
// current value appears. If there is no parent repo, it is
|
||||
// initialized as an empty string.
|
||||
this._inheritFromFilter = res.inherits_from ?
|
||||
this._inheritsFrom.name : '';
|
||||
this._inheritsFrom.name : '';
|
||||
this._local = res.local;
|
||||
this._groups = res.groups;
|
||||
this._weblinks = res.config_web_links || [];
|
||||
@@ -370,11 +370,11 @@
|
||||
};
|
||||
|
||||
const originalInheritsFromId = this._originalInheritsFrom ?
|
||||
this.singleDecodeURL(this._originalInheritsFrom.id) :
|
||||
null;
|
||||
this.singleDecodeURL(this._originalInheritsFrom.id) :
|
||||
null;
|
||||
const inheritsFromId = this._inheritsFrom ?
|
||||
this.singleDecodeURL(this._inheritsFrom.id) :
|
||||
null;
|
||||
this.singleDecodeURL(this._inheritsFrom.id) :
|
||||
null;
|
||||
|
||||
const inheritFromChanged =
|
||||
// Inherit from changed
|
||||
|
||||
@@ -676,7 +676,7 @@ limitations under the License.
|
||||
Polymer.dom(element.$$('gr-access-section').root).querySelectorAll(
|
||||
'gr-permission')[2];
|
||||
newPermission._handleAddRuleItem(
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
assert.deepEqual(element._computeAddAndRemove(), expectedInput);
|
||||
|
||||
// Modify a section reference.
|
||||
@@ -909,7 +909,7 @@ limitations under the License.
|
||||
Polymer.dom(element.$$('gr-access-section').root).querySelectorAll(
|
||||
'gr-permission')[1];
|
||||
readPermission._handleAddRuleItem(
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
{detail: {value: {id: 'Maintainers'}}});
|
||||
|
||||
expectedInput = {
|
||||
add: {
|
||||
|
||||
@@ -101,17 +101,17 @@
|
||||
_handleEditRepoConfig() {
|
||||
return this.$.restAPI.createChange(this.repo, CONFIG_BRANCH,
|
||||
EDIT_CONFIG_SUBJECT, undefined, false, true).then(change => {
|
||||
const message = change ?
|
||||
CREATE_CHANGE_SUCCEEDED_MESSAGE :
|
||||
CREATE_CHANGE_FAILED_MESSAGE;
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
'show-alert',
|
||||
{detail: {message}, bubbles: true, composed: true}));
|
||||
if (!change) { return; }
|
||||
const message = change ?
|
||||
CREATE_CHANGE_SUCCEEDED_MESSAGE :
|
||||
CREATE_CHANGE_FAILED_MESSAGE;
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
'show-alert',
|
||||
{detail: {message}, bubbles: true, composed: true}));
|
||||
if (!change) { return; }
|
||||
|
||||
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
|
||||
change, CONFIG_PATH, INITIAL_PATCHSET));
|
||||
});
|
||||
Gerrit.Nav.navigateToRelativeUrl(Gerrit.Nav.getEditUrlForDiff(
|
||||
change, CONFIG_PATH, INITIAL_PATCHSET));
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
// Group by ref and sort by id.
|
||||
const dashboards = res.concat.apply([], res).sort((a, b) =>
|
||||
a.id < b.id ? -1 : 1);
|
||||
a.id < b.id ? -1 : 1);
|
||||
const dashboardsByRef = {};
|
||||
dashboards.forEach(d => {
|
||||
if (!dashboardsByRef[d.ref]) {
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
_determineIfOwner(repo) {
|
||||
return this.$.restAPI.getRepoAccess(repo)
|
||||
.then(access =>
|
||||
this._isOwner = access && !!access[repo].is_owner);
|
||||
this._isOwner = access && !!access[repo].is_owner);
|
||||
},
|
||||
|
||||
_paramsChanged(params) {
|
||||
@@ -125,17 +125,17 @@
|
||||
if (detailType === DETAIL_TYPES.BRANCHES) {
|
||||
return this.$.restAPI.getRepoBranches(
|
||||
filter, repo, itemsPerPage, offset, errFn).then(items => {
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
});
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
});
|
||||
} else if (detailType === DETAIL_TYPES.TAGS) {
|
||||
return this.$.restAPI.getRepoTags(
|
||||
filter, repo, itemsPerPage, offset, errFn).then(items => {
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
});
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
_computeCanEditClass(ref, detailType, isOwner) {
|
||||
return isOwner && this._stripRefs(ref, detailType) === 'HEAD' ?
|
||||
'canEdit' : '';
|
||||
'canEdit' : '';
|
||||
},
|
||||
|
||||
_handleEditRevision(e) {
|
||||
|
||||
@@ -155,9 +155,9 @@ limitations under the License.
|
||||
const cancelBtn = Polymer.dom(element.root).querySelector('.cancelBtn');
|
||||
const editBtn = Polymer.dom(element.root).querySelector('.editBtn');
|
||||
const revisionNoEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionNoEditing');
|
||||
.querySelector('.revisionNoEditing');
|
||||
const revisionWithEditing = Polymer.dom(element.root)
|
||||
.querySelector('.revisionWithEditing');
|
||||
.querySelector('.revisionWithEditing');
|
||||
|
||||
sandbox.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
|
||||
sandbox.stub(element.$.restAPI, 'getRepoAccess').returns(
|
||||
|
||||
@@ -54,7 +54,7 @@ limitations under the License.
|
||||
{base: {config: {}}}), []);
|
||||
assert.deepEqual(element._computePluginConfigOptions(
|
||||
{base: {config: {testKey: 'testInfo'}}}),
|
||||
[{_key: 'testKey', info: 'testInfo'}]);
|
||||
[{_key: 'testKey', info: 'testInfo'}]);
|
||||
});
|
||||
|
||||
test('_computeDisabled', () => {
|
||||
|
||||
@@ -283,8 +283,8 @@
|
||||
_handleSaveRepoConfig() {
|
||||
return this.$.restAPI.saveRepoConfig(this.repo,
|
||||
this._formatRepoConfigForSave(this._repoConfig)).then(() => {
|
||||
this._configChanged = false;
|
||||
});
|
||||
this._configChanged = false;
|
||||
});
|
||||
},
|
||||
|
||||
_handleConfigChanged() {
|
||||
@@ -327,7 +327,7 @@
|
||||
command: commandObj[title]
|
||||
.replace(/\$\{project\}/gi, encodeURI(repo))
|
||||
.replace(/\$\{project-base-name\}/gi,
|
||||
encodeURI(repo.substring(repo.lastIndexOf('/') + 1))),
|
||||
encodeURI(repo.substring(repo.lastIndexOf('/') + 1))),
|
||||
});
|
||||
}
|
||||
return commands;
|
||||
|
||||
@@ -367,7 +367,7 @@ limitations under the License.
|
||||
element.$.matchAuthoredDateWithCommitterDateSelect.bindValue =
|
||||
configInputObj.match_author_to_committer_date;
|
||||
const inputElement = Polymer.Element ?
|
||||
element.$.maxGitObjSizeIronInput : element.$.maxGitObjSizeInput;
|
||||
element.$.maxGitObjSizeIronInput : element.$.maxGitObjSizeInput;
|
||||
inputElement.bindValue = configInputObj.max_object_size_limit;
|
||||
element.$.contributorAgreementSelect.bindValue =
|
||||
configInputObj.use_contributor_agreements;
|
||||
|
||||
@@ -125,7 +125,7 @@ limitations under the License.
|
||||
let permission = 'priority';
|
||||
let label;
|
||||
assert.deepEqual(element._getDefaultRuleValues(permission, label),
|
||||
{action: 'BATCH'});
|
||||
{action: 'BATCH'});
|
||||
permission = 'label-Code-Review';
|
||||
label = {values: [
|
||||
{value: -2, text: 'This shall not be merged'},
|
||||
@@ -139,7 +139,7 @@ limitations under the License.
|
||||
permission = 'push';
|
||||
label = undefined;
|
||||
assert.deepEqual(element._getDefaultRuleValues(permission, label),
|
||||
{action: 'ALLOW', force: false});
|
||||
{action: 'ALLOW', force: false});
|
||||
permission = 'submit';
|
||||
assert.deepEqual(element._getDefaultRuleValues(permission, label),
|
||||
{action: 'ALLOW'});
|
||||
|
||||
@@ -57,33 +57,34 @@ limitations under the License.
|
||||
'cell label u-gray-background');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {}}, 'Verified'), 'cell label u-gray-background');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
|
||||
assert.equal(
|
||||
element._computeLabelClass(
|
||||
{labels: {Verified: {approved: true, value: 1}}}, 'Verified'),
|
||||
'cell label u-green u-monospace');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {Verified: {rejected: true, value: -1}}}, 'Verified'),
|
||||
'cell label u-monospace u-red');
|
||||
'cell label u-monospace u-red');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {'Code-Review': {value: 1}}}, 'Code-Review'),
|
||||
'cell label u-green u-monospace');
|
||||
'cell label u-green u-monospace');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {'Code-Review': {value: -1}}}, 'Code-Review'),
|
||||
'cell label u-monospace u-red');
|
||||
'cell label u-monospace u-red');
|
||||
assert.equal(element._computeLabelClass(
|
||||
{labels: {'Code-Review': {value: -1}}}, 'Verified'),
|
||||
'cell label u-gray-background');
|
||||
'cell label u-gray-background');
|
||||
|
||||
assert.equal(element._computeLabelTitle({labels: {}}, 'Verified'),
|
||||
'Label not applicable');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {Verified: {approved: {name: 'Diffy'}}}}, 'Verified'),
|
||||
'Verified\nby Diffy');
|
||||
'Verified\nby Diffy');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {Verified: {approved: {name: 'Diffy'}}}}, 'Code-Review'),
|
||||
'Label not applicable');
|
||||
'Label not applicable');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {Verified: {rejected: {name: 'Diffy'}}}}, 'Verified'),
|
||||
'Verified\nby Diffy');
|
||||
'Verified\nby Diffy');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {'Code-Review': {disliked: {name: 'Diffy'}, value: -1}}},
|
||||
'Code-Review'), 'Code-Review\nby Diffy');
|
||||
@@ -93,19 +94,19 @@ limitations under the License.
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {'Code-Review': {recommended: {name: 'Diffy'},
|
||||
rejected: {name: 'Admin'}}}}, 'Code-Review'),
|
||||
'Code-Review\nby Admin');
|
||||
'Code-Review\nby Admin');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {'Code-Review': {approved: {name: 'Diffy'},
|
||||
rejected: {name: 'Admin'}}}}, 'Code-Review'),
|
||||
'Code-Review\nby Admin');
|
||||
'Code-Review\nby Admin');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {'Code-Review': {recommended: {name: 'Diffy'},
|
||||
disliked: {name: 'Admin'}, value: -1}}}, 'Code-Review'),
|
||||
'Code-Review\nby Admin');
|
||||
'Code-Review\nby Admin');
|
||||
assert.equal(element._computeLabelTitle(
|
||||
{labels: {'Code-Review': {approved: {name: 'Diffy'},
|
||||
disliked: {name: 'Admin'}, value: -1}}}, 'Code-Review'),
|
||||
'Code-Review\nby Diffy');
|
||||
'Code-Review\nby Diffy');
|
||||
|
||||
assert.equal(element._computeLabelValue({labels: {}}), '');
|
||||
assert.equal(element._computeLabelValue({labels: {}}, 'Verified'), '');
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
this.showNumber = !!(preferences &&
|
||||
preferences.legacycid_in_change_table);
|
||||
this.visibleChangeTableColumns = preferences.change_table.length > 0 ?
|
||||
this.getVisibleColumns(preferences.change_table) : this.columnNames;
|
||||
this.getVisibleColumns(preferences.change_table) : this.columnNames;
|
||||
} else {
|
||||
// Not logged in.
|
||||
this.showNumber = false;
|
||||
|
||||
@@ -113,7 +113,7 @@ limitations under the License.
|
||||
|
||||
test('computed fields', () => {
|
||||
assert.equal(element._computeLabelNames(
|
||||
[{results: [{_number: 0, labels: {}}]}]).length, 0);
|
||||
[{results: [{_number: 0, labels: {}}]}]).length, 0);
|
||||
assert.equal(element._computeLabelNames([
|
||||
{results: [
|
||||
{_number: 0, labels: {Verified: {approved: {}}}},
|
||||
|
||||
@@ -109,21 +109,21 @@
|
||||
};
|
||||
return this.$.restAPI.getDashboard(
|
||||
project, dashboard, errFn).then(response => {
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
title: response.title,
|
||||
sections: response.sections.map(section => {
|
||||
const suffix = response.foreach ? ' ' + response.foreach : '';
|
||||
return {
|
||||
title: response.title,
|
||||
sections: response.sections.map(section => {
|
||||
const suffix = response.foreach ? ' ' + response.foreach : '';
|
||||
return {
|
||||
name: section.name,
|
||||
query: (section.query + suffix).replace(
|
||||
PROJECT_PLACEHOLDER_PATTERN, project),
|
||||
};
|
||||
}),
|
||||
name: section.name,
|
||||
query: (section.query + suffix).replace(
|
||||
PROJECT_PLACEHOLDER_PATTERN, project),
|
||||
};
|
||||
});
|
||||
}),
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
_computeTitle(user) {
|
||||
@@ -156,11 +156,11 @@
|
||||
this._loading = true;
|
||||
const {project, dashboard, title, user, sections} = this.params;
|
||||
const dashboardPromise = project ?
|
||||
this._getProjectDashboard(project, dashboard) :
|
||||
Promise.resolve(Gerrit.Nav.getUserDashboard(
|
||||
user,
|
||||
sections,
|
||||
title || this._computeTitle(user)));
|
||||
this._getProjectDashboard(project, dashboard) :
|
||||
Promise.resolve(Gerrit.Nav.getUserDashboard(
|
||||
user,
|
||||
sections,
|
||||
title || this._computeTitle(user)));
|
||||
|
||||
const checkForNewUser = !project && user === 'self';
|
||||
return dashboardPromise
|
||||
@@ -194,8 +194,8 @@
|
||||
|
||||
const queries = res.sections
|
||||
.map(section => section.suffixForDashboard ?
|
||||
section.query + ' ' + section.suffixForDashboard :
|
||||
section.query);
|
||||
section.query + ' ' + section.suffixForDashboard :
|
||||
section.query);
|
||||
|
||||
if (checkForNewUser) {
|
||||
queries.push('owner:self limit:1');
|
||||
@@ -215,7 +215,7 @@
|
||||
results,
|
||||
isOutgoing: res.sections[i].isOutgoing,
|
||||
})).filter((section, i) => i < res.sections.length && (
|
||||
!res.sections[i].hideIfEmpty ||
|
||||
!res.sections[i].hideIfEmpty ||
|
||||
section.results.length));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
_computeDashboardLinkClass(showDashboardLink, loggedIn) {
|
||||
return showDashboardLink && loggedIn ?
|
||||
'dashboardLink' : 'dashboardLink hide';
|
||||
'dashboardLink' : 'dashboardLink hide';
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -437,7 +437,7 @@
|
||||
|
||||
_getRebaseAction(revisionActions) {
|
||||
return this._getRevisionAction(revisionActions, 'rebase',
|
||||
{rebaseOnCurrent: null}
|
||||
{rebaseOnCurrent: null}
|
||||
);
|
||||
},
|
||||
|
||||
@@ -628,7 +628,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {string=} actionName
|
||||
*/
|
||||
_deleteAndNotify(actionName) {
|
||||
@@ -1475,9 +1475,9 @@
|
||||
|
||||
_filterPrimaryActions(_topLevelActions) {
|
||||
this._topLevelPrimaryActions = _topLevelActions.filter(action =>
|
||||
action.__primary);
|
||||
action.__primary);
|
||||
this._topLevelSecondaryActions = _topLevelActions.filter(action =>
|
||||
!action.__primary);
|
||||
!action.__primary);
|
||||
},
|
||||
|
||||
_computeMenuActions(actionRecord, hiddenActionsRecord) {
|
||||
|
||||
@@ -378,7 +378,7 @@ limitations under the License.
|
||||
element._handleRebaseConfirm({detail: {base: '1234'}});
|
||||
rebaseAction.rebaseOnCurrent = true;
|
||||
assert.deepEqual(fireActionStub.lastCall.args,
|
||||
['/rebase', rebaseAction, true, {base: '1234'}]);
|
||||
['/rebase', rebaseAction, true, {base: '1234'}]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ limitations under the License.
|
||||
js_resource_paths: [],
|
||||
html_resource_paths: [
|
||||
new URL('test/plugin.html?' + Math.random(),
|
||||
window.location.href).toString(),
|
||||
window.location.href).toString(),
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -140,7 +140,7 @@ limitations under the License.
|
||||
setup(() => {
|
||||
Gerrit.install(p => plugin = p, '0.1',
|
||||
new URL('test/plugin.html?' + Math.random(),
|
||||
window.location.href).toString());
|
||||
window.location.href).toString());
|
||||
sandbox.stub(Gerrit, '_arePluginsLoaded').returns(true);
|
||||
Gerrit._loadPlugins([]);
|
||||
element = createElement();
|
||||
|
||||
@@ -228,12 +228,12 @@
|
||||
this._newHashtag = '';
|
||||
this.$.restAPI.setChangeHashtag(
|
||||
this.change._number, {add: [newHashtag]}).then(newHashtag => {
|
||||
this.set(['change', 'hashtags'], newHashtag);
|
||||
if (newHashtag !== lastHashtag) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
'hashtag-changed', {bubbles: true, composed: true}));
|
||||
}
|
||||
});
|
||||
this.set(['change', 'hashtags'], newHashtag);
|
||||
if (newHashtag !== lastHashtag) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
'hashtag-changed', {bubbles: true, composed: true}));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_computeTopicReadOnly(mutable, change) {
|
||||
@@ -344,7 +344,7 @@
|
||||
if (!this.change || !this.change.status) return '';
|
||||
return Gerrit.Nav.getUrlForBranch(branch, project,
|
||||
this.change.status == this.ChangeStatus.NEW ? 'open' :
|
||||
this.change.status.toLowerCase());
|
||||
this.change.status.toLowerCase());
|
||||
},
|
||||
|
||||
_computeTopicURL(topic) {
|
||||
|
||||
@@ -426,7 +426,7 @@ limitations under the License.
|
||||
{current_revision: '789', revisions: {456: {commit: {parents}}}}));
|
||||
assert.equal(element._computeParents(
|
||||
{current_revision: '456', revisions: {456: {commit: {parents}}}}),
|
||||
parents);
|
||||
parents);
|
||||
});
|
||||
|
||||
test('_computeParentsLabel', () => {
|
||||
|
||||
@@ -135,8 +135,8 @@
|
||||
|
||||
_computeShowHideIcon(showOptionalLabels) {
|
||||
return showOptionalLabels ?
|
||||
'gr-icons:expand-less' :
|
||||
'gr-icons:expand-more';
|
||||
'gr-icons:expand-less' :
|
||||
'gr-icons:expand-more';
|
||||
},
|
||||
|
||||
_computeSectionClass(show) {
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
computed:
|
||||
'_computeChangeIdCommitMessageError(_latestCommitMessage, _change)',
|
||||
},
|
||||
/** @type {?} */
|
||||
/** @type {?} */
|
||||
_patchRange: {
|
||||
type: Object,
|
||||
},
|
||||
@@ -456,16 +456,16 @@
|
||||
this.$.commitMessageEditor.disabled = true;
|
||||
this.$.restAPI.putChangeCommitMessage(
|
||||
this._changeNum, message).then(resp => {
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
if (!resp.ok) { return; }
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
if (!resp.ok) { return; }
|
||||
|
||||
this._latestCommitMessage = this._prepareCommitMsgForLinkify(
|
||||
message);
|
||||
this._editingCommitMessage = false;
|
||||
this._reloadWindow();
|
||||
}).catch(err => {
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
});
|
||||
this._latestCommitMessage = this._prepareCommitMsgForLinkify(
|
||||
message);
|
||||
this._editingCommitMessage = false;
|
||||
this._reloadWindow();
|
||||
}).catch(err => {
|
||||
this.$.commitMessageEditor.disabled = false;
|
||||
});
|
||||
},
|
||||
|
||||
_reloadWindow() {
|
||||
@@ -819,7 +819,7 @@
|
||||
|
||||
_viewStateChanged(viewState) {
|
||||
this._numFilesShown = viewState.numFilesShown ?
|
||||
viewState.numFilesShown : DEFAULT_NUM_FILES_SHOWN;
|
||||
viewState.numFilesShown : DEFAULT_NUM_FILES_SHOWN;
|
||||
},
|
||||
|
||||
_numFilesShownChanged(numFilesShown) {
|
||||
@@ -937,7 +937,7 @@
|
||||
// check that there is at least 2 parents otherwise fall back to 1,
|
||||
// which means there is only one parent.
|
||||
const parentCount = parentCounts.hasOwnProperty(1) ?
|
||||
parentCounts[1] : 1;
|
||||
parentCounts[1] : 1;
|
||||
|
||||
const preferFirst = this._prefs &&
|
||||
this._prefs.default_base_for_merges === 'FIRST_PARENT';
|
||||
@@ -1327,10 +1327,10 @@
|
||||
_getLatestCommitMessage() {
|
||||
return this.$.restAPI.getChangeCommitInfo(this._changeNum,
|
||||
this.computeLatestPatchNum(this._allPatchSets)).then(commitInfo => {
|
||||
if (!commitInfo) return Promise.resolve();
|
||||
this._latestCommitMessage =
|
||||
if (!commitInfo) return Promise.resolve();
|
||||
this._latestCommitMessage =
|
||||
this._prepareCommitMsgForLinkify(commitInfo.message);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_getLatestRevisionSHA(change) {
|
||||
@@ -1376,7 +1376,7 @@
|
||||
this._changeComments = comments;
|
||||
this._diffDrafts = Object.assign({}, this._changeComments.drafts);
|
||||
this._commentThreads = this._changeComments.getAllThreadsForChange()
|
||||
.map(c => Object.assign({}, c));
|
||||
.map(c => Object.assign({}, c));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1800,7 +1800,7 @@
|
||||
*/
|
||||
_handleEditTap() {
|
||||
const editInfo = Object.values(this._change.revisions).find(info =>
|
||||
info._number === this.EDIT_NAME);
|
||||
info._number === this.EDIT_NAME);
|
||||
|
||||
if (editInfo) {
|
||||
Gerrit.Nav.navigateToChange(this._change, this.EDIT_NAME);
|
||||
|
||||
@@ -176,7 +176,7 @@ limitations under the License.
|
||||
assert.isFalse(element.$.replyOverlay.opened);
|
||||
assert(openSpy.lastCall.calledWithExactly(
|
||||
element.$.replyDialog.FocusTarget.ANY),
|
||||
'_openReplyDialog should have been passed ANY');
|
||||
'_openReplyDialog should have been passed ANY');
|
||||
assert.equal(openSpy.callCount, 1);
|
||||
done();
|
||||
});
|
||||
@@ -1046,7 +1046,7 @@ limitations under the License.
|
||||
MockInteractions.tap(element.$.replyBtn);
|
||||
assert(openStub.lastCall.calledWithExactly(
|
||||
element.$.replyDialog.FocusTarget.ANY),
|
||||
'_openReplyDialog should have been passed ANY');
|
||||
'_openReplyDialog should have been passed ANY');
|
||||
assert.equal(openStub.callCount, 1);
|
||||
});
|
||||
|
||||
@@ -1058,7 +1058,7 @@ limitations under the License.
|
||||
{message: {message: 'text'}});
|
||||
assert(openStub.lastCall.calledWithExactly(
|
||||
element.$.replyDialog.FocusTarget.BODY),
|
||||
'_openReplyDialog should have been passed BODY');
|
||||
'_openReplyDialog should have been passed BODY');
|
||||
assert.equal(openStub.callCount, 1);
|
||||
done();
|
||||
});
|
||||
@@ -1483,7 +1483,7 @@ limitations under the License.
|
||||
|
||||
test('_computeEditMode', () => {
|
||||
const callCompute = (range, params) =>
|
||||
element._computeEditMode({base: range}, {base: params});
|
||||
element._computeEditMode({base: range}, {base: params});
|
||||
assert.isFalse(callCompute({}, {}));
|
||||
assert.isTrue(callCompute({}, {edit: true}));
|
||||
assert.isFalse(callCompute({basePatchNum: 'PARENT', patchNum: 1}, {}));
|
||||
@@ -1703,7 +1703,7 @@ limitations under the License.
|
||||
|
||||
element._patchRange = {patchNum: 1};
|
||||
element.$.actions.dispatchEvent(new CustomEvent('stop-edit-tap',
|
||||
{bubbles: false}));
|
||||
{bubbles: false}));
|
||||
});
|
||||
|
||||
suite('plugin endpoints', () => {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
_computeDiffLineURL(file, changeNum, patchNum, comment) {
|
||||
const basePatchNum = comment.hasOwnProperty('parent') ?
|
||||
-comment.parent : null;
|
||||
-comment.parent : null;
|
||||
return Gerrit.Nav.getUrlForDiffById(this.changeNum, this.projectName,
|
||||
file, patchNum, basePatchNum, comment.line,
|
||||
this._isOnParent(comment));
|
||||
|
||||
@@ -98,21 +98,21 @@
|
||||
}
|
||||
return this.$.restAPI.getRepoBranches(
|
||||
input, this.project, SUGGESTIONS_LIMIT).then(response => {
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -68,21 +68,21 @@
|
||||
}
|
||||
return this.$.restAPI.getRepoBranches(
|
||||
input, this.project, SUGGESTIONS_LIMIT).then(response => {
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
const branches = [];
|
||||
let branch;
|
||||
for (const key in response) {
|
||||
if (!response.hasOwnProperty(key)) { continue; }
|
||||
if (response[key].ref.startsWith('refs/heads/')) {
|
||||
branch = response[key].ref.substring('refs/heads/'.length);
|
||||
} else {
|
||||
branch = response[key].ref;
|
||||
}
|
||||
branches.push({
|
||||
name: branch,
|
||||
});
|
||||
}
|
||||
return branches;
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
_getChangeSuggestions(input) {
|
||||
return this._getRecentChanges().then(changes =>
|
||||
this._filterChanges(input, changes));
|
||||
this._filterChanges(input, changes));
|
||||
},
|
||||
|
||||
_filterChanges(input, changes) {
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
for (const rev of Object.values(change.revisions || {})) {
|
||||
if (this.patchNumEquals(rev._number, patchNum)) {
|
||||
const parentLength = rev.commit && rev.commit.parents ?
|
||||
rev.commit.parents.length : 0;
|
||||
rev.commit.parents.length : 0;
|
||||
return parentLength == 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ limitations under the License.
|
||||
test('computed fields', () => {
|
||||
assert.equal(element._computeArchiveDownloadLink(
|
||||
{project: 'test/project', _number: 123}, 2, 'tgz'),
|
||||
'/changes/test%2Fproject~123/revisions/2/archive?format=tgz');
|
||||
'/changes/test%2Fproject~123/revisions/2/archive?format=tgz');
|
||||
});
|
||||
|
||||
test('close event', done => {
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
|
||||
const rev = this.getRevisionByPatchNum(change.revisions, patchNum);
|
||||
this._patchsetDescription = (rev && rev.description) ?
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
},
|
||||
|
||||
_handleDescriptionRemoved(e) {
|
||||
@@ -257,7 +257,7 @@
|
||||
_computeUploadHelpContainerClass(change, account) {
|
||||
const changeIsMerged = change && change.status === MERGED_STATUS;
|
||||
const ownerId = change && change.owner && change.owner._account_id ?
|
||||
change.owner._account_id : null;
|
||||
change.owner._account_id : null;
|
||||
const userId = account && account._account_id;
|
||||
const userIsOwner = ownerId && userId && ownerId === userId;
|
||||
const hideContainer = !userIsOwner || changeIsMerged;
|
||||
|
||||
@@ -839,7 +839,7 @@
|
||||
|
||||
_computeShowHideIcon(path, expandedFilesRecord) {
|
||||
return this._isFileExpanded(path, expandedFilesRecord) ?
|
||||
'gr-icons:expand-less' : 'gr-icons:expand-more';
|
||||
'gr-icons:expand-less' : 'gr-icons:expand-more';
|
||||
},
|
||||
|
||||
_computeFiles(filesByPath, changeComments, patchRange, reviewed, loading) {
|
||||
@@ -879,7 +879,7 @@
|
||||
}
|
||||
|
||||
const previousNumFilesShown = this._shownFiles ?
|
||||
this._shownFiles.length : 0;
|
||||
this._shownFiles.length : 0;
|
||||
|
||||
const filesShown = files.slice(0, numFilesShown);
|
||||
this.fire('files-shown-changed', {length: filesShown.length});
|
||||
@@ -954,7 +954,7 @@
|
||||
|
||||
const rev = this.getRevisionByPatchNum(revisions, patchNum);
|
||||
return (rev && rev.description) ?
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -966,7 +966,7 @@
|
||||
_computeFileStatusLabel(status) {
|
||||
const statusCode = this._computeFileStatus(status);
|
||||
return FileStatus.hasOwnProperty(statusCode) ?
|
||||
FileStatus[statusCode] : 'Status Unknown';
|
||||
FileStatus[statusCode] : 'Status Unknown';
|
||||
},
|
||||
|
||||
_isFileExpanded(path, expandedFilesRecord) {
|
||||
@@ -998,7 +998,7 @@
|
||||
// Clear content for any diffs that are not open so if they get re-opened
|
||||
// the stale content does not flash before it is cleared and reloaded.
|
||||
const collapsedDiffs = this.diffs.filter(diff =>
|
||||
this._expandedFilePaths.indexOf(diff.path) === -1);
|
||||
this._expandedFilePaths.indexOf(diff.path) === -1);
|
||||
this._clearCollapsedDiffs(collapsedDiffs);
|
||||
|
||||
if (!record) { return; } // Happens after "Collapse all" clicked.
|
||||
@@ -1008,9 +1008,9 @@
|
||||
|
||||
// Find the paths introduced by the new index splices:
|
||||
const newPaths = record.indexSplices
|
||||
.map(splice => splice.object.slice(
|
||||
splice.index, splice.index + splice.addedCount))
|
||||
.reduce((acc, paths) => acc.concat(paths), []);
|
||||
.map(splice => splice.object.slice(
|
||||
splice.index, splice.index + splice.addedCount))
|
||||
.reduce((acc, paths) => acc.concat(paths), []);
|
||||
|
||||
// Required so that the newly created diff view is included in this.diffs.
|
||||
Polymer.dom.flush();
|
||||
|
||||
@@ -440,10 +440,10 @@ limitations under the License.
|
||||
'/COMMIT_MSG', 'comment'), '3 comments (1 unresolved)');
|
||||
assert.equal(
|
||||
element._computeCommentsStringMobile(element.changeComments, parentTo1
|
||||
, '/COMMIT_MSG'), '2c');
|
||||
, '/COMMIT_MSG'), '2c');
|
||||
assert.equal(
|
||||
element._computeCommentsStringMobile(element.changeComments, _1To2
|
||||
, '/COMMIT_MSG'), '3c');
|
||||
, '/COMMIT_MSG'), '3c');
|
||||
assert.equal(
|
||||
element._computeDraftsString(element.changeComments, parentTo1,
|
||||
'unresolved.file'), '1 draft');
|
||||
@@ -639,7 +639,7 @@ limitations under the License.
|
||||
|
||||
assert(navStub.lastCall.calledWith(element.change,
|
||||
'file_added_in_rev2.txt', '2'),
|
||||
'Should navigate to /c/42/2/file_added_in_rev2.txt');
|
||||
'Should navigate to /c/42/2/file_added_in_rev2.txt');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75, null, 'k');
|
||||
@@ -1639,7 +1639,7 @@ limitations under the License.
|
||||
|
||||
element.set('_filesByPath', _filesByPath);
|
||||
flushAsynchronousOperations();
|
||||
// Navigates when a file is selected.
|
||||
// Navigates when a file is selected.
|
||||
element._openSelectedFile();
|
||||
assert.isTrue(navStub.called);
|
||||
});
|
||||
@@ -1701,7 +1701,7 @@ limitations under the License.
|
||||
const editControls =
|
||||
Array.from(
|
||||
Polymer.dom(element.root)
|
||||
.querySelectorAll('.row:not(.header-row)'))
|
||||
.querySelectorAll('.row:not(.header-row)'))
|
||||
.map(row => row.querySelector('gr-edit-file-controls'));
|
||||
assert.isTrue(editControls[0].classList.contains('invisible'));
|
||||
});
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
if (!labels[label.name]) { return null; }
|
||||
const labelValue = this._getLabelValue(labels, permittedLabels, label);
|
||||
const len = permittedLabels[label.name] != null ?
|
||||
permittedLabels[label.name].length : 0;
|
||||
permittedLabels[label.name].length : 0;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const val = permittedLabels[label.name][i];
|
||||
if (val === labelValue) {
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
_computeHiddenClass(permittedLabels, label) {
|
||||
return !this._computeAnyPermittedLabelValues(permittedLabels, label) ?
|
||||
'hidden' : '';
|
||||
'hidden' : '';
|
||||
},
|
||||
|
||||
_computePermittedLabelValues(permittedLabels, label) {
|
||||
|
||||
@@ -123,7 +123,7 @@ limitations under the License.
|
||||
const labelName = 'Code-Review';
|
||||
assert.strictEqual(element._getVoteForAccount(
|
||||
element.change.labels, labelName, element.account),
|
||||
'+1');
|
||||
'+1');
|
||||
});
|
||||
|
||||
test('_computeColumns', () => {
|
||||
@@ -187,10 +187,10 @@ limitations under the License.
|
||||
{name: 'Verified', value: null}
|
||||
]);
|
||||
element.set(['change', 'labels', 'Verified', 'all'],
|
||||
[{_account_id: 123, value: 1}]);
|
||||
[{_account_id: 123, value: 1}]);
|
||||
assert.deepEqual(element._labels, [
|
||||
{name: 'Code-Review', value: null},
|
||||
{name: 'Verified', value: '+1'},
|
||||
{name: 'Code-Review', value: null},
|
||||
{name: 'Verified', value: '+1'},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,8 +102,8 @@
|
||||
el.set('message.expanded', true);
|
||||
let top = el.offsetTop;
|
||||
for (let offsetParent = el.offsetParent;
|
||||
offsetParent;
|
||||
offsetParent = offsetParent.offsetParent) {
|
||||
offsetParent;
|
||||
offsetParent = offsetParent.offsetParent) {
|
||||
top += offsetParent.offsetTop;
|
||||
}
|
||||
window.scrollTo(0, top);
|
||||
|
||||
@@ -368,7 +368,7 @@
|
||||
|
||||
_computeSubmittedTogetherClass(submittedTogether) {
|
||||
if (!submittedTogether || (
|
||||
submittedTogether.changes.length === 0 &&
|
||||
submittedTogether.changes.length === 0 &&
|
||||
!submittedTogether.non_visible_changes)) {
|
||||
return 'hidden';
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ limitations under the License.
|
||||
sandbox.stub(element, '_getCherryPicks')
|
||||
.returns(Promise.resolve());
|
||||
conflictsStub = sandbox.stub(element, '_getConflicts')
|
||||
.returns(Promise.resolve());
|
||||
.returns(Promise.resolve());
|
||||
});
|
||||
|
||||
test('request conflicts if open and mergeable', () => {
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
* @event comment-refresh
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fires when the state of the send button (enabled/disabled) changes.
|
||||
*
|
||||
* @event send-disabled-changed
|
||||
@@ -249,7 +249,7 @@
|
||||
this.fetchChangeUpdates(this.change, this.$.restAPI)
|
||||
.then(result => {
|
||||
this.knownLatestState = result.isLatest ?
|
||||
LatestPatchState.LATEST : LatestPatchState.NOT_LATEST;
|
||||
LatestPatchState.LATEST : LatestPatchState.NOT_LATEST;
|
||||
});
|
||||
|
||||
this._focusOn(opt_focusTarget);
|
||||
@@ -394,16 +394,16 @@
|
||||
|
||||
return this.$.restAPI.removeChangeReviewer(this.change._number,
|
||||
account._account_id).then(response => {
|
||||
if (!response.ok) { return response; }
|
||||
if (!response.ok) { return response; }
|
||||
|
||||
const reviewers = this.change.reviewers[type] || [];
|
||||
for (let i = 0; i < reviewers.length; i++) {
|
||||
if (reviewers[i]._account_id == account._account_id) {
|
||||
this.splice(`change.reviewers.${type}`, i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
const reviewers = this.change.reviewers[type] || [];
|
||||
for (let i = 0; i < reviewers.length; i++) {
|
||||
if (reviewers[i]._account_id == account._account_id) {
|
||||
this.splice(`change.reviewers.${type}`, i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_mapReviewer(reviewer) {
|
||||
|
||||
@@ -414,8 +414,8 @@ limitations under the License.
|
||||
}).then(() => {
|
||||
assert.isFalse(isVisible(element.$.reviewerConfirmationOverlay));
|
||||
const additions = cc ?
|
||||
element.$.ccs.additions() :
|
||||
element.$.reviewers.additions();
|
||||
element.$.ccs.additions() :
|
||||
element.$.reviewers.additions();
|
||||
assert.deepEqual(
|
||||
additions,
|
||||
[
|
||||
@@ -843,7 +843,7 @@ limitations under the License.
|
||||
// Send and purge and verify moves, delete cc3.
|
||||
element.send()
|
||||
.then(keepReviewers =>
|
||||
element._purgeReviewersPendingRemove(false, keepReviewers))
|
||||
element._purgeReviewersPendingRemove(false, keepReviewers))
|
||||
.then(() => {
|
||||
assert.deepEqual(
|
||||
mutations, [
|
||||
@@ -1084,7 +1084,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
assert.isTrue(fn(
|
||||
/* buttonLabel= */ 'Send',
|
||||
@@ -1093,7 +1093,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Mock nonempty comment draft array, with seding comments.
|
||||
assert.isFalse(fn(
|
||||
@@ -1103,7 +1103,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ true,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Mock nonempty comment draft array, without seding comments.
|
||||
assert.isTrue(fn(
|
||||
@@ -1113,7 +1113,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Mock nonempty change message.
|
||||
assert.isFalse(fn(
|
||||
@@ -1123,7 +1123,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Mock reviewers mutated.
|
||||
assert.isFalse(fn(
|
||||
@@ -1133,7 +1133,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ true,
|
||||
/* labelsChanged= */ false,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Mock labels changed.
|
||||
assert.isFalse(fn(
|
||||
@@ -1143,7 +1143,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ true,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ false,
|
||||
/* disabled= */ false
|
||||
));
|
||||
// Whole dialog is disabled.
|
||||
assert.isTrue(fn(
|
||||
@@ -1153,7 +1153,7 @@ limitations under the License.
|
||||
/* reviewersMutated= */ false,
|
||||
/* labelsChanged= */ true,
|
||||
/* includeComments= */ false,
|
||||
/* disabled= */ true,
|
||||
/* disabled= */ true
|
||||
));
|
||||
});
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ limitations under the License.
|
||||
element.maxReviewersDisplayed = 5;
|
||||
for (let i = 0; i < 6; i++) {
|
||||
reviewers.push(
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
}
|
||||
element.ccsOnly = true;
|
||||
|
||||
@@ -219,7 +219,7 @@ limitations under the License.
|
||||
element.maxReviewersDisplayed = 5;
|
||||
for (let i = 0; i < 7; i++) {
|
||||
reviewers.push(
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
}
|
||||
element.ccsOnly = true;
|
||||
|
||||
@@ -242,7 +242,7 @@ limitations under the License.
|
||||
const reviewers = [];
|
||||
for (let i = 0; i < 7; i++) {
|
||||
reviewers.push(
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
}
|
||||
element.ccsOnly = true;
|
||||
|
||||
@@ -265,7 +265,7 @@ limitations under the License.
|
||||
element.maxReviewersDisplayed = 5;
|
||||
for (let i = 0; i < 100; i++) {
|
||||
reviewers.push(
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
{email: i+'reviewer@google.com', name: 'reviewer-' + i});
|
||||
}
|
||||
element.ccsOnly = true;
|
||||
|
||||
@@ -298,7 +298,7 @@ limitations under the License.
|
||||
},
|
||||
Bar: {
|
||||
all: [{_account_id: 1, permitted_voting_range: {max: 1}},
|
||||
{_account_id: 7, permitted_voting_range: {max: 1}}],
|
||||
{_account_id: 7, permitted_voting_range: {max: 1}}],
|
||||
},
|
||||
FooBar: {
|
||||
all: [{_account_id: 7, value: 0}],
|
||||
|
||||
@@ -118,8 +118,8 @@
|
||||
|
||||
const lastNonDraftComment =
|
||||
(lastComment.__draft && thread.comments.length > 1) ?
|
||||
thread.comments[thread.comments.length - 2] :
|
||||
lastComment;
|
||||
thread.comments[thread.comments.length - 2] :
|
||||
lastComment;
|
||||
|
||||
return {
|
||||
thread,
|
||||
|
||||
@@ -78,7 +78,7 @@ limitations under the License.
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(element.$$('gr-account-dropdown'))
|
||||
.display,
|
||||
'none');
|
||||
'none');
|
||||
assert.notEqual(getComputedStyle(element.$$('.settingsButton')).display,
|
||||
'none');
|
||||
});
|
||||
@@ -116,28 +116,28 @@ limitations under the License.
|
||||
/* userLinks= */[],
|
||||
adminLinks,
|
||||
/* topMenus= */[],
|
||||
/* docBaseUrl= */ '',
|
||||
/* docBaseUrl= */ ''
|
||||
),
|
||||
defaultLinks.concat({
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
}));
|
||||
defaultLinks.concat({
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
}));
|
||||
assert.deepEqual(element._computeLinks(
|
||||
defaultLinks,
|
||||
userLinks,
|
||||
adminLinks,
|
||||
/* topMenus= */[],
|
||||
/* docBaseUrl= */ ''
|
||||
),
|
||||
defaultLinks.concat([
|
||||
{
|
||||
title: 'Your',
|
||||
links: userLinks,
|
||||
},
|
||||
{
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
}])
|
||||
),
|
||||
defaultLinks.concat([
|
||||
{
|
||||
title: 'Your',
|
||||
links: userLinks,
|
||||
},
|
||||
{
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
}])
|
||||
);
|
||||
});
|
||||
|
||||
@@ -185,7 +185,7 @@ limitations under the License.
|
||||
/* userLinks= */ [],
|
||||
adminLinks,
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
@@ -221,7 +221,7 @@ limitations under the License.
|
||||
/* userLinks= */ [],
|
||||
adminLinks,
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
@@ -260,7 +260,7 @@ limitations under the License.
|
||||
/* userLinks= */ [],
|
||||
adminLinks,
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Browse',
|
||||
links: adminLinks,
|
||||
@@ -297,7 +297,7 @@ limitations under the License.
|
||||
/* userLinks= */ [],
|
||||
/* adminLinks= */ [],
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Faves',
|
||||
links: defaultLinks[0].links.concat([{
|
||||
@@ -328,7 +328,7 @@ limitations under the License.
|
||||
userLinks,
|
||||
/* adminLinks= */ [],
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Your',
|
||||
links: userLinks.concat([{
|
||||
@@ -359,7 +359,7 @@ limitations under the License.
|
||||
/* userLinks= */ [],
|
||||
adminLinks,
|
||||
topMenus,
|
||||
/* baseDocUrl= */ '',
|
||||
/* baseDocUrl= */ ''
|
||||
), [{
|
||||
title: 'Browse',
|
||||
links: adminLinks.concat([{
|
||||
|
||||
@@ -732,11 +732,11 @@ limitations under the License.
|
||||
getUserDashboard(user = 'self', sections = DEFAULT_SECTIONS,
|
||||
title = '') {
|
||||
sections = sections
|
||||
.filter(section => (user === 'self' || !section.selfOnly))
|
||||
.map(section => Object.assign({}, section, {
|
||||
name: section.name,
|
||||
query: section.query.replace(USER_PLACEHOLDER_PATTERN, user),
|
||||
}));
|
||||
.filter(section => (user === 'self' || !section.selfOnly))
|
||||
.map(section => Object.assign({}, section, {
|
||||
name: section.name,
|
||||
query: section.query.replace(USER_PLACEHOLDER_PATTERN, user),
|
||||
}));
|
||||
return {title, sections};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ limitations under the License.
|
||||
assert.isTrue(
|
||||
element.reporter.calledWithExactly(
|
||||
'timing-report', 'UI Latency', 'App Started', 42
|
||||
));
|
||||
));
|
||||
});
|
||||
|
||||
test('WebComponentsReady', () => {
|
||||
|
||||
@@ -461,8 +461,8 @@
|
||||
// If there is a repo name provided, make sure to substitute it into the
|
||||
// ${repo} (or legacy ${project}) query tokens.
|
||||
const query = opt_repoName ?
|
||||
section.query.replace(REPO_TOKEN_PATTERN, opt_repoName) :
|
||||
section.query;
|
||||
section.query.replace(REPO_TOKEN_PATTERN, opt_repoName) :
|
||||
section.query;
|
||||
return encodeURIComponent(section.name) + '=' +
|
||||
encodeURIComponent(query);
|
||||
});
|
||||
|
||||
@@ -61,8 +61,8 @@ limitations under the License.
|
||||
|
||||
getActiveElement = () => {
|
||||
return document.activeElement.shadowRoot ?
|
||||
document.activeElement.shadowRoot.activeElement :
|
||||
document.activeElement;
|
||||
document.activeElement.shadowRoot.activeElement :
|
||||
document.activeElement;
|
||||
};
|
||||
|
||||
test('enter in search input fires event', done => {
|
||||
|
||||
@@ -144,8 +144,8 @@
|
||||
return accounts.map(account => ({
|
||||
label: account.name || '',
|
||||
text: account.email ?
|
||||
`${predicate}:${account.email}` :
|
||||
`${predicate}:"${this._accountOrAnon(account)}"`,
|
||||
`${predicate}:${account.email}` :
|
||||
`${predicate}:"${this._accountOrAnon(account)}"`,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -248,9 +248,9 @@
|
||||
const all = comments.concat(drafts).concat(robotComments);
|
||||
|
||||
const baseComments = all.filter(c =>
|
||||
this._isInBaseOfPatchRange(c, patchRange));
|
||||
this._isInBaseOfPatchRange(c, patchRange));
|
||||
const revisionComments = all.filter(c =>
|
||||
this._isInRevisionOfPatchRange(c, patchRange));
|
||||
this._isInRevisionOfPatchRange(c, patchRange));
|
||||
|
||||
return {
|
||||
meta: {
|
||||
@@ -348,7 +348,7 @@
|
||||
const threads = this.getCommentThreads(this._sortComments(comments));
|
||||
|
||||
const unresolvedThreads = threads
|
||||
.filter(thread =>
|
||||
.filter(thread =>
|
||||
thread.comments.length &&
|
||||
thread.comments[thread.comments.length - 1].unresolved);
|
||||
|
||||
@@ -491,7 +491,7 @@
|
||||
|
||||
return Promise.all(promises).then(([comments, robotComments, drafts]) => {
|
||||
this._changeComments = new ChangeComments(comments,
|
||||
robotComments, drafts, changeNum);
|
||||
robotComments, drafts, changeNum);
|
||||
return this._changeComments;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -109,7 +109,7 @@ limitations under the License.
|
||||
let draftStub;
|
||||
setup(() => {
|
||||
commentStub = sandbox.stub(element.$.restAPI, 'getDiffComments')
|
||||
.returns(Promise.resolve({}));
|
||||
.returns(Promise.resolve({}));
|
||||
robotCommentStub = sandbox.stub(element.$.restAPI,
|
||||
'getDiffRobotComments').returns(Promise.resolve({}));
|
||||
draftStub = sandbox.stub(element.$.restAPI, 'getDiffDrafts')
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
let tr = content.parentElement.parentElement;
|
||||
while (tr = tr.nextSibling) {
|
||||
if (tr.classList.contains('both') || (
|
||||
(side === 'left' && tr.classList.contains('remove')) ||
|
||||
(side === 'left' && tr.classList.contains('remove')) ||
|
||||
(side === 'right' && tr.classList.contains('add')))) {
|
||||
return tr.querySelector('.contentText');
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ limitations under the License.
|
||||
getLineNumberByChild(node) {
|
||||
const lineEl = this.getLineElByChild(node);
|
||||
return lineEl ?
|
||||
parseInt(lineEl.getAttribute('data-value'), 10) :
|
||||
null;
|
||||
parseInt(lineEl.getAttribute('data-value'), 10) :
|
||||
null;
|
||||
},
|
||||
|
||||
getContentByLine(lineNumber, opt_side, opt_root) {
|
||||
@@ -249,7 +249,7 @@ limitations under the License.
|
||||
|
||||
getSideByLineEl(lineEl) {
|
||||
return lineEl.classList.contains(GrDiffBuilder.Side.RIGHT) ?
|
||||
GrDiffBuilder.Side.RIGHT : GrDiffBuilder.Side.LEFT;
|
||||
GrDiffBuilder.Side.RIGHT : GrDiffBuilder.Side.LEFT;
|
||||
},
|
||||
|
||||
emitGroup(group, sectionEl) {
|
||||
@@ -304,7 +304,7 @@ limitations under the License.
|
||||
let builder = null;
|
||||
if (this.isImageDiff) {
|
||||
builder = new GrDiffBuilderImage(diff, prefs, this.diffElement,
|
||||
this.baseImage, this.revisionImage);
|
||||
this.baseImage, this.revisionImage);
|
||||
} else if (diff.binary) {
|
||||
// If the diff is binary, but not an image.
|
||||
return new GrDiffBuilderBinary(diff, prefs, this.diffElement);
|
||||
@@ -352,8 +352,8 @@ limitations under the License.
|
||||
|
||||
// If endIndex isn't present, continue to the end of the line.
|
||||
const endIndex = highlight.endIndex === undefined ?
|
||||
line.text.length :
|
||||
highlight.endIndex;
|
||||
line.text.length :
|
||||
highlight.endIndex;
|
||||
|
||||
GrAnnotation.annotateElement(
|
||||
contentEl,
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
continue;
|
||||
}
|
||||
const lineNumber = opt_side === 'left' ?
|
||||
line.beforeNumber : line.afterNumber;
|
||||
line.beforeNumber : line.afterNumber;
|
||||
if (lineNumber < start || lineNumber > end) { continue; }
|
||||
|
||||
if (out_lines) { out_lines.push(line); }
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
if (!this.diffRow) return null;
|
||||
|
||||
const hostOwner = Polymer.dom(/** @type {Node} */ (this.diffRow))
|
||||
.getOwnerRoot();
|
||||
.getOwnerRoot();
|
||||
if (hostOwner && hostOwner.host &&
|
||||
hostOwner.host.tagName === 'GR-DIFF') {
|
||||
return hostOwner.host;
|
||||
@@ -232,8 +232,8 @@
|
||||
if (!this.diffRow) {
|
||||
// does not scroll during init unless requested
|
||||
const scrollingBehaviorForInit = this.initialLineNumber ?
|
||||
ScrollBehavior.KEEP_VISIBLE :
|
||||
ScrollBehavior.NEVER;
|
||||
ScrollBehavior.KEEP_VISIBLE :
|
||||
ScrollBehavior.NEVER;
|
||||
this._scrollBehavior = scrollingBehaviorForInit;
|
||||
this.reInitCursor();
|
||||
}
|
||||
@@ -315,7 +315,7 @@
|
||||
if (this._getViewMode() === DiffViewMode.SIDE_BY_SIDE &&
|
||||
this._isTargetBlank()) {
|
||||
this.side = this.side === DiffSides.LEFT ?
|
||||
DiffSides.RIGHT : DiffSides.LEFT;
|
||||
DiffSides.RIGHT : DiffSides.LEFT;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -391,15 +391,15 @@
|
||||
splice = changeRecord.indexSplices[spliceIdx];
|
||||
|
||||
for (i = splice.index;
|
||||
i < splice.index + splice.addedCount;
|
||||
i++) {
|
||||
i < splice.index + splice.addedCount;
|
||||
i++) {
|
||||
this.listen(this.diffs[i], 'render-start', '_handleDiffRenderStart');
|
||||
this.listen(this.diffs[i], 'render-content', 'handleDiffUpdate');
|
||||
}
|
||||
|
||||
for (i = 0;
|
||||
i < splice.removed && splice.removed.length;
|
||||
i++) {
|
||||
i < splice.removed && splice.removed.length;
|
||||
i++) {
|
||||
this.unlisten(splice.removed[i],
|
||||
'render-start', '_handleDiffRenderStart');
|
||||
this.unlisten(splice.removed[i],
|
||||
|
||||
@@ -168,7 +168,7 @@ limitations under the License.
|
||||
assert.equal(layer4[0].textContent +
|
||||
layer4[1].textContent +
|
||||
layer4[2].textContent,
|
||||
layers[3]);
|
||||
layers[3]);
|
||||
});
|
||||
|
||||
test('splitTextNode', () => {
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
}
|
||||
|
||||
return this.commentRanges.findIndex(commentRange =>
|
||||
commentRange.side === side && rangesEqual(commentRange.range, range));
|
||||
commentRange.side === side && rangesEqual(commentRange.range, range));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -272,12 +272,12 @@ limitations under the License.
|
||||
};
|
||||
|
||||
const getActionRange = () =>
|
||||
Polymer.dom(element.root).querySelector(
|
||||
'gr-selection-action-box').range;
|
||||
Polymer.dom(element.root).querySelector(
|
||||
'gr-selection-action-box').range;
|
||||
|
||||
const getActionSide = () =>
|
||||
Polymer.dom(element.root).querySelector(
|
||||
'gr-selection-action-box').side;
|
||||
Polymer.dom(element.root).querySelector(
|
||||
'gr-selection-action-box').side;
|
||||
|
||||
const getLineElByChild = node => {
|
||||
const stubs = contentStubs.find(stub => stub.contentTd.contains(node));
|
||||
|
||||
@@ -512,7 +512,7 @@
|
||||
// digits. Diffs with no delta are considered 0%.
|
||||
const totalDelta = rebaseDelta + nonRebaseDelta;
|
||||
const percentRebaseDelta = !totalDelta ? 0 :
|
||||
Math.round(100 * rebaseDelta / totalDelta);
|
||||
Math.round(100 * rebaseDelta / totalDelta);
|
||||
|
||||
// Report the due_to_rebase percentage in the "diff" category when
|
||||
// applicable.
|
||||
@@ -589,7 +589,7 @@
|
||||
// thread and append to it.
|
||||
if (comment.in_reply_to) {
|
||||
const thread = threads.find(thread =>
|
||||
thread.comments.some(c => c.id === comment.in_reply_to));
|
||||
thread.comments.some(c => c.id === comment.in_reply_to));
|
||||
if (thread) {
|
||||
thread.comments.push(comment);
|
||||
continue;
|
||||
@@ -730,7 +730,7 @@
|
||||
}
|
||||
function matchesRange(threadEl) {
|
||||
const threadRange = /** @type {!Gerrit.Range} */(
|
||||
JSON.parse(threadEl.getAttribute('range')));
|
||||
JSON.parse(threadEl.getAttribute('range')));
|
||||
return Gerrit.rangesEqual(threadRange, range);
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@
|
||||
matchers.push(matchesFileComment);
|
||||
}
|
||||
return threadEls.filter(threadEl =>
|
||||
matchers.some(matcher => matcher(threadEl)));
|
||||
matchers.some(matcher => matcher(threadEl)));
|
||||
},
|
||||
|
||||
_getIgnoreWhitespace() {
|
||||
@@ -833,7 +833,7 @@
|
||||
*/
|
||||
_computeParentIndex(patchRangeRecord) {
|
||||
return this.isMergeParent(patchRangeRecord.base.basePatchNum) ?
|
||||
this.getParentIndex(patchRangeRecord.base.basePatchNum) : null;
|
||||
this.getParentIndex(patchRangeRecord.base.basePatchNum) : null;
|
||||
},
|
||||
|
||||
_handleCommentSave(e) {
|
||||
@@ -927,8 +927,8 @@
|
||||
if (!diff) return false;
|
||||
return diff.content.some(section => {
|
||||
const lines = section.ab ?
|
||||
section.ab :
|
||||
(section.a || []).concat(section.b || []);
|
||||
section.ab :
|
||||
(section.a || []).concat(section.b || []);
|
||||
return lines.some(line => line.length >= SYNTAX_MAX_LINE_LENGTH);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -509,7 +509,7 @@ limitations under the License.
|
||||
'getB64FileContents',
|
||||
(changeId, patchNum, path, opt_parentIndex) => {
|
||||
return Promise.resolve(opt_parentIndex === 1 ? mockFile1 :
|
||||
mockFile2);
|
||||
mockFile2);
|
||||
});
|
||||
|
||||
element.patchRange = {basePatchNum: 'PARENT', patchNum: 1};
|
||||
|
||||
@@ -290,7 +290,7 @@
|
||||
if (this.context !== WHOLE_FILE) {
|
||||
const hiddenStart = state.chunkIndex === 0 ? 0 : this.context;
|
||||
const hiddenEnd = lineCount - (
|
||||
firstUncollapsibleChunkIndex === chunks.length ?
|
||||
firstUncollapsibleChunkIndex === chunks.length ?
|
||||
0 : this.context);
|
||||
groups = GrDiffGroup.hideInContextControl(
|
||||
groups, hiddenStart, hiddenEnd);
|
||||
@@ -483,7 +483,7 @@
|
||||
|
||||
if (chunk.common && chunk.a.length != chunk.b.length) {
|
||||
throw new Error(
|
||||
'DiffContent with common=true must always have equal length');
|
||||
'DiffContent with common=true must always have equal length');
|
||||
}
|
||||
const numLines = this._commonChunkLength(chunk);
|
||||
const chunkEnds = this._findChunkEndsAtKeyLocations(
|
||||
@@ -494,7 +494,7 @@
|
||||
if (chunk.ab) {
|
||||
result.push(...this._splitAtChunkEnds(chunk.ab, chunkEnds)
|
||||
.map(({lines, keyLocation}) =>
|
||||
Object.assign({}, chunk, {ab: lines, keyLocation})));
|
||||
Object.assign({}, chunk, {ab: lines, keyLocation})));
|
||||
} else if (chunk.common) {
|
||||
const aChunks = this._splitAtChunkEnds(chunk.a, chunkEnds);
|
||||
const bChunks = this._splitAtChunkEnds(chunk.b, chunkEnds);
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
this._setClasses([
|
||||
SelectionClass.COMMENT,
|
||||
node.commentSide === 'left' ?
|
||||
SelectionClass.LEFT :
|
||||
SelectionClass.RIGHT,
|
||||
SelectionClass.LEFT :
|
||||
SelectionClass.RIGHT,
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
@@ -106,8 +106,8 @@
|
||||
const side = this.diffBuilder.getSideByLineEl(lineEl);
|
||||
|
||||
targetClasses.push(side === 'left' ?
|
||||
SelectionClass.LEFT :
|
||||
SelectionClass.RIGHT);
|
||||
SelectionClass.LEFT :
|
||||
SelectionClass.RIGHT);
|
||||
|
||||
if (commentSelected) {
|
||||
targetClasses.push(SelectionClass.COMMENT);
|
||||
|
||||
@@ -272,8 +272,8 @@
|
||||
const patchRange = patchRangeRecord.base;
|
||||
return this.$.restAPI.getChangeFilePathsAsSpeciallySortedArray(
|
||||
changeNum, patchRange).then(files => {
|
||||
this._fileList = files;
|
||||
});
|
||||
this._fileList = files;
|
||||
});
|
||||
},
|
||||
|
||||
_getDiffPreferences() {
|
||||
@@ -566,8 +566,8 @@
|
||||
let idx = fileList.indexOf(path);
|
||||
if (idx === -1) {
|
||||
const file = direction > 0 ?
|
||||
fileList[0] :
|
||||
fileList[fileList.length - 1];
|
||||
fileList[0] :
|
||||
fileList[fileList.length - 1];
|
||||
return {path: file};
|
||||
}
|
||||
|
||||
@@ -706,8 +706,8 @@
|
||||
// is specified.
|
||||
this._getReviewedStatus(this.editMode, this._changeNum,
|
||||
this._patchRange.patchNum, this._path).then(status => {
|
||||
this.$.reviewed.checked = status;
|
||||
});
|
||||
this.$.reviewed.checked = status;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,7 @@
|
||||
// so we resolve the right "next" file.
|
||||
const unreviewedFiles = this._fileList
|
||||
.filter(file =>
|
||||
(file === this._path || !this._reviewedFiles.has(file)));
|
||||
(file === this._path || !this._reviewedFiles.has(file)));
|
||||
this._navToFile(this._path, unreviewedFiles, 1);
|
||||
},
|
||||
|
||||
|
||||
@@ -269,28 +269,28 @@ limitations under the License.
|
||||
assert.isTrue(element._loading);
|
||||
assert(diffNavStub.lastCall.calledWithExactly(element._change,
|
||||
'wheatley.md', '10', '5'),
|
||||
'Should navigate to /c/42/5..10/wheatley.md');
|
||||
'Should navigate to /c/42/5..10/wheatley.md');
|
||||
element._path = 'wheatley.md';
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||
assert.isTrue(element._loading);
|
||||
assert(diffNavStub.lastCall.calledWithExactly(element._change,
|
||||
'glados.txt', '10', '5'),
|
||||
'Should navigate to /c/42/5..10/glados.txt');
|
||||
'Should navigate to /c/42/5..10/glados.txt');
|
||||
element._path = 'glados.txt';
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||
assert.isTrue(element._loading);
|
||||
assert(diffNavStub.lastCall.calledWithExactly(element._change, 'chell.go',
|
||||
'10', '5'),
|
||||
'Should navigate to /c/42/5..10/chell.go');
|
||||
'Should navigate to /c/42/5..10/chell.go');
|
||||
element._path = 'chell.go';
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||
assert.isTrue(element._loading);
|
||||
assert(changeNavStub.lastCall.calledWithExactly(element._change, '10',
|
||||
'5'),
|
||||
'Should navigate to /c/42/5..10');
|
||||
'Should navigate to /c/42/5..10');
|
||||
});
|
||||
|
||||
test('keyboard shortcuts with old patch number', () => {
|
||||
@@ -332,13 +332,13 @@ limitations under the License.
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 221, null, ']');
|
||||
assert(diffNavStub.lastCall.calledWithExactly(element._change,
|
||||
'wheatley.md', '1', PARENT),
|
||||
'Should navigate to /c/42/1/wheatley.md');
|
||||
'Should navigate to /c/42/1/wheatley.md');
|
||||
element._path = 'wheatley.md';
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||
assert(diffNavStub.lastCall.calledWithExactly(element._change,
|
||||
'glados.txt', '1', PARENT),
|
||||
'Should navigate to /c/42/1/glados.txt');
|
||||
'Should navigate to /c/42/1/glados.txt');
|
||||
element._path = 'glados.txt';
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 219, null, '[');
|
||||
|
||||
@@ -185,11 +185,11 @@
|
||||
|
||||
if (before.length) {
|
||||
beforeGroups.push(before.length === group.lines.length ?
|
||||
group : group.cloneWithLines(before));
|
||||
group : group.cloneWithLines(before));
|
||||
}
|
||||
if (after.length) {
|
||||
afterGroups.push(after.length === group.lines.length ?
|
||||
group : group.cloneWithLines(after));
|
||||
group : group.cloneWithLines(after));
|
||||
}
|
||||
}
|
||||
return [beforeGroups, afterGroups];
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
observer: '_viewModeObserver',
|
||||
},
|
||||
|
||||
/** @type ?Gerrit.LineOfInterest */
|
||||
/** @type ?Gerrit.LineOfInterest */
|
||||
lineOfInterest: Object,
|
||||
|
||||
loading: {
|
||||
@@ -332,8 +332,8 @@
|
||||
// up the diff, because they are in the shadow DOM of the gr-diff element.
|
||||
// This takes the shadow DOM selection if one exists.
|
||||
return this.root.getSelection ?
|
||||
this.root.getSelection() :
|
||||
document.getSelection();
|
||||
this.root.getSelection() :
|
||||
document.getSelection();
|
||||
},
|
||||
|
||||
_observeNodes() {
|
||||
@@ -535,8 +535,8 @@
|
||||
return false;
|
||||
}
|
||||
const patchNum = el.classList.contains(DiffSide.LEFT) ?
|
||||
this.patchRange.basePatchNum :
|
||||
this.patchRange.patchNum;
|
||||
this.patchRange.basePatchNum :
|
||||
this.patchRange.patchNum;
|
||||
|
||||
const isEdit = this.patchNumEquals(patchNum, this.EDIT_NAME);
|
||||
const isEditBase = this.patchNumEquals(patchNum, this.PARENT_NAME) &&
|
||||
@@ -903,8 +903,8 @@
|
||||
chunkIndex--;
|
||||
chunk = diff.content[chunkIndex];
|
||||
} while (
|
||||
// We haven't reached the beginning.
|
||||
chunkIndex >= 0 &&
|
||||
// We haven't reached the beginning.
|
||||
chunkIndex >= 0 &&
|
||||
|
||||
// The chunk doesn't have both sides.
|
||||
!chunk.ab &&
|
||||
|
||||
@@ -1070,7 +1070,7 @@ limitations under the License.
|
||||
/* loading= */ false,
|
||||
element.prefs,
|
||||
element._diffLength
|
||||
));
|
||||
));
|
||||
});
|
||||
|
||||
test('do not show the message if still loading', () => {
|
||||
@@ -1079,7 +1079,7 @@ limitations under the License.
|
||||
/* loading= */ true,
|
||||
element.prefs,
|
||||
element._diffLength
|
||||
));
|
||||
));
|
||||
});
|
||||
|
||||
test('do not show the message if contains valid changes', () => {
|
||||
@@ -1098,7 +1098,7 @@ limitations under the License.
|
||||
/* loading= */ false,
|
||||
element.prefs,
|
||||
element._diffLength
|
||||
));
|
||||
));
|
||||
});
|
||||
|
||||
test('do not show message if ignore whitespace is disabled', () => {
|
||||
@@ -1116,7 +1116,7 @@ limitations under the License.
|
||||
/* loading= */ false,
|
||||
element.prefs,
|
||||
element._diffLength
|
||||
));
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1129,7 +1129,7 @@ limitations under the License.
|
||||
element = fixture('basic');
|
||||
element.prefs = {};
|
||||
renderStub = sandbox.stub(element.$.diffBuilder, 'render')
|
||||
.returns(Promise.resolve());
|
||||
.returns(Promise.resolve());
|
||||
element.addEventListener('render', event => {
|
||||
assert.isTrue(event.detail.contentRendered);
|
||||
done();
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
const parentCounts = revisionInfo.getParentCountMap();
|
||||
const currentParentCount = parentCounts.hasOwnProperty(patchNum) ?
|
||||
parentCounts[patchNum] : 1;
|
||||
parentCounts[patchNum] : 1;
|
||||
const maxParents = revisionInfo.getMaxParents();
|
||||
const isMerge = currentParentCount > 1;
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
_computePatchSetDescription(revisions, patchNum, opt_addFrontSpace) {
|
||||
const rev = this.getRevisionByPatchNum(revisions, patchNum);
|
||||
return (rev && rev.description) ?
|
||||
(opt_addFrontSpace ? ' ' : '') +
|
||||
(opt_addFrontSpace ? ' ' : '') +
|
||||
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
|
||||
},
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ limitations under the License.
|
||||
assert.deepEqual(element._computeBaseDropdownContent(availablePatches,
|
||||
patchNum, sortedRevisions, element.changeComments,
|
||||
element.revisionInfo),
|
||||
expectedResult);
|
||||
expectedResult);
|
||||
});
|
||||
|
||||
test('_computeBaseDropdownContent called when patchNum updates', () => {
|
||||
@@ -344,7 +344,7 @@ limitations under the License.
|
||||
|
||||
assert.deepEqual(element._computePatchDropdownContent(availablePatches,
|
||||
basePatchNum, sortedRevisions, element.changeComments),
|
||||
expectedResult);
|
||||
expectedResult);
|
||||
});
|
||||
|
||||
test('filesWeblinks', () => {
|
||||
|
||||
@@ -66,12 +66,12 @@
|
||||
annotate(el, lineNumberEl, line) {
|
||||
let ranges = [];
|
||||
if (line.type === GrDiffLine.Type.REMOVE || (
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
el.getAttribute('data-side') !== 'right')) {
|
||||
ranges = ranges.concat(this._getRangesForLine(line, 'left'));
|
||||
}
|
||||
if (line.type === GrDiffLine.Type.ADD || (
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
el.getAttribute('data-side') !== 'left')) {
|
||||
ranges = ranges.concat(this._getRangesForLine(line, 'right'));
|
||||
}
|
||||
@@ -134,7 +134,7 @@
|
||||
this._updateRangesMap(
|
||||
side, range, hovering, (forLine, start, end, hovering) => {
|
||||
const index = forLine.findIndex(lineRange =>
|
||||
lineRange.start === start && lineRange.end === end);
|
||||
lineRange.start === start && lineRange.end === end);
|
||||
forLine[index].hovering = hovering;
|
||||
});
|
||||
}
|
||||
@@ -147,7 +147,7 @@
|
||||
this._updateRangesMap(
|
||||
side, range, hovering, (forLine, start, end) => {
|
||||
const index = forLine.findIndex(lineRange =>
|
||||
lineRange.start === start && lineRange.end === end);
|
||||
lineRange.start === start && lineRange.end === end);
|
||||
forLine.splice(index, 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,11 +191,11 @@
|
||||
// Determine the side.
|
||||
let side;
|
||||
if (line.type === GrDiffLine.Type.REMOVE || (
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
line.type === GrDiffLine.Type.BOTH &&
|
||||
el.getAttribute('data-side') !== 'right')) {
|
||||
side = 'left';
|
||||
} else if (line.type === GrDiffLine.Type.ADD || (
|
||||
el.getAttribute('data-side') !== 'left')) {
|
||||
el.getAttribute('data-side') !== 'left')) {
|
||||
side = 'right';
|
||||
}
|
||||
|
||||
|
||||
@@ -214,17 +214,17 @@
|
||||
const dialog = this._getDialogFromEvent(e);
|
||||
return this.$.restAPI.renameFileInChangeEdit(this.change._number,
|
||||
this._path, this._newPath).then(res => {
|
||||
if (!res.ok) { return; }
|
||||
this._closeDialog(dialog, true);
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
});
|
||||
if (!res.ok) { return; }
|
||||
this._closeDialog(dialog, true);
|
||||
Gerrit.Nav.navigateToChange(this.change);
|
||||
});
|
||||
},
|
||||
|
||||
_queryFiles(input) {
|
||||
return this.$.restAPI.queryChangeFiles(this.change._number,
|
||||
this.patchNum, input).then(res => res.map(file => {
|
||||
return {name: file};
|
||||
}));
|
||||
return {name: file};
|
||||
}));
|
||||
},
|
||||
|
||||
_computeIsInvisible(id, hiddenActions) {
|
||||
|
||||
@@ -192,8 +192,8 @@ suite('gr-edit-controls tests', () => {
|
||||
let renameStub;
|
||||
let renameAutocomplete;
|
||||
const inputSelector = Polymer.Element ?
|
||||
'.newPathIronInput' :
|
||||
'.newPathInput';
|
||||
'.newPathIronInput' :
|
||||
'.newPathInput';
|
||||
|
||||
setup(() => {
|
||||
navStub = sandbox.stub(Gerrit.Nav, 'navigateToChange');
|
||||
|
||||
@@ -141,11 +141,11 @@
|
||||
}
|
||||
return this.$.restAPI.renameFileInChangeEdit(this._changeNum,
|
||||
this._path, path).then(res => {
|
||||
if (!res.ok) { return; }
|
||||
if (!res.ok) { return; }
|
||||
|
||||
this._successfulSave = true;
|
||||
this._viewEditInChangeView();
|
||||
});
|
||||
this._successfulSave = true;
|
||||
this._viewEditInChangeView();
|
||||
});
|
||||
},
|
||||
|
||||
_viewEditInChangeView() {
|
||||
@@ -191,13 +191,13 @@
|
||||
this.$.storage.eraseEditableContentItem(this.storageKey);
|
||||
return this.$.restAPI.saveChangeEdit(this._changeNum, this._path,
|
||||
this._newContent).then(res => {
|
||||
this._saving = false;
|
||||
this._showAlert(res.ok ? SAVED_MESSAGE : SAVE_FAILED_MSG);
|
||||
if (!res.ok) { return; }
|
||||
this._saving = false;
|
||||
this._showAlert(res.ok ? SAVED_MESSAGE : SAVE_FAILED_MSG);
|
||||
if (!res.ok) { return; }
|
||||
|
||||
this._content = this._newContent;
|
||||
this._successfulSave = true;
|
||||
});
|
||||
this._content = this._newContent;
|
||||
this._successfulSave = true;
|
||||
});
|
||||
},
|
||||
|
||||
_showAlert(message) {
|
||||
|
||||
@@ -106,7 +106,7 @@ suite('gr-editor-view tests', () => {
|
||||
// Calling with the same path should not navigate.
|
||||
return element._handlePathChanged({detail: mockParams.path}).then(() => {
|
||||
assert.isFalse(savePathStub.called);
|
||||
// !ok response
|
||||
// !ok response
|
||||
element._handlePathChanged({detail: 'newPath'}).then(() => {
|
||||
assert.isTrue(savePathStub.called);
|
||||
assert.isFalse(navigateStub.called);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
this._createHook();
|
||||
}
|
||||
this._hook.onAttached(element =>
|
||||
this.plugin.attributeHelper(element).bind('labels', callback));
|
||||
this.plugin.attributeHelper(element).bind('labels', callback));
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
@@ -95,15 +95,15 @@
|
||||
return helper.get('value').then(
|
||||
value => helper.bind('value',
|
||||
value => plugin.attributeHelper(el).set(paramName, value))
|
||||
);
|
||||
);
|
||||
});
|
||||
let timeoutId;
|
||||
const timeout = new Promise(
|
||||
resolve => timeoutId = setTimeout(() => {
|
||||
console.warn(
|
||||
'Timeout waiting for endpoint properties initialization: ' +
|
||||
resolve => timeoutId = setTimeout(() => {
|
||||
console.warn(
|
||||
'Timeout waiting for endpoint properties initialization: ' +
|
||||
`plugin ${plugin.getPluginName()}, endpoint ${this.name}`);
|
||||
}, INIT_PROPERTIES_TIMEOUT_MS));
|
||||
}, INIT_PROPERTIES_TIMEOUT_MS));
|
||||
return Promise.race([timeout, Promise.all(expectProperties)])
|
||||
.then(() => {
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
@@ -46,17 +46,17 @@
|
||||
if (!this._openingPromise) {
|
||||
this._openingPromise =
|
||||
this.plugin.hook('plugin-overlay').getLastAttached()
|
||||
.then(hookEl => {
|
||||
const popup = document.createElement('gr-plugin-popup');
|
||||
if (this._moduleName) {
|
||||
const el = Polymer.dom(popup).appendChild(
|
||||
document.createElement(this._moduleName));
|
||||
el.plugin = this.plugin;
|
||||
}
|
||||
this._popup = Polymer.dom(hookEl).appendChild(popup);
|
||||
Polymer.dom.flush();
|
||||
return this._popup.open().then(() => this);
|
||||
});
|
||||
.then(hookEl => {
|
||||
const popup = document.createElement('gr-plugin-popup');
|
||||
if (this._moduleName) {
|
||||
const el = Polymer.dom(popup).appendChild(
|
||||
document.createElement(this._moduleName));
|
||||
el.plugin = this.plugin;
|
||||
}
|
||||
this._popup = Polymer.dom(hookEl).appendChild(popup);
|
||||
Polymer.dom.flush();
|
||||
return this._popup.open().then(() => this);
|
||||
});
|
||||
}
|
||||
return this._openingPromise;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
*/
|
||||
GrStyleObject.prototype.getClassName = function(element) {
|
||||
let rootNode = Polymer.Settings.useShadow
|
||||
? element.getRootNode() : document.body;
|
||||
? element.getRootNode() : document.body;
|
||||
if (rootNode === document) {
|
||||
rootNode = document.head;
|
||||
}
|
||||
|
||||
@@ -127,20 +127,20 @@
|
||||
|
||||
_maybeSetName() {
|
||||
return this._hasNameChange && this.nameMutable ?
|
||||
this.$.restAPI.setAccountName(this._account.name) :
|
||||
Promise.resolve();
|
||||
this.$.restAPI.setAccountName(this._account.name) :
|
||||
Promise.resolve();
|
||||
},
|
||||
|
||||
_maybeSetUsername() {
|
||||
return this._hasUsernameChange && this.usernameMutable ?
|
||||
this.$.restAPI.setAccountUsername(this._username) :
|
||||
Promise.resolve();
|
||||
this.$.restAPI.setAccountUsername(this._username) :
|
||||
Promise.resolve();
|
||||
},
|
||||
|
||||
_maybeSetStatus() {
|
||||
return this._hasStatusChange ?
|
||||
this.$.restAPI.setAccountStatus(this._account.status) :
|
||||
Promise.resolve();
|
||||
this.$.restAPI.setAccountStatus(this._account.status) :
|
||||
Promise.resolve();
|
||||
},
|
||||
|
||||
_computeHasUnsavedChanges(nameChanged, usernameChanged, statusChanged) {
|
||||
|
||||
@@ -152,7 +152,7 @@ limitations under the License.
|
||||
usernameChangedSpy = sandbox.spy(element, '_usernameChanged');
|
||||
statusChangedSpy = sandbox.spy(element, '_statusChanged');
|
||||
element.set('_serverConfig',
|
||||
{auth: {editable_account_fields: ['FULL_NAME', 'USER_NAME']}});
|
||||
{auth: {editable_account_fields: ['FULL_NAME', 'USER_NAME']}});
|
||||
|
||||
nameStub = sandbox.stub(element.$.restAPI, 'setAccountName',
|
||||
name => Promise.resolve());
|
||||
@@ -280,7 +280,7 @@ limitations under the License.
|
||||
setup(() => {
|
||||
statusChangedSpy = sandbox.spy(element, '_statusChanged');
|
||||
element.set('_serverConfig',
|
||||
{auth: {editable_account_fields: []}});
|
||||
{auth: {editable_account_fields: []}});
|
||||
|
||||
statusStub = sandbox.stub(element.$.restAPI, 'setAccountStatus',
|
||||
status => Promise.resolve());
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
_hideAggreements(item, groups, signedAgreements) {
|
||||
return this._disableAggreements(item, groups, signedAgreements) ?
|
||||
'' : 'hide';
|
||||
'' : 'hide';
|
||||
},
|
||||
|
||||
_disableAgreementsText(text) {
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
return;
|
||||
}
|
||||
this._keys = Object.keys(keys)
|
||||
.map(key => {
|
||||
const gpgKey = keys[key];
|
||||
gpgKey.id = key;
|
||||
return gpgKey;
|
||||
});
|
||||
.map(key => {
|
||||
const gpgKey = keys[key];
|
||||
gpgKey.id = key;
|
||||
return gpgKey;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
_inputTextChanged(text) {
|
||||
if (text.length && this.allowAnyInput) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
'account-text-changed', {bubbles: true, composed: true}));
|
||||
'account-text-changed', {bubbles: true, composed: true}));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ limitations under the License.
|
||||
|
||||
test('account-text-changed not fired when input text changed without ' +
|
||||
'allowAnyInput', () => {
|
||||
// Spy on query, as that is called when _updateSuggestions proceeds.
|
||||
// Spy on query, as that is called when _updateSuggestions proceeds.
|
||||
const changeStub = sandbox.stub();
|
||||
element.querySuggestions = input => Promise.resolve([]);
|
||||
element.addEventListener('account-text-changed', changeStub);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user