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

MarkUsProject / Markus / 13122420635

03 Feb 2025 08:39PM UTC coverage: 91.849% (-0.02%) from 91.865%
13122420635

Pull #7393

github

web-flow
Merge f9da04898 into 0597f5222
Pull Request #7393: update remote_autotest_settings_id validation

624 of 1361 branches covered (45.85%)

Branch coverage included in aggregate %.

23 of 23 new or added lines in 2 files covered. (100.0%)

85 existing lines in 11 files now uncovered.

41281 of 44263 relevant lines covered (93.26%)

120.26 hits per line

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

61.11
/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 ReactTable from "react-table";
6
import {selectFilter} from "./Helpers/table_helpers";
7

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

19
  componentDidMount() {
20
    this.fetchData();
3✔
21
  }
22

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

39
  removeTA = ta_id => {
3✔
40
    fetch(Routes.course_ta_path(this.props.course_id, ta_id), {
1✔
41
      method: "DELETE",
42
      headers: {
43
        "Content-Type": "application/json",
44
        "X-CSRF-Token": document.querySelector('[name="csrf-token"]').content,
45
      },
46
    })
47
      .then(response => {
48
        if (response.ok) {
1!
49
          this.fetchData();
1✔
50
        }
51
      })
52
      .catch(error => {
53
        console.error("Error deleting TA:", error);
×
54
      });
55
  };
56

57
  render() {
58
    const {data} = this.state;
6✔
59
    return (
6✔
60
      <ReactTable
61
        data={data}
62
        columns={[
63
          {
64
            Header: I18n.t("activerecord.attributes.user.user_name"),
65
            accessor: "user_name",
66
          },
67
          {
68
            Header: I18n.t("activerecord.attributes.user.first_name"),
69
            accessor: "first_name",
70
          },
71
          {
72
            Header: I18n.t("activerecord.attributes.user.last_name"),
73
            accessor: "last_name",
74
          },
75
          {
76
            Header: I18n.t("activerecord.attributes.user.email"),
77
            accessor: "email",
78
          },
79
          {
80
            Header: I18n.t("roles.active") + "?",
81
            accessor: "hidden",
82
            Cell: ({value}) => (value ? I18n.t("roles.inactive") : I18n.t("roles.active")),
5✔
83
            filterMethod: (filter, row) => {
84
              if (filter.value === "all") {
×
85
                return true;
×
86
              } else {
87
                return (
×
88
                  (filter.value === "active" && !row[filter.id]) ||
×
89
                  (filter.value === "inactive" && row[filter.id])
90
                );
91
              }
92
            },
93
            Filter: selectFilter,
94
            filterOptions: [
95
              {
96
                value: "active",
97
                text: `${I18n.t("roles.active")} (${this.state.counts.active})`,
98
              },
99
              {
100
                value: "inactive",
101
                text: `${I18n.t("roles.inactive")} (${this.state.counts.inactive})`,
102
              },
103
            ],
104
            filterAllOptionText: `${I18n.t("all")} (${this.state.counts.all})`,
105
          },
106
          {
107
            Header: I18n.t("actions"),
108
            accessor: "id",
109
            Cell: data => (
110
              <>
5✔
111
                <span>
112
                  <a href={Routes.edit_course_ta_path(this.props.course_id, data.value)}>
113
                    {I18n.t("edit")}
114
                  </a>
115
                </span>
116
                &nbsp;|&nbsp;
117
                <span>
118
                  <a href="#" onClick={() => this.removeTA(data.value)}>
1✔
119
                    {I18n.t("delete")}
120
                  </a>
121
                </span>
122
              </>
123
            ),
124
            filterable: false,
125
            sortable: false,
126
          },
127
        ]}
128
        filterable
129
        loading={this.state.loading}
130
      />
131
    );
132
  }
133
}
134

135
TATable.propTypes = {
1✔
136
  course_id: PropTypes.number,
137
};
138

139
function makeTATable(elem, props) {
140
  const root = createRoot(elem);
×
UNCOV
141
  root.render(<TATable {...props} />);
×
142
}
143

144
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

© 2025 Coveralls, Inc