Upgrade gr-editor-view to use patchNum param
Bug: Issue 4437 Change-Id: Idc1a35147cb64554a6a2d157b1b39bc0c1ffb277
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
_change: Object,
|
||||
_changeEditDetail: Object,
|
||||
_changeNum: String,
|
||||
_patchNum: String,
|
||||
_path: String,
|
||||
_type: String,
|
||||
_content: String,
|
||||
@@ -88,6 +89,7 @@
|
||||
|
||||
this._changeNum = value.changeNum;
|
||||
this._path = value.path;
|
||||
this._patchNum = value.patchNum || this.EDIT_NAME;
|
||||
|
||||
// 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
|
||||
@@ -100,7 +102,8 @@
|
||||
const promises = [];
|
||||
|
||||
promises.push(this._getChangeDetail(this._changeNum));
|
||||
promises.push(this._getFileData(this._changeNum, this._path));
|
||||
promises.push(
|
||||
this._getFileData(this._changeNum, this._path, this._patchNum));
|
||||
return Promise.all(promises);
|
||||
},
|
||||
|
||||
@@ -124,8 +127,8 @@
|
||||
Gerrit.Nav.navigateToChange(this._change, this.EDIT_NAME);
|
||||
},
|
||||
|
||||
_getFileData(changeNum, path) {
|
||||
return this.$.restAPI.getFileContent(changeNum, path, this.EDIT_NAME)
|
||||
_getFileData(changeNum, path, patchNum) {
|
||||
return this.$.restAPI.getFileContent(changeNum, path, patchNum)
|
||||
.then(res => {
|
||||
if (!res.ok) { return; }
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ suite('gr-editor-view tests', () => {
|
||||
const mockParams = {
|
||||
changeNum: '42',
|
||||
path: 'foo/bar.baz',
|
||||
patchNum: 'edit',
|
||||
};
|
||||
|
||||
setup(() => {
|
||||
@@ -83,7 +84,7 @@ suite('gr-editor-view tests', () => {
|
||||
assert.deepEqual(changeDetailStub.lastCall.args[0],
|
||||
mockParams.changeNum);
|
||||
assert.deepEqual(fileStub.lastCall.args,
|
||||
[mockParams.changeNum, mockParams.path]);
|
||||
[mockParams.changeNum, mockParams.path, mockParams.patchNum]);
|
||||
|
||||
return promises.then(() => {
|
||||
assert.equal(element._content, 'text');
|
||||
@@ -227,7 +228,7 @@ suite('gr-editor-view tests', () => {
|
||||
}));
|
||||
|
||||
// Ensure no data is set with a bad response.
|
||||
return element._getFileData('1', 'test/path').then(() => {
|
||||
return element._getFileData('1', 'test/path', 'edit').then(() => {
|
||||
assert.equal(element._newContent, 'new content');
|
||||
assert.equal(element._content, 'new content');
|
||||
assert.equal(element._type, 'text/javascript');
|
||||
@@ -239,7 +240,7 @@ suite('gr-editor-view tests', () => {
|
||||
.returns(Promise.resolve({}));
|
||||
|
||||
// Ensure no data is set with a bad response.
|
||||
return element._getFileData('1', 'test/path').then(() => {
|
||||
return element._getFileData('1', 'test/path', 'edit').then(() => {
|
||||
assert.equal(element._newContent, 'initial');
|
||||
assert.equal(element._content, 'initial');
|
||||
assert.equal(element._type, 'initial');
|
||||
@@ -253,7 +254,7 @@ suite('gr-editor-view tests', () => {
|
||||
type: 'text/javascript',
|
||||
}));
|
||||
|
||||
return element._getFileData('1', 'test/path').then(() => {
|
||||
return element._getFileData('1', 'test/path', 'edit').then(() => {
|
||||
assert.equal(element._newContent, '');
|
||||
assert.equal(element._content, '');
|
||||
assert.equal(element._type, 'text/javascript');
|
||||
@@ -266,7 +267,7 @@ suite('gr-editor-view tests', () => {
|
||||
ok: true,
|
||||
}));
|
||||
|
||||
return element._getFileData('1', 'test/path').then(() => {
|
||||
return element._getFileData('1', 'test/path', 'edit').then(() => {
|
||||
assert.equal(element._newContent, '');
|
||||
assert.equal(element._content, '');
|
||||
assert.equal(element._type, '');
|
||||
|
||||
Reference in New Issue
Block a user