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

mongodb-js / mongodb-mcp-server / 20316573569

17 Dec 2025 08:38PM UTC coverage: 79.128% (-0.3%) from 79.433%
20316573569

Pull #811

github

web-flow
Merge 792b50d74 into ff4901030
Pull Request #811: feat(mcp-ui): polish up `ListDatabases` UI and enable it to render as standalone component

1469 of 1926 branches covered (76.27%)

Branch coverage included in aggregate %.

0 of 69 new or added lines in 6 files covered. (0.0%)

3 existing lines in 2 files now uncovered.

6735 of 8442 relevant lines covered (79.78%)

84.01 hits per line

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

1.79
/src/ui/components/ListDatabases/ListDatabases.tsx
1
import React, { type ComponentPropsWithoutRef, type FC, type ReactElement } from "react";
3✔
NEW
2
import { useDarkMode, useRenderData } from "../../hooks/index.js";
×
UNCOV
3
import {
×
4
    Cell as LGCell,
5
    HeaderCell as LGHeaderCell,
6
    HeaderRow,
7
    Row as LGRow,
8
    Table,
9
    TableBody,
10
    TableHead,
11
} from "@leafygreen-ui/table";
NEW
12
import { Body } from "@leafygreen-ui/typography";
×
13
import type { ListDatabasesOutput } from "../../../tools/mongodb/metadata/listDatabases.js";
NEW
14
import { AmountTextStyles, getContainerStyles } from "./ListDatabases.styles.js";
×
15

NEW
16
const HeaderCell = LGHeaderCell as FC<ComponentPropsWithoutRef<"th">>;
×
NEW
17
const Cell = LGCell as FC<ComponentPropsWithoutRef<"td">>;
×
NEW
18
const Row = LGRow as FC<ComponentPropsWithoutRef<"tr">>;
×
19

20
export type Database = ListDatabasesOutput["databases"][number];
21

22
interface ListDatabasesProps {
23
    databases?: Database[];
24
    darkMode?: boolean;
25
}
26

27
function formatBytes(bytes: number): string {
×
28
    if (bytes === 0) return "0 Bytes";
×
29

30
    const k = 1024;
×
31
    const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
×
32
    const i = Math.floor(Math.log(bytes) / Math.log(k));
×
33

34
    return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
×
35
}
×
36

NEW
37
export const ListDatabases = ({
×
NEW
38
    databases: propDatabases,
×
NEW
39
    darkMode: darkModeProp,
×
NEW
40
}: ListDatabasesProps): ReactElement | null => {
×
NEW
41
    const darkMode = useDarkMode(darkModeProp);
×
NEW
42
    const { data: hookData, isLoading, error } = useRenderData<ListDatabasesOutput>();
×
NEW
43
    const databases = propDatabases ?? hookData?.databases;
×
44

NEW
45
    if (!propDatabases) {
×
NEW
46
        if (isLoading) {
×
NEW
47
            return <div>Loading...</div>;
×
NEW
48
        }
×
49

NEW
50
        if (error) {
×
NEW
51
            return <div>Error: {error}</div>;
×
NEW
52
        }
×
UNCOV
53
    }
×
54

NEW
55
    if (!databases) {
×
56
        return null;
×
57
    }
×
58

59
    return (
×
NEW
60
        <div className={getContainerStyles(darkMode)}>
×
NEW
61
            <Body className={AmountTextStyles} darkMode={darkMode}>
×
NEW
62
                Your cluster has <strong>{databases.length} databases</strong>:
×
NEW
63
            </Body>
×
NEW
64
            <Table darkMode={darkMode}>
×
NEW
65
                <TableHead>
×
NEW
66
                    <HeaderRow>
×
NEW
67
                        <HeaderCell>Database</HeaderCell>
×
NEW
68
                        <HeaderCell>Size</HeaderCell>
×
NEW
69
                    </HeaderRow>
×
NEW
70
                </TableHead>
×
NEW
71
                <TableBody>
×
NEW
72
                    {databases.map((db) => (
×
NEW
73
                        <Row key={db.name}>
×
NEW
74
                            <Cell>{db.name}</Cell>
×
NEW
75
                            <Cell>{formatBytes(db.size)}</Cell>
×
NEW
76
                        </Row>
×
NEW
77
                    ))}
×
NEW
78
                </TableBody>
×
NEW
79
            </Table>
×
NEW
80
        </div>
×
81
    );
82
};
×
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