buildkite / frontend

🌏 The front-end application code for https://buildkite.com
MIT License
137 stars 27 forks source link

Implement a handler for job link clicks within build annotations #744

Closed ticky closed 5 years ago

ticky commented 5 years ago

It’s been a long time coming, and probably should’ve been part of the round of annotation improvements we launched a while back, but here it is.

This adds a click handler to annotations, at the top level (so we don’t mess with the html content client-side!), which;

  1. Checks for modifier keys
  2. Ignores non-anchor elements, or anchor elements with no href
  3. Checks the URL, ignoring the hash, matches the current URL
  4. Checks a job matching the hash exists on the page
  5. If we get here, emits a job:focus event in the same way the build header does, and the job is expanded and scrolled to!

👩🏻‍🍳👌🏼

sj26 commented 5 years ago

Omg yes please amazing!!!

keithpitt commented 5 years ago

This great, peeps are gonna love it!

ticky commented 5 years ago

📆🚢

plasticine commented 5 years ago

@ticky Sorry to be a pain, but I’m not sure what this does 🙃 Is it just that you can click links in an annotation? Sorry, clearly I’m missing some context on what this change actually is.

keithpitt commented 5 years ago

(I'm driving by this PR so I'll hop in)

Here's an annotation with an RSpec failure:

image

And the link's HTML is this:

<a href="https://buildkite.com/buildkite/buildkite/builds/20574#c9f62f17-fc09-4a33-a2db-e5db079dfdbb">Job #c9f62f17-fc09-4a33-a2db-e5db079dfdbb</a>

But it doesn't actually take you to the job or expand it. This change just makes it so if you click on a link in an annotation that looks like a reference to a job, we'll do the #righthing.

plasticine commented 5 years ago

@keithpitt Ahhhh, yeah I see — very cool! Thanks!