Merge "Remove property _showInlineDiff"
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index b8f01de..40a2e1f 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -227,9 +227,6 @@
@property({type: Object, notify: true, observer: '_updateDiffPreferences'})
diffPrefs?: DiffPreferencesInfo;
- @property({type: Boolean})
- _showInlineDiffs?: boolean;
-
@property({type: Number, notify: true})
numFilesShown: number = DEFAULT_NUM_FILES_SHOWN;
@@ -629,8 +626,6 @@
}
expandAllDiffs() {
- this._showInlineDiffs = true;
-
// Find the list of paths that are in the file list, but not in the
// expanded list.
const newFiles: PatchSetFile[] = [];
@@ -646,7 +641,6 @@
}
collapseAllDiffs() {
- this._showInlineDiffs = false;
this._expandedFiles = [];
this.filesExpanded = this._computeExpandedFiles(
this._expandedFiles.length,
@@ -950,7 +944,7 @@
return;
}
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
e.preventDefault();
this.diffCursor.moveDown();
this._displayLine = true;
@@ -970,7 +964,7 @@
return;
}
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
e.preventDefault();
this.diffCursor.moveUp();
this._displayLine = true;
@@ -1020,7 +1014,7 @@
}
e.preventDefault();
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
this._openCursorFile();
return;
}
@@ -1086,7 +1080,7 @@
}
_toggleInlineDiffs() {
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
this.collapseAllDiffs();
} else {
this.expandAllDiffs();
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
index 4acf245..b8c6cde 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
@@ -593,7 +593,8 @@
for (const diff of element.diffs) {
assert.isTrue(element._expandedFiles.some(f => f.path === diff.path));
}
-
+ // since _expandedFilesChanged is stubbed
+ element.filesExpanded = FilesExpandedState.ALL;
MockInteractions.keyUpOn(element, 73, 'shift', 'i');
flush();
assert.equal(element.diffs.length, 0);
@@ -653,17 +654,17 @@
});
test('open from selected file', () => {
- element._showInlineDiffs = false;
+ element.filesExpanded = FilesExpandedState.NONE;
assert.deepEqual(interact(), {opened_selected: true});
});
test('open from diff cursor', () => {
- element._showInlineDiffs = true;
+ element.filesExpanded = FilesExpandedState.ALL;
assert.deepEqual(interact(), {opened_cursor: true});
});
test('expand when user prefers', () => {
- element._showInlineDiffs = false;
+ element.filesExpanded = FilesExpandedState.NONE;
assert.deepEqual(interact(), {opened_selected: true});
element._userPrefs = {};
assert.deepEqual(interact(), {opened_selected: true});
@@ -929,14 +930,14 @@
element._filesByPath = {[path]: {}};
element.expandAllDiffs();
flush();
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
assert.isTrue(reInitStub.calledOnce);
assert.equal(collapseStub.lastCall.args[0].length, 0);
element.collapseAllDiffs();
flush();
assert.equal(element._expandedFiles.length, 0);
- assert.isFalse(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.NONE);
assert.isTrue(cursorUpdateStub.calledOnce);
assert.equal(collapseStub.lastCall.args[0].length, 1);
});
@@ -1699,7 +1700,7 @@
// This is also called in diffCursor.moveToFirstChunk.
assert.equal(nextChunkStub.callCount, 1);
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
});
test('n key without all files expanded and no shift key', async () => {
@@ -1712,7 +1713,7 @@
// This is also called in diffCursor.moveToFirstChunk.
assert.equal(nextChunkStub.callCount, 0);
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
});
});
@@ -1736,7 +1737,7 @@
.callsFake(() => false);
sinon.stub(element, 'modifierPressed')
.callsFake(() => false);
- element._showInlineDiffs = true;
+ element.filesExpanded = FilesExpandedState.ALL;
const mockEvent = {preventDefault() {}};
element._displayLine = false;