Sfoglia il codice sorgente

Improved alert & ClosableTextInput

Taichi Masuyama 4 anni fa
parent
commit
bc95f2378d

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

@@ -168,7 +168,8 @@
   "form_validation": {
   "form_validation": {
     "error_message": "Some values ​​are incorrect",
     "error_message": "Some values ​​are incorrect",
     "required": "%s is required",
     "required": "%s is required",
-    "invalid_syntax": "The syntax of %s is invalid."
+    "invalid_syntax": "The syntax of %s is invalid.",
+    "title_required": "Title is required."
   },
   },
   "not_found_page": {
   "not_found_page": {
     "Create Page": "Create Page",
     "Create Page": "Create Page",

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

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

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

@@ -168,7 +168,8 @@
 	"form_validation": {
 	"form_validation": {
 		"error_message": "有些值不正确",
 		"error_message": "有些值不正确",
 		"required": "%s 是必需的",
 		"required": "%s 是必需的",
-		"invalid_syntax": "%s的语法无效。"
+		"invalid_syntax": "%s的语法无效。",
+    "title_required": "标题是必需的。"
   },
   },
   "not_found_page": {
   "not_found_page": {
     "Create Page": "创建页面",
     "Create Page": "创建页面",

+ 4 - 3
packages/app/src/components/Common/ClosableTextInput.tsx

@@ -3,8 +3,8 @@ import React, {
 } from 'react';
 } from 'react';
 
 
 export const AlertType = {
 export const AlertType = {
-  WARNING: 'warning',
-  ERROR: 'error',
+  WARNING: 'Warning',
+  ERROR: 'Error',
 } as const;
 } as const;
 
 
 export type AlertType = typeof AlertType[keyof typeof AlertType];
 export type AlertType = typeof AlertType[keyof typeof AlertType];
@@ -81,8 +81,9 @@ const ClosableTextInput: FC<ClosableTextInputProps> = memo((props: ClosableTextI
 
 
     const alertType = currentAlertInfo.type != null ? currentAlertInfo.type : AlertType.ERROR;
     const alertType = currentAlertInfo.type != null ? currentAlertInfo.type : AlertType.ERROR;
     const alertMessage = currentAlertInfo.message != null ? currentAlertInfo.message : 'Invalid value';
     const alertMessage = currentAlertInfo.message != null ? currentAlertInfo.message : 'Invalid value';
+    const alertTextStyle = alertType === AlertType.ERROR ? 'text-danger' : 'text-warning';
     return (
     return (
-      <p className="text-danger text-center mt-1">{alertType}: {alertMessage}</p>
+      <p className={`${alertTextStyle} text-center mt-1`}>{alertType}: {alertMessage}</p>
     );
     );
   };
   };
 
 

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

@@ -139,8 +139,8 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
   const inputValidator = (title: string | null): AlertInfo | null => {
   const inputValidator = (title: string | null): AlertInfo | null => {
     if (title == null || title === '') {
     if (title == null || title === '') {
       return {
       return {
-        type: AlertType.ERROR,
-        message: t('Page title is required'),
+        type: AlertType.WARNING,
+        message: t('form_validation.title_required'),
       };
       };
     }
     }