Skip to content

Commit 08c6e8f

Browse files
authored
refactor(new-webui): Remove redundant StatCard and DetailsCard. (#1088)
1 parent f57135a commit 08c6e8f

File tree

13 files changed

+95
-141
lines changed

13 files changed

+95
-141
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {
2+
theme,
3+
Typography,
4+
} from "antd";
5+
6+
7+
const {Text} = Typography;
8+
9+
interface StatProps {
10+
text: string;
11+
fontSize?: string;
12+
color?: string;
13+
}
14+
15+
/**
16+
* A text component for displaying statistical values.
17+
*
18+
* @param props
19+
* @param props.text
20+
* @param props.color
21+
* @param props.fontSize
22+
* @return
23+
*/
24+
const Stat = ({text, color, fontSize}: StatProps) => {
25+
const {token} = theme.useToken();
26+
return (
27+
<Text style={{color: color ?? token.colorTextSecondary, fontSize: fontSize ?? "1.4rem"}}>
28+
{text}
29+
</Text>
30+
);
31+
};
32+
33+
34+
export default Stat;

components/webui/client/src/components/StatCard/index.module.css

Whitespace-only changes.

components/webui/client/src/components/StatCard/index.tsx

Lines changed: 0 additions & 62 deletions
This file was deleted.

components/webui/client/src/pages/IngestPage/Details/DetailsCard.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

components/webui/client/src/pages/IngestPage/Details/Files.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Nullable} from "src/typings/common";
22

3-
import DetailsCard from "./DetailsCard";
3+
import {DashboardCard} from "../../../components/DashboardCard";
4+
import Stat from "../../../components/Stat";
45

56

67
interface FilesProps {
@@ -18,10 +19,12 @@ interface FilesProps {
1819
*/
1920
const Files = ({numFiles, isLoading}: FilesProps) => {
2021
return (
21-
<DetailsCard
22+
<DashboardCard
2223
isLoading={isLoading}
23-
stat={(numFiles ?? 0).toString()}
24-
title={"Files"}/>
24+
title={"Files"}
25+
>
26+
<Stat text={(numFiles ?? 0).toString()}/>
27+
</DashboardCard>
2528
);
2629
};
2730

components/webui/client/src/pages/IngestPage/Details/Messages.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Nullable} from "src/typings/common";
22

3-
import DetailsCard from "./DetailsCard";
3+
import {DashboardCard} from "../../../components/DashboardCard";
4+
import Stat from "../../../components/Stat";
45

56

67
interface MessagesProps {
@@ -18,10 +19,12 @@ interface MessagesProps {
1819
*/
1920
const Messages = ({numMessages, isLoading}: MessagesProps) => {
2021
return (
21-
<DetailsCard
22+
<DashboardCard
2223
isLoading={isLoading}
23-
stat={(numMessages ?? 0).toString()}
24-
title={"Messages"}/>
24+
title={"Messages"}
25+
>
26+
<Stat text={(numMessages ?? 0).toString()}/>
27+
</DashboardCard>
2528
);
2629
};
2730

components/webui/client/src/pages/IngestPage/Details/TimeRange.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Dayjs} from "dayjs";
22

3-
import DetailsCard from "./DetailsCard";
3+
import {DashboardCard} from "../../../components/DashboardCard";
4+
import Stat from "../../../components/Stat";
45

56

67
const DATE_FORMAT = "MMMM D, YYYY";
@@ -29,10 +30,12 @@ const TimeRange = ({beginDate, endDate, isLoading}: TimeRangeProps) => {
2930
}
3031

3132
return (
32-
<DetailsCard
33+
<DashboardCard
3334
isLoading={isLoading}
34-
stat={stat}
35-
title={"Time Range"}/>
35+
title={"Time Range"}
36+
>
37+
<Stat text={stat}/>
38+
</DashboardCard>
3639
);
3740
};
3841

components/webui/client/src/pages/IngestPage/Jobs/index.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ import {convertQueryJobsItemToJobData} from "./utils";
1818

1919
const DAYS_TO_SHOW: number = 30;
2020

21-
interface JobsProps {
22-
className: string;
23-
}
24-
2521
/**
2622
* Renders table with ingestion jobs inside a card.
2723
*
28-
* @param props
29-
* @param props.className
3024
* @return
3125
*/
32-
const Jobs = ({className}: JobsProps) => {
26+
const Jobs = () => {
3327
const {data: jobs = [], isPending} = useQuery({
3428
queryKey: ["jobs"],
3529
queryFn: async () => {
@@ -41,17 +35,17 @@ const Jobs = ({className}: JobsProps) => {
4135
});
4236

4337
return (
44-
<div className={className}>
45-
<DashboardCard title={"Ingestion Jobs"}>
46-
<VirtualTable<JobData>
47-
className={styles["jobs"] || ""}
48-
columns={jobColumns}
49-
dataSource={jobs}
50-
loading={isPending}
51-
pagination={false}
52-
scroll={{y: 400}}/>
53-
</DashboardCard>
54-
</div>
38+
<DashboardCard
39+
isLoading={isPending}
40+
title={"Ingestion Jobs"}
41+
>
42+
<VirtualTable<JobData>
43+
className={styles["jobs"] || ""}
44+
columns={jobColumns}
45+
dataSource={jobs}
46+
pagination={false}
47+
scroll={{y: 400}}/>
48+
</DashboardCard>
5549
);
5650
};
5751

components/webui/client/src/pages/IngestPage/SpaceSavings/CompressedSize.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import DetailsCard from "../Details/DetailsCard";
1+
import {DashboardCard} from "../../../components/DashboardCard";
2+
import Stat from "../../../components/Stat";
23
import {formatSizeInBytes} from "../Jobs/units";
34

45

@@ -17,10 +18,12 @@ interface CompressedSizeProps {
1718
*/
1819
const CompressedSize = ({compressedSize, isLoading}: CompressedSizeProps) => {
1920
return (
20-
<DetailsCard
21+
<DashboardCard
2122
isLoading={isLoading}
22-
stat={formatSizeInBytes(compressedSize, false)}
23-
title={"Compressed Size"}/>
23+
title={"Compressed Size"}
24+
>
25+
<Stat text={formatSizeInBytes(compressedSize, false)}/>
26+
</DashboardCard>
2427
);
2528
};
2629

components/webui/client/src/pages/IngestPage/SpaceSavings/UncompressedSize.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import DetailsCard from "../Details/DetailsCard";
1+
import {DashboardCard} from "../../../components/DashboardCard";
2+
import Stat from "../../../components/Stat";
23
import {formatSizeInBytes} from "../Jobs/units";
34

45

@@ -17,10 +18,12 @@ interface UncompressedSizeProps {
1718
*/
1819
const UncompressedSize = ({uncompressedSize, isLoading}: UncompressedSizeProps) => {
1920
return (
20-
<DetailsCard
21+
<DashboardCard
2122
isLoading={isLoading}
22-
stat={formatSizeInBytes(uncompressedSize, false)}
23-
title={"Uncompressed Size"}/>
23+
title={"Uncompressed Size"}
24+
>
25+
<Stat text={formatSizeInBytes(uncompressedSize, false)}/>
26+
</DashboardCard>
2427
);
2528
};
2629

0 commit comments

Comments
 (0)