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
3f56ce47
Commit
3f56ce47
authored
Jul 27, 2025
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update definition of workspace setting
parent
53d39785
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
792 additions
and
702 deletions
+792
-702
workspace_service.proto
proto/api/v1/workspace_service.proto
+96
-90
workspace_service.pb.go
proto/gen/api/v1/workspace_service.pb.go
+312
-310
openapi.yaml
proto/gen/openapi.yaml
+138
-78
workspace_service.go
server/router/api/v1/workspace_service.go
+15
-15
MemoRelatedSettings.tsx
web/src/components/Settings/MemoRelatedSettings.tsx
+5
-5
StorageSection.tsx
web/src/components/Settings/StorageSection.tsx
+26
-22
WorkspaceSection.tsx
web/src/components/Settings/WorkspaceSection.tsx
+5
-5
UpdateCustomizedProfileDialog.tsx
web/src/components/UpdateCustomizedProfileDialog.tsx
+4
-4
workspace.ts
web/src/store/workspace.ts
+7
-3
workspace_service.ts
web/src/types/proto/api/v1/workspace_service.ts
+184
-170
No files found.
proto/api/v1/workspace_service.proto
View file @
3f56ce47
...
@@ -65,25 +65,24 @@ message WorkspaceSetting {
...
@@ -65,25 +65,24 @@ message WorkspaceSetting {
string
name
=
1
[(
google.api.field_behavior
)
=
IDENTIFIER
];
string
name
=
1
[(
google.api.field_behavior
)
=
IDENTIFIER
];
oneof
value
{
oneof
value
{
Workspace
GeneralSetting
general_setting
=
2
;
GeneralSetting
general_setting
=
2
;
Workspace
StorageSetting
storage_setting
=
3
;
StorageSetting
storage_setting
=
3
;
Workspace
MemoRelatedSetting
memo_related_setting
=
4
;
MemoRelatedSetting
memo_related_setting
=
4
;
}
}
// Enumeration of workspace setting keys.
enum
Key
{
enum
Key
{
KEY_UNSPECIFIED
=
0
;
KEY_UNSPECIFIED
=
0
;
// BASIC is the key for basic settings.
BASIC
=
1
;
// GENERAL is the key for general settings.
// GENERAL is the key for general settings.
GENERAL
=
2
;
GENERAL
=
1
;
// STORAGE is the key for storage settings.
// STORAGE is the key for storage settings.
STORAGE
=
3
;
STORAGE
=
2
;
// MEMO_RELATED is the key for memo related settings.
// MEMO_RELATED is the key for memo related settings.
MEMO_RELATED
=
4
;
MEMO_RELATED
=
3
;
}
}
}
message
WorkspaceGeneralSetting
{
// General workspace settings configuration.
message
GeneralSetting
{
// theme is the name of the selected theme.
// theme is the name of the selected theme.
// This references a CSS file in the web/public/themes/ directory.
// This references a CSS file in the web/public/themes/ directory.
string
theme
=
1
;
string
theme
=
1
;
...
@@ -96,7 +95,7 @@ message WorkspaceGeneralSetting {
...
@@ -96,7 +95,7 @@ message WorkspaceGeneralSetting {
// additional_style is the additional style.
// additional_style is the additional style.
string
additional_style
=
5
;
string
additional_style
=
5
;
// custom_profile is the custom profile.
// custom_profile is the custom profile.
Workspace
CustomProfile
custom_profile
=
6
;
CustomProfile
custom_profile
=
6
;
// week_start_day_offset is the week start day offset from Sunday.
// week_start_day_offset is the week start day offset from Sunday.
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
// Default is Sunday.
// Default is Sunday.
...
@@ -106,17 +105,20 @@ message WorkspaceGeneralSetting {
...
@@ -106,17 +105,20 @@ message WorkspaceGeneralSetting {
bool
disallow_change_username
=
8
;
bool
disallow_change_username
=
8
;
// disallow_change_nickname disallows changing nickname.
// disallow_change_nickname disallows changing nickname.
bool
disallow_change_nickname
=
9
;
bool
disallow_change_nickname
=
9
;
}
message
WorkspaceCustomProfile
{
// Custom profile configuration for workspace branding.
message
CustomProfile
{
string
title
=
1
;
string
title
=
1
;
string
description
=
2
;
string
description
=
2
;
string
logo_url
=
3
;
string
logo_url
=
3
;
string
locale
=
4
;
string
locale
=
4
;
string
appearance
=
5
;
string
appearance
=
5
;
}
}
}
message
WorkspaceStorageSetting
{
// Storage configuration settings for workspace attachments.
message
StorageSetting
{
// Storage type enumeration for different storage backends.
enum
StorageType
{
enum
StorageType
{
STORAGE_TYPE_UNSPECIFIED
=
0
;
STORAGE_TYPE_UNSPECIFIED
=
0
;
// DATABASE is the database storage type.
// DATABASE is the database storage type.
...
@@ -133,6 +135,8 @@ message WorkspaceStorageSetting {
...
@@ -133,6 +135,8 @@ message WorkspaceStorageSetting {
string
filepath_template
=
2
;
string
filepath_template
=
2
;
// The max upload size in megabytes.
// The max upload size in megabytes.
int64
upload_size_limit_mb
=
3
;
int64
upload_size_limit_mb
=
3
;
// S3 configuration for cloud storage backend.
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
message
S3Config
{
message
S3Config
{
string
access_key_id
=
1
;
string
access_key_id
=
1
;
...
@@ -144,9 +148,10 @@ message WorkspaceStorageSetting {
...
@@ -144,9 +148,10 @@ message WorkspaceStorageSetting {
}
}
// The S3 config.
// The S3 config.
S3Config
s3_config
=
4
;
S3Config
s3_config
=
4
;
}
}
message
WorkspaceMemoRelatedSetting
{
// Memo-related workspace settings and policies.
message
MemoRelatedSetting
{
// disallow_public_visibility disallows set memo as public visibility.
// disallow_public_visibility disallows set memo as public visibility.
bool
disallow_public_visibility
=
1
;
bool
disallow_public_visibility
=
1
;
// display_with_update_time orders and displays memo with update time.
// display_with_update_time orders and displays memo with update time.
...
@@ -167,6 +172,7 @@ message WorkspaceMemoRelatedSetting {
...
@@ -167,6 +172,7 @@ message WorkspaceMemoRelatedSetting {
bool
enable_blur_nsfw_content
=
9
;
bool
enable_blur_nsfw_content
=
9
;
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
// nsfw_tags is the list of tags that mark content as NSFW for blurring.
repeated
string
nsfw_tags
=
10
;
repeated
string
nsfw_tags
=
10
;
}
}
}
// Request message for GetWorkspaceSetting method.
// Request message for GetWorkspaceSetting method.
...
...
proto/gen/api/v1/workspace_service.pb.go
View file @
3f56ce47
This diff is collapsed.
Click to expand it.
proto/gen/openapi.yaml
View file @
3f56ce47
This diff is collapsed.
Click to expand it.
server/router/api/v1/workspace_service.go
View file @
3f56ce47
...
@@ -105,15 +105,15 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *v1pb.W
...
@@ -105,15 +105,15 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *v1pb.W
}
}
switch
setting
.
Value
.
(
type
)
{
switch
setting
.
Value
.
(
type
)
{
case
*
storepb
.
WorkspaceSetting_GeneralSetting
:
case
*
storepb
.
WorkspaceSetting_GeneralSetting
:
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_GeneralSetting
{
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_GeneralSetting
_
{
GeneralSetting
:
convertWorkspaceGeneralSettingFromStore
(
setting
.
GetGeneralSetting
()),
GeneralSetting
:
convertWorkspaceGeneralSettingFromStore
(
setting
.
GetGeneralSetting
()),
}
}
case
*
storepb
.
WorkspaceSetting_StorageSetting
:
case
*
storepb
.
WorkspaceSetting_StorageSetting
:
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_StorageSetting
{
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_StorageSetting
_
{
StorageSetting
:
convertWorkspaceStorageSettingFromStore
(
setting
.
GetStorageSetting
()),
StorageSetting
:
convertWorkspaceStorageSettingFromStore
(
setting
.
GetStorageSetting
()),
}
}
case
*
storepb
.
WorkspaceSetting_MemoRelatedSetting
:
case
*
storepb
.
WorkspaceSetting_MemoRelatedSetting
:
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_MemoRelatedSetting
{
workspaceSetting
.
Value
=
&
v1pb
.
WorkspaceSetting_MemoRelatedSetting
_
{
MemoRelatedSetting
:
convertWorkspaceMemoRelatedSettingFromStore
(
setting
.
GetMemoRelatedSetting
()),
MemoRelatedSetting
:
convertWorkspaceMemoRelatedSettingFromStore
(
setting
.
GetMemoRelatedSetting
()),
}
}
}
}
...
@@ -145,7 +145,7 @@ func convertWorkspaceSettingToStore(setting *v1pb.WorkspaceSetting) *storepb.Wor
...
@@ -145,7 +145,7 @@ func convertWorkspaceSettingToStore(setting *v1pb.WorkspaceSetting) *storepb.Wor
return
workspaceSetting
return
workspaceSetting
}
}
func
convertWorkspaceGeneralSettingFromStore
(
setting
*
storepb
.
WorkspaceGeneralSetting
)
*
v1pb
.
WorkspaceGeneralSetting
{
func
convertWorkspaceGeneralSettingFromStore
(
setting
*
storepb
.
WorkspaceGeneralSetting
)
*
v1pb
.
Workspace
Setting_
GeneralSetting
{
if
setting
==
nil
{
if
setting
==
nil
{
return
nil
return
nil
}
}
...
@@ -155,7 +155,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
...
@@ -155,7 +155,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
theme
=
"default"
theme
=
"default"
}
}
generalSetting
:=
&
v1pb
.
WorkspaceGeneralSetting
{
generalSetting
:=
&
v1pb
.
Workspace
Setting_
GeneralSetting
{
Theme
:
theme
,
Theme
:
theme
,
DisallowUserRegistration
:
setting
.
DisallowUserRegistration
,
DisallowUserRegistration
:
setting
.
DisallowUserRegistration
,
DisallowPasswordAuth
:
setting
.
DisallowPasswordAuth
,
DisallowPasswordAuth
:
setting
.
DisallowPasswordAuth
,
...
@@ -166,7 +166,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
...
@@ -166,7 +166,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
DisallowChangeNickname
:
setting
.
DisallowChangeNickname
,
DisallowChangeNickname
:
setting
.
DisallowChangeNickname
,
}
}
if
setting
.
CustomProfile
!=
nil
{
if
setting
.
CustomProfile
!=
nil
{
generalSetting
.
CustomProfile
=
&
v1pb
.
WorkspaceCustomProfile
{
generalSetting
.
CustomProfile
=
&
v1pb
.
Workspace
Setting_GeneralSetting_
CustomProfile
{
Title
:
setting
.
CustomProfile
.
Title
,
Title
:
setting
.
CustomProfile
.
Title
,
Description
:
setting
.
CustomProfile
.
Description
,
Description
:
setting
.
CustomProfile
.
Description
,
LogoUrl
:
setting
.
CustomProfile
.
LogoUrl
,
LogoUrl
:
setting
.
CustomProfile
.
LogoUrl
,
...
@@ -177,7 +177,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
...
@@ -177,7 +177,7 @@ func convertWorkspaceGeneralSettingFromStore(setting *storepb.WorkspaceGeneralSe
return
generalSetting
return
generalSetting
}
}
func
convertWorkspaceGeneralSettingToStore
(
setting
*
v1pb
.
WorkspaceGeneralSetting
)
*
storepb
.
WorkspaceGeneralSetting
{
func
convertWorkspaceGeneralSettingToStore
(
setting
*
v1pb
.
Workspace
Setting_
GeneralSetting
)
*
storepb
.
WorkspaceGeneralSetting
{
if
setting
==
nil
{
if
setting
==
nil
{
return
nil
return
nil
}
}
...
@@ -203,17 +203,17 @@ func convertWorkspaceGeneralSettingToStore(setting *v1pb.WorkspaceGeneralSetting
...
@@ -203,17 +203,17 @@ func convertWorkspaceGeneralSettingToStore(setting *v1pb.WorkspaceGeneralSetting
return
generalSetting
return
generalSetting
}
}
func
convertWorkspaceStorageSettingFromStore
(
settingpb
*
storepb
.
WorkspaceStorageSetting
)
*
v1pb
.
WorkspaceStorageSetting
{
func
convertWorkspaceStorageSettingFromStore
(
settingpb
*
storepb
.
WorkspaceStorageSetting
)
*
v1pb
.
WorkspaceS
etting_S
torageSetting
{
if
settingpb
==
nil
{
if
settingpb
==
nil
{
return
nil
return
nil
}
}
setting
:=
&
v1pb
.
WorkspaceStorageSetting
{
setting
:=
&
v1pb
.
WorkspaceS
etting_S
torageSetting
{
StorageType
:
v1pb
.
WorkspaceStorageSetting_StorageType
(
settingpb
.
StorageType
),
StorageType
:
v1pb
.
WorkspaceS
etting_S
torageSetting_StorageType
(
settingpb
.
StorageType
),
FilepathTemplate
:
settingpb
.
FilepathTemplate
,
FilepathTemplate
:
settingpb
.
FilepathTemplate
,
UploadSizeLimitMb
:
settingpb
.
UploadSizeLimitMb
,
UploadSizeLimitMb
:
settingpb
.
UploadSizeLimitMb
,
}
}
if
settingpb
.
S3Config
!=
nil
{
if
settingpb
.
S3Config
!=
nil
{
setting
.
S3Config
=
&
v1pb
.
WorkspaceStorageSetting_S3Config
{
setting
.
S3Config
=
&
v1pb
.
WorkspaceS
etting_S
torageSetting_S3Config
{
AccessKeyId
:
settingpb
.
S3Config
.
AccessKeyId
,
AccessKeyId
:
settingpb
.
S3Config
.
AccessKeyId
,
AccessKeySecret
:
settingpb
.
S3Config
.
AccessKeySecret
,
AccessKeySecret
:
settingpb
.
S3Config
.
AccessKeySecret
,
Endpoint
:
settingpb
.
S3Config
.
Endpoint
,
Endpoint
:
settingpb
.
S3Config
.
Endpoint
,
...
@@ -225,7 +225,7 @@ func convertWorkspaceStorageSettingFromStore(settingpb *storepb.WorkspaceStorage
...
@@ -225,7 +225,7 @@ func convertWorkspaceStorageSettingFromStore(settingpb *storepb.WorkspaceStorage
return
setting
return
setting
}
}
func
convertWorkspaceStorageSettingToStore
(
setting
*
v1pb
.
WorkspaceStorageSetting
)
*
storepb
.
WorkspaceStorageSetting
{
func
convertWorkspaceStorageSettingToStore
(
setting
*
v1pb
.
WorkspaceS
etting_S
torageSetting
)
*
storepb
.
WorkspaceStorageSetting
{
if
setting
==
nil
{
if
setting
==
nil
{
return
nil
return
nil
}
}
...
@@ -247,11 +247,11 @@ func convertWorkspaceStorageSettingToStore(setting *v1pb.WorkspaceStorageSetting
...
@@ -247,11 +247,11 @@ func convertWorkspaceStorageSettingToStore(setting *v1pb.WorkspaceStorageSetting
return
settingpb
return
settingpb
}
}
func
convertWorkspaceMemoRelatedSettingFromStore
(
setting
*
storepb
.
WorkspaceMemoRelatedSetting
)
*
v1pb
.
WorkspaceMemoRelatedSetting
{
func
convertWorkspaceMemoRelatedSettingFromStore
(
setting
*
storepb
.
WorkspaceMemoRelatedSetting
)
*
v1pb
.
Workspace
Setting_
MemoRelatedSetting
{
if
setting
==
nil
{
if
setting
==
nil
{
return
nil
return
nil
}
}
return
&
v1pb
.
WorkspaceMemoRelatedSetting
{
return
&
v1pb
.
Workspace
Setting_
MemoRelatedSetting
{
DisallowPublicVisibility
:
setting
.
DisallowPublicVisibility
,
DisallowPublicVisibility
:
setting
.
DisallowPublicVisibility
,
DisplayWithUpdateTime
:
setting
.
DisplayWithUpdateTime
,
DisplayWithUpdateTime
:
setting
.
DisplayWithUpdateTime
,
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
ContentLengthLimit
:
setting
.
ContentLengthLimit
,
...
@@ -265,7 +265,7 @@ func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoR
...
@@ -265,7 +265,7 @@ func convertWorkspaceMemoRelatedSettingFromStore(setting *storepb.WorkspaceMemoR
}
}
}
}
func
convertWorkspaceMemoRelatedSettingToStore
(
setting
*
v1pb
.
WorkspaceMemoRelatedSetting
)
*
storepb
.
WorkspaceMemoRelatedSetting
{
func
convertWorkspaceMemoRelatedSettingToStore
(
setting
*
v1pb
.
Workspace
Setting_
MemoRelatedSetting
)
*
storepb
.
WorkspaceMemoRelatedSetting
{
if
setting
==
nil
{
if
setting
==
nil
{
return
nil
return
nil
}
}
...
...
web/src/components/Settings/MemoRelatedSettings.tsx
View file @
3f56ce47
...
@@ -9,18 +9,18 @@ import { Input } from "@/components/ui/input";
...
@@ -9,18 +9,18 @@ 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
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
Workspace
Setting_
MemoRelatedSetting
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
const
MemoRelatedSettings
=
observer
(()
=>
{
const
MemoRelatedSettings
=
observer
(()
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
[
originalSetting
,
setOriginalSetting
]
=
useState
<
WorkspaceMemoRelatedSetting
>
(
workspaceStore
.
state
.
memoRelatedSetting
);
const
[
originalSetting
,
setOriginalSetting
]
=
useState
<
Workspace
Setting_
MemoRelatedSetting
>
(
workspaceStore
.
state
.
memoRelatedSetting
);
const
[
memoRelatedSetting
,
setMemoRelatedSetting
]
=
useState
<
WorkspaceMemoRelatedSetting
>
(
originalSetting
);
const
[
memoRelatedSetting
,
setMemoRelatedSetting
]
=
useState
<
Workspace
Setting_
MemoRelatedSetting
>
(
originalSetting
);
const
[
editingReaction
,
setEditingReaction
]
=
useState
<
string
>
(
""
);
const
[
editingReaction
,
setEditingReaction
]
=
useState
<
string
>
(
""
);
const
[
editingNsfwTag
,
setEditingNsfwTag
]
=
useState
<
string
>
(
""
);
const
[
editingNsfwTag
,
setEditingNsfwTag
]
=
useState
<
string
>
(
""
);
const
updatePartialSetting
=
(
partial
:
Partial
<
WorkspaceMemoRelatedSetting
>
)
=>
{
const
updatePartialSetting
=
(
partial
:
Partial
<
Workspace
Setting_
MemoRelatedSetting
>
)
=>
{
const
newWorkspaceMemoRelatedSetting
=
WorkspaceMemoRelatedSetting
.
fromPartial
({
const
newWorkspaceMemoRelatedSetting
=
Workspace
Setting_
MemoRelatedSetting
.
fromPartial
({
...
memoRelatedSetting
,
...
memoRelatedSetting
,
...
partial
,
...
partial
,
});
});
...
...
web/src/components/Settings/StorageSection.tsx
View file @
3f56ce47
...
@@ -15,21 +15,25 @@ import { workspaceStore } from "@/store";
...
@@ -15,21 +15,25 @@ import { workspaceStore } from "@/store";
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
workspaceSettingNamePrefix
}
from
"@/store/common"
;
import
{
import
{
WorkspaceSetting_Key
,
WorkspaceSetting_Key
,
WorkspaceStorageSetting
,
WorkspaceS
etting_S
torageSetting
,
WorkspaceStorageSetting_S3Config
,
WorkspaceS
etting_S
torageSetting_S3Config
,
WorkspaceStorageSetting_StorageType
,
WorkspaceS
etting_S
torageSetting_StorageType
,
}
from
"@/types/proto/api/v1/workspace_service"
;
}
from
"@/types/proto/api/v1/workspace_service"
;
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
<
WorkspaceSetting_StorageSetting
>
(
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{}),
WorkspaceSetting_StorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{},
),
);
);
useEffect
(()
=>
{
useEffect
(()
=>
{
setWorkspaceStorageSetting
(
setWorkspaceStorageSetting
(
WorkspaceStorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{}),
WorkspaceSetting_StorageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{},
),
);
);
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)]);
},
[
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)]);
...
@@ -38,14 +42,14 @@ const StorageSection = observer(() => {
...
@@ -38,14 +42,14 @@ const StorageSection = observer(() => {
return
false
;
return
false
;
}
}
const
origin
=
WorkspaceStorageSetting
.
fromPartial
(
const
origin
=
WorkspaceS
etting_S
torageSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{},
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
STORAGE
)?.
storageSetting
||
{},
);
);
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceStorageSetting_StorageType
.
LOCAL
)
{
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceS
etting_S
torageSetting_StorageType
.
LOCAL
)
{
if
(
workspaceStorageSetting
.
filepathTemplate
.
length
===
0
)
{
if
(
workspaceStorageSetting
.
filepathTemplate
.
length
===
0
)
{
return
false
;
return
false
;
}
}
}
else
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceStorageSetting_StorageType
.
S3
)
{
}
else
if
(
workspaceStorageSetting
.
storageType
===
WorkspaceS
etting_S
torageSetting_StorageType
.
S3
)
{
if
(
if
(
workspaceStorageSetting
.
s3Config
?.
accessKeyId
.
length
===
0
||
workspaceStorageSetting
.
s3Config
?.
accessKeyId
.
length
===
0
||
workspaceStorageSetting
.
s3Config
?.
accessKeySecret
.
length
===
0
||
workspaceStorageSetting
.
s3Config
?.
accessKeySecret
.
length
===
0
||
...
@@ -64,7 +68,7 @@ const StorageSection = observer(() => {
...
@@ -64,7 +68,7 @@ const StorageSection = observer(() => {
if
(
Number
.
isNaN
(
num
))
{
if
(
Number
.
isNaN
(
num
))
{
num
=
0
;
num
=
0
;
}
}
const
update
:
WorkspaceStorageSetting
=
{
const
update
:
WorkspaceS
etting_S
torageSetting
=
{
...
workspaceStorageSetting
,
...
workspaceStorageSetting
,
uploadSizeLimitMb
:
num
,
uploadSizeLimitMb
:
num
,
};
};
...
@@ -72,17 +76,17 @@ const StorageSection = observer(() => {
...
@@ -72,17 +76,17 @@ const StorageSection = observer(() => {
};
};
const
handleFilepathTemplateChanged
=
async
(
event
:
React
.
FocusEvent
<
HTMLInputElement
>
)
=>
{
const
handleFilepathTemplateChanged
=
async
(
event
:
React
.
FocusEvent
<
HTMLInputElement
>
)
=>
{
const
update
:
WorkspaceStorageSetting
=
{
const
update
:
WorkspaceS
etting_S
torageSetting
=
{
...
workspaceStorageSetting
,
...
workspaceStorageSetting
,
filepathTemplate
:
event
.
target
.
value
,
filepathTemplate
:
event
.
target
.
value
,
};
};
setWorkspaceStorageSetting
(
update
);
setWorkspaceStorageSetting
(
update
);
};
};
const
handlePartialS3ConfigChanged
=
async
(
s3Config
:
Partial
<
WorkspaceStorageSetting_S3Config
>
)
=>
{
const
handlePartialS3ConfigChanged
=
async
(
s3Config
:
Partial
<
WorkspaceS
etting_S
torageSetting_S3Config
>
)
=>
{
const
update
:
WorkspaceStorageSetting
=
{
const
update
:
WorkspaceS
etting_S
torageSetting
=
{
...
workspaceStorageSetting
,
...
workspaceStorageSetting
,
s3Config
:
WorkspaceStorageSetting_S3Config
.
fromPartial
({
s3Config
:
WorkspaceS
etting_S
torageSetting_S3Config
.
fromPartial
({
...
workspaceStorageSetting
.
s3Config
,
...
workspaceStorageSetting
.
s3Config
,
...
s3Config
,
...
s3Config
,
}),
}),
...
@@ -116,8 +120,8 @@ const StorageSection = observer(() => {
...
@@ -116,8 +120,8 @@ const StorageSection = observer(() => {
});
});
};
};
const
handleStorageTypeChanged
=
async
(
storageType
:
WorkspaceStorageSetting_StorageType
)
=>
{
const
handleStorageTypeChanged
=
async
(
storageType
:
WorkspaceS
etting_S
torageSetting_StorageType
)
=>
{
const
update
:
WorkspaceStorageSetting
=
{
const
update
:
WorkspaceS
etting_S
torageSetting
=
{
...
workspaceStorageSetting
,
...
workspaceStorageSetting
,
storageType
:
storageType
,
storageType
:
storageType
,
};
};
...
@@ -138,20 +142,20 @@ const StorageSection = observer(() => {
...
@@ -138,20 +142,20 @@ const StorageSection = observer(() => {
<
RadioGroup
<
RadioGroup
value=
{
workspaceStorageSetting
.
storageType
}
value=
{
workspaceStorageSetting
.
storageType
}
onValueChange=
{
(
value
)
=>
{
onValueChange=
{
(
value
)
=>
{
handleStorageTypeChanged
(
value
as
WorkspaceStorageSetting_StorageType
);
handleStorageTypeChanged
(
value
as
WorkspaceS
etting_S
torageSetting_StorageType
);
}
}
}
}
className=
"flex flex-row gap-4"
className=
"flex flex-row gap-4"
>
>
<
div
className=
"flex items-center space-x-2"
>
<
div
className=
"flex items-center space-x-2"
>
<
RadioGroupItem
value=
{
WorkspaceStorageSetting_StorageType
.
DATABASE
}
id=
"database"
/>
<
RadioGroupItem
value=
{
WorkspaceS
etting_S
torageSetting_StorageType
.
DATABASE
}
id=
"database"
/>
<
Label
htmlFor=
"database"
>
{
t
(
"setting.storage-section.type-database"
)
}
</
Label
>
<
Label
htmlFor=
"database"
>
{
t
(
"setting.storage-section.type-database"
)
}
</
Label
>
</
div
>
</
div
>
<
div
className=
"flex items-center space-x-2"
>
<
div
className=
"flex items-center space-x-2"
>
<
RadioGroupItem
value=
{
WorkspaceStorageSetting_StorageType
.
LOCAL
}
id=
"local"
/>
<
RadioGroupItem
value=
{
WorkspaceS
etting_S
torageSetting_StorageType
.
LOCAL
}
id=
"local"
/>
<
Label
htmlFor=
"local"
>
{
t
(
"setting.storage-section.type-local"
)
}
</
Label
>
<
Label
htmlFor=
"local"
>
{
t
(
"setting.storage-section.type-local"
)
}
</
Label
>
</
div
>
</
div
>
<
div
className=
"flex items-center space-x-2"
>
<
div
className=
"flex items-center space-x-2"
>
<
RadioGroupItem
value=
{
WorkspaceStorageSetting_StorageType
.
S3
}
id=
"s3"
/>
<
RadioGroupItem
value=
{
WorkspaceS
etting_S
torageSetting_StorageType
.
S3
}
id=
"s3"
/>
<
Label
htmlFor=
"s3"
>
S3
</
Label
>
<
Label
htmlFor=
"s3"
>
S3
</
Label
>
</
div
>
</
div
>
</
RadioGroup
>
</
RadioGroup
>
...
@@ -171,7 +175,7 @@ const StorageSection = observer(() => {
...
@@ -171,7 +175,7 @@ const StorageSection = observer(() => {
</
div
>
</
div
>
<
Input
className=
"w-16 font-mono"
value=
{
workspaceStorageSetting
.
uploadSizeLimitMb
}
onChange=
{
handleMaxUploadSizeChanged
}
/>
<
Input
className=
"w-16 font-mono"
value=
{
workspaceStorageSetting
.
uploadSizeLimitMb
}
onChange=
{
handleMaxUploadSizeChanged
}
/>
</
div
>
</
div
>
{
workspaceStorageSetting
.
storageType
!==
WorkspaceStorageSetting_StorageType
.
DATABASE
&&
(
{
workspaceStorageSetting
.
storageType
!==
WorkspaceS
etting_S
torageSetting_StorageType
.
DATABASE
&&
(
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
className=
"text-muted-foreground mr-1"
>
{
t
(
"setting.storage-section.filepath-template"
)
}
</
span
>
<
span
className=
"text-muted-foreground mr-1"
>
{
t
(
"setting.storage-section.filepath-template"
)
}
</
span
>
<
Input
<
Input
...
@@ -182,7 +186,7 @@ const StorageSection = observer(() => {
...
@@ -182,7 +186,7 @@ const StorageSection = observer(() => {
/>
/>
</
div
>
</
div
>
)
}
)
}
{
workspaceStorageSetting
.
storageType
===
WorkspaceStorageSetting_StorageType
.
S3
&&
(
{
workspaceStorageSetting
.
storageType
===
WorkspaceS
etting_S
torageSetting_StorageType
.
S3
&&
(
<>
<>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
span
className=
"text-muted-foreground mr-1"
>
Access key id
</
span
>
<
span
className=
"text-muted-foreground mr-1"
>
Access key id
</
span
>
...
...
web/src/components/Settings/WorkspaceSection.tsx
View file @
3f56ce47
...
@@ -14,7 +14,7 @@ import useDialog from "@/hooks/useDialog";
...
@@ -14,7 +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
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
Workspace
Setting_
GeneralSetting
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
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"
;
...
@@ -22,10 +22,10 @@ import UpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
...
@@ -22,10 +22,10 @@ import UpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
const
WorkspaceSection
=
observer
(()
=>
{
const
WorkspaceSection
=
observer
(()
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
customizeDialog
=
useDialog
();
const
customizeDialog
=
useDialog
();
const
originalSetting
=
WorkspaceGeneralSetting
.
fromPartial
(
const
originalSetting
=
Workspace
Setting_
GeneralSetting
.
fromPartial
(
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
GENERAL
)?.
generalSetting
||
{},
workspaceStore
.
getWorkspaceSettingByKey
(
WorkspaceSetting_Key
.
GENERAL
)?.
generalSetting
||
{},
);
);
const
[
workspaceGeneralSetting
,
setWorkspaceGeneralSetting
]
=
useState
<
WorkspaceGeneralSetting
>
(
originalSetting
);
const
[
workspaceGeneralSetting
,
setWorkspaceGeneralSetting
]
=
useState
<
Workspace
Setting_
GeneralSetting
>
(
originalSetting
);
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -36,9 +36,9 @@ const WorkspaceSection = observer(() => {
...
@@ -36,9 +36,9 @@ const WorkspaceSection = observer(() => {
customizeDialog
.
open
();
customizeDialog
.
open
();
};
};
const
updatePartialSetting
=
(
partial
:
Partial
<
WorkspaceGeneralSetting
>
)
=>
{
const
updatePartialSetting
=
(
partial
:
Partial
<
Workspace
Setting_
GeneralSetting
>
)
=>
{
setWorkspaceGeneralSetting
(
setWorkspaceGeneralSetting
(
WorkspaceGeneralSetting
.
fromPartial
({
Workspace
Setting_
GeneralSetting
.
fromPartial
({
...
workspaceGeneralSetting
,
...
workspaceGeneralSetting
,
...
partial
,
...
partial
,
}),
}),
...
...
web/src/components/UpdateCustomizedProfileDialog.tsx
View file @
3f56ce47
...
@@ -7,7 +7,7 @@ import { Label } from "@/components/ui/label";
...
@@ -7,7 +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
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
Workspace
Setting_GeneralSetting_
CustomProfile
,
WorkspaceSetting_Key
}
from
"@/types/proto/api/v1/workspace_service"
;
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"
;
...
@@ -21,13 +21,13 @@ interface Props {
...
@@ -21,13 +21,13 @@ interface Props {
function
UpdateCustomizedProfileDialog
({
open
,
onOpenChange
,
onSuccess
}:
Props
)
{
function
UpdateCustomizedProfileDialog
({
open
,
onOpenChange
,
onSuccess
}:
Props
)
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
workspaceGeneralSetting
=
workspaceStore
.
state
.
generalSetting
;
const
workspaceGeneralSetting
=
workspaceStore
.
state
.
generalSetting
;
const
[
customProfile
,
setCustomProfile
]
=
useState
<
WorkspaceCustomProfile
>
(
const
[
customProfile
,
setCustomProfile
]
=
useState
<
Workspace
Setting_GeneralSetting_
CustomProfile
>
(
WorkspaceCustomProfile
.
fromPartial
(
workspaceGeneralSetting
.
customProfile
||
{}),
Workspace
Setting_GeneralSetting_
CustomProfile
.
fromPartial
(
workspaceGeneralSetting
.
customProfile
||
{}),
);
);
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
);
const
[
isLoading
,
setIsLoading
]
=
useState
(
false
);
const
setPartialState
=
(
partialState
:
Partial
<
WorkspaceCustomProfile
>
)
=>
{
const
setPartialState
=
(
partialState
:
Partial
<
Workspace
Setting_GeneralSetting_
CustomProfile
>
)
=>
{
setCustomProfile
((
state
)
=>
({
setCustomProfile
((
state
)
=>
({
...
state
,
...
state
,
...
partialState
,
...
partialState
,
...
...
web/src/store/workspace.ts
View file @
3f56ce47
...
@@ -2,7 +2,11 @@ import { uniqBy } from "lodash-es";
...
@@ -2,7 +2,11 @@ import { uniqBy } from "lodash-es";
import
{
makeAutoObservable
}
from
"mobx"
;
import
{
makeAutoObservable
}
from
"mobx"
;
import
{
workspaceServiceClient
}
from
"@/grpcweb"
;
import
{
workspaceServiceClient
}
from
"@/grpcweb"
;
import
{
WorkspaceProfile
,
WorkspaceSetting_Key
}
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
{
WorkspaceSetting_GeneralSetting
,
WorkspaceSetting_MemoRelatedSetting
,
WorkspaceSetting
,
}
from
"@/types/proto/api/v1/workspace_service"
;
import
{
isValidateLocale
}
from
"@/utils/i18n"
;
import
{
isValidateLocale
}
from
"@/utils/i18n"
;
import
{
workspaceSettingNamePrefix
}
from
"./common"
;
import
{
workspaceSettingNamePrefix
}
from
"./common"
;
...
@@ -15,14 +19,14 @@ class LocalState {
...
@@ -15,14 +19,14 @@ class LocalState {
get
generalSetting
()
{
get
generalSetting
()
{
return
(
return
(
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting_Key
.
GENERAL
}
`
)?.
generalSetting
||
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting_Key
.
GENERAL
}
`
)?.
generalSetting
||
WorkspaceGeneralSetting
.
fromPartial
({})
Workspace
Setting_
GeneralSetting
.
fromPartial
({})
);
);
}
}
get
memoRelatedSetting
()
{
get
memoRelatedSetting
()
{
return
(
return
(
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting_Key
.
MEMO_RELATED
}
`
)
this
.
settings
.
find
((
setting
)
=>
setting
.
name
===
`
${
workspaceSettingNamePrefix
}${
WorkspaceSetting_Key
.
MEMO_RELATED
}
`
)
?.
memoRelatedSetting
||
WorkspaceMemoRelatedSetting
.
fromPartial
({})
?.
memoRelatedSetting
||
Workspace
Setting_
MemoRelatedSetting
.
fromPartial
({})
);
);
}
}
...
...
web/src/types/proto/api/v1/workspace_service.ts
View file @
3f56ce47
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