in src/pr/CircleCICard.js [86:163]
renderLogViewer(step) {
let log = null;
const radios = ["Minimal", "All"];
if (step.log.shown) {
if (step.log.text) {
let logText = null;
if (step.log.logLevel === "All") {
logText = step.log.text;
} else {
logText = filterLog(step.log.text);
}
const totalLines = (logText.match(/\n/g) || "").length + 1;
if (step.log.existingEditor) {
step.log.existingEditor.setValue(logText);
step.log.existingEditor.revealLine(totalLines);
}
log = (
<div
style={{
marginBottom: "20px",
}}
>
<div className="hideRadio">
<span>Log Level: </span>
<div style={{ display: "inline" }}>
<ButtonGroup>
{radios.map((radio, idx) => (
<ToggleButton
key={idx}
id={`radio-${idx}`}
type="radio"
variant="outline-info"
name="radio"
value={radio}
checked={step.log.logLevel === radio}
onChange={(e) => {
step.log.logLevel = radio;
this.setState(this.state);
}}
>
{radio}
</ToggleButton>
))}
</ButtonGroup>
</div>
</div>
<Editor
height="80vh"
defaultLanguage="logText"
defaultValue={logText}
theme="logTheme"
beforeMount={(monaco) => {
const groupRanges = [];
registerLogLanguage(monaco, groupRanges);
}}
options={{
scrollBeyondLastLine: false,
lineNumbersMinChars: totalLines.toString().length + 1,
folding: true,
}}
onMount={(editor, monaco) => {
step.log.existingEditor = editor;
let foldAction = editor.getAction("editor.foldAll");
foldAction.run().then(() => {
editor.revealLine(totalLines);
});
}}
loading={<p>Loading viewer...</p>}
/>
</div>
);
} else {
log = <p>Fetching logs...</p>;
}
}
return log;
}