renderLogViewer()

in src/PrDisplay.js [602:682]


  renderLogViewer(check) {
    let log = null;
    let isShowing = false;
    const radios = ["Minimal", "All"];
    if (check.log.shown) {
      isShowing = true;
      if (check.log.text) {
        let logText = null;
        if (check.log.logLevel === "All") {
          logText = check.log.text;
        } else {
          logText = filterLog(check.log.text);
        }

        const totalLines = (logText.match(/\n/g) || "").length + 1;
        if (check.log.existingEditor) {
          check.log.existingEditor.setValue(logText);
          check.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={check.log.logLevel === radio}
                      onChange={(e) => {
                        check.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 = this.getGroupRanges(monaco, logText);
                registerLogLanguage(monaco, groupRanges);
              }}
              options={{
                scrollBeyondLastLine: false,
                lineNumbersMinChars: totalLines.toString().length + 1,
                folding: true,
              }}
              onMount={(editor, monaco) => {
                check.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, isShowing];
  }