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
2f33ecea
Commit
2f33ecea
authored
Aug 19, 2022
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: set default memo visibility
parent
d5b88775
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
12 deletions
+43
-12
Memo.tsx
web/src/components/Memo.tsx
+6
-1
MemoCardDialog.tsx
web/src/components/MemoCardDialog.tsx
+2
-7
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+14
-0
consts.ts
web/src/helpers/consts.ts
+6
-0
useI18n.ts
web/src/labs/i18n/useI18n.ts
+0
-2
en.json
web/src/locales/en.json
+3
-0
zh.json
web/src/locales/zh.json
+3
-0
userService.ts
web/src/services/userService.ts
+1
-0
setting.d.ts
web/src/types/modules/setting.d.ts
+8
-2
No files found.
web/src/components/Memo.tsx
View file @
2f33ecea
...
...
@@ -60,11 +60,16 @@ const Memo: React.FC<Props> = (props: Props) => {
});
}
let
intervalFlag
=
-
1
;
if
(
Date
.
now
()
-
memo
.
createdTs
<
1000
*
60
*
60
*
24
)
{
setInterval
(()
=>
{
intervalFlag
=
setInterval
(()
=>
{
setCreatedAtStr
(
getFormatedMemoCreatedAtStr
(
memo
.
createdTs
,
locale
));
},
1000
*
1
);
}
return
()
=>
{
clearInterval
(
intervalFlag
);
};
},
[
locale
]);
const
handleShowMemoStoryDialog
=
()
=>
{
...
...
web/src/components/MemoCardDialog.tsx
View file @
2f33ecea
import
{
useState
,
useEffect
,
useCallback
}
from
"react"
;
import
{
editorStateService
,
memoService
,
userService
}
from
"../services"
;
import
{
IMAGE_URL_REG
,
MEMO_LINK_REG
,
UNKNOWN_ID
}
from
"../helpers/consts"
;
import
{
IMAGE_URL_REG
,
MEMO_LINK_REG
,
UNKNOWN_ID
,
VISIBILITY_SELECTOR_ITEMS
}
from
"../helpers/consts"
;
import
*
as
utils
from
"../helpers/utils"
;
import
{
formatMemoContent
,
parseHtmlToRawText
}
from
"../helpers/marked"
;
import
Only
from
"./common/OnlyWhen"
;
...
...
@@ -27,11 +27,6 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
const
[
linkMemos
,
setLinkMemos
]
=
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
visibilityList
=
[
{
text
:
"PUBLIC"
,
value
:
"PUBLIC"
},
{
text
:
"PROTECTED"
,
value
:
"PROTECTED"
},
{
text
:
"PRIVATE"
,
value
:
"PRIVATE"
},
];
useEffect
(()
=>
{
const
fetchLinkedMemos
=
async
()
=>
{
...
...
@@ -132,7 +127,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
<
Icon
.
Eye
className=
"icon-img"
/>
<
Selector
className=
"visibility-selector"
dataSource=
{
visibilityList
}
dataSource=
{
VISIBILITY_SELECTOR_ITEMS
}
value=
{
memo
.
visibility
}
handleValueChanged=
{
(
value
)
=>
handleVisibilitySelectorChange
(
value
as
Visibility
)
}
/>
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
2f33ecea
import
{
globalService
,
userService
}
from
"../../services"
;
import
{
useAppSelector
}
from
"../../store"
;
import
{
VISIBILITY_SELECTOR_ITEMS
}
from
"../../helpers/consts"
;
import
useI18n
from
"../../hooks/useI18n"
;
import
Selector
from
"../common/Selector"
;
import
"../../less/settings/preferences-section.less"
;
...
...
@@ -26,12 +27,25 @@ const PreferencesSection: React.FC<Props> = () => {
await
userService
.
upsertUserSetting
(
"locale"
,
value
);
};
const
handleDefaultMemoVisibilityChanged
=
async
(
value
:
string
)
=>
{
await
userService
.
upsertUserSetting
(
"memoVisibility"
,
value
);
};
return
(
<
div
className=
"section-container preferences-section-container"
>
<
label
className=
"form-label"
>
<
span
className=
"normal-text"
>
{
t
(
"common.language"
)
}
:
</
span
>
<
Selector
className=
"ml-2 w-28"
value=
{
setting
.
locale
}
dataSource=
{
localeSelectorItems
}
handleValueChanged=
{
handleLocaleChanged
}
/>
</
label
>
<
label
className=
"form-label"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.default-memo-visibility"
)
}
:
</
span
>
<
Selector
className=
"ml-2 w-28"
value=
{
setting
.
memoVisibility
}
dataSource=
{
VISIBILITY_SELECTOR_ITEMS
}
handleValueChanged=
{
handleDefaultMemoVisibilityChanged
}
/>
</
label
>
</
div
>
);
};
...
...
web/src/helpers/consts.ts
View file @
2f33ecea
...
...
@@ -21,3 +21,9 @@ export const LINK_URL_REG = /\[(.*?)\]\((.+?)\)/g;
// linked memo regex
export
const
MEMO_LINK_REG
=
/@
\[(
.+
?)\]\((
.+
?)\)
/g
;
export
const
VISIBILITY_SELECTOR_ITEMS
=
[
{
text
:
"PUBLIC"
,
value
:
"PUBLIC"
},
{
text
:
"PROTECTED"
,
value
:
"PROTECTED"
},
{
text
:
"PRIVATE"
,
value
:
"PRIVATE"
},
];
web/src/labs/i18n/useI18n.ts
View file @
2f33ecea
...
...
@@ -3,8 +3,6 @@ import i18nStore from "./i18nStore";
import
enLocale
from
"../../locales/en.json"
;
import
zhLocale
from
"../../locales/zh.json"
;
type
Locale
=
"en"
|
"zh"
;
const
resources
:
Record
<
string
,
any
>
=
{
en
:
enLocale
,
zh
:
zhLocale
,
...
...
web/src/locales/en.json
View file @
2f33ecea
...
...
@@ -51,6 +51,9 @@
"account-section"
:
{
"title"
:
"Account Information"
},
"preference-section"
:
{
"default-memo-visibility"
:
"Default memo visibility"
},
"member-section"
:
{
"create-a-member"
:
"Create a member"
}
...
...
web/src/locales/zh.json
View file @
2f33ecea
...
...
@@ -52,6 +52,9 @@
"account-section"
:
{
"title"
:
"账号信息"
},
"preference-section"
:
{
"default-memo-visibility"
:
"默认 Memo 可见性"
},
"member-section"
:
{
"create-a-member"
:
"创建成员"
}
...
...
web/src/services/userService.ts
View file @
2f33ecea
...
...
@@ -6,6 +6,7 @@ import { setUser, patchUser, setHost, setOwner } from "../store/modules/user";
const
defauleSetting
:
Setting
=
{
locale
:
"en"
,
memoVisibility
:
"PRIVATE"
,
};
export
const
convertResponseModelUser
=
(
user
:
User
):
User
=>
{
...
...
web/src/types/modules/setting.d.ts
View file @
2f33ecea
interface
Setting
{
locale
:
"en"
|
"zh"
;
locale
:
Locale
;
memoVisibility
:
Visibility
;
}
interface
UserLocaleSetting
{
key
:
"locale"
;
value
:
"en"
|
"zh"
;
value
:
Locale
;
}
interface
UserMemoVisibilitySetting
{
key
:
"memoVisibility"
;
value
:
Visibility
;
}
type
UserSetting
=
UserLocaleSetting
;
...
...
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