Skip to content

Commit 640f2b3

Browse files
committed
fix(frontend): storage unit search and fix breadcrumb bug
1 parent e22314a commit 640f2b3

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

frontend/src/components/table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export const Table: FC<ITableProps> = ({ className, columns: actualColumns, rows
409409
}, [rows]);
410410

411411
const handleKeyUp = useCallback((e: KeyboardEvent<HTMLInputElement>) => {
412-
if (tableRef.current == null) {
412+
if (tableRef.current == null || search.length === 0) {
413413
return;
414414
}
415415
let interval: NodeJS.Timeout;

frontend/src/pages/storage-unit/explore-storage-unit.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FetchResult } from "@apollo/client";
22
import { entries, map } from "lodash";
33
import { FC, useCallback, useEffect, useMemo, useState } from "react";
4-
import { Navigate, useLocation } from "react-router-dom";
4+
import { Navigate, useLocation, useNavigate } from "react-router-dom";
55
import { AnimatedButton } from "../../components/button";
66
import { Icons } from "../../components/icons";
77
import { InputWithlabel } from "../../components/input";
@@ -23,15 +23,20 @@ export const ExploreStorageUnit: FC = () => {
2323
const unit: StorageUnit = useLocation().state?.unit;
2424
const schema = useAppSelector(state => state.database.schema);
2525
const current = useAppSelector(state => state.auth.current);
26+
const navigate = useNavigate();
2627

2728
const [getStorageUnitRows, { data: rows, loading }] = useGetStorageUnitRowsLazyQuery();
2829

30+
const unitName = useMemo(() => {
31+
return unit?.Name;
32+
}, [unit]);
33+
2934
const handleSubmitRequest = useCallback(() => {
3035
getStorageUnitRows({
3136
variables: {
3237
type: current?.Type as DatabaseType,
3338
schema,
34-
storageUnit: unit.Name,
39+
storageUnit: unitName,
3540
where: whereCondition,
3641
pageSize: Number.parseInt(bufferPageSize),
3742
pageOffset: currentPage,
@@ -41,21 +46,21 @@ export const ExploreStorageUnit: FC = () => {
4146
},
4247
fetchPolicy: "no-cache",
4348
});
44-
}, [getStorageUnitRows, current?.Type, schema, unit.Name, whereCondition, bufferPageSize, currentPage]);
49+
}, [getStorageUnitRows, current?.Type, schema, unitName, whereCondition, bufferPageSize, currentPage]);
4550

4651
const handlePageChange = useCallback((page: number) => {
4752
setCurrentPage(page-1);
4853
getStorageUnitRows({
4954
variables: {
5055
type: current?.Type as DatabaseType,
5156
schema,
52-
storageUnit: unit.Name,
57+
storageUnit: unitName,
5358
where: whereCondition,
5459
pageSize: Number.parseInt(bufferPageSize),
5560
pageOffset: currentPage,
5661
}
5762
});
58-
}, [current?.Type, currentPage, getStorageUnitRows, bufferPageSize, schema, unit.Name, whereCondition]);
63+
}, [getStorageUnitRows, current?.Type, schema, unitName, whereCondition, bufferPageSize, currentPage]);
5964

6065
const handleQuery = useCallback(() => {
6166
handleSubmitRequest();
@@ -78,7 +83,7 @@ export const ExploreStorageUnit: FC = () => {
7883
mutation: UpdateStorageUnitDocument,
7984
variables: {
8085
schema,
81-
storageUnit: unit.Name,
86+
storageUnit: unitName,
8287
type: current.Type as DatabaseType,
8388
values,
8489
},
@@ -93,7 +98,7 @@ export const ExploreStorageUnit: FC = () => {
9398
}
9499
return rej();
95100
});
96-
}, [current, schema, unit.Name]);
101+
}, [current, schema, unitName]);
97102

98103
const totalCount = useMemo(() => {
99104
return unit?.Attributes.find(attribute => attribute.Key === "Count")?.Value ?? "unknown";
@@ -122,6 +127,12 @@ export const ExploreStorageUnit: FC = () => {
122127
];
123128
}, [current]);
124129

130+
useEffect(() => {
131+
if (unitName == null) {
132+
navigate(InternalRoutes.Dashboard.StorageUnit.path);
133+
}
134+
}, [navigate, unitName]);
135+
125136
if (unit == null) {
126137
return <Navigate to={InternalRoutes.Dashboard.StorageUnit.path} />
127138
}
@@ -136,7 +147,7 @@ export const ExploreStorageUnit: FC = () => {
136147
<div className="flex flex-col grow gap-4 h-[calc(100%-100px)]">
137148
<div className="flex items-center justify-between">
138149
<div className="flex gap-2 items-center">
139-
<div className="text-xl font-bold mr-4 dark:text-neutral-300">{unit.Name}</div>
150+
<div className="text-xl font-bold mr-4 dark:text-neutral-300">{unitName}</div>
140151
</div>
141152
<div className="text-sm mr-4 dark:text-neutral-300"><span className="font-semibold">Total Count:</span> {totalCount}</div>
142153
</div>

0 commit comments

Comments
 (0)