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

MarkUsProject / Markus / 15466657172

05 Jun 2025 12:10PM UTC coverage: 91.953% (+0.001%) from 91.952%
15466657172

Pull #7557

github

web-flow
Merge 71c6473c1 into 055a2709b
Pull Request #7557: Design improvement for student, ta, and instructor tables

631 of 1371 branches covered (46.02%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

11 existing lines in 3 files now uncovered.

41944 of 44930 relevant lines covered (93.35%)

117.55 hits per line

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

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

5
import ReactTable from "react-table";
6
import {selectFilter} from "./Helpers/table_helpers";
7
import {tableNoDataComponent} from "./table_no_data";
8

9
class InstructorTable extends React.Component {
10
  constructor() {
11
    super();
3✔
12
    this.state = {
2✔
13
      data: [],
14
      counts: {all: 0, active: 0, inactive: 0},
15
      loading: true,
16
    };
17
    this.fetchData = this.fetchData.bind(this);
2✔
18
  }
19

20
  componentDidMount() {
21
    this.fetchData();
2✔
22
  }
23

24
  fetchData() {
25
    fetch(Routes.course_instructors_path(this.props.course_id), {
2✔
26
      headers: {
27
        Accept: "application/json",
28
      },
29
    })
30
      .then(response => {
31
        if (response.ok) {
2!
32
          return response.json();
2✔
33
        }
34
      })
35
      .then(res => {
36
        this.setState({data: res.data, counts: res.counts, loading: false});
2✔
37
      });
38
  }
39

40
  render() {
41
    const {data} = this.state;
4✔
42
    return (
4✔
43
      <ReactTable
44
        data={data}
45
        columns={[
46
          {
47
            Header: I18n.t("activerecord.attributes.user.user_name"),
48
            accessor: "user_name",
49
          },
50
          {
51
            Header: I18n.t("activerecord.attributes.user.first_name"),
52
            accessor: "first_name",
53
          },
54
          {
55
            Header: I18n.t("activerecord.attributes.user.last_name"),
56
            accessor: "last_name",
57
          },
58
          {
59
            Header: I18n.t("activerecord.attributes.user.email"),
60
            accessor: "email",
61
          },
62
          {
63
            Header: I18n.t("roles.active") + "?",
64
            accessor: "hidden",
65
            Cell: ({value}) => (value ? I18n.t("roles.inactive") : I18n.t("roles.active")),
2✔
66
            filterMethod: (filter, row) => {
67
              if (filter.value === "all") {
×
UNCOV
68
                return true;
×
69
              } else {
UNCOV
70
                return (
×
71
                  (filter.value === "active" && !row[filter.id]) ||
×
72
                  (filter.value === "inactive" && row[filter.id])
73
                );
74
              }
75
            },
76
            Filter: selectFilter,
77
            filterOptions: [
78
              {
79
                value: "active",
80
                text: `${I18n.t("roles.active")} (${this.state.counts.active})`,
81
              },
82
              {
83
                value: "inactive",
84
                text: `${I18n.t("roles.inactive")} (${this.state.counts.inactive})`,
85
              },
86
            ],
87
            filterAllOptionText: `${I18n.t("all")} (${this.state.counts.all})`,
88
          },
89
          {
90
            Header: I18n.t("actions"),
91
            accessor: "id",
92
            Cell: data => (
93
              <span>
2✔
94
                <a href={Routes.edit_course_instructor_path(this.props.course_id, data.value)}>
95
                  {I18n.t("edit")}
96
                </a>
97
              </span>
98
            ),
99
            sortable: false,
100
          },
101
        ]}
102
        filterable
103
        loading={this.state.loading}
104
        NoDataComponent={() => tableNoDataComponent(I18n.t("instructors.empty_table"))}
5✔
105
      />
106
    );
107
  }
108
}
109

110
InstructorTable.propTypes = {
1✔
111
  course_id: PropTypes.number,
112
};
113

114
function makeInstructorTable(elem, props) {
115
  const root = createRoot(elem);
×
UNCOV
116
  root.render(<InstructorTable {...props} />);
×
117
}
118

119
export {makeInstructorTable, InstructorTable};
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

© 2025 Coveralls, Inc