Spaces:
Runtime error
Runtime error
File size: 1,119 Bytes
8822914 |
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 |
'use client';
import { useEffect, useState } from 'react';
import YAML from 'yaml';
import Editor from '@monaco-editor/react';
import { Job } from '@prisma/client';
interface Props {
job: Job;
}
const yamlConfig: YAML.DocumentOptions &
YAML.SchemaOptions &
YAML.ParseOptions &
YAML.CreateNodeOptions &
YAML.ToStringOptions = {
indent: 2,
lineWidth: 999999999999,
defaultStringType: 'QUOTE_DOUBLE',
defaultKeyType: 'PLAIN',
directives: true,
};
export default function JobConfigViewer({ job }: Props) {
const [editorValue, setEditorValue] = useState<string>('');
useEffect(() => {
if (job?.job_config) {
const yamlContent = YAML.stringify(JSON.parse(job.job_config), yamlConfig);
setEditorValue(yamlContent);
}
}, [job]);
return (
<>
<Editor
height="100%"
width="100%"
defaultLanguage="yaml"
value={editorValue}
theme="vs-dark"
options={{
minimap: { enabled: true },
scrollBeyondLastLine: false,
automaticLayout: true,
readOnly: true,
}}
/>
</>
);
}
|