Skip to content

Commit d46d627

Browse files
authored
fix(stream_routes): rm upstream when has service_id (#3120)
1 parent 4d5744a commit d46d627

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/routes/stream_routes/add.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { FormTOCBox } from '@/components/form-slice/FormSection';
3232
import PageHeader from '@/components/page/PageHeader';
3333
import { req } from '@/config/req';
3434
import type { APISIXType } from '@/types/schema/apisix';
35+
import { produceRmUpstreamWhenHas } from '@/utils/form-producer';
3536
import { pipeProduce } from '@/utils/producer';
3637

3738
type Props = {
@@ -45,7 +46,10 @@ export const StreamRouteAddForm = (props: Props) => {
4546

4647
const postStreamRoute = useMutation({
4748
mutationFn: (d: StreamRoutePostType) =>
48-
postStreamRouteReq(req, pipeProduce()(d)),
49+
postStreamRouteReq(
50+
req,
51+
pipeProduce(produceRmUpstreamWhenHas('service_id'))(d)
52+
),
4953
async onSuccess(res) {
5054
notifications.show({
5155
message: t('info.add.success', { name: t('streamRoutes.singular') }),

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import PageHeader from '@/components/page/PageHeader';
3939
import { API_STREAM_ROUTES } from '@/config/constant';
4040
import { req } from '@/config/req';
4141
import { APISIX, type APISIXType } from '@/types/schema/apisix';
42+
import { produceRmUpstreamWhenHas } from '@/utils/form-producer';
4243
import { pipeProduce } from '@/utils/producer';
4344

4445
type Props = {
@@ -70,7 +71,10 @@ const StreamRouteDetailForm = (props: Props) => {
7071

7172
const putStreamRoute = useMutation({
7273
mutationFn: (d: APISIXType['StreamRoute']) =>
73-
putStreamRouteReq(req, pipeProduce()(d)),
74+
putStreamRouteReq(
75+
req,
76+
pipeProduce(produceRmUpstreamWhenHas('service_id'))(d)
77+
),
7478
async onSuccess() {
7579
notifications.show({
7680
message: t('info.edit.success', { name: t('streamRoutes.singular') }),

0 commit comments

Comments
 (0)