• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MarkUsProject / Markus / 17583918575

09 Sep 2025 01:17PM UTC coverage: 91.815% (-0.03%) from 91.849%
17583918575

push

github

web-flow
Fixed preview of URL submissions and generation of URL display names (#7661)

* Fixed preview of URL submissions
* Fixed autogeneration of URL alias in URL submission form

683 of 1464 branches covered (46.65%)

Branch coverage included in aggregate %.

0 of 22 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

42136 of 45172 relevant lines covered (93.28%)

118.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/app/javascript/Components/Result/file_viewer.jsx
1
import React from "react";
2

3
import {ImageViewer} from "./image_viewer";
4
import {TextViewer} from "./text_viewer";
5
import {PDFViewer} from "./pdf_viewer";
6
import {HTMLViewer} from "./html_viewer";
7
import {BinaryViewer} from "./binary_viewer";
8
import {URLViewer} from "./url_viewer";
9

10
export class FileViewer extends React.Component {
11
  state = {
3✔
12
    loading: false,
13
    errorMessage: null,
14
  };
15

16
  mounted = false;
3✔
17

18
  setLoading = loading => {
3✔
19
    if (this.mounted) {
10✔
20
      this.setState({loading: loading});
7✔
21
    }
22
  };
23

24
  setErrorMessage = message => {
3✔
25
    if (this.mounted) {
1!
26
      this.setState({errorMessage: message});
1✔
27
    }
28
  };
29

30
  componentDidMount() {
31
    this.mounted = true;
3✔
32
  }
33

34
  componentWillUnmount() {
35
    this.mounted = false;
3✔
36
  }
37

38
  componentDidUpdate(prevProps, prevState, snapshot) {
39
    if (this.props !== prevProps) {
9✔
40
      this.setState({
2✔
41
        loading: false,
42
        errorMessage: null,
43
      });
44
    }
45
  }
46

47
  getViewer() {
48
    const commonProps = {
12✔
49
      submission_file_id: this.props.selectedFile,
50
      annotations: this.props.annotations ? this.props.annotations : [],
12!
51
      released_to_students: this.props.released_to_students,
52
      resultView: !!this.props.result_id,
53
      course_id: this.props.course_id,
54
      key: `${this.props.selectedFileType}-viewer`,
55
      url: this.props.selectedFileURL,
56
      setLoadingCallback: this.setLoading,
57
      setErrorMessageCallback: this.setErrorMessage,
58
    };
59

60
    if (this.props.selectedFileType === "image") {
12!
61
      return <ImageViewer mime_type={this.props.mime_type} {...commonProps} />;
×
62
    } else if (this.props.selectedFileType === "pdf") {
12!
63
      return <PDFViewer annotationFocus={this.props.annotationFocus} {...commonProps} />;
×
64
    } else if (
12!
65
      this.props.selectedFileType === "jupyter-notebook" ||
24!
66
      (this.props.selectedFileType === "rmarkdown" && this.props.rmd_convert_enabled)
67
    ) {
68
      return <HTMLViewer annotationFocus={this.props.annotationFocus} {...commonProps} />;
×
69
    } else if (this.props.selectedFileType === "binary") {
12!
NEW
70
      return <BinaryViewer {...commonProps} />;
×
71
    } else if (this.props.selectedFileType === "markusurl") {
12!
NEW
72
      return <URLViewer {...commonProps} />;
×
73
    } else if (this.props.selectedFileType !== "") {
12!
74
      return (
12✔
75
        <TextViewer
76
          type={
77
            this.props.selectedFileType === "rmarkdown" ? "markdown" : this.props.selectedFileType
12!
78
          }
79
          focusLine={this.props.focusLine}
80
          {...commonProps}
81
        />
82
      );
83
    } else {
84
      return "";
×
85
    }
86
  }
87

88
  render() {
89
    const viewer = this.getViewer();
12✔
90
    const outerDivStyle = {
12✔
91
      display: this.state.loading || this.state.errorMessage ? "none" : "block",
36✔
92
      height: "100%",
93
    };
94
    return (
12✔
95
      <React.Fragment>
96
        <div style={outerDivStyle}>{viewer}</div>
97
        {this.state.errorMessage && <p>{this.state.errorMessage}</p>}
13✔
98
        {this.state.loading && !this.state.errorMessage && <p>{I18n.t("working")}</p>}
12!
99
      </React.Fragment>
100
    );
101
  }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc