Просмотр исходного кода

warn when a title containing a slash is entered in the validating stage

Shun Miyazawa 4 лет назад
Родитель
Сommit
bb5e365ca7

+ 3 - 1
packages/app/resource/locales/en_US/translation.json

@@ -178,7 +178,9 @@
     "error_message": "Some values ​​are incorrect",
     "required": "%s is required",
     "invalid_syntax": "The syntax of %s is invalid.",
-    "title_required": "Title is required."
+    "title_required": "Title is required.",
+    "slashed_are_not_yet_supported": "Titles containing slashes are not yet supported"
+
   },
   "not_found_page": {
     "Create Page": "Create Page",

+ 2 - 1
packages/app/resource/locales/ja_JP/translation.json

@@ -180,7 +180,8 @@
     "error_message": "いくつかの値が設定されていません",
     "required": "%sに値を入力してください",
     "invalid_syntax": "%sの構文が不正です",
-    "title_required": "タイトルを入力してください"
+    "title_required": "タイトルを入力してください",
+    "slashed_are_not_yet_supported": "スラッシュを含むタイトルにはまだ対応していません"
   },
   "not_found_page": {
     "Create Page": "ページを作成する",

+ 2 - 1
packages/app/resource/locales/zh_CN/translation.json

@@ -178,7 +178,8 @@
 		"error_message": "有些值不正确",
 		"required": "%s 是必需的",
 		"invalid_syntax": "%s的语法无效。",
-    "title_required": "标题是必需的。"
+    "title_required": "标题是必需的。",
+    "slashed_are_not_yet_supported": "スラッシュを含むタイトルにはまだ対応していません"
   },
   "not_found_page": {
     "Create Page": "创建页面",

+ 7 - 5
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -197,11 +197,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
   }, []);
 
   const onPressEnterForRenameHandler = async(inputText: string) => {
-    if (inputText.includes('/')) {
-      toastWarning(t('pagetree.cannot_rename_a_title_that_contains_slash'));
-      return;
-    }
-
     const parentPath = nodePath.dirname(page.path as string);
     const newPagePath = `${parentPath}/${inputText}`;
 
@@ -231,6 +226,13 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
       };
     }
 
+    if (title.includes('/')) {
+      return {
+        type: AlertType.WARNING,
+        message: t('form_validation.slashed_are_not_yet_supported'),
+      };
+    }
+
     return null;
   };