Move blame information into diff model
And only render blame cells, if the blame column is explicitly enabled.
Stop using a `display:none` css rule for that.
This also means removing one usage of the ugly `querySelector` based
`findRow()` lookup.
Release-Notes: skip
Change-Id: I26a860a705238e1c979d455535b59049ee628952
diff --git a/polygerrit-ui/app/embed/diff/gr-diff/gr-diff-utils.ts b/polygerrit-ui/app/embed/diff/gr-diff/gr-diff-utils.ts
index 219f16e..6dc292e 100644
--- a/polygerrit-ui/app/embed/diff/gr-diff/gr-diff-utils.ts
+++ b/polygerrit-ui/app/embed/diff/gr-diff/gr-diff-utils.ts
@@ -3,7 +3,7 @@
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
-import {CommentRange} from '../../../types/common';
+import {BlameInfo, CommentRange} from '../../../types/common';
import {Side, SpecialFilePath} from '../../../constants/constants';
import {
DiffContextExpandedExternalDetail,
@@ -462,3 +462,10 @@
groups: GrDiffGroup[];
numLines: number;
}
+
+export function findBlame(blameInfos: BlameInfo[], line?: LineNumber) {
+ if (typeof line !== 'number') return undefined;
+ return blameInfos.find(info =>
+ info.ranges.find(range => range.start <= line && line <= range.end)
+ );
+}