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
c93b1efb
Commit
c93b1efb
authored
Apr 10, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update workspace setting store
parent
58ae3217
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
210 additions
and
72 deletions
+210
-72
README.md
proto/gen/store/README.md
+20
-1
workspace_setting.pb.go
proto/gen/store/workspace_setting.pb.go
+166
-57
workspace_setting.proto
proto/store/workspace_setting.proto
+11
-1
workspace_setting_service.go
server/route/api/v2/workspace_setting_service.go
+3
-3
workspace_setting.go
store/db/mysql/workspace_setting.go
+2
-2
workspace_setting.go
store/db/postgres/workspace_setting.go
+2
-2
workspace_setting.go
store/db/sqlite/workspace_setting.go
+2
-2
migrator.go
store/migrator.go
+1
-1
workspace_setting.go
store/workspace_setting.go
+1
-1
workspace_setting_test.go
test/store/workspace_setting_test.go
+2
-2
No files found.
proto/gen/store/README.md
View file @
c93b1efb
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
-
[
store/workspace_setting.proto
](
#store_workspace_setting-proto
)
-
[
store/workspace_setting.proto
](
#store_workspace_setting-proto
)
-
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
-
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
-
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
-
[
WorkspaceSetting
](
#memos-store-WorkspaceSetting
)
-
[
WorkspaceSetting
](
#memos-store-WorkspaceSetting
)
-
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
-
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
...
@@ -457,6 +458,22 @@
...
@@ -457,6 +458,22 @@
<a
name=
"memos-store-WorkspaceMemoRelatedSetting"
></a>
### WorkspaceMemoRelatedSetting
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| disallow_public_visible |
[
bool
](
#bool
)
| | disallow_public_share disallows set memo as public visible. |
| display_with_update_time |
[
bool
](
#bool
)
| | display_with_update_time orders and displays memo with update time. |
<a
name=
"memos-store-WorkspaceSetting"
></a>
<a
name=
"memos-store-WorkspaceSetting"
></a>
### WorkspaceSetting
### WorkspaceSetting
...
@@ -466,7 +483,8 @@
...
@@ -466,7 +483,8 @@
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| key |
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
| | |
| key |
[
WorkspaceSettingKey
](
#memos-store-WorkspaceSettingKey
)
| | |
| general |
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
| | |
| general_setting |
[
WorkspaceGeneralSetting
](
#memos-store-WorkspaceGeneralSetting
)
| | |
| memo_related_setting |
[
WorkspaceMemoRelatedSetting
](
#memos-store-WorkspaceMemoRelatedSetting
)
| | |
...
@@ -484,6 +502,7 @@
...
@@ -484,6 +502,7 @@
| ---- | ------ | ----------- |
| ---- | ------ | ----------- |
| WORKSPACE_SETTING_KEY_UNSPECIFIED | 0 | |
| WORKSPACE_SETTING_KEY_UNSPECIFIED | 0 | |
| WORKSPACE_SETTING_GENERAL | 1 | WORKSPACE_SETTING_GENERAL is the key for general settings. |
| WORKSPACE_SETTING_GENERAL | 1 | WORKSPACE_SETTING_GENERAL is the key for general settings. |
| WORKSPACE_SETTING_MEMO_RELATED | 2 | WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings. |
...
...
proto/gen/store/workspace_setting.pb.go
View file @
c93b1efb
This diff is collapsed.
Click to expand it.
proto/store/workspace_setting.proto
View file @
c93b1efb
...
@@ -8,12 +8,15 @@ enum WorkspaceSettingKey {
...
@@ -8,12 +8,15 @@ enum WorkspaceSettingKey {
WORKSPACE_SETTING_KEY_UNSPECIFIED
=
0
;
WORKSPACE_SETTING_KEY_UNSPECIFIED
=
0
;
// WORKSPACE_SETTING_GENERAL is the key for general settings.
// WORKSPACE_SETTING_GENERAL is the key for general settings.
WORKSPACE_SETTING_GENERAL
=
1
;
WORKSPACE_SETTING_GENERAL
=
1
;
// WORKSPACE_SETTING_MEMO_RELATED is the key for memo related settings.
WORKSPACE_SETTING_MEMO_RELATED
=
2
;
}
}
message
WorkspaceSetting
{
message
WorkspaceSetting
{
WorkspaceSettingKey
key
=
1
;
WorkspaceSettingKey
key
=
1
;
oneof
value
{
oneof
value
{
WorkspaceGeneralSetting
general
=
2
;
WorkspaceGeneralSetting
general_setting
=
2
;
WorkspaceMemoRelatedSetting
memo_related_setting
=
3
;
}
}
}
}
...
@@ -29,3 +32,10 @@ message WorkspaceGeneralSetting {
...
@@ -29,3 +32,10 @@ message WorkspaceGeneralSetting {
// additional_style is the additional style.
// additional_style is the additional style.
string
additional_style
=
6
;
string
additional_style
=
6
;
}
}
message
WorkspaceMemoRelatedSetting
{
// disallow_public_share disallows set memo as public visible.
bool
disallow_public_visible
=
1
;
// display_with_update_time orders and displays memo with update time.
bool
display_with_update_time
=
2
;
}
server/route/api/v2/workspace_setting_service.go
View file @
c93b1efb
...
@@ -57,7 +57,7 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *apiv2p
...
@@ -57,7 +57,7 @@ func convertWorkspaceSettingFromStore(setting *storepb.WorkspaceSetting) *apiv2p
return
&
apiv2pb
.
WorkspaceSetting
{
return
&
apiv2pb
.
WorkspaceSetting
{
Name
:
fmt
.
Sprintf
(
"%s%s"
,
WorkspaceSettingNamePrefix
,
setting
.
Key
.
String
()),
Name
:
fmt
.
Sprintf
(
"%s%s"
,
WorkspaceSettingNamePrefix
,
setting
.
Key
.
String
()),
Value
:
&
apiv2pb
.
WorkspaceSetting_GeneralSetting
{
Value
:
&
apiv2pb
.
WorkspaceSetting_GeneralSetting
{
GeneralSetting
:
convertWorkspaceGeneralSettingFromStore
(
setting
.
GetGeneral
()),
GeneralSetting
:
convertWorkspaceGeneralSettingFromStore
(
setting
.
GetGeneral
Setting
()),
},
},
}
}
}
}
...
@@ -66,8 +66,8 @@ func convertWorkspaceSettingToStore(setting *apiv2pb.WorkspaceSetting) *storepb.
...
@@ -66,8 +66,8 @@ func convertWorkspaceSettingToStore(setting *apiv2pb.WorkspaceSetting) *storepb.
settingKeyString
,
_
:=
ExtractWorkspaceSettingKeyFromName
(
setting
.
Name
)
settingKeyString
,
_
:=
ExtractWorkspaceSettingKeyFromName
(
setting
.
Name
)
return
&
storepb
.
WorkspaceSetting
{
return
&
storepb
.
WorkspaceSetting
{
Key
:
storepb
.
WorkspaceSettingKey
(
storepb
.
WorkspaceSettingKey_value
[
settingKeyString
]),
Key
:
storepb
.
WorkspaceSettingKey
(
storepb
.
WorkspaceSettingKey_value
[
settingKeyString
]),
Value
:
&
storepb
.
WorkspaceSetting_General
{
Value
:
&
storepb
.
WorkspaceSetting_General
Setting
{
General
:
convertWorkspaceGeneralSettingToStore
(
setting
.
GetGeneralSetting
()),
General
Setting
:
convertWorkspaceGeneralSettingToStore
(
setting
.
GetGeneralSetting
()),
},
},
}
}
}
}
...
...
store/db/mysql/workspace_setting.go
View file @
c93b1efb
...
@@ -74,7 +74,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -74,7 +74,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
ON DUPLICATE KEY UPDATE value = ?`
ON DUPLICATE KEY UPDATE value = ?`
var
valueString
string
var
valueString
string
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
())
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
Setting
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -116,7 +116,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -116,7 +116,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
{
General
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
Setting
{
GeneralSetting
:
generalSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
store/db/postgres/workspace_setting.go
View file @
c93b1efb
...
@@ -84,7 +84,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -84,7 +84,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
SET value = EXCLUDED.value`
SET value = EXCLUDED.value`
var
valueString
string
var
valueString
string
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
())
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
Setting
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -126,7 +126,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -126,7 +126,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
{
General
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
Setting
{
GeneralSetting
:
generalSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
store/db/sqlite/workspace_setting.go
View file @
c93b1efb
...
@@ -84,7 +84,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
...
@@ -84,7 +84,7 @@ func (d *DB) UpsertWorkspaceSettingV1(ctx context.Context, upsert *storepb.Works
SET value = EXCLUDED.value`
SET value = EXCLUDED.value`
var
valueString
string
var
valueString
string
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
if
upsert
.
Key
==
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
{
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
())
valueBytes
,
err
:=
protojson
.
Marshal
(
upsert
.
GetGeneral
Setting
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -125,7 +125,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
...
@@ -125,7 +125,7 @@ func (d *DB) ListWorkspaceSettingsV1(ctx context.Context, find *store.FindWorksp
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
if
err
:=
protojson
.
Unmarshal
([]
byte
(
valueString
),
generalSetting
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
{
General
:
generalSetting
}
workspaceSetting
.
Value
=
&
storepb
.
WorkspaceSetting_General
Setting
{
GeneralSetting
:
generalSetting
}
}
else
{
}
else
{
// Skip unknown workspace setting key.
// Skip unknown workspace setting key.
continue
continue
...
...
store/migrator.go
View file @
c93b1efb
...
@@ -52,7 +52,7 @@ func (s *Store) MigrateWorkspaceSetting(ctx context.Context) error {
...
@@ -52,7 +52,7 @@ func (s *Store) MigrateWorkspaceSetting(ctx context.Context) error {
if
_
,
err
:=
s
.
UpsertWorkspaceSettingV1
(
ctx
,
&
storepb
.
WorkspaceSetting
{
if
_
,
err
:=
s
.
UpsertWorkspaceSettingV1
(
ctx
,
&
storepb
.
WorkspaceSetting
{
Key
:
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
,
Key
:
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
,
Value
:
&
storepb
.
WorkspaceSetting_General
{
General
:
workspaceGeneralSetting
},
Value
:
&
storepb
.
WorkspaceSetting_General
Setting
{
GeneralSetting
:
workspaceGeneralSetting
},
});
err
!=
nil
{
});
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to upsert workspace general setting"
)
return
errors
.
Wrap
(
err
,
"failed to upsert workspace general setting"
)
}
}
...
...
store/workspace_setting.go
View file @
c93b1efb
...
@@ -123,7 +123,7 @@ func (s *Store) GetWorkspaceGeneralSetting(ctx context.Context) (*storepb.Worksp
...
@@ -123,7 +123,7 @@ func (s *Store) GetWorkspaceGeneralSetting(ctx context.Context) (*storepb.Worksp
workspaceGeneralSetting
:=
&
storepb
.
WorkspaceGeneralSetting
{}
workspaceGeneralSetting
:=
&
storepb
.
WorkspaceGeneralSetting
{}
if
workspaceSetting
!=
nil
{
if
workspaceSetting
!=
nil
{
workspaceGeneralSetting
=
workspaceSetting
.
GetGeneral
()
workspaceGeneralSetting
=
workspaceSetting
.
GetGeneral
Setting
()
}
}
return
workspaceGeneralSetting
,
nil
return
workspaceGeneralSetting
,
nil
}
}
test/store/workspace_setting_test.go
View file @
c93b1efb
...
@@ -15,8 +15,8 @@ func TestWorkspaceSettingV1Store(t *testing.T) {
...
@@ -15,8 +15,8 @@ func TestWorkspaceSettingV1Store(t *testing.T) {
ts
:=
NewTestingStore
(
ctx
,
t
)
ts
:=
NewTestingStore
(
ctx
,
t
)
workspaceSetting
,
err
:=
ts
.
UpsertWorkspaceSettingV1
(
ctx
,
&
storepb
.
WorkspaceSetting
{
workspaceSetting
,
err
:=
ts
.
UpsertWorkspaceSettingV1
(
ctx
,
&
storepb
.
WorkspaceSetting
{
Key
:
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
,
Key
:
storepb
.
WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL
,
Value
:
&
storepb
.
WorkspaceSetting_General
{
Value
:
&
storepb
.
WorkspaceSetting_General
Setting
{
General
:
&
storepb
.
WorkspaceGeneralSetting
{
General
Setting
:
&
storepb
.
WorkspaceGeneralSetting
{
DisallowSignup
:
true
,
DisallowSignup
:
true
,
},
},
},
},
...
...
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