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
d22b7722
Commit
d22b7722
authored
Feb 15, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add memo actions to memo detail page
parent
f1ec5775
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
12 deletions
+43
-12
MemoActionMenu.tsx
web/src/components/MemoActionMenu.tsx
+23
-11
MemoView.tsx
web/src/components/MemoView.tsx
+1
-1
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+19
-0
No files found.
web/src/components/MemoActionMenu.tsx
View file @
d22b7722
...
@@ -12,11 +12,13 @@ import showShareMemoDialog from "./ShareMemoDialog";
...
@@ -12,11 +12,13 @@ import showShareMemoDialog from "./ShareMemoDialog";
interface
Props
{
interface
Props
{
memo
:
Memo
;
memo
:
Memo
;
showPinned
?:
boolean
;
hiddenActions
?:
(
"edit"
|
"archive"
|
"delete"
|
"share"
|
"pin"
)[];
onArchived
?:
()
=>
void
;
onDeleted
?:
()
=>
void
;
}
}
const
MemoActionMenu
=
(
props
:
Props
)
=>
{
const
MemoActionMenu
=
(
props
:
Props
)
=>
{
const
{
memo
,
showPinned
}
=
props
;
const
{
memo
,
hiddenActions
}
=
props
;
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
...
@@ -64,6 +66,9 @@ const MemoActionMenu = (props: Props) => {
...
@@ -64,6 +66,9 @@ const MemoActionMenu = (props: Props) => {
console
.
error
(
error
);
console
.
error
(
error
);
toast
.
error
(
error
.
response
.
data
.
message
);
toast
.
error
(
error
.
response
.
data
.
message
);
}
}
if
(
props
.
onArchived
)
{
props
.
onArchived
();
}
};
};
const
handleDeleteMemoClick
=
async
()
=>
{
const
handleDeleteMemoClick
=
async
()
=>
{
...
@@ -74,6 +79,9 @@ const MemoActionMenu = (props: Props) => {
...
@@ -74,6 +79,9 @@ const MemoActionMenu = (props: Props) => {
dialogName
:
"delete-memo-dialog"
,
dialogName
:
"delete-memo-dialog"
,
onConfirm
:
async
()
=>
{
onConfirm
:
async
()
=>
{
await
memoStore
.
deleteMemo
(
memo
.
id
);
await
memoStore
.
deleteMemo
(
memo
.
id
);
if
(
props
.
onDeleted
)
{
props
.
onDeleted
();
}
},
},
});
});
};
};
...
@@ -91,20 +99,24 @@ const MemoActionMenu = (props: Props) => {
...
@@ -91,20 +99,24 @@ const MemoActionMenu = (props: Props) => {
</
span
>
</
span
>
</
MenuButton
>
</
MenuButton
>
<
Menu
className=
"text-sm"
size=
"sm"
placement=
"bottom-end"
>
<
Menu
className=
"text-sm"
size=
"sm"
placement=
"bottom-end"
>
{
showPinned
&&
(
{
!
hiddenActions
?.
includes
(
"pin"
)
&&
(
<
MenuItem
onClick=
{
handleTogglePinMemoBtnClick
}
>
<
MenuItem
onClick=
{
handleTogglePinMemoBtnClick
}
>
{
memo
.
pinned
?
<
Icon
.
BookmarkMinus
className=
"w-4 h-auto"
/>
:
<
Icon
.
BookmarkPlus
className=
"w-4 h-auto"
/>
}
{
memo
.
pinned
?
<
Icon
.
BookmarkMinus
className=
"w-4 h-auto"
/>
:
<
Icon
.
BookmarkPlus
className=
"w-4 h-auto"
/>
}
{
memo
.
pinned
?
t
(
"common.unpin"
)
:
t
(
"common.pin"
)
}
{
memo
.
pinned
?
t
(
"common.unpin"
)
:
t
(
"common.pin"
)
}
</
MenuItem
>
</
MenuItem
>
)
}
)
}
{
!
hiddenActions
?.
includes
(
"edit"
)
&&
(
<
MenuItem
onClick=
{
handleEditMemoClick
}
>
<
MenuItem
onClick=
{
handleEditMemoClick
}
>
<
Icon
.
Edit3
className=
"w-4 h-auto"
/>
<
Icon
.
Edit3
className=
"w-4 h-auto"
/>
{
t
(
"common.edit"
)
}
{
t
(
"common.edit"
)
}
</
MenuItem
>
</
MenuItem
>
)
}
{
!
hiddenActions
?.
includes
(
"share"
)
&&
(
<
MenuItem
onClick=
{
()
=>
showShareMemoDialog
(
memo
.
id
)
}
>
<
MenuItem
onClick=
{
()
=>
showShareMemoDialog
(
memo
.
id
)
}
>
<
Icon
.
Share
className=
"w-4 h-auto"
/>
<
Icon
.
Share
className=
"w-4 h-auto"
/>
{
t
(
"common.share"
)
}
{
t
(
"common.share"
)
}
</
MenuItem
>
</
MenuItem
>
)
}
<
Divider
className=
"!my-1"
/>
<
Divider
className=
"!my-1"
/>
<
MenuItem
color=
"warning"
onClick=
{
handleArchiveMemoClick
}
>
<
MenuItem
color=
"warning"
onClick=
{
handleArchiveMemoClick
}
>
<
Icon
.
Archive
className=
"w-4 h-auto"
/>
<
Icon
.
Archive
className=
"w-4 h-auto"
/>
...
...
web/src/components/MemoView.tsx
View file @
d22b7722
...
@@ -135,7 +135,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -135,7 +135,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
)
}
)
}
{
currentUser
&&
<
ReactionSelector
className=
"border-none"
memo=
{
memo
}
/>
}
{
currentUser
&&
<
ReactionSelector
className=
"border-none"
memo=
{
memo
}
/>
}
</
div
>
</
div
>
{
!
readonly
&&
<
MemoActionMenu
memo=
{
memo
}
showPinned=
{
props
.
showPinned
}
/>
}
{
!
readonly
&&
<
MemoActionMenu
memo=
{
memo
}
hiddenActions=
{
props
.
showPinned
?
[]
:
[
"pin"
]
}
/>
}
</
div
>
</
div
>
</
div
>
</
div
>
<
MemoContent
<
MemoContent
...
...
web/src/pages/MemoDetail.tsx
View file @
d22b7722
...
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
...
@@ -5,6 +5,7 @@ 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
MemoActionMenu
from
"@/components/MemoActionMenu"
;
import
MemoContent
from
"@/components/MemoContent"
;
import
MemoContent
from
"@/components/MemoContent"
;
import
MemoEditor
from
"@/components/MemoEditor"
;
import
MemoEditor
from
"@/components/MemoEditor"
;
import
showMemoEditorDialog
from
"@/components/MemoEditor/MemoEditorDialog"
;
import
showMemoEditorDialog
from
"@/components/MemoEditor/MemoEditorDialog"
;
...
@@ -113,6 +114,16 @@ const MemoDetail = () => {
...
@@ -113,6 +114,16 @@ const MemoDetail = () => {
await
memoStore
.
getOrFetchMemoById
(
memo
.
id
,
{
skipCache
:
true
});
await
memoStore
.
getOrFetchMemoById
(
memo
.
id
,
{
skipCache
:
true
});
};
};
const
handleMemoArchived
=
()
=>
{
navigateTo
(
"/archived"
);
toast
.
success
(
"Memo archived"
);
};
const
handleMemoDeleted
=
()
=>
{
navigateTo
(
"/"
);
toast
.
success
(
"Memo deleted"
);
};
return
(
return
(
<
section
className=
"@container w-full max-w-5xl min-h-full flex flex-col justify-start items-center sm:pt-3 md:pt-6 pb-8"
>
<
section
className=
"@container w-full max-w-5xl min-h-full flex flex-col justify-start items-center sm:pt-3 md:pt-6 pb-8"
>
<
MobileHeader
/>
<
MobileHeader
/>
...
@@ -184,6 +195,14 @@ const MemoDetail = () => {
...
@@ -184,6 +195,14 @@ const MemoDetail = () => {
<
Icon
.
Share
className=
"w-4 h-auto text-gray-600 dark:text-gray-400"
/>
<
Icon
.
Share
className=
"w-4 h-auto text-gray-600 dark:text-gray-400"
/>
</
IconButton
>
</
IconButton
>
</
Tooltip
>
</
Tooltip
>
{
!
readonly
&&
(
<
MemoActionMenu
memo=
{
memo
}
hiddenActions=
{
[
"pin"
,
"share"
]
}
onArchived=
{
handleMemoArchived
}
onDeleted=
{
handleMemoDeleted
}
/>
)
}
</
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