Welcome to mirror list, hosted at ThFree Co, Russian Federation.

line.vue « log « components « job_details « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 416f75372f9c56ced040a3ea1df655fc0b6f0647 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!-- eslint-disable vue/multi-word-component-names -->
<script>
import { getLocationHash } from '~/lib/utils/url_utility';
import { linkRegex } from './utils';
import LineNumber from './line_number.vue';

export default {
  functional: true,
  props: {
    line: {
      type: Object,
      required: true,
    },
    path: {
      type: String,
      required: true,
    },
    isHighlighted: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  render(h, { props }) {
    const { line, path, isHighlighted } = props;

    const chars = line.content.map((content) => {
      return h(
        'span',
        {
          class: ['gl-white-space-pre-wrap', content.style],
        },
        // Simple "tokenization": Split text in chunks of text
        // which alternate between text and urls.
        content.text.split(linkRegex).map((chunk) => {
          // Return normal string for non-links
          if (!chunk.match(linkRegex)) {
            return chunk;
          }
          return h(
            'a',
            {
              attrs: {
                href: chunk,
                class: 'gl-reset-color! gl-text-decoration-underline',
                rel: 'nofollow noopener noreferrer', // eslint-disable-line @gitlab/require-i18n-strings
              },
            },
            chunk,
          );
        }),
      );
    });

    let applyHashHighlight = false;

    if (window.location.hash) {
      const hash = getLocationHash();
      const lineToMatch = `L${line.lineNumber}`;

      if (hash === lineToMatch) {
        applyHashHighlight = true;
      }
    }

    return h(
      'div',
      {
        class: [
          'js-log-line',
          'log-line',
          { 'gl-bg-gray-700': isHighlighted || applyHashHighlight },
        ],
      },
      [
        h(LineNumber, {
          props: {
            lineNumber: line.lineNumber,
            path,
          },
        }),
        ...chars,
      ],
    );
  },
};
</script>