Skip to content

Commit b991078

Browse files
authored
Highlight deep-linked log line (#833)
1 parent 1065330 commit b991078

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLine.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,14 @@ export const ConsoleLine = memo(function ConsoleLine(props: ConsoleLineProps) {
3535
className="console-output-line"
3636
key={`console-line-pre${props.lineNumber}`}
3737
>
38-
<div
39-
className="console-output-line-anchor"
40-
id={`log-${props.lineNumber}`}
41-
key={`${props.lineNumber}-anchor`}
42-
/>
4338
<div
4439
className="console-output-line"
4540
key={`${props.lineNumber}-body`}
4641
ref={ref}
4742
>
4843
<a
4944
className="console-line-number"
45+
id={`log-${props.lineNumber}`}
5046
href={`?start-byte=${props.startByte}&selected-node=${props.stepId}#log-${props.lineNumber}`}
5147
style={{
5248
width: Math.max(9 * String(props.lineNumber).length, 30) + "px",

src/main/frontend/pipeline-console-view/pipeline-console/main/ConsoleLogStream.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default function ConsoleLogStream(props: ConsoleLogStreamProps) {
8181
const element = document.getElementById(`log-${lineNumber}`);
8282
if (element) {
8383
element.scrollIntoView({ behavior: "smooth", block: "center" });
84+
const hash = location.hash;
85+
location.hash = "";
86+
location.hash = hash;
8487
}
8588
}
8689
}, []);

src/main/frontend/pipeline-console-view/pipeline-console/main/console-log-card.scss

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,39 @@ pre.console-output-line {
124124

125125
a.console-line-number {
126126
text-align: right;
127-
margin-right: 14px;
127+
margin-right: 0.875rem;
128128
color: var(--text-color-secondary);
129129
white-space: nowrap;
130130
display: inline-block;
131131
flex-shrink: 0;
132132
user-select: none;
133-
}
133+
outline: none;
134134

135-
div.console-output-line-anchor {
136-
position: relative;
137-
// This is the width of the '.jenkins-breadcrumbs' div + a little extra.
138-
top: -50px;
139-
visibility: hidden;
135+
&:target {
136+
text-decoration: none;
137+
scroll-margin-top: calc(var(--pgv-header-height) + 3.4375rem);
138+
}
140139
}
141140

142141
div.console-output-line {
143142
position: relative;
144143
display: flex;
145144
padding-block: 2px;
145+
z-index: 0;
146+
147+
&:has(:target) {
148+
&::before {
149+
background-color: color-mix(
150+
in srgb,
151+
var(--blue) 15%,
152+
transparent
153+
) !important;
154+
// TODO - var fallback can removed after baseline is moved >= 2.496
155+
border: var(--jenkins-border-width, 2px) solid
156+
color-mix(in srgb, var(--blue) 10%, transparent);
157+
opacity: 1;
158+
}
159+
}
146160

147161
&::before {
148162
content: "";
@@ -160,6 +174,7 @@ div.console-output-line {
160174
opacity: 0;
161175
transition: opacity var(--standard-transition);
162176
pointer-events: none;
177+
z-index: -1;
163178
}
164179

165180
&:hover {

0 commit comments

Comments
 (0)