This is an automated email from the ASF dual-hosted git repository.

imbajin pushed a commit to branch hubble-dev
in repository https://gitbox.apache.org/repos/asf/hugegraph-toolchain.git


The following commit(s) were added to refs/heads/hubble-dev by this push:
     new 8a4e8d6f fix(hubble): address review comments on frontend validation
8a4e8d6f is described below

commit 8a4e8d6f4e4de1396a859401300e8a9e7a06127c
Author: imbajin <[email protected]>
AuthorDate: Sun Jul 12 15:32:18 2026 +0800

    fix(hubble): address review comments on frontend validation
---
 .../src/i18n/resources/en-US/components/common.json    |  1 +
 .../src/i18n/resources/zh-CN/components/common.json    |  1 +
 .../analysis/QueryBar/ContentCommon/index.test.js      | 18 +++++++++++++++---
 hugegraph-hubble/hubble-fe/src/utils/rules.js          |  4 ++--
 hugegraph-hubble/hubble-fe/src/utils/rules.test.js     | 12 +++++++++++-
 5 files changed, 30 insertions(+), 6 deletions(-)

diff --git 
a/hugegraph-hubble/hubble-fe/src/i18n/resources/en-US/components/common.json 
b/hugegraph-hubble/hubble-fe/src/i18n/resources/en-US/components/common.json
index 44f8f3a9..f2fdcafe 100644
--- a/hugegraph-hubble/hubble-fe/src/i18n/resources/en-US/components/common.json
+++ b/hugegraph-hubble/hubble-fe/src/i18n/resources/en-US/components/common.json
@@ -27,6 +27,7 @@
       "normal_name_rule": "Use Chinese characters, letters, numbers, or 
underscores only, up to 20 characters",
       "jdbc_rule": "Enter a valid JDBC URL, for example: 
jdbc:mysql://127.0.0.1:3306/db_name",
       "account_name_rule": "Account name must be within 16 characters and 
cannot start or end with an underscore",
+      "favorite_name_rule": "Use Chinese characters, letters, numbers, or 
underscores only, up to 48 characters",
       "invalid_data_format": "Invalid data format"
     }
   },
diff --git 
a/hugegraph-hubble/hubble-fe/src/i18n/resources/zh-CN/components/common.json 
b/hugegraph-hubble/hubble-fe/src/i18n/resources/zh-CN/components/common.json
index 5e3147c2..e8a4e004 100644
--- a/hugegraph-hubble/hubble-fe/src/i18n/resources/zh-CN/components/common.json
+++ b/hugegraph-hubble/hubble-fe/src/i18n/resources/zh-CN/components/common.json
@@ -27,6 +27,7 @@
       "normal_name_rule": "只能包含中文、字母、数字、_, 不能超过20个字符",
       "jdbc_rule": "请输入正确的jdbc url, 例如:jdbc:mysql://127.0.0.1:3306/db_name",
       "account_name_rule": "账号名不超过16个字符,且不能以下划线开始和结尾",
+      "favorite_name_rule": "只能包含中文、字母、数字、_, 不能超过48个字符",
       "invalid_data_format": "非法的数据格式"
     }
   },
diff --git 
a/hugegraph-hubble/hubble-fe/src/modules/analysis/QueryBar/ContentCommon/index.test.js
 
b/hugegraph-hubble/hubble-fe/src/modules/analysis/QueryBar/ContentCommon/index.test.js
index 5a72884c..836da74c 100644
--- 
a/hugegraph-hubble/hubble-fe/src/modules/analysis/QueryBar/ContentCommon/index.test.js
+++ 
b/hugegraph-hubble/hubble-fe/src/modules/analysis/QueryBar/ContentCommon/index.test.js
@@ -1,8 +1,19 @@
 /*
+ *
  * 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.
+ * 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 {fireEvent, render, screen} from '@testing-library/react';
@@ -49,6 +60,7 @@ test('keeps favorite submission disabled until the name is 
backend-compatible',
     const input = 
screen.getByPlaceholderText('analysis.query.favorite_name_placeholder');
     const submit = screen.getAllByRole('button', {name: 
'analysis.query.favorite'})
         .find(button => button.closest('.ant-popover'));
+    expect(submit).toBeDefined();
 
     fireEvent.change(input, {target: {value: 'query-name'}});
     expect(submit).toBeDisabled();
diff --git a/hugegraph-hubble/hubble-fe/src/utils/rules.js 
b/hugegraph-hubble/hubble-fe/src/utils/rules.js
index cacf1cf1..3255860d 100644
--- a/hugegraph-hubble/hubble-fe/src/utils/rules.js
+++ b/hugegraph-hubble/hubble-fe/src/utils/rules.js
@@ -158,7 +158,7 @@ const isAccountName = msg => ({
     },
 });
 
-const isValidFavoriteName = value => /^[A-Za-z0-9_]{1,48}$/.test(value);
+const isValidFavoriteName = value => typeof value === 'string' && 
/^[A-Za-z0-9_\u4e00-\u9fa5]{1,48}$/.test(value);
 
 const isFavoriteName = msg => ({
     validator(_, value) {
@@ -166,7 +166,7 @@ const isFavoriteName = msg => ({
             return Promise.resolve();
         }
         return Promise.reject(new Error(
-            typeof msg === 'string' ? msg : 'Use letters, numbers, or 
underscores only'
+            typeof msg === 'string' ? msg : 
validationMessage('favorite_name_rule')
         ));
     },
 });
diff --git a/hugegraph-hubble/hubble-fe/src/utils/rules.test.js 
b/hugegraph-hubble/hubble-fe/src/utils/rules.test.js
index 4aaeafe5..8128fc93 100644
--- a/hugegraph-hubble/hubble-fe/src/utils/rules.test.js
+++ b/hugegraph-hubble/hubble-fe/src/utils/rules.test.js
@@ -38,6 +38,8 @@ jest.mock('../i18n', () => ({
                     'Enter a valid JDBC URL, for example: 
jdbc:mysql://127.0.0.1:3306/db_name',
                 'common.validation.account_name_rule':
                     'Account name must be within 16 characters and cannot 
start or end with an underscore',
+                'common.validation.favorite_name_rule':
+                    'Use Chinese characters, letters, numbers, or underscores 
only, up to 48 characters',
                 'common.validation.invalid_data_format': 'Invalid data format',
             },
             'zh-CN': {
@@ -53,6 +55,7 @@ jest.mock('../i18n', () => ({
                 'common.validation.jdbc_rule':
                     '请输入正确的jdbc url, 例如:jdbc:mysql://127.0.0.1:3306/db_name',
                 'common.validation.account_name_rule': 
'账号名不超过16个字符,且不能以下划线开始和结尾',
+                'common.validation.favorite_name_rule': '只能包含中文、字母、数字、_, 
不能超过48个字符',
                 'common.validation.invalid_data_format': '非法的数据格式',
             },
         };
@@ -146,10 +149,17 @@ describe('rules i18n defaults', () => {
     });
 
     it('accepts only backend-compatible favorite names', async () => {
+        await i18n.changeLanguage('en-US');
         await expect(rules.isFavoriteName().validator(null, 'query_2026'))
             .resolves.toBeUndefined();
+        await expect(rules.isFavoriteName().validator(null, '我的查询_123'))
+            .resolves.toBeUndefined();
         await expect(rules.isFavoriteName().validator(null, 'query-2026'))
-            .rejects.toBeInstanceOf(Error);
+            .rejects.toThrow('Use Chinese characters, letters, numbers, or 
underscores only, up to 48 characters');
+        await expect(rules.isFavoriteName().validator(null, undefined))
+            .rejects.toThrow('Use Chinese characters, letters, numbers, or 
underscores only, up to 48 characters');
+        await expect(rules.isFavoriteName().validator(null, null))
+            .rejects.toThrow('Use Chinese characters, letters, numbers, or 
underscores only, up to 48 characters');
     });
 
     it('uses Chinese messages when the active language is Chinese', async () 
=> {

Reply via email to