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
ac386c21
Commit
ac386c21
authored
Jul 22, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: workspace setting keys
parent
c133f552
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
309 additions
and
79 deletions
+309
-79
workspace_service.proto
proto/api/v1/workspace_service.proto
+12
-0
workspace_service.pb.go
proto/gen/api/v1/workspace_service.pb.go
+98
-32
MemoRelatedSettings.tsx
web/src/components/Settings/MemoRelatedSettings.tsx
+2
-3
StorageSection.tsx
web/src/components/Settings/StorageSection.tsx
+6
-6
WorkspaceSection.tsx
web/src/components/Settings/WorkspaceSection.tsx
+4
-5
UpdateCustomizedProfileDialog.tsx
web/src/components/UpdateCustomizedProfileDialog.tsx
+2
-3
Home.tsx
web/src/pages/Home.tsx
+2
-2
Setting.tsx
web/src/pages/Setting.tsx
+2
-2
workspace.ts
web/src/store/workspace.ts
+6
-7
workspace_service.ts
web/src/types/proto/api/v1/workspace_service.ts
+55
-0
descriptor.ts
web/src/types/proto/google/protobuf/descriptor.ts
+120
-19
No files found.
proto/api/v1/workspace_service.proto
View file @
ac386c21
...
@@ -69,6 +69,18 @@ message WorkspaceSetting {
...
@@ -69,6 +69,18 @@ message WorkspaceSetting {
WorkspaceStorageSetting
storage_setting
=
3
;
WorkspaceStorageSetting
storage_setting
=
3
;
WorkspaceMemoRelatedSetting
memo_related_setting
=
4
;
WorkspaceMemoRelatedSetting
memo_related_setting
=
4
;
}
}
enum
Key
{
KEY_UNSPECIFIED
=
0
;
// BASIC is the key for basic settings.
BASIC
=
1
;
// GENERAL is the key for general settings.
GENERAL
=
2
;
// STORAGE is the key for storage settings.
STORAGE
=
3
;
// MEMO_RELATED is the key for memo related settings.
MEMO_RELATED
=
4
;
}
}
}
message
WorkspaceGeneralSetting
{
message
WorkspaceGeneralSetting
{
...
...
proto/gen/api/v1/workspace_service.pb.go
View file @
ac386c21
This diff is collapsed.
Click to expand it.
web/src/components/Settings/MemoRelatedSettings.tsx
View file @
ac386c21
...
@@ -9,8 +9,7 @@ import { Input } from "@/components/ui/input";
...
@@ -9,8 +9,7 @@ import { Input } from "@/components/ui/input";
import
{
Switch
}
from
"@/components/ui/switch"
;
import
{
Switch
}
from
"@/components/ui/switch"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
WorkspaceMemoRelatedSetting
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceMemoRelatedSetting
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
const
MemoRelatedSettings
=
observer
(()
=>
{
const
MemoRelatedSettings
=
observer
(()
=>
{
...
@@ -54,7 +53,7 @@ const MemoRelatedSettings = observer(() => {
...
@@ -54,7 +53,7 @@ const MemoRelatedSettings = observer(() => {
try
{
try
{
await
workspaceStore
.
upsertWorkspaceSetting
({
await
workspaceStore
.
upsertWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
MEMO_RELATED
}
`
,
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
MEMO_RELATED
}
`
,
memoRelatedSetting
,
memoRelatedSetting
,
});
});
setOriginalSetting
(
memoRelatedSetting
);
setOriginalSetting
(
memoRelatedSetting
);
...
...
web/src/components/Settings/StorageSection.tsx
View file @
ac386c21
...
@@ -14,24 +14,24 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
...
@@ -14,24 +14,24 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
import
{
WorkspaceSetting_Key
,
WorkspaceStorageSetting
,
WorkspaceStorageSetting
,
WorkspaceStorageSetting_S3Config
,
WorkspaceStorageSetting_S3Config
,
WorkspaceStorageSetting_StorageType
,
WorkspaceStorageSetting_StorageType
,
}
from
"@/types/proto/api/v1/workspace_service"
;
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
const
StorageSection
=
observer
(()
=>
{
const
StorageSection
=
observer
(()
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
[
workspaceStorageSetting
,
setWorkspaceStorageSetting
]
=
useState
<
WorkspaceStorageSetting
>
(
const
[
workspaceStorageSetting
,
setWorkspaceStorageSetting
]
=
useState
<
WorkspaceStorageSetting
>
(
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
STORAGE
)?.
storageSetting
||
{}),
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
STORAGE
)?.
storageSetting
||
{}),
);
);
useEffect
(()
=>
{
useEffect
(()
=>
{
setWorkspaceStorageSetting
(
setWorkspaceStorageSetting
(
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
STORAGE
)?.
storageSetting
||
{}),
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
STORAGE
)?.
storageSetting
||
{}),
);
);
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
STORAGE
)]);
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
STORAGE
)]);
const
allowSaveStorageSetting
=
useMemo
(()
=>
{
const
allowSaveStorageSetting
=
useMemo
(()
=>
{
if
(
workspaceStorageSetting
.
uploadSizeLimitMb
<=
0
)
{
if
(
workspaceStorageSetting
.
uploadSizeLimitMb
<=
0
)
{
...
@@ -39,7 +39,7 @@ const StorageSection = observer(() => {
...
@@ -39,7 +39,7 @@ const StorageSection = observer(() => {
}
}
const
origin
=
WorkspaceStorageSetting
.
fromPartial
(
const
origin
=
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
STORAGE
)?.
storageSetting
||
{},
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
STORAGE
)?.
storageSetting
||
{},
);
);
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceStorageSetting_StorageType
.
LOCAL
)
{
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceStorageSetting_StorageType
.
LOCAL
)
{
if
(
workspaceStorageSetting
.
filepathTemplate
.
length
===
0
)
{
if
(
workspaceStorageSetting
.
filepathTemplate
.
length
===
0
)
{
...
@@ -126,7 +126,7 @@ const StorageSection = observer(() => {
...
@@ -126,7 +126,7 @@ const StorageSection = observer(() => {
const
saveWorkspaceStorageSetting
=
async
()
=>
{
const
saveWorkspaceStorageSetting
=
async
()
=>
{
await
workspaceStore
.
upsertWorkspaceSetting
({
await
workspaceStore
.
upsertWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
STORAGE
}
`
,
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
STORAGE
}
`
,
storageSetting
:
workspaceStorageSetting
,
storageSetting
:
workspaceStorageSetting
,
});
});
toast
.
success
(
"Updated"
);
toast
.
success
(
"Updated"
);
...
...
web/src/components/Settings/WorkspaceSection.tsx
View file @
ac386c21
...
@@ -14,8 +14,7 @@ import useDialog from "@/hooks/useDialog";
...
@@ -14,8 +14,7 @@ import useDialog from "@/hooks/useDialog";
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
IdentityProvider
}
from
"@/types/proto/api/v1/idp_service"
;
import
{
IdentityProvider
}
from
"@/types/proto/api/v1/idp_service"
;
import
{
WorkspaceGeneralSetting
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceGeneralSetting
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
ThemeSelector
from
"../ThemeSelector"
;
import
ThemeSelector
from
"../ThemeSelector"
;
import
UpdateCustomizedProfileDialog
from
"../UpdateCustomizedProfileDialog"
;
import
UpdateCustomizedProfileDialog
from
"../UpdateCustomizedProfileDialog"
;
...
@@ -24,14 +23,14 @@ const WorkspaceSection = observer(() => {
...
@@ -24,14 +23,14 @@ const WorkspaceSection = observer(() => {
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
customizeDialog
=
useDialog
();
const
customizeDialog
=
useDialog
();
const
originalSetting
=
WorkspaceGeneralSetting
.
fromPartial
(
const
originalSetting
=
WorkspaceGeneralSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
GENERAL
)?.
generalSetting
||
{},
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
GENERAL
)?.
generalSetting
||
{},
);
);
const
[
workspaceGeneralSetting
,
setWorkspaceGeneralSetting
]
=
useState
<
WorkspaceGeneralSetting
>
(
originalSetting
);
const
[
workspaceGeneralSetting
,
setWorkspaceGeneralSetting
]
=
useState
<
WorkspaceGeneralSetting
>
(
originalSetting
);
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
useEffect
(()
=>
{
useEffect
(()
=>
{
setWorkspaceGeneralSetting
({
...
workspaceGeneralSetting
,
customProfile
:
originalSetting
.
customProfile
});
setWorkspaceGeneralSetting
({
...
workspaceGeneralSetting
,
customProfile
:
originalSetting
.
customProfile
});
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
GENERAL
)]);
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
GENERAL
)]);
const
handleUpdateCustomizedProfileButtonClick
=
()
=>
{
const
handleUpdateCustomizedProfileButtonClick
=
()
=>
{
customizeDialog
.
open
();
customizeDialog
.
open
();
...
@@ -49,7 +48,7 @@ const WorkspaceSection = observer(() => {
...
@@ -49,7 +48,7 @@ const WorkspaceSection = observer(() => {
const
handleSaveGeneralSetting
=
async
()
=>
{
const
handleSaveGeneralSetting
=
async
()
=>
{
try
{
try
{
await
workspaceStore
.
upsertWorkspaceSetting
({
await
workspaceStore
.
upsertWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
GENERAL
}
`
,
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
GENERAL
}
`
,
generalSetting
:
workspaceGeneralSetting
,
generalSetting
:
workspaceGeneralSetting
,
});
});
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
...
...
web/src/components/UpdateCustomizedProfileDialog.tsx
View file @
ac386c21
...
@@ -7,8 +7,7 @@ import { Label } from "@/components/ui/label";
...
@@ -7,8 +7,7 @@ import { Label } from "@/components/ui/label";
import
{
Textarea
}
from
"@/components/ui/textarea"
;
import
{
Textarea
}
from
"@/components/ui/textarea"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
WorkspaceCustomProfile
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceCustomProfile
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
AppearanceSelect
from
"./AppearanceSelect"
;
import
AppearanceSelect
from
"./AppearanceSelect"
;
import
LocaleSelect
from
"./LocaleSelect"
;
import
LocaleSelect
from
"./LocaleSelect"
;
...
@@ -88,7 +87,7 @@ function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props)
...
@@ -88,7 +87,7 @@ function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props)
setIsLoading
(
true
);
setIsLoading
(
true
);
try
{
try
{
await
workspaceStore
.
upsertWorkspaceSetting
({
await
workspaceStore
.
upsertWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
GENERAL
}
`
,
name
:
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
GENERAL
}
`
,
generalSetting
:
{
generalSetting
:
{
...
workspaceGeneralSetting
,
...
workspaceGeneralSetting
,
customProfile
:
customProfile
,
customProfile
:
customProfile
,
...
...
web/src/pages/Home.tsx
View file @
ac386c21
...
@@ -8,7 +8,7 @@ import { viewStore, userStore, workspaceStore } from "@/store";
...
@@ -8,7 +8,7 @@ import { viewStore, userStore, workspaceStore } from "@/store";
import
memoFilterStore
from
"@/store/memoFilter"
;
import
memoFilterStore
from
"@/store/memoFilter"
;
import
{
State
}
from
"@/types/proto/api/v1/common"
;
import
{
State
}
from
"@/types/proto/api/v1/common"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
Memo
}
from
"@/types/proto/api/v1/memo_service"
;
import
{
WorkspaceSetting
Key
}
from
"@/types/proto/store/workspace_setting
"
;
import
{
WorkspaceSetting
_Key
}
from
"@/types/proto/api/v1/workspace_service
"
;
// Helper function to extract shortcut ID from resource name
// Helper function to extract shortcut ID from resource name
// Format: users/{user}/shortcuts/{shortcut}
// Format: users/{user}/shortcuts/{shortcut}
...
@@ -40,7 +40,7 @@ const Home = observer(() => {
...
@@ -40,7 +40,7 @@ const Home = observer(() => {
}
else
if
(
filter
.
factor
===
"property.hasCode"
)
{
}
else
if
(
filter
.
factor
===
"property.hasCode"
)
{
conditions
.
push
(
`has_code`
);
conditions
.
push
(
`has_code`
);
}
else
if
(
filter
.
factor
===
"displayTime"
)
{
}
else
if
(
filter
.
factor
===
"displayTime"
)
{
const
displayWithUpdateTime
=
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
MEMO_RELATED
).
memoRelatedSetting
const
displayWithUpdateTime
=
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting
_
Key
.
MEMO_RELATED
).
memoRelatedSetting
?.
displayWithUpdateTime
;
?.
displayWithUpdateTime
;
const
factor
=
displayWithUpdateTime
?
"updated_ts"
:
"created_ts"
;
const
factor
=
displayWithUpdateTime
?
"updated_ts"
:
"created_ts"
;
const
filterDate
=
new
Date
(
filter
.
value
);
const
filterDate
=
new
Date
(
filter
.
value
);
...
...
web/src/pages/Setting.tsx
View file @
ac386c21
...
@@ -16,7 +16,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
...
@@ -16,7 +16,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
workspaceStore
}
from
"@/store"
;
import
{
User_Role
}
from
"@/types/proto/api/v1/user_service"
;
import
{
User_Role
}
from
"@/types/proto/api/v1/user_service"
;
import
{
WorkspaceSetting
Key
}
from
"@/types/proto/store/workspace_setting
"
;
import
{
WorkspaceSetting
_Key
}
from
"@/types/proto/api/v1/workspace_service
"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
type
SettingSection
=
"my-account"
|
"preference"
|
"member"
|
"system"
|
"memo-related"
|
"storage"
|
"sso"
;
type
SettingSection
=
"my-account"
|
"preference"
|
"member"
|
"system"
|
"memo-related"
|
"storage"
|
"sso"
;
...
@@ -73,7 +73,7 @@ const Setting = observer(() => {
...
@@ -73,7 +73,7 @@ const Setting = observer(() => {
// Initial fetch for workspace settings.
// Initial fetch for workspace settings.
(
async
()
=>
{
(
async
()
=>
{
[
WorkspaceSetting
Key
.
MEMO_RELATED
,
WorkspaceSetting
Key
.
STORAGE
].
forEach
(
async
(
key
)
=>
{
[
WorkspaceSetting
_Key
.
MEMO_RELATED
,
WorkspaceSetting_
Key
.
STORAGE
].
forEach
(
async
(
key
)
=>
{
await
workspaceStore
.
fetchWorkspaceSetting
(
key
);
await
workspaceStore
.
fetchWorkspaceSetting
(
key
);
});
});
})();
})();
...
...
web/src/store/workspace.ts
View file @
ac386c21
import
{
uniqBy
}
from
"lodash-es"
;
import
{
uniqBy
}
from
"lodash-es"
;
import
{
makeAutoObservable
}
from
"mobx"
;
import
{
makeAutoObservable
}
from
"mobx"
;
import
{
workspaceServiceClient
}
from
"@/grpcweb"
;
import
{
workspaceServiceClient
}
from
"@/grpcweb"
;
import
{
WorkspaceProfile
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceProfile
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceGeneralSetting
,
WorkspaceMemoRelatedSetting
,
WorkspaceSetting
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceGeneralSetting
,
WorkspaceMemoRelatedSetting
,
WorkspaceSetting
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
isValidateLocale
}
from
"@/utils/i18n"
;
import
{
isValidateLocale
}
from
"@/utils/i18n"
;
import
{
workspaceSettingNamePrefix
}
from
"./common"
;
import
{
workspaceSettingNamePrefix
}
from
"./common"
;
...
@@ -15,14 +14,14 @@ class LocalState {
...
@@ -15,14 +14,14 @@ class LocalState {
get
generalSetting
()
{
get
generalSetting
()
{
return
(
return
(
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
GENERAL
}
`
)?.
generalSetting
||
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
GENERAL
}
`
)?.
generalSetting
||
WorkspaceGeneralSetting
.
fromPartial
({})
WorkspaceGeneralSetting
.
fromPartial
({})
);
);
}
}
get
memoRelatedSetting
()
{
get
memoRelatedSetting
()
{
return
(
return
(
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSettingKey
.
MEMO_RELATED
}
`
)
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting
_
Key
.
MEMO_RELATED
}
`
)
?.
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({})
?.
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({})
);
);
}
}
...
@@ -49,7 +48,7 @@ class LocalState {
...
@@ -49,7 +48,7 @@ class LocalState {
const
workspaceStore
=
(()
=>
{
const
workspaceStore
=
(()
=>
{
const
state
=
new
LocalState
();
const
state
=
new
LocalState
();
const
fetchWorkspaceSetting
=
async
(
settingKey
:
WorkspaceSettingKey
)
=>
{
const
fetchWorkspaceSetting
=
async
(
settingKey
:
WorkspaceSetting
_
Key
)
=>
{
const
setting
=
await
workspaceServiceClient
.
getWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
settingKey
}
`
});
const
setting
=
await
workspaceServiceClient
.
getWorkspaceSetting
({
name
:
`
${
workspaceSettingNamePrefix
}${
settingKey
}
`
});
state
.
setPartial
({
state
.
setPartial
({
settings
:
uniqBy
([
setting
,
...
state
.
settings
],
"name"
),
settings
:
uniqBy
([
setting
,
...
state
.
settings
],
"name"
),
...
@@ -63,7 +62,7 @@ const workspaceStore = (() => {
...
@@ -63,7 +62,7 @@ const workspaceStore = (() => {
});
});
};
};
const
getWorkspaceSettingByKey
=
(
settingKey
:
WorkspaceSettingKey
)
=>
{
const
getWorkspaceSettingByKey
=
(
settingKey
:
WorkspaceSetting
_
Key
)
=>
{
return
(
return
(
state
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
settingKey
}
`
)
||
WorkspaceSetting
.
fromPartial
({})
state
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
settingKey
}
`
)
||
WorkspaceSetting
.
fromPartial
({})
);
);
...
@@ -80,7 +79,7 @@ const workspaceStore = (() => {
...
@@ -80,7 +79,7 @@ const workspaceStore = (() => {
export
const
initialWorkspaceStore
=
async
()
=>
{
export
const
initialWorkspaceStore
=
async
()
=>
{
const
workspaceProfile
=
await
workspaceServiceClient
.
getWorkspaceProfile
({});
const
workspaceProfile
=
await
workspaceServiceClient
.
getWorkspaceProfile
({});
// Prepare workspace settings.
// Prepare workspace settings.
for
(
const
key
of
[
WorkspaceSetting
Key
.
GENERAL
,
WorkspaceSetting
Key
.
MEMO_RELATED
])
{
for
(
const
key
of
[
WorkspaceSetting
_Key
.
GENERAL
,
WorkspaceSetting_
Key
.
MEMO_RELATED
])
{
await
workspaceStore
.
fetchWorkspaceSetting
(
key
);
await
workspaceStore
.
fetchWorkspaceSetting
(
key
);
}
}
...
...
web/src/types/proto/api/v1/workspace_service.ts
View file @
ac386c21
...
@@ -41,6 +41,61 @@ export interface WorkspaceSetting {
...
@@ -41,6 +41,61 @@ export interface WorkspaceSetting {
memoRelatedSetting
?:
WorkspaceMemoRelatedSetting
|
undefined
;
memoRelatedSetting
?:
WorkspaceMemoRelatedSetting
|
undefined
;
}
}
export
enum
WorkspaceSetting_Key
{
KEY_UNSPECIFIED
=
"KEY_UNSPECIFIED"
,
/** BASIC - BASIC is the key for basic settings. */
BASIC
=
"BASIC"
,
/** GENERAL - GENERAL is the key for general settings. */
GENERAL
=
"GENERAL"
,
/** STORAGE - STORAGE is the key for storage settings. */
STORAGE
=
"STORAGE"
,
/** MEMO_RELATED - MEMO_RELATED is the key for memo related settings. */
MEMO_RELATED
=
"MEMO_RELATED"
,
UNRECOGNIZED
=
"UNRECOGNIZED"
,
}
export
function
workspaceSetting_KeyFromJSON
(
object
:
any
):
WorkspaceSetting_Key
{
switch
(
object
)
{
case
0
:
case
"KEY_UNSPECIFIED"
:
return
WorkspaceSetting_Key
.
KEY_UNSPECIFIED
;
case
1
:
case
"BASIC"
:
return
WorkspaceSetting_Key
.
BASIC
;
case
2
:
case
"GENERAL"
:
return
WorkspaceSetting_Key
.
GENERAL
;
case
3
:
case
"STORAGE"
:
return
WorkspaceSetting_Key
.
STORAGE
;
case
4
:
case
"MEMO_RELATED"
:
return
WorkspaceSetting_Key
.
MEMO_RELATED
;
case
-
1
:
case
"UNRECOGNIZED"
:
default
:
return
WorkspaceSetting_Key
.
UNRECOGNIZED
;
}
}
export
function
workspaceSetting_KeyToNumber
(
object
:
WorkspaceSetting_Key
):
number
{
switch
(
object
)
{
case
WorkspaceSetting_Key
.
KEY_UNSPECIFIED
:
return
0
;
case
WorkspaceSetting_Key
.
BASIC
:
return
1
;
case
WorkspaceSetting_Key
.
GENERAL
:
return
2
;
case
WorkspaceSetting_Key
.
STORAGE
:
return
3
;
case
WorkspaceSetting_Key
.
MEMO_RELATED
:
return
4
;
case
WorkspaceSetting_Key
.
UNRECOGNIZED
:
default
:
return
-
1
;
}
}
export
interface
WorkspaceGeneralSetting
{
export
interface
WorkspaceGeneralSetting
{
/**
/**
* theme is the name of the selected theme.
* theme is the name of the selected theme.
...
...
web/src/types/proto/google/protobuf/descriptor.ts
View file @
ac386c21
This diff is collapsed.
Click to expand it.
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