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
2acad978
Commit
2acad978
authored
Oct 10, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(frontend): add reactions setting
parent
e527b6a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
+56
-5
ReactionSelector.tsx
web/src/components/ReactionSelector.tsx
+3
-3
MemoRelatedSettings.tsx
web/src/components/Settings/MemoRelatedSettings.tsx
+53
-2
No files found.
web/src/components/ReactionSelector.tsx
View file @
2acad978
...
...
@@ -68,15 +68,15 @@ const ReactionSelector = (props: Props) => {
<
SmilePlusIcon
className=
"w-4 h-4 mx-auto text-gray-500 dark:text-gray-400"
/>
</
span
>
</
MenuButton
>
<
Menu
className=
"relative
text-sm
"
component=
"div"
size=
"sm"
placement=
"bottom-start"
>
<
Menu
className=
"relative"
component=
"div"
size=
"sm"
placement=
"bottom-start"
>
<
div
ref=
{
containerRef
}
>
<
div
className=
"
grid grid-cols-6 py-0.5 px-2 h-auto font-mono gap-1
"
>
<
div
className=
"
flex flex-row flex-wrap py-0.5 px-2 h-auto gap-1 max-w-56
"
>
{
workspaceMemoRelatedSetting
.
reactions
.
map
((
reactionType
)
=>
{
return
(
<
span
key=
{
reactionType
}
className=
{
clsx
(
"inline-flex w-auto
cursor-pointer rounded text-lg
px-1 text-gray-500 dark:text-gray-400 hover:opacity-80"
,
"inline-flex w-auto
text-base cursor-pointer rounded
px-1 text-gray-500 dark:text-gray-400 hover:opacity-80"
,
hasReacted
(
reactionType
)
&&
"bg-blue-100 dark:bg-zinc-800"
,
)
}
onClick=
{
()
=>
handleReactionClick
(
reactionType
)
}
...
...
web/src/components/Settings/MemoRelatedSettings.tsx
View file @
2acad978
import
{
Button
,
Input
,
Switch
,
Select
,
Option
}
from
"@mui/joy"
;
import
{
isEqual
}
from
"lodash-es"
;
import
{
Button
,
Input
,
Switch
,
Select
,
Option
,
Chip
,
ChipDelete
}
from
"@mui/joy"
;
import
{
isEqual
,
uniq
}
from
"lodash-es"
;
import
{
CheckIcon
}
from
"lucide-react"
;
import
{
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
workspaceSettingNamePrefix
,
useWorkspaceSettingStore
}
from
"@/store/v1"
;
...
...
@@ -17,6 +18,7 @@ const MemoRelatedSettings = () => {
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
MEMO_RELATED
)?.
memoRelatedSetting
||
{},
);
const
[
memoRelatedSetting
,
setMemoRelatedSetting
]
=
useState
<
WorkspaceMemoRelatedSetting
>
(
originalSetting
);
const
[
editingReaction
,
setEditingReaction
]
=
useState
<
string
>
(
""
);
const
updatePartialSetting
=
(
partial
:
Partial
<
WorkspaceMemoRelatedSetting
>
)
=>
{
const
newWorkspaceMemoRelatedSetting
=
WorkspaceMemoRelatedSetting
.
fromPartial
({
...
...
@@ -26,7 +28,21 @@ const MemoRelatedSettings = () => {
setMemoRelatedSetting
(
newWorkspaceMemoRelatedSetting
);
};
const
upsertReaction
=
()
=>
{
if
(
!
editingReaction
)
{
return
;
}
updatePartialSetting
({
reactions
:
uniq
([...
memoRelatedSetting
.
reactions
,
editingReaction
.
trim
()])
});
setEditingReaction
(
""
);
};
const
updateSetting
=
async
()
=>
{
if
(
memoRelatedSetting
.
reactions
.
length
===
0
)
{
toast
.
error
(
"Reactions must not be empty."
);
return
;
}
try
{
await
workspaceSettingStore
.
setWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
MEMO_RELATED
}
`
,
...
...
@@ -120,6 +136,41 @@ const MemoRelatedSettings = () => {
))
}
</
Select
>
</
div
>
<
div
className=
"w-full"
>
<
span
className=
"truncate"
>
Reactions
</
span
>
<
div
className=
"mt-2 w-full flex flex-row flex-wrap gap-1"
>
{
memoRelatedSetting
.
reactions
.
map
((
reactionType
)
=>
{
return
(
<
Chip
className=
"!h-8"
key=
{
reactionType
}
variant=
"outlined"
size=
"lg"
endDecorator=
{
<
ChipDelete
onDelete=
{
()
=>
updatePartialSetting
({
reactions
:
memoRelatedSetting
.
reactions
.
filter
((
r
)
=>
r
!==
reactionType
)
})
}
/>
}
>
{
reactionType
}
</
Chip
>
);
})
}
<
Input
className=
"w-32 !rounded-full !pl-3"
placeholder=
"Input"
size=
"sm"
value=
{
editingReaction
}
onChange=
{
(
event
)
=>
setEditingReaction
(
event
.
target
.
value
.
trim
())
}
endDecorator=
{
<
CheckIcon
className=
"w-5 h-5 text-gray-500 dark:text-gray-400 cursor-pointer hover:text-teal-600"
onClick=
{
()
=>
upsertReaction
()
}
/>
}
/>
</
div
>
</
div
>
<
div
className=
"mt-2 w-full flex justify-end"
>
<
Button
disabled=
{
isEqual
(
memoRelatedSetting
,
originalSetting
)
}
onClick=
{
updateSetting
}
>
{
t
(
"common.save"
)
}
...
...
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