Copilot commented on code in PR #3023:
URL: https://github.com/apache/apisix-dashboard/pull/3023#discussion_r2079502102


##########
src/config/req.ts:
##########
@@ -60,6 +56,11 @@ req.interceptors.response.use(
         message: d.error_msg,
         color: 'red',
       });
+      // Requires to enter admin key at 401
+      if (err.response.status === 401) {
+        globalStore.settings.set('isOpen', true);
+        return Promise.resolve({ data: {} });

Review Comment:
   Returning an empty data object on a 401 error may unintentionally mask 
authentication failures and cause unexpected behavior downstream. Consider 
handling the error in a way that appropriately signals an authentication issue.
   ```suggestion
           return Promise.reject(err);
   ```



##########
vite.config.ts:
##########
@@ -42,8 +43,14 @@ export default defineConfig({
       compiler: 'jsx',
       jsx: 'react',
     }),
-    TanStackRouterVite({ target: 'react', autoCodeSplitting: true, semicolons: 
false }),
-    react(),
+    TanStackRouterVite({
+      target: 'react',
+      autoCodeSplitting: true,
+      semicolons: false,
+    }),
+    react({
+      plugins: [observerPlugin() as never],

Review Comment:
   [nitpick] Using 'as never' to cast observerPlugin's return type may bypass 
type safety checks. Consider verifying the correct type definitions for the 
plugin to ensure robust type safety.
   ```suggestion
         plugins: [observerPlugin()],
   ```



##########
src/components/page/SettingsModal.tsx:
##########
@@ -0,0 +1,30 @@
+import { queryClient } from '@/config/global';
+import { globalStore } from '@/stores/global';
+import { Modal, TextInput } from '@mantine/core';
+import { useTranslation } from 'react-i18next';
+
+export const SettingsModal = () => {
+  const { t } = useTranslation();
+
+  return (
+    <Modal
+      opened={globalStore.settings.isOpen}
+      onClose={() => globalStore.settings.set('isOpen', false)}
+      centered
+      title={t('settings.title')}
+    >
+      <TextInput
+        label={t('settings.adminKey')}
+        value={globalStore.settings.adminKey}
+        onChange={(e) => {
+          globalStore.settings.set('adminKey', e.currentTarget.value);
+          setTimeout(() => {
+            queryClient.invalidateQueries();
+            queryClient.refetchQueries();
+          });

Review Comment:
   [nitpick] Consider specifying an explicit delay for the setTimeout call to 
ensure consistent scheduling, even though it defaults to 0.
   ```suggestion
             }, 0);
   ```



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to