Skip to content

Commit 3749e08

Browse files
committed
feat(services): filter stream_routes by service_id
1 parent 67aa1e4 commit 3749e08

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/apis/routes.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ import { API_ROUTES, PAGE_SIZE_MAX, PAGE_SIZE_MIN } from '@/config/constant';
2121
import type { APISIXType } from '@/types/schema/apisix';
2222
import type { PageSearchType } from '@/types/schema/pageSearch';
2323

24-
export type GetRouteListReqParams = PageSearchType & {
24+
export type WithServiceIdFilter = PageSearchType & {
2525
filter?: {
2626
service_id?: string;
2727
};
2828
};
29-
export const getRouteListReq = (
30-
req: AxiosInstance,
31-
params: GetRouteListReqParams
32-
) =>
29+
30+
export const getRouteListReq = (req: AxiosInstance, params: WithServiceIdFilter) =>
3331
req
3432
.get<undefined, APISIXType['RespRouteList']>(API_ROUTES, { params })
3533
.then((v) => v.data);

src/apis/stream_routes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ import type { AxiosInstance } from 'axios';
2020
import type { StreamRoutePostType } from '@/components/form-slice/FormPartStreamRoute/schema';
2121
import { API_STREAM_ROUTES } from '@/config/constant';
2222
import type { APISIXType } from '@/types/schema/apisix';
23-
import type { PageSearchType } from '@/types/schema/pageSearch';
2423

25-
export const getStreamRouteListReq = (req: AxiosInstance, params: PageSearchType) =>
24+
import type { WithServiceIdFilter } from './routes';
25+
26+
export const getStreamRouteListReq = (
27+
req: AxiosInstance,
28+
params: WithServiceIdFilter
29+
) =>
2630
req
2731
.get<unknown, APISIXType['RespStreamRouteList']>(API_STREAM_ROUTES, {
2832
params,

src/routes/services/detail.$id/stream_routes/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ function StreamRouteComponent() {
3939
params={{ id, routeId: record.value.id }}
4040
/>
4141
)}
42+
defaultParams={{
43+
filter: {
44+
service_id: id,
45+
},
46+
}}
4247
/>
4348
</>
4449
);

src/routes/stream_routes/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useMemo } from 'react';
2121
import { useTranslation } from 'react-i18next';
2222

2323
import { getStreamRouteListQueryOptions, useStreamRouteList } from '@/apis/hooks';
24+
import type { WithServiceIdFilter } from '@/apis/routes';
2425
import { DeleteResourceBtn } from '@/components/page/DeleteResourceBtn';
2526
import PageHeader from '@/components/page/PageHeader';
2627
import { ToAddPageBtn, ToDetailPageBtn } from '@/components/page/ToAddPageBtn';
@@ -39,11 +40,15 @@ export type StreamRouteListProps = {
3940
ToDetailBtn: (props: {
4041
record: APISIXType['RespStreamRouteItem'];
4142
}) => React.ReactNode;
43+
defaultParams?: Partial<WithServiceIdFilter>;
4244
};
4345

4446
export const StreamRouteList = (props: StreamRouteListProps) => {
45-
const { routeKey, ToDetailBtn } = props;
46-
const { data, isLoading, refetch, pagination } = useStreamRouteList(routeKey);
47+
const { routeKey, ToDetailBtn, defaultParams } = props;
48+
const { data, isLoading, refetch, pagination } = useStreamRouteList(
49+
routeKey,
50+
defaultParams
51+
);
4752
const { t } = useTranslation();
4853

4954
const columns = useMemo<

0 commit comments

Comments
 (0)