Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
e129b122
Unverified
Commit
e129b122
authored
Mar 15, 2023
by
远浅
Committed by
GitHub
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: useTranslation in CreateTagDialog (#1356)
parent
7f30e2e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
CreateTagDialog.tsx
web/src/components/CreateTagDialog.tsx
+5
-3
en.json
web/src/locales/en.json
+4
-1
zh.json
web/src/locales/zh.json
+4
-1
No files found.
web/src/components/CreateTagDialog.tsx
View file @
e129b122
import
{
Input
}
from
"@mui/joy"
;
import
{
Input
}
from
"@mui/joy"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTagStore
}
from
"../store/module"
;
import
{
useTagStore
}
from
"../store/module"
;
import
{
getTagSuggestionList
}
from
"../helpers/api"
;
import
{
getTagSuggestionList
}
from
"../helpers/api"
;
import
{
matcher
}
from
"../labs/marked/matcher"
;
import
{
matcher
}
from
"../labs/marked/matcher"
;
...
@@ -21,6 +22,7 @@ const validateTagName = (tagName: string): boolean => {
...
@@ -21,6 +22,7 @@ const validateTagName = (tagName: string): boolean => {
const
CreateTagDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
CreateTagDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
destroy
}
=
props
;
const
{
destroy
}
=
props
;
const
tagStore
=
useTagStore
();
const
tagStore
=
useTagStore
();
const
{
t
}
=
useTranslation
();
const
[
tagName
,
setTagName
]
=
useState
<
string
>
(
""
);
const
[
tagName
,
setTagName
]
=
useState
<
string
>
(
""
);
const
[
suggestTagNameList
,
setSuggestTagNameList
]
=
useState
<
string
[]
>
([]);
const
[
suggestTagNameList
,
setSuggestTagNameList
]
=
useState
<
string
[]
>
([]);
const
[
showTagSuggestions
,
setShowTagSuggestions
]
=
useState
<
boolean
>
(
false
);
const
[
showTagSuggestions
,
setShowTagSuggestions
]
=
useState
<
boolean
>
(
false
);
...
@@ -82,7 +84,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -82,7 +84,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
return
(
return
(
<>
<>
<
div
className=
"dialog-header-container"
>
<
div
className=
"dialog-header-container"
>
<
p
className=
"title-text"
>
Create Tag
</
p
>
<
p
className=
"title-text"
>
{
t
(
"tag-list.create-tag"
)
}
</
p
>
<
button
className=
"btn close-btn"
onClick=
{
()
=>
destroy
()
}
>
<
button
className=
"btn close-btn"
onClick=
{
()
=>
destroy
()
}
>
<
Icon
.
X
/>
<
Icon
.
X
/>
</
button
>
</
button
>
...
@@ -91,7 +93,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -91,7 +93,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
<
Input
<
Input
className=
"mb-2"
className=
"mb-2"
size=
"md"
size=
"md"
placeholder=
"TAG_NAME"
placeholder=
{
t
(
"tag-list.tag-name"
)
}
value=
{
tagName
}
value=
{
tagName
}
onChange=
{
handleTagNameChanged
}
onChange=
{
handleTagNameChanged
}
onKeyDown=
{
handleTagNameInputKeyDown
}
onKeyDown=
{
handleTagNameInputKeyDown
}
...
@@ -101,7 +103,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -101,7 +103,7 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
/>
/>
{
tagNameList
.
length
>
0
&&
(
{
tagNameList
.
length
>
0
&&
(
<>
<>
<
p
className=
"w-full mt-2 mb-1 text-sm text-gray-400"
>
All tags
</
p
>
<
p
className=
"w-full mt-2 mb-1 text-sm text-gray-400"
>
{
t
(
"tag-list.all-tags"
)
}
</
p
>
<
div
className=
"w-full flex flex-row justify-start items-start flex-wrap"
>
<
div
className=
"w-full flex flex-row justify-start items-start flex-wrap"
>
{
Array
.
from
(
tagNameList
)
{
Array
.
from
(
tagNameList
)
.
sort
()
.
sort
()
...
...
web/src/locales/en.json
View file @
e129b122
...
@@ -142,7 +142,10 @@
...
@@ -142,7 +142,10 @@
"text-placeholder"
:
"Starts with ^ to use regex"
"text-placeholder"
:
"Starts with ^ to use regex"
},
},
"tag-list"
:
{
"tag-list"
:
{
"tip-text"
:
"Input `#tag` to create"
"tip-text"
:
"Input `#tag` to create"
,
"create-tag"
:
"Create Tag"
,
"all-tags"
:
"All Tags"
,
"tag-name"
:
"TAG_NAME"
},
},
"search"
:
{
"search"
:
{
"quickly-filter"
:
"Quickly filter"
"quickly-filter"
:
"Quickly filter"
...
...
web/src/locales/zh.json
View file @
e129b122
...
@@ -142,7 +142,10 @@
...
@@ -142,7 +142,10 @@
"text-placeholder"
:
"以 ^ 开头使用正则表达式"
"text-placeholder"
:
"以 ^ 开头使用正则表达式"
},
},
"tag-list"
:
{
"tag-list"
:
{
"tip-text"
:
"输入`#tag `来创建标签"
"tip-text"
:
"输入`#tag `来创建标签"
,
"create-tag"
:
"创建标签"
,
"all-tags"
:
"全部标签"
,
"tag-name"
:
"标签名称"
},
},
"search"
:
{
"search"
:
{
"quickly-filter"
:
"快速过滤"
"quickly-filter"
:
"快速过滤"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment