Skip to content

Scroll to job line from URL hash

Payton Burdette requested to merge 211793-fix-job-link-scroll-bottom-bug into master

What does this MR do and why?

URLs like https://gitlab.com/gitlab-org/gitlab/-/jobs/4080590653#L47 with a hash previously always scrolled to the bottom of the job log. The hash was not taken into account. This MR grabs the hash and scrolls to the line number if a hash exists. If a hash exists and their are collapsed sections, we expand the sections before hand to ensure line numbers are rendered in the DOM.

Screenshots or screen recordings

Screen_Shot_2023-04-07_at_2.07.06_PM

How to set up and validate locally

  1. Have a job with a large log output
  2. Visit the job with a line number hash (should scroll to hash)
  3. Visit the job without a line number hash (should scroll to end of log)
  4. Visit a line within a collapsed section (should open section and scroll to line)

Example of custom collapsed section with large output. Note sometimes collapsed sections like this don't play nice with local shell runner, I had to setup a docker runner for this to render correctly.

large_log_output:
    stage: build
    script:
        - echo -e "\e[0Ksection_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
        - cat README.md
        - echo -e "\e[0Ksection_end:`date +%s`:my_first_section\r\e[0K"
        - echo "hello world!"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #211793 (closed)

Edited by Payton Burdette

Merge request reports