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
07d9649b
Commit
07d9649b
authored
Jul 26, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add visibility selector
parent
b7339e00
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
25 deletions
+21
-25
Memo.tsx
web/src/components/Memo.tsx
+2
-2
MemoCardDialog.tsx
web/src/components/MemoCardDialog.tsx
+17
-20
memo-card-dialog.less
web/src/less/memo-card-dialog.less
+1
-2
memo.d.ts
web/src/types/modules/memo.d.ts
+1
-1
No files found.
web/src/components/Memo.tsx
View file @
07d9649b
...
@@ -175,8 +175,8 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -175,8 +175,8 @@ const Memo: React.FC<Props> = (props: Props) => {
<
Only
when=
{
memo
.
pinned
}
>
<
Only
when=
{
memo
.
pinned
}
>
<
span
className=
"status-text"
>
PINNED
</
span
>
<
span
className=
"status-text"
>
PINNED
</
span
>
</
Only
>
</
Only
>
<
Only
when=
{
memo
.
visibility
===
"PUBLIC
"
&&
!
isVisitorMode
}
>
<
Only
when=
{
memo
.
visibility
!==
"PRIVATE
"
&&
!
isVisitorMode
}
>
<
span
className=
"status-text"
>
PUBLIC
</
span
>
<
span
className=
"status-text"
>
{
memo
.
visibility
}
</
span
>
</
Only
>
</
Only
>
</
div
>
</
div
>
<
div
className=
{
`btns-container ${userService.isVisitorMode() ? "!hidden" : ""}`
}
>
<
div
className=
{
`btns-container ${userService.isVisitorMode() ? "!hidden" : ""}`
}
>
...
...
web/src/components/MemoCardDialog.tsx
View file @
07d9649b
...
@@ -9,6 +9,7 @@ import { showDialog } from "./Dialog";
...
@@ -9,6 +9,7 @@ import { showDialog } from "./Dialog";
import
Image
from
"./Image"
;
import
Image
from
"./Image"
;
import
{
formatMemoContent
}
from
"./Memo"
;
import
{
formatMemoContent
}
from
"./Memo"
;
import
"../less/memo-card-dialog.less"
;
import
"../less/memo-card-dialog.less"
;
import
Selector
from
"./common/Selector"
;
interface
LinkedMemo
extends
Memo
{
interface
LinkedMemo
extends
Memo
{
createdAtStr
:
string
;
createdAtStr
:
string
;
...
@@ -26,6 +27,11 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
...
@@ -26,6 +27,11 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
const
[
linkMemos
,
setLinkMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
[
linkMemos
,
setLinkMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
[
linkedMemos
,
setLinkedMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
[
linkedMemos
,
setLinkedMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
const
visibilityList
=
[
{
text
:
"PUBLIC"
,
value
:
"PUBLIC"
},
{
text
:
"PROTECTED"
,
value
:
"PROTECTED"
},
{
text
:
"PRIVATE"
,
value
:
"PRIVATE"
},
];
useEffect
(()
=>
{
useEffect
(()
=>
{
const
fetchLinkedMemos
=
async
()
=>
{
const
fetchLinkedMemos
=
async
()
=>
{
...
@@ -98,25 +104,16 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
...
@@ -98,25 +104,16 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
setMemo
(
memo
);
setMemo
(
memo
);
},
[]);
},
[]);
const
handleEditMemoBtnClick
=
useCallback
(
()
=>
{
const
handleEditMemoBtnClick
=
()
=>
{
props
.
destroy
();
props
.
destroy
();
editorStateService
.
setEditMemoWithId
(
memo
.
id
);
editorStateService
.
setEditMemoWithId
(
memo
.
id
);
}
,
[
memo
.
id
])
;
};
const
handlePinClick
=
async
()
=>
{
const
handleVisibilitySelectorChange
=
async
(
visibility
:
Visibility
)
=>
{
if
(
memo
.
pinned
)
{
if
(
memo
.
visibility
===
visibility
)
{
await
memoService
.
unpinMemo
(
memo
.
id
);
return
;
}
else
{
await
memoService
.
pinMemo
(
memo
.
id
);
}
}
setMemo
({
...
memo
,
pinned
:
!
memo
.
pinned
,
});
};
const
handleVisibilityClick
=
async
()
=>
{
const
visibility
=
memo
.
visibility
===
"PRIVATE"
?
"PUBLIC"
:
"PRIVATE"
;
await
memoService
.
patchMemo
({
await
memoService
.
patchMemo
({
id
:
memo
.
id
,
id
:
memo
.
id
,
visibility
:
visibility
,
visibility
:
visibility
,
...
@@ -135,12 +132,12 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
...
@@ -135,12 +132,12 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
<
div
className=
"btns-container"
>
<
div
className=
"btns-container"
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<>
<>
<
button
className=
"btn"
onClick=
{
handlePinClick
}
>
<
Selector
<
i
className=
{
`fa-solid fa-thumbtack icon-img ${memo.pinned ? "" : "opacity-20"}`
}
></
i
>
className=
"w-24"
</
button
>
dataSource=
{
visibilityList
}
<
button
className=
"btn"
onClick=
{
handleVisibilityClick
}
>
value=
{
memo
.
visibility
}
<
i
className=
{
`fa-solid fa-eye icon-img ${memo.visibility === "PUBLIC" ? "" : "opacity-20"}`
}
></
i
>
handleValueChanged=
{
(
value
)
=>
handleVisibilitySelectorChange
(
value
as
Visibility
)
}
</
button
>
/
>
<
button
className=
"btn edit-btn"
onClick=
{
handleEditMemoBtnClick
}
>
<
button
className=
"btn edit-btn"
onClick=
{
handleEditMemoBtnClick
}
>
<
i
className=
"fa-solid fa-pen-to-square icon-img"
></
i
>
<
i
className=
"fa-solid fa-pen-to-square icon-img"
></
i
>
</
button
>
</
button
>
...
...
web/src/less/memo-card-dialog.less
View file @
07d9649b
...
@@ -15,8 +15,7 @@
...
@@ -15,8 +15,7 @@
}
}
> .header-container {
> .header-container {
.flex(row, space-between, center);
@apply flex flex-row justify-between items-center w-full h-auto z-10 pb-0 my-0;
@apply w-full h-auto pb-0 my-0;
> .time-text {
> .time-text {
@apply text-sm text-gray-500 font-mono;
@apply text-sm text-gray-500 font-mono;
...
...
web/src/types/modules/memo.d.ts
View file @
07d9649b
type
MemoId
=
number
;
type
MemoId
=
number
;
type
Visibility
=
"PUBLIC"
|
"PRIVATE"
;
type
Visibility
=
"PUBLIC"
|
"PR
OTECTED"
|
"PR
IVATE"
;
interface
Memo
{
interface
Memo
{
id
:
MemoId
;
id
:
MemoId
;
...
...
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