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
18d16abd
Commit
18d16abd
authored
Mar 21, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update workspace service
parent
1d83c68c
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
121 additions
and
89 deletions
+121
-89
workspace_service.proto
proto/api/v2/workspace_service.proto
+11
-8
README.md
proto/gen/api/v2/README.md
+3
-2
workspace_service.pb.go
proto/gen/api/v2/workspace_service.pb.go
+31
-20
apidocs.swagger.md
server/route/api/v2/apidocs.swagger.md
+3
-2
apidocs.swagger.yaml
server/route/api/v2/apidocs.swagger.yaml
+8
-3
workspace_service.go
server/route/api/v2/workspace_service.go
+42
-1
App.tsx
web/src/App.tsx
+3
-3
ChangePasswordDialog.tsx
web/src/components/ChangePasswordDialog.tsx
+1
-1
SSOSection.tsx
web/src/components/Settings/SSOSection.tsx
+1
-15
Setting.tsx
web/src/pages/Setting.tsx
+1
-1
SignIn.tsx
web/src/pages/SignIn.tsx
+3
-4
SignUp.tsx
web/src/pages/SignUp.tsx
+2
-2
global.ts
web/src/store/module/global.ts
+9
-1
global.ts
web/src/store/reducer/global.ts
+3
-5
system.d.ts
web/src/types/modules/system.d.ts
+0
-7
user.d.ts
web/src/types/modules/user.d.ts
+0
-14
No files found.
proto/api/v2/workspace_service.proto
View file @
18d16abd
...
@@ -14,18 +14,21 @@ service WorkspaceService {
...
@@ -14,18 +14,21 @@ service WorkspaceService {
}
}
message
WorkspaceProfile
{
message
WorkspaceProfile
{
// The name of intance owner.
// Format: "users/{id}"
string
owner
=
1
;
// version is the current version of instance
// version is the current version of instance
string
version
=
1
;
string
version
=
2
;
// mode is the instance mode (e.g. "prod", "dev" or "demo").
// mode is the instance mode (e.g. "prod", "dev" or "demo").
string
mode
=
2
;
string
mode
=
3
;
//
allow_registration is whether the registration is
allowed.
//
disallow_signup is whether the signup is dis
allowed.
bool
allow_registration
=
3
;
bool
disallow_signup
=
4
;
//
allow_password_login is whether the password login is allow
ed.
//
disable_password_login is whether the password login is disabl
ed.
bool
disable_password_login
=
4
;
bool
disable_password_login
=
5
;
// additional_script is the additional script.
// additional_script is the additional script.
string
additional_script
=
5
;
string
additional_script
=
6
;
// additional_style is the additional style.
// additional_style is the additional style.
string
additional_style
=
6
;
string
additional_style
=
7
;
}
}
message
GetWorkspaceProfileRequest
{}
message
GetWorkspaceProfileRequest
{}
...
...
proto/gen/api/v2/README.md
View file @
18d16abd
...
@@ -2600,10 +2600,11 @@ Used internally for obfuscating the page token.
...
@@ -2600,10 +2600,11 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| owner |
[
string
](
#string
)
| | The name of intance owner. Format:
"
users/{id}
"
|
| version |
[
string
](
#string
)
| | version is the current version of instance |
| version |
[
string
](
#string
)
| | version is the current version of instance |
| mode |
[
string
](
#string
)
| | mode is the instance mode (e.g.
"
prod
"
,
"
dev
"
or
"
demo
"
). |
| mode |
[
string
](
#string
)
| | mode is the instance mode (e.g.
"
prod
"
,
"
dev
"
or
"
demo
"
). |
|
allow_registration |
[
bool
](
#bool
)
| | allow_registration is whether the registration is
allowed. |
|
disallow_signup |
[
bool
](
#bool
)
| | disallow_signup is whether the signup is dis
allowed. |
| disable_password_login |
[
bool
](
#bool
)
| |
allow_password_login is whether the password login is allow
ed. |
| disable_password_login |
[
bool
](
#bool
)
| |
disable_password_login is whether the password login is disabl
ed. |
| additional_script |
[
string
](
#string
)
| | additional_script is the additional script. |
| additional_script |
[
string
](
#string
)
| | additional_script is the additional script. |
| additional_style |
[
string
](
#string
)
| | additional_style is the additional style. |
| additional_style |
[
string
](
#string
)
| | additional_style is the additional style. |
...
...
proto/gen/api/v2/workspace_service.pb.go
View file @
18d16abd
...
@@ -26,18 +26,21 @@ type WorkspaceProfile struct {
...
@@ -26,18 +26,21 @@ type WorkspaceProfile struct {
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
unknownFields
protoimpl
.
UnknownFields
// The name of intance owner.
// Format: "users/{id}"
Owner
string
`protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
// version is the current version of instance
// version is the current version of instance
Version
string
`protobuf:"bytes,
1
,opt,name=version,proto3" json:"version,omitempty"`
Version
string
`protobuf:"bytes,
2
,opt,name=version,proto3" json:"version,omitempty"`
// mode is the instance mode (e.g. "prod", "dev" or "demo").
// mode is the instance mode (e.g. "prod", "dev" or "demo").
Mode
string
`protobuf:"bytes,
2
,opt,name=mode,proto3" json:"mode,omitempty"`
Mode
string
`protobuf:"bytes,
3
,opt,name=mode,proto3" json:"mode,omitempty"`
//
allow_registration is whether the registration is
allowed.
//
disallow_signup is whether the signup is dis
allowed.
AllowRegistration
bool
`protobuf:"varint,3,opt,name=allow_registration,json=allowRegistration,proto3" json:"allow_registration
,omitempty"`
DisallowSignup
bool
`protobuf:"varint,4,opt,name=disallow_signup,json=disallowSignup,proto3" json:"disallow_signup
,omitempty"`
//
allow_password_login is whether the password login is allow
ed.
//
disable_password_login is whether the password login is disabl
ed.
DisablePasswordLogin
bool
`protobuf:"varint,
4
,opt,name=disable_password_login,json=disablePasswordLogin,proto3" json:"disable_password_login,omitempty"`
DisablePasswordLogin
bool
`protobuf:"varint,
5
,opt,name=disable_password_login,json=disablePasswordLogin,proto3" json:"disable_password_login,omitempty"`
// additional_script is the additional script.
// additional_script is the additional script.
AdditionalScript
string
`protobuf:"bytes,
5
,opt,name=additional_script,json=additionalScript,proto3" json:"additional_script,omitempty"`
AdditionalScript
string
`protobuf:"bytes,
6
,opt,name=additional_script,json=additionalScript,proto3" json:"additional_script,omitempty"`
// additional_style is the additional style.
// additional_style is the additional style.
AdditionalStyle
string
`protobuf:"bytes,
6
,opt,name=additional_style,json=additionalStyle,proto3" json:"additional_style,omitempty"`
AdditionalStyle
string
`protobuf:"bytes,
7
,opt,name=additional_style,json=additionalStyle,proto3" json:"additional_style,omitempty"`
}
}
func
(
x
*
WorkspaceProfile
)
Reset
()
{
func
(
x
*
WorkspaceProfile
)
Reset
()
{
...
@@ -72,6 +75,13 @@ func (*WorkspaceProfile) Descriptor() ([]byte, []int) {
...
@@ -72,6 +75,13 @@ func (*WorkspaceProfile) Descriptor() ([]byte, []int) {
return
file_api_v2_workspace_service_proto_rawDescGZIP
(),
[]
int
{
0
}
return
file_api_v2_workspace_service_proto_rawDescGZIP
(),
[]
int
{
0
}
}
}
func
(
x
*
WorkspaceProfile
)
GetOwner
()
string
{
if
x
!=
nil
{
return
x
.
Owner
}
return
""
}
func
(
x
*
WorkspaceProfile
)
GetVersion
()
string
{
func
(
x
*
WorkspaceProfile
)
GetVersion
()
string
{
if
x
!=
nil
{
if
x
!=
nil
{
return
x
.
Version
return
x
.
Version
...
@@ -86,9 +96,9 @@ func (x *WorkspaceProfile) GetMode() string {
...
@@ -86,9 +96,9 @@ func (x *WorkspaceProfile) GetMode() string {
return
""
return
""
}
}
func
(
x
*
WorkspaceProfile
)
Get
AllowRegistration
()
bool
{
func
(
x
*
WorkspaceProfile
)
Get
DisallowSignup
()
bool
{
if
x
!=
nil
{
if
x
!=
nil
{
return
x
.
AllowRegistration
return
x
.
DisallowSignup
}
}
return
false
return
false
}
}
...
@@ -206,22 +216,23 @@ var file_api_v2_workspace_service_proto_rawDesc = []byte{
...
@@ -206,22 +216,23 @@ var file_api_v2_workspace_service_proto_rawDesc = []byte{
0x63
,
0x65
,
0x5f
,
0x73
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x63
,
0x65
,
0x5f
,
0x73
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x1a
,
0x1c
,
0x12
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x1a
,
0x1c
,
0x67
,
0x6f
,
0x6f
,
0x67
,
0x6c
,
0x65
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x61
,
0x6e
,
0x6e
,
0x6f
,
0x74
,
0x67
,
0x6f
,
0x6f
,
0x67
,
0x6c
,
0x65
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x61
,
0x6e
,
0x6e
,
0x6f
,
0x74
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x
fd
,
0x01
,
0x0a
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x
8d
,
0x02
,
0x0a
,
0x10
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x10
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x01
,
0x20
,
0x01
,
0x65
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x6f
,
0x77
,
0x6e
,
0x65
,
0x72
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x28
,
0x09
,
0x52
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x6d
,
0x52
,
0x05
,
0x6f
,
0x77
,
0x6e
,
0x65
,
0x72
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x64
,
0x65
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x04
,
0x6d
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x6f
,
0x6e
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x2d
,
0x0a
,
0x12
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x77
,
0x5f
,
0x72
,
0x65
,
0x67
,
0x69
,
0x73
,
0x74
,
0x72
,
0x6e
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x6d
,
0x6f
,
0x64
,
0x65
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x11
,
0x61
,
0x6c
,
0x6c
,
0x04
,
0x6d
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x27
,
0x0a
,
0x0f
,
0x64
,
0x69
,
0x73
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x6f
,
0x77
,
0x52
,
0x65
,
0x67
,
0x69
,
0x73
,
0x74
,
0x72
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x12
,
0x34
,
0x77
,
0x5f
,
0x73
,
0x69
,
0x67
,
0x6e
,
0x75
,
0x70
,
0x18
,
0x04
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x0e
,
0x64
,
0x69
,
0x73
,
0x61
,
0x6c
,
0x6c
,
0x6f
,
0x77
,
0x53
,
0x69
,
0x67
,
0x6e
,
0x75
,
0x70
,
0x12
,
0x34
,
0x0a
,
0x16
,
0x64
,
0x69
,
0x73
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x0a
,
0x16
,
0x64
,
0x69
,
0x73
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x5f
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x5f
,
0x6c
,
0x6f
,
0x67
,
0x69
,
0x6e
,
0x18
,
0x0
4
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x14
,
0x72
,
0x64
,
0x5f
,
0x6c
,
0x6f
,
0x67
,
0x69
,
0x6e
,
0x18
,
0x0
5
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x14
,
0x64
,
0x69
,
0x73
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x50
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x4c
,
0x64
,
0x69
,
0x73
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x50
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x4c
,
0x6f
,
0x67
,
0x69
,
0x6e
,
0x12
,
0x2b
,
0x0a
,
0x11
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x6f
,
0x67
,
0x69
,
0x6e
,
0x12
,
0x2b
,
0x0a
,
0x11
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x5f
,
0x73
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x18
,
0x0
5
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x61
,
0x6c
,
0x5f
,
0x73
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x18
,
0x0
6
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x10
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x53
,
0x63
,
0x72
,
0x69
,
0x70
,
0x10
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x53
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x12
,
0x29
,
0x0a
,
0x10
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x5f
,
0x74
,
0x12
,
0x29
,
0x0a
,
0x10
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x5f
,
0x73
,
0x74
,
0x79
,
0x6c
,
0x65
,
0x18
,
0x0
6
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0f
,
0x61
,
0x64
,
0x64
,
0x73
,
0x74
,
0x79
,
0x6c
,
0x65
,
0x18
,
0x0
7
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0f
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x53
,
0x74
,
0x79
,
0x6c
,
0x65
,
0x22
,
0x1c
,
0x0a
,
0x1a
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x61
,
0x6c
,
0x53
,
0x74
,
0x79
,
0x6c
,
0x65
,
0x22
,
0x1c
,
0x0a
,
0x1a
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x22
,
0x6a
,
0x0a
,
0x1b
,
0x47
,
0x65
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x22
,
0x6a
,
0x0a
,
0x1b
,
0x47
,
0x65
,
...
...
server/route/api/v2/apidocs.swagger.md
View file @
18d16abd
...
@@ -1857,9 +1857,10 @@ GetActivity returns the activity with the given id.
...
@@ -1857,9 +1857,10 @@ GetActivity returns the activity with the given id.
| Name | Type | Description | Required |
| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| ---- | ---- | ----------- | -------- |
| owner | string | | No |
| version | string | | No |
| version | string | | No |
| mode | string | mode is the instance mode (e.g. "prod", "dev" or "demo"). | No |
| mode | string | mode is the instance mode (e.g. "prod", "dev" or "demo"). | No |
|
allowRegistration | boolean | allow_registration is whether the registration is
allowed. | No |
|
disallowSignup | boolean | disallow_signup is whether the signup is dis
allowed. | No |
| disablePasswordLogin | boolean |
allow_password_login is whether the password login is allow
ed. | No |
| disablePasswordLogin | boolean |
disable_password_login is whether the password login is disabl
ed. | No |
| additionalScript | string | additional_script is the additional script. | No |
| additionalScript | string | additional_script is the additional script. | No |
| additionalStyle | string | additional_style is the additional style. | No |
| additionalStyle | string | additional_style is the additional style. | No |
server/route/api/v2/apidocs.swagger.yaml
View file @
18d16abd
...
@@ -2346,18 +2346,23 @@ definitions:
...
@@ -2346,18 +2346,23 @@ definitions:
v2WorkspaceProfile
:
v2WorkspaceProfile
:
type
:
object
type
:
object
properties
:
properties
:
owner
:
type
:
string
title
:
|-
The name of intance owner.
Format: "users/{id}"
version
:
version
:
type
:
string
type
:
string
title
:
version is the current version of instance
title
:
version is the current version of instance
mode
:
mode
:
type
:
string
type
:
string
description
:
mode is the instance mode (e.g. "prod", "dev" or "demo").
description
:
mode is the instance mode (e.g. "prod", "dev" or "demo").
allowRegistration
:
disallowSignup
:
type
:
boolean
type
:
boolean
description
:
allow_registration is whether the registration is
allowed.
description
:
disallow_signup is whether the signup is dis
allowed.
disablePasswordLogin
:
disablePasswordLogin
:
type
:
boolean
type
:
boolean
description
:
allow_password_login is whether the password login is allow
ed.
description
:
disable_password_login is whether the password login is disabl
ed.
additionalScript
:
additionalScript
:
type
:
string
type
:
string
description
:
additional_script is the additional script.
description
:
additional_script is the additional script.
...
...
server/route/api/v2/workspace_service.go
View file @
18d16abd
...
@@ -3,15 +3,56 @@ package v2
...
@@ -3,15 +3,56 @@ package v2
import
(
import
(
"context"
"context"
"github.com/pkg/errors"
apiv2pb
"github.com/usememos/memos/proto/gen/api/v2"
apiv2pb
"github.com/usememos/memos/proto/gen/api/v2"
"github.com/usememos/memos/store"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
)
func
(
s
*
APIV2Service
)
GetWorkspaceProfile
(
_
context
.
Context
,
_
*
apiv2pb
.
GetWorkspaceProfileRequest
)
(
*
apiv2pb
.
GetWorkspaceProfileResponse
,
error
)
{
var
owner
*
apiv2pb
.
User
=
nil
func
(
s
*
APIV2Service
)
GetWorkspaceProfile
(
ctx
context
.
Context
,
_
*
apiv2pb
.
GetWorkspaceProfileRequest
)
(
*
apiv2pb
.
GetWorkspaceProfileResponse
,
error
)
{
workspaceProfile
:=
&
apiv2pb
.
WorkspaceProfile
{
workspaceProfile
:=
&
apiv2pb
.
WorkspaceProfile
{
Version
:
s
.
Profile
.
Version
,
Version
:
s
.
Profile
.
Version
,
Mode
:
s
.
Profile
.
Mode
,
Mode
:
s
.
Profile
.
Mode
,
}
}
owner
,
err
:=
s
.
GetInstanceOwner
(
ctx
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to get instance owner: %v"
,
err
)
}
if
owner
!=
nil
{
workspaceProfile
.
Owner
=
owner
.
Name
}
generalSetting
,
err
:=
s
.
Store
.
GetWorkspaceGeneralSetting
(
ctx
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to get workspace general setting: %v"
,
err
)
}
workspaceProfile
.
DisallowSignup
=
generalSetting
.
DisallowSignup
workspaceProfile
.
DisablePasswordLogin
=
generalSetting
.
DisallowPasswordLogin
workspaceProfile
.
AdditionalStyle
=
generalSetting
.
AdditionalStyle
workspaceProfile
.
AdditionalScript
=
generalSetting
.
AdditionalScript
return
&
apiv2pb
.
GetWorkspaceProfileResponse
{
return
&
apiv2pb
.
GetWorkspaceProfileResponse
{
WorkspaceProfile
:
workspaceProfile
,
WorkspaceProfile
:
workspaceProfile
,
},
nil
},
nil
}
}
func
(
s
*
APIV2Service
)
GetInstanceOwner
(
ctx
context
.
Context
)
(
*
apiv2pb
.
User
,
error
)
{
if
owner
!=
nil
{
return
owner
,
nil
}
hostUserType
:=
store
.
RoleHost
user
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
Role
:
&
hostUserType
,
})
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to find owner"
)
}
if
user
==
nil
{
return
nil
,
errors
.
New
(
"owner not found"
)
}
owner
=
convertUserFromStore
(
user
)
return
owner
,
nil
}
web/src/App.tsx
View file @
18d16abd
...
@@ -16,7 +16,7 @@ const App = () => {
...
@@ -16,7 +16,7 @@ const App = () => {
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
{
appearance
,
locale
,
systemStatus
,
workspaceProfile
}
=
globalStore
.
state
;
const
userSetting
=
userStore
.
userSetting
;
const
userSetting
=
userStore
.
userSetting
;
const
workspaceGeneralSetting
=
const
workspaceGeneralSetting
=
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
WORKSPACE_SETTING_GENERAL
).
generalSetting
||
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
WORKSPACE_SETTING_GENERAL
).
generalSetting
||
...
@@ -24,10 +24,10 @@ const App = () => {
...
@@ -24,10 +24,10 @@ const App = () => {
// Redirect to sign up page if no host.
// Redirect to sign up page if no host.
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
systemStatus
.
host
)
{
if
(
!
workspaceProfile
.
owner
)
{
navigateTo
(
"/auth/signup"
);
navigateTo
(
"/auth/signup"
);
}
}
},
[
systemStatus
.
host
]);
},
[
workspaceProfile
.
owner
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
darkMediaQuery
=
window
.
matchMedia
(
"(prefers-color-scheme: dark)"
);
const
darkMediaQuery
=
window
.
matchMedia
(
"(prefers-color-scheme: dark)"
);
...
...
web/src/components/ChangePasswordDialog.tsx
View file @
18d16abd
...
@@ -15,7 +15,7 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -15,7 +15,7 @@ const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
const
profile
=
globalStore
.
state
.
systemStatus
.
p
rofile
;
const
profile
=
globalStore
.
state
.
workspaceP
rofile
;
const
[
newPassword
,
setNewPassword
]
=
useState
(
""
);
const
[
newPassword
,
setNewPassword
]
=
useState
(
""
);
const
[
newPasswordAgain
,
setNewPasswordAgain
]
=
useState
(
""
);
const
[
newPasswordAgain
,
setNewPasswordAgain
]
=
useState
(
""
);
...
...
web/src/components/Settings/SSOSection.tsx
View file @
18d16abd
...
@@ -3,24 +3,14 @@ import { useEffect, useState } from "react";
...
@@ -3,24 +3,14 @@ import { useEffect, useState } from "react";
import
{
toast
}
from
"react-hot-toast"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
Link
}
from
"react-router-dom"
;
import
{
Link
}
from
"react-router-dom"
;
import
*
as
api
from
"@/helpers/api"
;
import
*
as
api
from
"@/helpers/api"
;
import
{
useGlobalStore
}
from
"@/store/module"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
showCreateIdentityProviderDialog
from
"../CreateIdentityProviderDialog"
;
import
showCreateIdentityProviderDialog
from
"../CreateIdentityProviderDialog"
;
import
{
showCommonDialog
}
from
"../Dialog/CommonDialog"
;
import
{
showCommonDialog
}
from
"../Dialog/CommonDialog"
;
import
Icon
from
"../Icon"
;
import
Icon
from
"../Icon"
;
import
LearnMore
from
"../LearnMore"
;
import
LearnMore
from
"../LearnMore"
;
interface
State
{
disablePasswordLogin
:
boolean
;
}
const
SSOSection
=
()
=>
{
const
SSOSection
=
()
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
globalStore
=
useGlobalStore
();
const
systemStatus
=
globalStore
.
state
.
systemStatus
;
const
[
state
]
=
useState
<
State
>
({
disablePasswordLogin
:
systemStatus
.
disablePasswordLogin
,
});
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
const
[
identityProviderList
,
setIdentityProviderList
]
=
useState
<
IdentityProvider
[]
>
([]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -33,11 +23,7 @@ const SSOSection = () => {
...
@@ -33,11 +23,7 @@ const SSOSection = () => {
};
};
const
handleDeleteIdentityProvider
=
async
(
identityProvider
:
IdentityProvider
)
=>
{
const
handleDeleteIdentityProvider
=
async
(
identityProvider
:
IdentityProvider
)
=>
{
let
content
=
t
(
"setting.sso-section.confirm-delete"
,
{
name
:
identityProvider
.
name
});
const
content
=
t
(
"setting.sso-section.confirm-delete"
,
{
name
:
identityProvider
.
name
});
if
(
state
.
disablePasswordLogin
)
{
content
+=
"
\n\n
"
+
t
(
"setting.sso-section.disabled-password-login-warning"
);
}
showCommonDialog
({
showCommonDialog
({
title
:
t
(
"setting.sso-section.delete-sso"
),
title
:
t
(
"setting.sso-section.delete-sso"
),
...
...
web/src/pages/Setting.tsx
View file @
18d16abd
...
@@ -88,7 +88,7 @@ const Setting = () => {
...
@@ -88,7 +88,7 @@ const Setting = () => {
onClick=
{
()
=>
handleSectionSelectorItemClick
(
item
)
}
onClick=
{
()
=>
handleSectionSelectorItemClick
(
item
)
}
/>
/>
))
}
))
}
<
span
className=
"px-3 mt-2 opacity-70 text-sm"
>
Version: v
{
globalStore
.
state
.
systemStatus
.
p
rofile
.
version
}
</
span
>
<
span
className=
"px-3 mt-2 opacity-70 text-sm"
>
Version: v
{
globalStore
.
state
.
workspaceP
rofile
.
version
}
</
span
>
</
div
>
</
div
>
</>
</>
)
:
null
}
)
:
null
}
...
...
web/src/pages/SignIn.tsx
View file @
18d16abd
...
@@ -23,8 +23,7 @@ const SignIn = () => {
...
@@ -23,8 +23,7 @@ const SignIn = () => {
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
workspaceSettingStore
=
useWorkspaceSettingStore
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
actionBtnLoadingState
=
useLoading
(
false
);
const
actionBtnLoadingState
=
useLoading
(
false
);
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
{
appearance
,
locale
,
systemStatus
,
workspaceProfile
}
=
globalStore
.
state
;
const
mode
=
systemStatus
.
profile
.
mode
;
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
[
remember
,
setRemember
]
=
useState
(
true
);
const
[
remember
,
setRemember
]
=
useState
(
true
);
...
@@ -42,11 +41,11 @@ const SignIn = () => {
...
@@ -42,11 +41,11 @@ const SignIn = () => {
},
[]);
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
mode
===
"demo"
)
{
if
(
workspaceProfile
.
mode
===
"demo"
)
{
setUsername
(
"memos-demo"
);
setUsername
(
"memos-demo"
);
setPassword
(
"secret"
);
setPassword
(
"secret"
);
}
}
},
[
mode
]);
},
[
workspaceProfile
.
mode
]);
const
handleUsernameInputChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleUsernameInputChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
text
=
e
.
target
.
value
as
string
;
const
text
=
e
.
target
.
value
as
string
;
...
...
web/src/pages/SignUp.tsx
View file @
18d16abd
...
@@ -17,7 +17,7 @@ const SignUp = () => {
...
@@ -17,7 +17,7 @@ const SignUp = () => {
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
actionBtnLoadingState
=
useLoading
(
false
);
const
actionBtnLoadingState
=
useLoading
(
false
);
const
{
appearance
,
locale
,
systemStatus
}
=
globalStore
.
state
;
const
{
appearance
,
locale
,
systemStatus
,
workspaceProfile
}
=
globalStore
.
state
;
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
...
@@ -119,7 +119,7 @@ const SignUp = () => {
...
@@ -119,7 +119,7 @@ const SignUp = () => {
</
Button
>
</
Button
>
</
div
>
</
div
>
</
form
>
</
form
>
{
!
systemStatus
.
host
&&
<
p
className=
"w-full mt-4 text-sm font-medium dark:text-gray-500"
>
{
t
(
"auth.host-tip"
)
}
</
p
>
}
{
!
workspaceProfile
.
owner
&&
<
p
className=
"w-full mt-4 text-sm font-medium dark:text-gray-500"
>
{
t
(
"auth.host-tip"
)
}
</
p
>
}
<
p
className=
"w-full mt-4 text-sm"
>
<
p
className=
"w-full mt-4 text-sm"
>
<
span
className=
"dark:text-gray-500"
>
{
t
(
"auth.sign-in-tip"
)
}
</
span
>
<
span
className=
"dark:text-gray-500"
>
{
t
(
"auth.sign-in-tip"
)
}
</
span
>
<
Link
to=
"/auth"
className=
"cursor-pointer ml-2 text-blue-600 hover:underline"
unstable_viewTransition
>
<
Link
to=
"/auth"
className=
"cursor-pointer ml-2 text-blue-600 hover:underline"
unstable_viewTransition
>
...
...
web/src/store/module/global.ts
View file @
18d16abd
import
{
workspaceServiceClient
}
from
"@/grpcweb"
;
import
*
as
api
from
"@/helpers/api"
;
import
*
as
api
from
"@/helpers/api"
;
import
storage
from
"@/helpers/storage"
;
import
storage
from
"@/helpers/storage"
;
import
i18n
from
"@/i18n"
;
import
i18n
from
"@/i18n"
;
import
{
WorkspaceProfile
}
from
"@/types/proto/api/v2/workspace_service"
;
import
{
findNearestMatchedLanguage
}
from
"@/utils/i18n"
;
import
{
findNearestMatchedLanguage
}
from
"@/utils/i18n"
;
import
store
,
{
useAppSelector
}
from
"../"
;
import
store
,
{
useAppSelector
}
from
"../"
;
import
{
setAppearance
,
setGlobalState
,
setLocale
}
from
"../reducer/global"
;
import
{
setAppearance
,
setGlobalState
,
setLocale
}
from
"../reducer/global"
;
...
@@ -22,8 +24,14 @@ export const initialGlobalState = async () => {
...
@@ -22,8 +24,14 @@ export const initialGlobalState = async () => {
appearance
:
"system"
,
appearance
:
"system"
,
},
},
}
as
SystemStatus
,
}
as
SystemStatus
,
workspaceProfile
:
WorkspaceProfile
.
fromPartial
({}),
};
};
const
{
workspaceProfile
}
=
await
workspaceServiceClient
.
getWorkspaceProfile
({});
if
(
workspaceProfile
)
{
defaultGlobalState
.
workspaceProfile
=
workspaceProfile
;
}
const
{
data
}
=
await
api
.
getSystemStatus
();
const
{
data
}
=
await
api
.
getSystemStatus
();
if
(
data
)
{
if
(
data
)
{
const
customizedProfile
=
data
.
customizedProfile
;
const
customizedProfile
=
data
.
customizedProfile
;
...
@@ -62,7 +70,7 @@ export const useGlobalStore = () => {
...
@@ -62,7 +70,7 @@ export const useGlobalStore = () => {
return
store
.
getState
().
global
.
systemStatus
.
disablePublicMemos
;
return
store
.
getState
().
global
.
systemStatus
.
disablePublicMemos
;
},
},
isDev
:
()
=>
{
isDev
:
()
=>
{
return
state
.
systemStatus
.
p
rofile
.
mode
!==
"prod"
;
return
state
.
workspaceP
rofile
.
mode
!==
"prod"
;
},
},
fetchSystemStatus
:
async
()
=>
{
fetchSystemStatus
:
async
()
=>
{
const
{
data
:
systemStatus
}
=
await
api
.
getSystemStatus
();
const
{
data
:
systemStatus
}
=
await
api
.
getSystemStatus
();
...
...
web/src/store/reducer/global.ts
View file @
18d16abd
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
createSlice
,
PayloadAction
}
from
"@reduxjs/toolkit"
;
import
{
WorkspaceProfile
}
from
"@/types/proto/api/v2/workspace_service"
;
interface
State
{
interface
State
{
locale
:
Locale
;
locale
:
Locale
;
appearance
:
Appearance
;
appearance
:
Appearance
;
systemStatus
:
SystemStatus
;
systemStatus
:
SystemStatus
;
workspaceProfile
:
WorkspaceProfile
;
}
}
const
globalSlice
=
createSlice
({
const
globalSlice
=
createSlice
({
...
@@ -12,11 +14,6 @@ const globalSlice = createSlice({
...
@@ -12,11 +14,6 @@ const globalSlice = createSlice({
locale
:
"en"
,
locale
:
"en"
,
appearance
:
"system"
,
appearance
:
"system"
,
systemStatus
:
{
systemStatus
:
{
host
:
undefined
,
profile
:
{
mode
:
"demo"
,
version
:
""
,
},
disablePasswordLogin
:
false
,
disablePasswordLogin
:
false
,
disablePublicMemos
:
false
,
disablePublicMemos
:
false
,
memoDisplayWithUpdatedTs
:
false
,
memoDisplayWithUpdatedTs
:
false
,
...
@@ -28,6 +25,7 @@ const globalSlice = createSlice({
...
@@ -28,6 +25,7 @@ const globalSlice = createSlice({
appearance
:
"system"
,
appearance
:
"system"
,
},
},
},
},
workspaceProfile
:
WorkspaceProfile
.
fromPartial
({}),
}
as
State
,
}
as
State
,
reducers
:
{
reducers
:
{
setGlobalState
:
(
state
,
action
:
PayloadAction
<
Partial
<
State
>>
)
=>
{
setGlobalState
:
(
state
,
action
:
PayloadAction
<
Partial
<
State
>>
)
=>
{
...
...
web/src/types/modules/system.d.ts
View file @
18d16abd
interface
Profile
{
mode
:
string
;
version
:
string
;
}
interface
CustomizedProfile
{
interface
CustomizedProfile
{
name
:
string
;
name
:
string
;
logoUrl
:
string
;
logoUrl
:
string
;
...
@@ -12,8 +7,6 @@ interface CustomizedProfile {
...
@@ -12,8 +7,6 @@ interface CustomizedProfile {
}
}
interface
SystemStatus
{
interface
SystemStatus
{
host
?:
User
;
profile
:
Profile
;
// System settings
// System settings
disablePasswordLogin
:
boolean
;
disablePasswordLogin
:
boolean
;
disablePublicMemos
:
boolean
;
disablePublicMemos
:
boolean
;
...
...
web/src/types/modules/user.d.ts
deleted
100644 → 0
View file @
1d83c68c
type
UserRole
=
"HOST"
|
"USER"
;
interface
User
{
id
:
number
;
createdTs
:
number
;
updatedTs
:
number
;
username
:
string
;
role
:
UserRole
;
email
:
string
;
nickname
:
string
;
avatarUrl
:
string
;
}
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