Commit 37a2c1ea authored by Olena Horal-Koretska's avatar Olena Horal-Koretska Committed by Natalia Tepluhina

Display fn, line num and column in stacktrace entry caption

Add caption for all entries
parent 350bb258
<script> <script>
import _ from 'underscore';
import { GlTooltip } from '@gitlab/ui'; import { GlTooltip } from '@gitlab/ui';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
...@@ -56,17 +57,36 @@ export default { ...@@ -56,17 +57,36 @@ export default {
collapseIcon() { collapseIcon() {
return this.isExpanded ? 'chevron-down' : 'chevron-right'; return this.isExpanded ? 'chevron-down' : 'chevron-right';
}, },
noCodeFn() { errorFnText() {
return this.errorFn ? sprintf(__('in %{errorFn} '), { errorFn: this.errorFn }) : ''; return this.errorFn
? sprintf(
__(`%{spanStart}in%{spanEnd} %{errorFn}`),
{
errorFn: `<strong>${_.escape(this.errorFn)}</strong>`,
spanStart: `<span class="text-tertiary">`,
spanEnd: `</span>`,
},
false,
)
: '';
}, },
noCodeLine() { errorPositionText() {
return this.errorLine return this.errorLine
? sprintf(__('at line %{errorLine}%{errorColumn}'), { ? sprintf(
errorLine: this.errorLine, __(`%{spanStart}at line%{spanEnd} %{errorLine}%{errorColumn}`),
errorColumn: this.errorColumn ? `:${this.errorColumn}` : '', {
}) errorLine: `<strong>${this.errorLine}</strong>`,
errorColumn: this.errorColumn ? `:<strong>${this.errorColumn}</strong>` : ``,
spanStart: `<span class="text-tertiary">`,
spanEnd: `</span>`,
},
false,
)
: ''; : '';
}, },
errorInfo() {
return `${this.errorFnText} ${this.errorPositionText}`;
},
}, },
methods: { methods: {
isHighlighted(lineNum) { isHighlighted(lineNum) {
...@@ -102,8 +122,7 @@ export default { ...@@ -102,8 +122,7 @@ export default {
<strong <strong
v-gl-tooltip v-gl-tooltip
:title="filePath" :title="filePath"
class="file-title-name d-inline-block overflow-hidden text-truncate" class="file-title-name d-inline-block overflow-hidden text-truncate limited-width"
:class="{ 'limited-width': !hasCode }"
data-container="body" data-container="body"
> >
{{ filePath }} {{ filePath }}
...@@ -113,7 +132,7 @@ export default { ...@@ -113,7 +132,7 @@ export default {
:text="filePath" :text="filePath"
css-class="btn-default btn-transparent btn-clipboard position-static" css-class="btn-default btn-transparent btn-clipboard position-static"
/> />
<span v-if="!hasCode" class="text-tertiary">{{ noCodeFn }}{{ noCodeLine }}</span> <span v-html="errorInfo"></span>
</div> </div>
</div> </div>
......
---
title: Display fn, line num and column in stacktrace entry caption
merge_request: 22905
author:
type: added
...@@ -373,6 +373,12 @@ msgstr "" ...@@ -373,6 +373,12 @@ msgstr ""
msgid "%{spammable_titlecase} was submitted to Akismet successfully." msgid "%{spammable_titlecase} was submitted to Akismet successfully."
msgstr "" msgstr ""
msgid "%{spanStart}at line%{spanEnd} %{errorLine}%{errorColumn}"
msgstr ""
msgid "%{spanStart}in%{spanEnd} %{errorFn}"
msgstr ""
msgid "%{start} to %{end}" msgid "%{start} to %{end}"
msgstr "" msgstr ""
...@@ -21522,9 +21528,6 @@ msgstr "" ...@@ -21522,9 +21528,6 @@ msgstr ""
msgid "assign yourself" msgid "assign yourself"
msgstr "" msgstr ""
msgid "at line %{errorLine}%{errorColumn}"
msgstr ""
msgid "attach a new file" msgid "attach a new file"
msgstr "" msgstr ""
...@@ -21997,9 +22000,6 @@ msgstr "" ...@@ -21997,9 +22000,6 @@ msgstr ""
msgid "importing" msgid "importing"
msgstr "" msgstr ""
msgid "in %{errorFn} "
msgstr ""
msgid "in group %{link_to_group}" msgid "in group %{link_to_group}"
msgstr "" msgstr ""
......
...@@ -46,8 +46,8 @@ describe('Stacktrace Entry', () => { ...@@ -46,8 +46,8 @@ describe('Stacktrace Entry', () => {
expect(wrapper.findAll('.line_content.old').length).toBe(1); expect(wrapper.findAll('.line_content.old').length).toBe(1);
}); });
describe('no code block', () => { describe('entry caption', () => {
const findFileHeaderContent = () => wrapper.find('.file-header-content').html(); const findFileHeaderContent = () => wrapper.find('.file-header-content').text();
it('should hide collapse icon and render error fn name and error line when there is no code block', () => { it('should hide collapse icon and render error fn name and error line when there is no code block', () => {
const extraInfo = { errorLine: 34, errorFn: 'errorFn', errorColumn: 77 }; const extraInfo = { errorLine: 34, errorFn: 'errorFn', errorColumn: 77 };
......
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