summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/log/line_number.vue
blob: c8ceac2c7ffc655d0ed5e55c4f3a71a4965c5b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script>
import { INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF } from '../../constants';

export default {
  functional: true,
  props: {
    lineNumber: {
      type: Number,
      required: true,
    },
    path: {
      type: String,
      required: true,
    },
  },
  render(h, { props }) {
    const { lineNumber, path } = props;

    const parsedLineNumber = gon.features?.[INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF]
      ? lineNumber
      : lineNumber + 1;
    const lineId = `L${parsedLineNumber}`;
    const lineHref = `${path}#${lineId}`;

    return h(
      'a',
      {
        class: 'gl-link d-inline-block text-right line-number flex-shrink-0',
        attrs: {
          id: lineId,
          href: lineHref,
        },
      },
      parsedLineNumber,
    );
  },
};
</script>