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

MarkUsProject / Markus / 29662909844

18 Jul 2026 10:08PM UTC coverage: 90.356%. First build
29662909844

Pull #8067

github

web-flow
Merge b5fbfae23 into 35deb772c
Pull Request #8067: V2.10.1

1156 of 2380 branches covered (48.57%)

Branch coverage included in aggregate %.

1187 of 1268 new or added lines in 107 files covered. (93.61%)

46952 of 50863 relevant lines covered (92.31%)

133.31 hits per line

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

72.73
/app/javascript/Components/admin_users_list.jsx
1
import React from "react";
2
import {createRoot} from "react-dom/client";
3
import ReactTable from "react-table";
4
import {selectFilter} from "./Helpers/table_helpers";
5
import {faPencil} from "@fortawesome/free-solid-svg-icons";
6
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
7

8
export class AdminUsersList extends React.Component {
9
  constructor() {
10
    super();
2✔
11
    this.state = {
2✔
12
      users: [],
13
      pages: 0,
14
      loading: true,
15
      page: 0,
16
      pageSize: 100,
17
    };
18
    this.previousFiltered = "[]";
2✔
19
    this.previousSorted = "[]";
2✔
20
  }
21

22
  fetchDataServerSide = state => {
2✔
23
    this.setState({loading: true});
3✔
24
    const currentFilteredStr = JSON.stringify(state.filtered);
3✔
25
    const currentSortedStr = JSON.stringify(state.sorted);
3✔
26

27
    let targetPage = state.page;
3✔
28
    if (this.previousFiltered !== currentFilteredStr || this.previousSorted !== currentSortedStr) {
3!
29
      targetPage = 0;
3✔
30
      this.previousFiltered = currentFilteredStr;
3✔
31
      this.previousSorted = currentSortedStr;
3✔
32
    }
33

34
    fetch(
3✔
35
      Routes.admin_users_path({
36
        page: targetPage + 1,
37
        per_page: state.pageSize,
38
        sorted: currentSortedStr,
39
        filtered: currentFilteredStr,
40
      }),
41
      {
42
        headers: {Accept: "application/json"},
43
      }
44
    )
45
      .then(response => {
46
        if (response.ok) return response.json();
3!
NEW
47
        throw new Error("Failed to fetch grid data");
×
48
      })
49
      .then(data => {
50
        this.setState({
3✔
51
          users: data && data.users ? data.users : [],
9!
52
          pages: data && data.total_pages ? data.total_pages : 1,
9!
53
          loading: false,
54
          page: targetPage,
55
          pageSize: state.pageSize,
56
        });
57
      })
58
      .catch(err => {
NEW
59
        console.error("Pagination error:", err);
×
NEW
60
        this.setState({users: [], pages: 1, loading: false});
×
61
      });
62
  };
63

64
  columns = [
2✔
65
    {
66
      Header: I18n.t("activerecord.attributes.user.user_name"),
67
      accessor: "user_name",
68
      id: "user_name",
69
      minWidth: 120,
70
    },
71
    {
72
      Header: I18n.t("activerecord.attributes.user.first_name"),
73
      accessor: "first_name",
74
      minWidth: 120,
75
    },
76
    {
77
      Header: I18n.t("activerecord.attributes.user.last_name"),
78
      accessor: "last_name",
79
      minWidth: 120,
80
    },
81
    {
82
      Header: I18n.t("activerecord.attributes.user.email"),
83
      accessor: "email",
84
      minWidth: 150,
85
    },
86
    {
87
      Header: I18n.t("activerecord.attributes.user.id_number"),
88
      accessor: "id_number",
89
      minWidth: 90,
90
      className: "number",
91
    },
92
    {
93
      Header: I18n.t("activerecord.attributes.user.user_type"),
94
      accessor: "type",
95
      minWidth: 90,
96
      Cell: ({value}) => {
97
        if (value === "AdminUser") {
1!
98
          return I18n.t("activerecord.models.admin_user.one");
×
99
        } else {
100
          return I18n.t("activerecord.models.end_user.one");
1✔
101
        }
102
      },
103
      Filter: selectFilter,
104
      filterOptions: [
105
        {
106
          text: I18n.t("activerecord.models.admin_user.one"),
107
          value: "AdminUser",
108
        },
109
        {
110
          text: I18n.t("activerecord.models.end_user.one"),
111
          value: "EndUser",
112
        },
113
      ],
114
    },
115
    {
116
      Header: I18n.t("actions"),
117
      accessor: "id",
118
      minWidth: 70,
119
      Cell: ({value}) => (
120
        <a
1✔
121
          href={Routes.edit_admin_user_path(value)}
122
          aria-label={I18n.t("edit")}
123
          title={I18n.t("edit")}
124
        >
125
          <FontAwesomeIcon icon={faPencil} />
126
        </a>
127
      ),
128
      sortable: false,
129
      filterable: false,
130
    },
131
  ];
132

133
  render() {
134
    return (
6✔
135
      <ReactTable
136
        manual
137
        data={this.state.users}
138
        pages={this.state.pages}
139
        page={this.state.page}
140
        pageSize={this.state.pageSize}
141
        columns={this.columns}
142
        filterable
143
        showPagination={true}
144
        showPaginationBottom={true}
145
        showPageSizeOptions={false}
146
        defaultPageSize={100}
147
        defaultSorted={[{id: "user_name"}]}
148
        loading={this.state.loading}
149
        onFetchData={this.fetchDataServerSide}
NEW
150
        onPageChange={page => this.setState({page})}
×
151
      />
152
    );
153
  }
154
}
155

156
export function makeAdminUsersList(elem, props) {
157
  const root = createRoot(elem);
×
158
  root.render(<AdminUsersList {...props} />);
×
159
}
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