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

MarkUsProject / Markus / 16590227485

29 Jul 2025 08:00AM UTC coverage: 91.883% (+0.001%) from 91.882%
16590227485

Pull #7602

github

web-flow
Merge 581c293ba into 8944608a8
Pull Request #7602: Added loading icon for instructor table

662 of 1423 branches covered (46.52%)

Branch coverage included in aggregate %.

2 of 16 new or added lines in 2 files covered. (12.5%)

26 existing lines in 3 files now uncovered.

42038 of 45049 relevant lines covered (93.32%)

118.7 hits per line

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

85.71
/app/javascript/Components/ta_table.jsx
1
import React from "react";
2
import {createRoot} from "react-dom/client";
3
import PropTypes from "prop-types";
4

5
import {faPencil, faTrashCan} from "@fortawesome/free-solid-svg-icons";
6
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
7

8
import Table from "./table/table";
9
import {createColumnHelper} from "@tanstack/react-table";
10

11
class TATable extends React.Component {
12
  constructor() {
13
    super();
4✔
14
    this.state = {
3✔
15
      data: [],
16
      loading: true,
17
    };
18
    this.fetchData = this.fetchData.bind(this);
3✔
19

20
    const columnHelper = createColumnHelper();
3✔
21
    this.columns = [
3✔
22
      columnHelper.accessor("user_name", {
23
        header: () => I18n.t("activerecord.attributes.user.user_name"),
8✔
24
      }),
25
      columnHelper.accessor("first_name", {
26
        header: () => I18n.t("activerecord.attributes.user.first_name"),
8✔
27
      }),
28
      columnHelper.accessor("last_name", {
29
        header: () => I18n.t("activerecord.attributes.user.last_name"),
8✔
30
      }),
31
      columnHelper.accessor("email", {
32
        header: () => I18n.t("activerecord.attributes.user.email"),
8✔
33
      }),
34
      columnHelper.accessor("hidden", {
35
        header: () => I18n.t("roles.active") + "?",
8✔
36
        filterFn: "equalsString",
37
        meta: {
38
          filterVariant: "select",
39
        },
40
      }),
41
      columnHelper.accessor("id", {
42
        id: "id",
43
        enableSorting: false,
44
        enableColumnFilter: false,
45
        header: () => I18n.t("actions"),
8✔
46
        cell: props => (
47
          <span>
10✔
48
            <a
49
              href={Routes.edit_course_ta_path(this.props.course_id, props.getValue())}
50
              aria-label={I18n.t("edit")}
51
              title={I18n.t("edit")}
52
            >
53
              <FontAwesomeIcon icon={faPencil} />
54
            </a>
55
            &nbsp;|&nbsp;
56
            <a
57
              href="#"
58
              onClick={() => this.removeTA(props.getValue())}
1✔
59
              aria-label={I18n.t("remove")}
60
              title={I18n.t("remove")}
61
            >
62
              <FontAwesomeIcon icon={faTrashCan} />
63
            </a>
64
          </span>
65
        ),
66
      }),
67
    ];
68
  }
69

70
  componentDidMount() {
71
    this.fetchData().then(data => this.setState({data: this.processData(data)}));
3✔
72
  }
73

74
  fetchData() {
75
    return fetch(Routes.course_tas_path(this.props.course_id), {
4✔
76
      headers: {
77
        Accept: "application/json",
78
      },
79
    })
80
      .then(response => {
81
        if (response.ok) {
4!
82
          return response.json();
4✔
83
        }
84
      })
85
      .then(json => json.data);
4✔
86
  }
87

88
  processData(data) {
89
    data.forEach(row => (row.hidden = I18n.t(row.hidden ? "roles.inactive" : "roles.active")));
5✔
90
    return data;
3✔
91
  }
92

93
  removeTA = ta_id => {
3✔
94
    fetch(Routes.course_ta_path(this.props.course_id, ta_id), {
1✔
95
      method: "DELETE",
96
      headers: {
97
        "Content-Type": "application/json",
98
        "X-CSRF-Token": document.querySelector('[name="csrf-token"]').content,
99
      },
100
    })
101
      .then(response => {
102
        if (response.ok) {
1!
103
          this.fetchData();
1✔
104
        }
105
      })
106
      .catch(error => {
107
        console.error("Error removing TA:", error);
×
108
      });
109
  };
110

111
  render() {
112
    return (
6✔
113
      <Table data={this.state.data} columns={this.columns} noDataText={I18n.t("tas.empty_table")} />
114
    );
115
  }
116
}
117

118
TATable.propTypes = {
1✔
119
  course_id: PropTypes.number,
120
};
121

122
function makeTATable(elem, props) {
UNCOV
123
  const root = createRoot(elem);
×
UNCOV
124
  root.render(<TATable {...props} />);
×
125
}
126

127
export {makeTATable, TATable};
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