diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 06:13:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 06:13:36 +0300 |
commit | bdf7b581f80cf7119528eab0ac31e2c549563872 (patch) | |
tree | 23b20f65beb31a5ec35a273f9229e214eb8aa0bf /app/assets/javascripts/notebook | |
parent | 9c1accf52813b2b4b98ce85c9ec4a16fdbb86ee1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/notebook')
-rw-r--r-- | app/assets/javascripts/notebook/cells/output/error.vue | 40 | ||||
-rw-r--r-- | app/assets/javascripts/notebook/cells/output/index.vue | 10 | ||||
-rw-r--r-- | app/assets/javascripts/notebook/index.vue | 4 |
3 files changed, 54 insertions, 0 deletions
diff --git a/app/assets/javascripts/notebook/cells/output/error.vue b/app/assets/javascripts/notebook/cells/output/error.vue new file mode 100644 index 00000000000..9afc89cde4f --- /dev/null +++ b/app/assets/javascripts/notebook/cells/output/error.vue @@ -0,0 +1,40 @@ +<script> +import Prompt from '../prompt.vue'; +import Markdown from '../markdown.vue'; + +export default { + name: 'ErrorOutput', + components: { + Prompt, + Markdown, + }, + props: { + count: { + type: Number, + required: true, + }, + rawCode: { + type: Array, + required: true, + }, + index: { + type: Number, + required: true, + }, + }, + computed: { + parsedError() { + let parsed = this.rawCode.map((l) => l.replace(/\u001B\[[0-9][0-9;]*m/g, '')); // eslint-disable-line no-control-regex + parsed = ['```error', ...parsed, '```'].join('\n'); // eslint-disable-line @gitlab/require-i18n-strings + return { source: [parsed] }; + }, + }, +}; +</script> + +<template> + <div class="output"> + <prompt type="Out" :count="count" /> + <markdown :cell="parsedError" :hide-prompt="true" /> + </div> +</template> diff --git a/app/assets/javascripts/notebook/cells/output/index.vue b/app/assets/javascripts/notebook/cells/output/index.vue index bd01534089e..22bcb5dd66a 100644 --- a/app/assets/javascripts/notebook/cells/output/index.vue +++ b/app/assets/javascripts/notebook/cells/output/index.vue @@ -4,8 +4,10 @@ import HtmlOutput from './html.vue'; import ImageOutput from './image.vue'; import LatexOutput from './latex.vue'; import MarkdownOutput from './markdown.vue'; +import ErrorOutput from './error.vue'; const TEXT_MARKDOWN = 'text/markdown'; +const ERROR_OUTPUT_TYPE = 'error'; export default { props: { @@ -28,6 +30,8 @@ export default { outputType(output) { if (output.text) { return 'text/plain'; + } else if (output.output_type === ERROR_OUTPUT_TYPE) { + return 'error'; } else if (output.data['image/png']) { return 'image/png'; } else if (output.data['image/jpeg']) { @@ -56,6 +60,8 @@ export default { getComponent(output) { if (output.text) { return CodeOutput; + } else if (output.output_type === ERROR_OUTPUT_TYPE) { + return ErrorOutput; } else if (output.data['image/png']) { return ImageOutput; } else if (output.data['image/jpeg']) { @@ -80,6 +86,10 @@ export default { return output.text.join(''); } + if (output.output_type === ERROR_OUTPUT_TYPE) { + return output.traceback; + } + return this.dataForType(output, this.outputType(output)); }, }, diff --git a/app/assets/javascripts/notebook/index.vue b/app/assets/javascripts/notebook/index.vue index df9694b7cd8..5f254cae73d 100644 --- a/app/assets/javascripts/notebook/index.vue +++ b/app/assets/javascripts/notebook/index.vue @@ -60,6 +60,10 @@ export default { margin-bottom: 10px; } +.output .text-cell { + overflow-x: auto; +} + .cell pre { margin: 0; width: 100%; |