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
435bd5c4
Commit
435bd5c4
authored
Oct 19, 2024
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update relation graph checks
parent
04d6329d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
MemoDetailSidebar.tsx
web/src/components/MemoDetailSidebar/MemoDetailSidebar.tsx
+3
-1
MemoRelationForceGraph.tsx
...ponents/MemoRelationForceGraph/MemoRelationForceGraph.tsx
+2
-1
No files found.
web/src/components/MemoDetailSidebar/MemoDetailSidebar.tsx
View file @
435bd5c4
import
clsx
from
"clsx"
;
import
clsx
from
"clsx"
;
import
{
isEqual
}
from
"lodash-es"
;
import
{
isEqual
}
from
"lodash-es"
;
import
{
CheckCircleIcon
,
Code2Icon
,
HashIcon
,
LinkIcon
}
from
"lucide-react"
;
import
{
CheckCircleIcon
,
Code2Icon
,
HashIcon
,
LinkIcon
}
from
"lucide-react"
;
import
{
MemoRelation_Type
}
from
"@/types/proto/api/v1/memo_relation_service"
;
import
{
Memo
,
MemoProperty
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
Memo
,
MemoProperty
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
MemoRelationForceGraph
from
"../MemoRelationForceGraph"
;
import
MemoRelationForceGraph
from
"../MemoRelationForceGraph"
;
...
@@ -14,6 +15,7 @@ const MemoDetailSidebar = ({ memo, className }: Props) => {
...
@@ -14,6 +15,7 @@ const MemoDetailSidebar = ({ memo, className }: Props) => {
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
property
=
MemoProperty
.
fromPartial
(
memo
.
property
||
{});
const
property
=
MemoProperty
.
fromPartial
(
memo
.
property
||
{});
const
hasSpecialProperty
=
property
.
hasLink
||
property
.
hasTaskList
||
property
.
hasCode
||
property
.
hasIncompleteTasks
;
const
hasSpecialProperty
=
property
.
hasLink
||
property
.
hasTaskList
||
property
.
hasCode
||
property
.
hasIncompleteTasks
;
const
shouldShowRelationGraph
=
memo
.
relations
.
filter
((
r
)
=>
r
.
type
===
MemoRelation_Type
.
REFERENCE
).
length
>
0
;
return
(
return
(
<
aside
<
aside
...
@@ -23,7 +25,7 @@ const MemoDetailSidebar = ({ memo, className }: Props) => {
...
@@ -23,7 +25,7 @@ const MemoDetailSidebar = ({ memo, className }: Props) => {
)
}
)
}
>
>
<
div
className=
"flex flex-col justify-start items-start w-full px-1 gap-2 h-auto shrink-0 flex-nowrap hide-scrollbar"
>
<
div
className=
"flex flex-col justify-start items-start w-full px-1 gap-2 h-auto shrink-0 flex-nowrap hide-scrollbar"
>
{
memo
.
relations
.
length
>
0
&&
(
{
shouldShowRelationGraph
&&
(
<
div
className=
"relative w-full h-36 border rounded-lg bg-zinc-50 dark:bg-zinc-900 dark:border-zinc-800"
>
<
div
className=
"relative w-full h-36 border rounded-lg bg-zinc-50 dark:bg-zinc-900 dark:border-zinc-800"
>
<
MemoRelationForceGraph
className=
"w-full h-full"
memo=
{
memo
}
/>
<
MemoRelationForceGraph
className=
"w-full h-full"
memo=
{
memo
}
/>
<
span
className=
"absolute top-1 left-2 text-xs opacity-60 font-mono"
>
Relations
</
span
>
<
span
className=
"absolute top-1 left-2 text-xs opacity-60 font-mono"
>
Relations
</
span
>
...
...
web/src/components/MemoRelationForceGraph/MemoRelationForceGraph.tsx
View file @
435bd5c4
...
@@ -3,6 +3,7 @@ import clsx from "clsx";
...
@@ -3,6 +3,7 @@ import clsx from "clsx";
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
ForceGraph2D
,
{
ForceGraphMethods
,
LinkObject
,
NodeObject
}
from
"react-force-graph-2d"
;
import
ForceGraph2D
,
{
ForceGraphMethods
,
LinkObject
,
NodeObject
}
from
"react-force-graph-2d"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
useNavigateTo
from
"@/hooks/useNavigateTo"
;
import
{
MemoRelation_Type
}
from
"@/types/proto/api/v1/memo_relation_service"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
LinkType
,
NodeType
}
from
"./types"
;
import
{
LinkType
,
NodeType
}
from
"./types"
;
import
{
convertMemoRelationsToGraphData
}
from
"./utils"
;
import
{
convertMemoRelationsToGraphData
}
from
"./utils"
;
...
@@ -44,7 +45,7 @@ const MemoRelationForceGraph = ({ className, memo }: Props) => {
...
@@ -44,7 +45,7 @@ const MemoRelationForceGraph = ({ className, memo }: Props) => {
nodeRelSize=
{
3
}
nodeRelSize=
{
3
}
nodeLabel=
{
(
node
)
=>
node
.
memo
.
uid
.
slice
(
0
,
6
).
toLowerCase
()
}
nodeLabel=
{
(
node
)
=>
node
.
memo
.
uid
.
slice
(
0
,
6
).
toLowerCase
()
}
linkColor=
{
()
=>
(
mode
===
"light"
?
"#e4e4e7"
:
"#3f3f46"
)
}
linkColor=
{
()
=>
(
mode
===
"light"
?
"#e4e4e7"
:
"#3f3f46"
)
}
graphData=
{
convertMemoRelationsToGraphData
(
memo
.
relations
)
}
graphData=
{
convertMemoRelationsToGraphData
(
memo
.
relations
.
filter
((
r
)
=>
r
.
type
===
MemoRelation_Type
.
REFERENCE
)
)
}
onNodeClick=
{
onNodeClick
}
onNodeClick=
{
onNodeClick
}
linkDirectionalArrowLength=
{
3
}
linkDirectionalArrowLength=
{
3
}
linkDirectionalArrowRelPos=
{
1
}
linkDirectionalArrowRelPos=
{
1
}
...
...
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