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
078bc164
Commit
078bc164
authored
Oct 02, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update memo relations view
parent
70f464e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
12 deletions
+44
-12
Memo.tsx
web/src/components/Memo.tsx
+12
-3
index.tsx
web/src/components/MemoEditor/index.tsx
+6
-1
MemoRelationListView.tsx
web/src/components/MemoRelationListView.tsx
+1
-3
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+25
-5
No files found.
web/src/components/Memo.tsx
View file @
078bc164
...
@@ -44,6 +44,10 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -44,6 +44,10 @@ const Memo: React.FC<Props> = (props: Props) => {
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
readonly
=
memo
.
creatorUsername
!==
user
?.
username
;
const
readonly
=
memo
.
creatorUsername
!==
user
?.
username
;
const
creator
=
userV1Store
.
getUserByUsername
(
memo
.
creatorUsername
);
const
creator
=
userV1Store
.
getUserByUsername
(
memo
.
creatorUsername
);
const
referenceRelations
=
memo
.
relationList
.
filter
(
(
relation
)
=>
relation
.
memoId
===
memo
.
id
&&
relation
.
relatedMemoId
!==
memo
.
id
&&
relation
.
type
===
"REFERENCE"
);
const
commentRelations
=
memo
.
relationList
.
filter
((
relation
)
=>
relation
.
relatedMemoId
===
memo
.
id
&&
relation
.
type
===
"COMMENT"
);
// Prepare memo creator.
// Prepare memo creator.
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -89,7 +93,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -89,7 +93,7 @@ const Memo: React.FC<Props> = (props: Props) => {
if
(
!
shouldRender
)
{
if
(
!
shouldRender
)
{
// Render a placeholder to occupy the space.
// Render a placeholder to occupy the space.
return
<
div
className=
{
`
memo-wrapper min-h-[128px]
${"memos-" + memo.id}`
}
ref=
{
memoContainerRef
}
></
div
>;
return
<
div
className=
{
`
w-full h-32 !bg-transparent
${"memos-" + memo.id}`
}
ref=
{
memoContainerRef
}
></
div
>;
}
}
const
handleGotoMemoDetailPage
=
(
event
:
React
.
MouseEvent
<
HTMLDivElement
>
)
=>
{
const
handleGotoMemoDetailPage
=
(
event
:
React
.
MouseEvent
<
HTMLDivElement
>
)
=>
{
...
@@ -271,7 +275,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -271,7 +275,7 @@ const Memo: React.FC<Props> = (props: Props) => {
{
memo
.
parent
&&
props
.
showCommentEntry
&&
(
{
memo
.
parent
&&
props
.
showCommentEntry
&&
(
<
div
>
<
div
>
<
Link
to=
{
`/m/${memo.parent.id}`
}
>
<
Link
to=
{
`/m/${memo.parent.id}`
}
>
<
span
className=
"text-xs text-gray-400 opacity-80
dark:text-gray-500
"
>
This is a comment of #
{
memo
.
parent
.
id
}
</
span
>
<
span
className=
"text-xs text-gray-400 opacity-80"
>
This is a comment of #
{
memo
.
parent
.
id
}
</
span
>
</
Link
>
</
Link
>
</
div
>
</
div
>
)
}
)
}
...
@@ -281,7 +285,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -281,7 +285,7 @@ const Memo: React.FC<Props> = (props: Props) => {
onMemoContentDoubleClick=
{
handleMemoContentDoubleClick
}
onMemoContentDoubleClick=
{
handleMemoContentDoubleClick
}
/>
/>
<
MemoResourceListView
resourceList=
{
memo
.
resourceList
}
/>
<
MemoResourceListView
resourceList=
{
memo
.
resourceList
}
/>
<
MemoRelationListView
relationList=
{
memo
.
relationList
}
/>
<
MemoRelationListView
relationList=
{
referenceRelations
}
/>
<
div
className=
"mt-4 w-full flex flex-row justify-between items-center gap-2"
>
<
div
className=
"mt-4 w-full flex flex-row justify-between items-center gap-2"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center"
>
{
creator
&&
(
{
creator
&&
(
...
@@ -306,6 +310,11 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -306,6 +310,11 @@ const Memo: React.FC<Props> = (props: Props) => {
</
Tooltip
>
</
Tooltip
>
</>
</>
)
}
)
}
<
Icon
.
Dot
className=
"w-4 h-auto text-gray-400 dark:text-zinc-400"
/>
<
Link
className=
"flex flex-row justify-start items-center"
to=
{
`/m/${memo.id}#comments`
}
>
<
Icon
.
MessageCircle
className=
"w-4 h-auto text-gray-400 dark:text-zinc-400"
/>
<
span
className=
"text-sm text-gray-500 dark:text-gray-400 ml-1"
>
{
commentRelations
.
length
}
</
span
>
</
Link
>
</>
</>
)
}
)
}
</
div
>
</
div
>
...
...
web/src/components/MemoEditor/index.tsx
View file @
078bc164
...
@@ -61,6 +61,11 @@ const MemoEditor = (props: Props) => {
...
@@ -61,6 +61,11 @@ const MemoEditor = (props: Props) => {
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
user
=
userStore
.
state
.
user
as
User
;
const
user
=
userStore
.
state
.
user
as
User
;
const
setting
=
user
.
setting
;
const
setting
=
user
.
setting
;
const
referenceRelations
=
memoId
?
state
.
relationList
.
filter
(
(
relation
)
=>
relation
.
memoId
===
memoId
&&
relation
.
relatedMemoId
!==
memoId
&&
relation
.
type
===
"REFERENCE"
)
:
state
.
relationList
.
filter
((
relation
)
=>
relation
.
type
===
"REFERENCE"
);
useEffect
(()
=>
{
useEffect
(()
=>
{
editorRef
.
current
?.
setContent
(
contentCache
||
""
);
editorRef
.
current
?.
setContent
(
contentCache
||
""
);
...
@@ -406,7 +411,7 @@ const MemoEditor = (props: Props) => {
...
@@ -406,7 +411,7 @@ const MemoEditor = (props: Props) => {
</
div
>
</
div
>
</
div
>
</
div
>
<
ResourceListView
resourceList=
{
state
.
resourceList
}
setResourceList=
{
handleSetResourceList
}
/>
<
ResourceListView
resourceList=
{
state
.
resourceList
}
setResourceList=
{
handleSetResourceList
}
/>
<
RelationListView
relationList=
{
state
.
relationList
}
setRelationList=
{
handleSetRelationList
}
/>
<
RelationListView
relationList=
{
referenceRelations
}
setRelationList=
{
handleSetRelationList
}
/>
<
div
className=
"editor-footer-container"
>
<
div
className=
"editor-footer-container"
>
<
MemoVisibilitySelector
value=
{
state
.
memoVisibility
}
onChange=
{
handleMemoVisibilityChange
}
/>
<
MemoVisibilitySelector
value=
{
state
.
memoVisibility
}
onChange=
{
handleMemoVisibilityChange
}
/>
<
div
className=
"buttons-container"
>
<
div
className=
"buttons-container"
>
...
...
web/src/components/MemoRelationListView.tsx
View file @
078bc164
...
@@ -12,9 +12,7 @@ const MemoRelationListView = (props: Props) => {
...
@@ -12,9 +12,7 @@ const MemoRelationListView = (props: Props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
(
async
()
=>
{
// Only show reference relations.
const
memoList
=
await
Promise
.
all
(
props
.
relationList
.
map
((
relation
)
=>
memoCacheStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
)));
const
relationList
=
props
.
relationList
.
filter
((
relation
)
=>
relation
.
type
===
"REFERENCE"
);
const
memoList
=
await
Promise
.
all
(
relationList
.
map
((
relation
)
=>
memoCacheStore
.
getOrFetchMemoById
(
relation
.
relatedMemoId
)));
setRelatedMemoList
(
memoList
);
setRelatedMemoList
(
memoList
);
})();
})();
},
[
props
.
relationList
]);
},
[
props
.
relationList
]);
...
...
web/src/pages/MemoDetail.tsx
View file @
078bc164
...
@@ -38,6 +38,10 @@ const MemoDetail = () => {
...
@@ -38,6 +38,10 @@ const MemoDetail = () => {
const
memoId
=
Number
(
params
.
memoId
);
const
memoId
=
Number
(
params
.
memoId
);
const
memo
=
memoStore
.
state
.
memos
.
find
((
memo
)
=>
memo
.
id
===
memoId
);
const
memo
=
memoStore
.
state
.
memos
.
find
((
memo
)
=>
memo
.
id
===
memoId
);
const
allowEdit
=
memo
?.
creatorUsername
===
currentUser
?.
username
;
const
allowEdit
=
memo
?.
creatorUsername
===
currentUser
?.
username
;
const
referenceRelations
=
memo
?.
relationList
.
filter
(
(
relation
)
=>
relation
.
memoId
===
memo
?.
id
&&
relation
.
relatedMemoId
!==
memo
?.
id
&&
relation
.
type
===
"REFERENCE"
)
||
[];
// Prepare memo.
// Prepare memo.
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -114,9 +118,16 @@ const MemoDetail = () => {
...
@@ -114,9 +118,16 @@ const MemoDetail = () => {
<
div
className=
"w-full mb-4 flex flex-row justify-start items-center mr-1"
>
<
div
className=
"w-full mb-4 flex flex-row justify-start items-center mr-1"
>
<
span
className=
"text-gray-400 select-none"
>
{
getDateTimeString
(
memo
.
displayTs
)
}
</
span
>
<
span
className=
"text-gray-400 select-none"
>
{
getDateTimeString
(
memo
.
displayTs
)
}
</
span
>
</
div
>
</
div
>
{
memo
.
parent
&&
(
<
div
className=
"mb-2"
>
<
Link
to=
{
`/m/${memo.parent.id}`
}
>
<
span
className=
"text-xs text-gray-400 opacity-80"
>
This is a comment of #
{
memo
.
parent
.
id
}
</
span
>
</
Link
>
</
div
>
)
}
<
MemoContent
content=
{
memo
.
content
}
/>
<
MemoContent
content=
{
memo
.
content
}
/>
<
MemoResourceListView
resourceList=
{
memo
.
resourceList
}
/>
<
MemoResourceListView
resourceList=
{
memo
.
resourceList
}
/>
<
MemoRelationListView
relationList=
{
memo
.
relationList
}
/>
<
MemoRelationListView
relationList=
{
referenceRelations
}
/>
<
div
className=
"w-full mt-4 flex flex-col sm:flex-row justify-start sm:justify-between sm:items-center gap-2"
>
<
div
className=
"w-full mt-4 flex flex-col sm:flex-row justify-start sm:justify-between sm:items-center gap-2"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
Tooltip
title=
{
"The identifier of memo"
}
placement=
"top"
>
<
Tooltip
title=
{
"The identifier of memo"
}
placement=
"top"
>
...
@@ -174,15 +185,24 @@ const MemoDetail = () => {
...
@@ -174,15 +185,24 @@ const MemoDetail = () => {
</
div
>
</
div
>
<
div
className=
"py-6 w-full border-t dark:border-t-zinc-700"
>
<
div
className=
"py-6 w-full border-t dark:border-t-zinc-700"
>
<
div
className=
"relative mx-auto flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 gap-y-1"
>
<
div
className=
"relative mx-auto flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4 gap-y-1"
>
{
comments
.
map
((
comment
)
=>
(
{
comments
.
length
===
0
?
(
<
Memo
key=
{
comment
.
id
}
memo=
{
comment
}
/>
))
}
{
comments
.
length
===
0
&&
(
<
div
className=
"w-full flex flex-col justify-center items-center py-6"
>
<
div
className=
"w-full flex flex-col justify-center items-center py-6"
>
<
Icon
.
MessageCircle
strokeWidth=
{
1
}
className=
"w-8 h-auto text-gray-400"
/>
<
Icon
.
MessageCircle
strokeWidth=
{
1
}
className=
"w-8 h-auto text-gray-400"
/>
<
p
className=
"text-gray-400 italic text-sm"
>
No comments
</
p
>
<
p
className=
"text-gray-400 italic text-sm"
>
No comments
</
p
>
</
div
>
</
div
>
)
:
(
<>
<
div
className=
"w-full flex flex-row justify-start items-center mb-2"
>
<
Icon
.
MessageCircle
strokeWidth=
{
1
}
className=
"w-5 h-auto text-gray-400 mr-1"
/>
<
span
className=
"text-gray-400 text-sm"
>
Comments
</
span
>
<
span
className=
"text-gray-400 text-sm"
>
(
{
comments
.
length
}
)
</
span
>
</
div
>
{
comments
.
map
((
comment
)
=>
(
<
Memo
key=
{
comment
.
id
}
memo=
{
comment
}
/>
))
}
</>
)
}
)
}
{
/* Only show comment editor when user login */
}
{
/* Only show comment editor when user login */
}
{
currentUser
&&
(
{
currentUser
&&
(
<>
<>
...
...
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