Remove the `loading` feature from the file-list It hinders the migration of the file-list to using the files model. Well, it makes it more complicated. The benefit of the `loading` feature is to just overlay the file list with opacity:0.5. Loading files is extremely fast, so it is actually hard to see any instances of this overlay apart from a quick flash. I think we could also just wipe the list of files while loading. Or if we feel there was a benefit after all, then we can bring back the feature after the migration to files model. Release-Notes: skip Change-Id: I227c72560731f922005b57d58faffe478ffbaccd
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 8f5d4f9..3b3f1c5 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
@@ -17,7 +17,7 @@ import '../../shared/gr-tooltip-content/gr-tooltip-content'; import '../../shared/gr-copy-clipboard/gr-copy-clipboard'; import '../../shared/gr-file-status-chip/gr-file-status-chip'; -import {asyncForeach, debounce, DelayedTask} from '../../../utils/async-util'; +import {asyncForeach} from '../../../utils/async-util'; import {FilesExpandedState} from '../gr-file-list-constants'; import {pluralize} from '../../../utils/string-util'; import {GerritNav} from '../../core/gr-navigation/gr-navigation'; @@ -82,7 +82,6 @@ export const DEFAULT_NUM_FILES_SHOWN = 200; const WARN_SHOW_ALL_THRESHOLD = 1000; -const LOADING_DEBOUNCE_INTERVAL = 100; const SIZE_BAR_MAX_WIDTH = 61; const SIZE_BAR_GAP_WIDTH = 1; @@ -244,9 +243,6 @@ @state() displayLine?: boolean; - @state() - loading?: boolean; - // Private but used in tests. @state() showSizeBars = true; @@ -263,8 +259,6 @@ private cancelForEachDiff?: () => void; - loadingTask?: DelayedTask; - @state() private dynamicHeaderEndpoints?: string[]; @@ -334,9 +328,6 @@ /* inline-block instead of block, such that it can control width */ display: inline-block; } - :host(.loading) .row { - opacity: 0.5; - } :host(.editMode) .hideOnEdit { display: none; } @@ -737,16 +728,11 @@ changedProperties.has('filesByPath') || changedProperties.has('changeComments') || changedProperties.has('patchRange') || - changedProperties.has('reviewed') || - changedProperties.has('loading') + changedProperties.has('reviewed') ) { changedProperties.set('files', this.files); this.computeFiles(); } - if (changedProperties.has('loading')) { - // Should run after files has been updated. - this.loadingChanged(); - } if (changedProperties.has('files')) { this.filesChanged(); } @@ -822,7 +808,6 @@ this.diffCursor?.dispose(); this.fileCursor.unsetCursor(); this.cancelDiffs(); - this.loadingTask?.cancel(); for (const cleanup of this.cleanups) cleanup(); this.cleanups = []; super.disconnectedCallback(); @@ -1404,7 +1389,6 @@ async reload() { if (!this.changeNum || !this.patchRange?.patchNum) return; - this.loading = true; this.collapseAllDiffs(); this.filesByPath = await this.restApiService.getChangeOrEditFiles( @@ -1412,7 +1396,6 @@ this.patchRange ); - this.loading = false; this.detectChromiteButler(); this.reporting.fileListDisplayed(); } @@ -2024,15 +2007,12 @@ this.filesByPath === undefined || this.changeComments === undefined || this.patchRange === undefined || - this.reviewed === undefined || - this.loading === undefined + this.reviewed === undefined ) { return; } // Await all promises resolving from reload. @See Issue 9057 - if (this.loading || !this.changeComments) { - return; - } + if (!this.changeComments) return; const commentedPaths = this.changeComments.getPaths(this.patchRange); const files: FileNameToReviewedFileInfoMap = {...this.filesByPath}; addUnmodifiedFiles(files, commentedPaths); @@ -2292,24 +2272,6 @@ this.displayLine = false; } - /** - * Update the loading class for the file list rows. The update is inside a - * debouncer so that the file list doesn't flash gray when the API requests - * are reasonably fast. - */ - private loadingChanged() { - const loading = this.loading; - this.loadingTask = debounce( - this.loadingTask, - () => { - // Only show set the loading if there have been files loaded to show. In - // this way, the gray loading style is not shown on initial loads. - this.classList.toggle('loading', loading && !!this.files.length); - }, - LOADING_DEBOUNCE_INTERVAL - ); - } - private computeReviewedClass(isReviewed?: boolean) { return isReviewed ? 'isReviewed' : ''; }
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts index ab7089a..83033bf 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.ts
@@ -22,12 +22,10 @@ EDIT, NumericChangeId, PARENT, - PatchRange, RepoName, RevisionPatchSetNum, Timestamp, UrlEncodedCommentId, - FileNameToFileInfoMap, } from '../../../types/common'; import {createCommentThreads} from '../../../utils/comment-util'; import { @@ -90,7 +88,6 @@ element = basicFixture.instantiate(); - element.loading = false; element.diffPrefs = { context: 10, tab_size: 8, @@ -1504,57 +1501,6 @@ assert.isTrue(reviewStub.calledWithExactly('p', true)); }); - test('loadingChanged fired from reload in debouncer', async () => { - const reloadBlocker = mockPromise<FileNameToFileInfoMap | undefined>(); - stubRestApi('getChangeOrEditFiles').returns( - reloadBlocker.then(() => { - return {'foo.bar': {size: 0, size_delta: 0}}; - }) - ); - stubRestApi('getReviewedFiles').resolves(undefined); - stubRestApi('getDiffPreferences').resolves(createDefaultDiffPrefs()); - - element.changeNum = 123 as NumericChangeId; - element.patchRange = {patchNum: 12 as RevisionPatchSetNum} as PatchRange; - element.filesByPath = {'foo.bar': {size: 0, size_delta: 0}}; - element.change = { - ...createParsedChange(), - _number: 123 as NumericChangeId, - }; - await element.updateComplete; - await flush(); - - const reloaded = element.reload(); - await element.updateComplete; - assert.isTrue(element.loading); - assert.isFalse(element.classList.contains('loading')); - element.loadingTask!.flush(); - assert.isTrue(element.classList.contains('loading')); - - reloadBlocker.resolve(); - await reloaded; - - assert.isFalse(element.loading); - element.loadingTask!.flush(); - assert.isFalse(element.classList.contains('loading')); - }); - - test('loadingChanged does not set class when there are no files', () => { - element.changeNum = 123 as NumericChangeId; - element.patchRange = {patchNum: 12 as RevisionPatchSetNum} as PatchRange; - element.change = { - ...createParsedChange(), - _number: 123 as NumericChangeId, - }; - element.reload(); - - assert.isTrue(element.loading); - - element.loadingTask!.flush(); - - assert.isFalse(element.classList.contains('loading')); - }); - suite('for merge commits', () => { let filesStub: sinon.SinonStub; @@ -2024,7 +1970,6 @@ }; reviewFileStub = sinon.stub(element, 'reviewFile'); - element.loading = false; element.numFilesShown = 75; element.selectedIndex = 0; element.filesByPath = {