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
e7a788fa
Commit
e7a788fa
authored
May 09, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak memo detail page
parent
942052b1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
34 deletions
+57
-34
MemoEditorDialog.tsx
web/src/components/MemoEditor/MemoEditorDialog.tsx
+22
-10
index.tsx
web/src/components/MemoEditor/index.tsx
+1
-1
base-dialog.less
web/src/less/base-dialog.less
+1
-1
en.json
web/src/locales/en.json
+2
-2
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+31
-20
No files found.
web/src/components/MemoEditor/MemoEditorDialog.tsx
View file @
e7a788fa
import
{
IconButton
}
from
"@mui/joy"
;
import
{
IconButton
}
from
"@mui/joy"
;
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
{
useTagStore
}
from
"@/store/v1"
;
import
{
useTagStore
}
from
"@/store/v1"
;
import
{
MemoRelation
}
from
"@/types/proto/api/v1/memo_relation_service"
;
import
MemoEditor
,
{
Props
as
MemoEditorProps
}
from
"."
;
import
MemoEditor
from
"."
;
import
{
generateDialog
}
from
"../Dialog"
;
import
{
generateDialog
}
from
"../Dialog"
;
import
Icon
from
"../Icon"
;
import
Icon
from
"../Icon"
;
interface
Props
extends
DialogProps
{
interface
Props
extends
DialogProps
,
MemoEditorProps
{}
memoName
?:
string
;
cacheKey
?:
string
;
relationList
?:
MemoRelation
[];
}
const
MemoEditorDialog
:
React
.
FC
<
Props
>
=
({
memoName
:
memo
,
cacheKey
,
relationList
,
destroy
}:
Props
)
=>
{
const
MemoEditorDialog
:
React
.
FC
<
Props
>
=
({
memoName
:
memo
,
parentMemoName
,
placeholder
,
cacheKey
,
relationList
,
onConfirm
,
destroy
,
}:
Props
)
=>
{
const
tagStore
=
useTagStore
();
const
tagStore
=
useTagStore
();
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -23,6 +26,13 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
...
@@ -23,6 +26,13 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
destroy
();
destroy
();
};
};
const
handleConfirm
=
(
memoName
:
string
)
=>
{
handleCloseBtnClick
();
if
(
onConfirm
)
{
onConfirm
(
memoName
);
}
};
return
(
return
(
<>
<>
<
div
className=
"w-full flex flex-row justify-between items-center mb-2"
>
<
div
className=
"w-full flex flex-row justify-between items-center mb-2"
>
...
@@ -39,8 +49,10 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
...
@@ -39,8 +49,10 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
className=
"border-none !p-0 -mb-2"
className=
"border-none !p-0 -mb-2"
cacheKey=
{
`memo-editor-${cacheKey || memo}`
}
cacheKey=
{
`memo-editor-${cacheKey || memo}`
}
memoName=
{
memo
}
memoName=
{
memo
}
parentMemoName=
{
parentMemoName
}
placeholder=
{
placeholder
}
relationList=
{
relationList
}
relationList=
{
relationList
}
onConfirm=
{
handleC
loseBtnClick
}
onConfirm=
{
handleC
onfirm
}
autoFocus
autoFocus
/>
/>
</
div
>
</
div
>
...
@@ -48,7 +60,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
...
@@ -48,7 +60,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationL
);
);
};
};
export
default
function
showMemoEditorDialog
(
props
:
P
ick
<
Props
,
"memoName"
|
"cacheKey"
|
"relationList"
>
=
{}):
void
{
export
default
function
showMemoEditorDialog
(
props
:
P
artial
<
Props
>
=
{}):
void
{
generateDialog
(
generateDialog
(
{
{
className
:
"memo-editor-dialog"
,
className
:
"memo-editor-dialog"
,
...
...
web/src/components/MemoEditor/index.tsx
View file @
e7a788fa
...
@@ -28,7 +28,7 @@ import ResourceListView from "./ResourceListView";
...
@@ -28,7 +28,7 @@ import ResourceListView from "./ResourceListView";
import
{
handleEditorKeydownWithMarkdownShortcuts
,
hyperlinkHighlightedText
}
from
"./handlers"
;
import
{
handleEditorKeydownWithMarkdownShortcuts
,
hyperlinkHighlightedText
}
from
"./handlers"
;
import
{
MemoEditorContext
}
from
"./types"
;
import
{
MemoEditorContext
}
from
"./types"
;
interface
Props
{
export
interface
Props
{
className
?:
string
;
className
?:
string
;
cacheKey
?:
string
;
cacheKey
?:
string
;
placeholder
?:
string
;
placeholder
?:
string
;
...
...
web/src/less/base-dialog.less
View file @
e7a788fa
.dialog-wrapper {
.dialog-wrapper {
@apply fixed top-0 left-0 flex flex-col justify-start items-center w-full h-full pt-16 pb-8 px-4 z-
2
000 overflow-x-hidden overflow-y-scroll bg-transparent transition-all hide-scrollbar bg-black bg-opacity-60;
@apply fixed top-0 left-0 flex flex-col justify-start items-center w-full h-full pt-16 pb-8 px-4 z-
1
000 overflow-x-hidden overflow-y-scroll bg-transparent transition-all hide-scrollbar bg-black bg-opacity-60;
> .dialog-container {
> .dialog-container {
@apply max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg;
@apply max-w-full shadow flex flex-col justify-start items-start bg-white dark:bg-zinc-800 dark:text-gray-300 p-4 rounded-lg;
...
...
web/src/locales/en.json
View file @
e7a788fa
...
@@ -96,8 +96,8 @@
...
@@ -96,8 +96,8 @@
"memo"
:
{
"memo"
:
{
"archived-at"
:
"Archived at"
,
"archived-at"
:
"Archived at"
,
"comment"
:
{
"comment"
:
{
"
no-comment"
:
"No comment
"
,
"
self"
:
"Comments
"
,
"
self"
:
"Comments
"
"
write-a-comment"
:
"Write a comment
"
},
},
"copy-link"
:
"Copy Link"
,
"copy-link"
:
"Copy Link"
,
"count-memos-in-date"
:
"{{count}} memos in {{date}}"
,
"count-memos-in-date"
:
"{{count}} memos in {{date}}"
,
...
...
web/src/pages/MemoDetail.tsx
View file @
e7a788fa
import
{
Button
}
from
"@mui/joy"
;
import
{
ClientError
}
from
"nice-grpc-web"
;
import
{
ClientError
}
from
"nice-grpc-web"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
Link
,
useParams
}
from
"react-router-dom"
;
import
{
Link
,
useParams
}
from
"react-router-dom"
;
import
Icon
from
"@/components/Icon"
;
import
Icon
from
"@/components/Icon"
;
import
MemoEditor
from
"@/components/MemoEditor
"
;
import
showMemoEditorDialog
from
"@/components/MemoEditor/MemoEditorDialog
"
;
import
MemoView
from
"@/components/MemoView"
;
import
MemoView
from
"@/components/MemoView"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
...
@@ -60,6 +61,14 @@ const MemoDetail = () => {
...
@@ -60,6 +61,14 @@ const MemoDetail = () => {
return
null
;
return
null
;
}
}
const
handleShowCommentEditor
=
()
=>
{
showMemoEditorDialog
({
placeholder
:
t
(
"editor.add-your-comment-here"
),
parentMemoName
:
memo
.
name
,
onConfirm
:
handleCommentCreated
,
});
};
const
handleCommentCreated
=
async
(
memoCommentName
:
string
)
=>
{
const
handleCommentCreated
=
async
(
memoCommentName
:
string
)
=>
{
await
memoStore
.
getOrFetchMemoByName
(
memoCommentName
);
await
memoStore
.
getOrFetchMemoByName
(
memoCommentName
);
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
...
@@ -96,33 +105,35 @@ const MemoDetail = () => {
...
@@ -96,33 +105,35 @@ const MemoDetail = () => {
</
h2
>
</
h2
>
<
div
className=
"relative mx-auto flex-grow w-full min-h-full flex flex-col justify-start items-start gap-y-1"
>
<
div
className=
"relative mx-auto flex-grow w-full min-h-full flex flex-col justify-start items-start gap-y-1"
>
{
comments
.
length
===
0
?
(
{
comments
.
length
===
0
?
(
<
div
className=
"w-full flex flex-col justify-center items-center py-6 mb-2"
>
currentUser
&&
(
<
Icon
.
MessageCircle
strokeWidth=
{
1
}
className=
"w-8 h-auto text-gray-400"
/>
<
div
className=
"w-full flex flex-row justify-center items-center py-6"
>
<
p
className=
"text-gray-400 italic text-sm"
>
{
t
(
"memo.comment.no-comment"
)
}
</
p
>
<
Button
variant=
"plain"
color=
"neutral"
startDecorator=
{
<
Icon
.
MessageCircle
className=
"w-5 h-auto text-gray-400"
/>
}
onClick=
{
handleShowCommentEditor
}
>
<
span
className=
""
>
{
t
(
"memo.comment.write-a-comment"
)
}
</
span
>
</
Button
>
</
div
>
</
div
>
)
)
:
(
)
:
(
<>
<>
<
div
className=
"w-full flex flex-row justify-start items-center pl-3 mb-3"
>
<
div
className=
"w-full flex flex-row justify-between items-center px-3 mb-2"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
Icon
.
MessageCircle
className=
"w-5 h-auto text-gray-400 mr-1"
/>
<
Icon
.
MessageCircle
className=
"w-5 h-auto text-gray-400 mr-1"
/>
<
span
className=
"text-gray-400 text-sm"
>
{
t
(
"memo.comment.self"
)
}
</
span
>
<
span
className=
"text-gray-400 text-sm"
>
{
t
(
"memo.comment.self"
)
}
</
span
>
<
span
className=
"text-gray-400 text-sm ml-0.5"
>
(
{
comments
.
length
}
)
</
span
>
<
span
className=
"text-gray-400 text-sm ml-1"
>
(
{
comments
.
length
}
)
</
span
>
</
div
>
<
Button
variant=
"plain"
color=
"neutral"
onClick=
{
handleShowCommentEditor
}
>
<
span
className=
"font-normal"
>
{
t
(
"memo.comment.write-a-comment"
)
}
</
span
>
</
Button
>
</
div
>
</
div
>
{
comments
.
map
((
comment
)
=>
(
{
comments
.
map
((
comment
)
=>
(
<
MemoView
key=
{
`${comment.name}-${comment.displayTime}`
}
memo=
{
comment
}
showCreator
/>
<
MemoView
key=
{
`${comment.name}-${comment.displayTime}`
}
memo=
{
comment
}
showCreator
/>
))
}
))
}
</>
</>
)
}
)
}
{
/* Only show comment editor when user login */
}
{
currentUser
&&
(
<
MemoEditor
key=
{
memo
.
name
}
cacheKey=
{
`comment-editor-${memo.name}`
}
placeholder=
{
t
(
"editor.add-your-comment-here"
)
}
parentMemoName=
{
memo
.
name
}
onConfirm=
{
handleCommentCreated
}
/>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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