Commit d7f6eeec authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'psi-funtional-line-component' into 'master'

Speed up job log rendering

See merge request gitlab-org/gitlab!35504
parents 3506a3a3 f49d43c3
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
import LineNumber from './line_number.vue'; import LineNumber from './line_number.vue';
export default { export default {
components: { functional: true,
LineNumber,
},
props: { props: {
line: { line: {
type: Object, type: Object,
...@@ -15,18 +13,28 @@ export default { ...@@ -15,18 +13,28 @@ export default {
required: true, required: true,
}, },
}, },
render(h, { props }) {
const { line, path } = props;
const chars = line.content.map(content => {
return h(
'span',
{
class: ['ws-pre-wrap', content.style],
},
content.text,
);
});
return h('div', { class: 'js-line log-line' }, [
h(LineNumber, {
props: {
lineNumber: line.lineNumber,
path,
},
}),
...chars,
]);
},
}; };
</script> </script>
<template>
<div class="js-line log-line">
<line-number :line-number="line.lineNumber" :path="path" />
<span
v-for="(content, i) in line.content"
:key="i"
:class="content.style"
class="ws-pre-wrap"
>{{ content.text }}</span
>
</div>
</template>
<script> <script>
import { GlLink } from '@gitlab/ui';
export default { export default {
components: { functional: true,
GlLink,
},
props: { props: {
lineNumber: { lineNumber: {
type: Number, type: Number,
...@@ -15,41 +11,24 @@ export default { ...@@ -15,41 +11,24 @@ export default {
required: true, required: true,
}, },
}, },
computed: { render(h, { props }) {
/** const { lineNumber, path } = props;
* Builds the url for each line number
*
* @returns {String}
*/
buildLineNumber() {
return `${this.path}#${this.lineNumberId}`;
},
/**
* Array indexes start with 0, so we add 1
* to create the line number
*
* @returns {Number} the line number
*/
parsedLineNumber() {
return this.lineNumber + 1;
},
/** const parsedLineNumber = lineNumber + 1;
* Creates the anchor for each link const lineId = `L${parsedLineNumber}`;
* const lineHref = `${path}#${lineId}`;
* @returns {String}
*/ return h(
lineNumberId() { 'a',
return `L${this.parsedLineNumber}`; {
}, class: 'gl-link d-inline-block text-right line-number flex-shrink-0',
attrs: {
id: lineId,
href: lineHref,
},
},
parsedLineNumber,
);
}, },
}; };
</script> </script>
<template>
<gl-link
:id="lineNumberId"
class="d-inline-block text-right line-number flex-shrink-0"
:href="buildLineNumber"
>{{ parsedLineNumber }}</gl-link
>
</template>
---
title: Performance improvement for job logs
merge_request: 35504
author:
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment