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

cartesi / rollups-explorer / 8962206712

06 May 2024 12:17AM CUT coverage: 95.125% (-0.1%) from 95.257%
8962206712

push

github

web-flow
Feat: Application summary page access (#176)

536 of 658 branches covered (81.46%)

Branch coverage included in aggregate %.

95 of 95 new or added lines in 3 files covered. (100.0%)

8 existing lines in 2 files now uncovered.

7191 of 7465 relevant lines covered (96.33%)

21.16 hits per line

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

89.43
/apps/web/src/components/applications/applications.tsx
1
"use client";
1✔
2

1✔
3
import { Tabs } from "@mantine/core";
1✔
4
import { FC, useCallback, useState } from "react";
1✔
5
import { useAccount } from "wagmi";
1✔
6
import {
1✔
7
    useApplicationsConnectionOwnerQuery,
1✔
8
    useApplicationsConnectionQuery,
1✔
9
} from "../../graphql/explorer/hooks/queries";
1✔
10
import { ApplicationOrderByInput } from "../../graphql/explorer/types";
1✔
11
import ApplicationsTable from "../applications/applicationsTable";
1✔
12
import Paginated from "../paginated";
1✔
13
import UserApplicationsTable from "./userApplicationsTable";
1✔
14

1✔
15
const UserApplications: FC = () => {
1✔
16
    const { address, isConnected } = useAccount();
1✔
17
    const [limit, setLimit] = useState(10);
1✔
18
    const [page, setPage] = useState(1);
1✔
19
    const after = page === 1 ? undefined : ((page - 1) * limit).toString();
1!
20
    const [query] = useApplicationsConnectionOwnerQuery({
1✔
21
        variables: {
1✔
22
            after,
1✔
23
            limit,
1✔
24
            orderBy: ApplicationOrderByInput.IdAsc,
1✔
25
            ownerId: address?.toLowerCase(),
1✔
26
        },
1✔
27
        pause: !isConnected,
1✔
28
    });
1✔
29
    const applications =
1✔
30
        !isConnected || !query.data
1!
UNCOV
31
            ? []
×
32
            : query.data?.applicationsConnection.edges.map((edge) => edge.node);
1✔
33
    const totalCount =
1✔
34
        !isConnected || !query.data
1!
UNCOV
35
            ? 0
×
36
            : query.data?.applicationsConnection.totalCount;
1✔
37

1✔
38
    const onChangePagination = useCallback((limit: number, page: number) => {
1✔
39
        setLimit(limit);
×
40
        setPage(page);
×
41
    }, []);
1✔
42

1✔
43
    return (
1✔
44
        <Paginated
1✔
45
            fetching={query.fetching}
1✔
46
            totalCount={totalCount}
1✔
47
            onChange={onChangePagination}
1✔
48
            data-testid="user-applications"
1✔
49
            py="sm"
1✔
50
        >
1✔
51
            <UserApplicationsTable
1✔
52
                applications={applications}
1✔
53
                fetching={query.fetching}
1✔
54
                totalCount={totalCount}
1✔
55
                noResultsMessage={
1✔
56
                    isConnected
1✔
57
                        ? undefined
1!
UNCOV
58
                        : "Connect your wallet to list your Applications."
×
59
                }
1✔
60
            />
1✔
61
        </Paginated>
1✔
62
    );
1✔
63
};
1✔
64

1✔
65
const AllApplications: FC = () => {
1✔
66
    const [limit, setLimit] = useState(10);
5✔
67
    const [page, setPage] = useState(1);
5✔
68
    const after = page === 1 ? undefined : ((page - 1) * limit).toString();
5!
69
    const [query] = useApplicationsConnectionQuery({
5✔
70
        variables: { orderBy: ApplicationOrderByInput.IdAsc, limit, after },
5✔
71
    });
5✔
72
    const applications =
5✔
73
        query.data?.applicationsConnection.edges.map((edge) => edge.node) ?? [];
5!
74

5✔
75
    const onChangePagination = useCallback((limit: number, page: number) => {
5✔
76
        setLimit(limit);
×
77
        setPage(page);
×
78
    }, []);
5✔
79

5✔
80
    return (
5✔
81
        <Paginated
5✔
82
            fetching={query.fetching}
5✔
83
            totalCount={query.data?.applicationsConnection.totalCount}
5✔
84
            onChange={onChangePagination}
5✔
85
            data-testid="all-applications"
5✔
86
            py="sm"
5✔
87
        >
5✔
88
            <ApplicationsTable
5✔
89
                applications={applications}
5✔
90
                fetching={query.fetching}
5✔
91
                totalCount={query.data?.applicationsConnection.totalCount ?? 0}
5✔
92
            />
5✔
93
        </Paginated>
5✔
94
    );
5✔
95
};
5✔
96

1✔
97
export const Applications = () => {
1✔
98
    return (
4✔
99
        <Tabs defaultValue="all-apps" keepMounted={false}>
4✔
100
            <Tabs.List>
4✔
101
                <Tabs.Tab value="all-apps">All Apps</Tabs.Tab>
4✔
102
                <Tabs.Tab value="my-apps">My Apps</Tabs.Tab>
4✔
103
            </Tabs.List>
4✔
104

4✔
105
            <Tabs.Panel value="all-apps">
4✔
106
                <AllApplications />
4✔
107
            </Tabs.Panel>
4✔
108

4✔
109
            <Tabs.Panel value="my-apps">
4✔
110
                <UserApplications />
4✔
111
            </Tabs.Panel>
4✔
112
        </Tabs>
4✔
113
    );
4✔
114
};
4✔
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