Baoyuantop commented on code in PR #3295:
URL: https://github.com/apache/apisix-dashboard/pull/3295#discussion_r2959089279


##########
src/routes/upstreams/detail.$id.tsx:
##########
@@ -68,11 +72,14 @@ const UpstreamDetailForm = (
     refetch,
   } = useSuspenseQuery(getUpstreamQueryOptions(id));
 
-  const form = useForm({
+  const formDefaults = produceToUpstreamForm(upstreamData) as 
FormPartUpstreamType;
+  type FormPartUpstreamInput = z.input<typeof FormPartUpstreamSchema>;
+  const form = useForm<FormPartUpstreamInput, unknown, FormPartUpstreamType>({
     resolver: zodResolver(FormPartUpstreamSchema),
     shouldUnregister: true,
     mode: 'all',
     disabled: readOnly,
+    defaultValues: formDefaults,
   });
 
   const putUpstream = useMutation({

Review Comment:
   **🔴 Missing Suspense boundary**
   
   Same issue as Service detail — `useSuspenseQuery` is used but no 
`<Suspense>` boundary wraps `UpstreamDetailForm` in the parent 
`RouteComponent`. The old `isLoading` / `<Skeleton>` guard was removed on 
master but no Suspense fallback was added.
   
   Please add a `<Suspense fallback={<Skeleton height={400} />}>` wrapper 
around `<UpstreamDetailForm>` in `RouteComponent`, consistent with Route 
detail's pattern.



##########
src/routes/services/detail.$id/index.tsx:
##########
@@ -53,21 +53,20 @@ const ServiceDetailForm = (props: Props) => {
   const { id } = useParams({ from: '/services/detail/$id' });
 
   const serviceQuery = useSuspenseQuery(getServiceQueryOptions(id));
-  const { data: serviceData, isLoading, refetch } = serviceQuery;
+  const { data: serviceData, refetch } = serviceQuery;
 
   const form = useForm({
     resolver: zodResolver(APISIX.Service),
     shouldUnregister: true,
     shouldFocusError: true,
     mode: 'all',
     disabled: readOnly,
+    defaultValues: serviceData.value,

Review Comment:
   **🔴 Missing Suspense boundary**
   
   This file uses `useSuspenseQuery` but has no `<Suspense>` boundary wrapping 
`ServiceDetailForm`. The PR also removes the `isLoading` / `<Skeleton>` 
fallback.
   
   Without a local Suspense boundary, React will bubble up to the nearest 
ancestor boundary (likely the router level), which may result in a blank area 
or full-page loading spinner — a UX regression.
   
   Route detail and Stream Route detail both got Suspense boundaries in this 
PR. Service detail should be consistent.
   
   ```tsx
   // In RouteComponent, wrap ServiceDetailForm similar to how RouteDetail does 
it:
   <Suspense
     fallback={
       <FormTOCBox>
         <Skeleton height={400} />
       </FormTOCBox>
     }
   >
     <FormTOCBox>
       <ServiceDetailForm readOnly={readOnly} setReadOnly={setReadOnly} />
     </FormTOCBox>
   </Suspense>
   ```



##########
src/routes/upstreams/detail.$id.tsx:
##########
@@ -68,11 +72,14 @@ const UpstreamDetailForm = (
     refetch,
   } = useSuspenseQuery(getUpstreamQueryOptions(id));
 
-  const form = useForm({
+  const formDefaults = produceToUpstreamForm(upstreamData) as 
FormPartUpstreamType;

Review Comment:
   **🟡 Nit: `formDefaults` recomputed every render**
   
   `produceToUpstreamForm(upstreamData)` runs `produce()` (immer) on every 
render. While `defaultValues` is only consumed on first mount, the computation 
still runs. Consider wrapping in `useMemo`:
   
   ```ts
   const formDefaults = useMemo(
     () => produceToUpstreamForm(upstreamData) as FormPartUpstreamType,
     [upstreamData]
   );
   ```
   
   Same applies to the `formDefaults` computation in `routes/detail.$id.tsx`.



##########
e2e/tests/upstreams.pass-host-reset.spec.ts:
##########
@@ -0,0 +1,312 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { upstreamsPom } from '@e2e/pom/upstreams';
+import { randomId } from '@e2e/utils/common';
+import { e2eReq } from '@e2e/utils/req';
+import { test } from '@e2e/utils/test';
+import { uiHasToastMsg } from '@e2e/utils/ui';
+import { expect } from '@playwright/test';
+
+import { deleteAllUpstreams } from '@/apis/upstreams';
+
+test.beforeAll(async () => {
+  await deleteAllUpstreams(e2eReq);
+});

Review Comment:
   **🔴 `deleteAllUpstreams` still present — race condition risk**
   
   The Copilot reviewer flagged this and you marked it resolved, but 
`deleteAllUpstreams(e2eReq)` is still here in the final diff. With 
`fullyParallel: true`, this will nuke upstreams created by other parallel specs.
   
   The `routes.clear-upstream-field.spec.ts` changes in this same PR 
demonstrate the correct pattern — track created resource IDs and clean up only 
what you created in `afterEach`/`afterAll`.
   
   Since each test in this file already creates its own upstream with 
`randomId` and deletes it at the end via UI, you can likely just remove this 
`beforeAll` entirely. The tests are self-contained.



##########
src/routes/stream_routes/detail.$id.tsx:
##########
@@ -104,6 +99,20 @@ const StreamRouteDetailForm = (props: Props) => {
   );
 };
 
+const StreamRouteDetailForm = (props: Props) => {
+  return (
+    <Suspense
+      fallback={

Review Comment:
   **🟡 Inconsistent Suspense fallback style**
   
   Route detail uses `<Skeleton height={400} />` as fallback (consistent with 
what was there before), but Stream Route detail uses `<Center><Loader 
/></Center>` with an inline `style={{ padding: 16 }}`.
   
   For consistency across detail pages, consider using the same `<Skeleton>` 
pattern. The inline `style` prop is also uncommon in this codebase (Mantine 
style props like `p={16}` are preferred).
   
   ```tsx
   <Suspense
     fallback={
       <FormTOCBox>
         <Skeleton height={400} />
       </FormTOCBox>
     }
   >
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to