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
97d12db3
Commit
97d12db3
authored
Feb 01, 2025
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: renovate create memo
parent
98aa0b73
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
451 additions
and
433 deletions
+451
-433
memo_service.proto
proto/api/v1/memo_service.proto
+8
-12
memo_service.pb.go
proto/gen/api/v1/memo_service.pb.go
+301
-347
memo_service.pb.gw.go
proto/gen/api/v1/memo_service.pb.gw.go
+2
-2
apidocs.swagger.yaml
proto/gen/apidocs.swagger.yaml
+124
-58
memo_service.go
server/router/api/v1/memo_service.go
+9
-9
index.tsx
web/src/components/MemoEditor/index.tsx
+7
-5
No files found.
proto/api/v1/memo_service.proto
View file @
97d12db3
...
@@ -21,7 +21,7 @@ service MemoService {
...
@@ -21,7 +21,7 @@ service MemoService {
rpc
CreateMemo
(
CreateMemoRequest
)
returns
(
Memo
)
{
rpc
CreateMemo
(
CreateMemoRequest
)
returns
(
Memo
)
{
option
(
google.api.http
)
=
{
option
(
google.api.http
)
=
{
post
:
"/api/v1/memos"
post
:
"/api/v1/memos"
body
:
"
*
"
body
:
"
memo
"
};
};
}
}
// ListMemos lists memos with pagination and filter.
// ListMemos lists memos with pagination and filter.
...
@@ -185,15 +185,8 @@ message Location {
...
@@ -185,15 +185,8 @@ message Location {
}
}
message
CreateMemoRequest
{
message
CreateMemoRequest
{
string
content
=
1
;
// The memo to create.
Memo
memo
=
1
[(
google.api.field_behavior
)
=
REQUIRED
];
Visibility
visibility
=
2
;
repeated
Resource
resources
=
3
;
repeated
MemoRelation
relations
=
4
;
optional
Location
location
=
5
;
}
}
message
ListMemosRequest
{
message
ListMemosRequest
{
...
@@ -223,7 +216,9 @@ message GetMemoRequest {
...
@@ -223,7 +216,9 @@ message GetMemoRequest {
}
}
message
UpdateMemoRequest
{
message
UpdateMemoRequest
{
Memo
memo
=
1
;
// The memo to update.
// The `name` field is required.
Memo
memo
=
1
[(
google.api.field_behavior
)
=
REQUIRED
];
google.protobuf.FieldMask
update_mask
=
2
;
google.protobuf.FieldMask
update_mask
=
2
;
}
}
...
@@ -285,7 +280,8 @@ message CreateMemoCommentRequest {
...
@@ -285,7 +280,8 @@ message CreateMemoCommentRequest {
// The name of the memo.
// The name of the memo.
string
name
=
1
;
string
name
=
1
;
CreateMemoRequest
comment
=
2
;
// The comment to create.
Memo
comment
=
2
;
}
}
message
ListMemoCommentsRequest
{
message
ListMemoCommentsRequest
{
...
...
proto/gen/api/v1/memo_service.pb.go
View file @
97d12db3
This diff is collapsed.
Click to expand it.
proto/gen/api/v1/memo_service.pb.gw.go
View file @
97d12db3
...
@@ -40,7 +40,7 @@ func request_MemoService_CreateMemo_0(ctx context.Context, marshaler runtime.Mar
...
@@ -40,7 +40,7 @@ func request_MemoService_CreateMemo_0(ctx context.Context, marshaler runtime.Mar
protoReq
CreateMemoRequest
protoReq
CreateMemoRequest
metadata
runtime
.
ServerMetadata
metadata
runtime
.
ServerMetadata
)
)
if
err
:=
marshaler
.
NewDecoder
(
req
.
Body
)
.
Decode
(
&
protoReq
);
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
if
err
:=
marshaler
.
NewDecoder
(
req
.
Body
)
.
Decode
(
&
protoReq
.
Memo
);
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
msg
,
err
:=
client
.
CreateMemo
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
msg
,
err
:=
client
.
CreateMemo
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
...
@@ -52,7 +52,7 @@ func local_request_MemoService_CreateMemo_0(ctx context.Context, marshaler runti
...
@@ -52,7 +52,7 @@ func local_request_MemoService_CreateMemo_0(ctx context.Context, marshaler runti
protoReq
CreateMemoRequest
protoReq
CreateMemoRequest
metadata
runtime
.
ServerMetadata
metadata
runtime
.
ServerMetadata
)
)
if
err
:=
marshaler
.
NewDecoder
(
req
.
Body
)
.
Decode
(
&
protoReq
);
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
if
err
:=
marshaler
.
NewDecoder
(
req
.
Body
)
.
Decode
(
&
protoReq
.
Memo
);
err
!=
nil
&&
!
errors
.
Is
(
err
,
io
.
EOF
)
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"%v"
,
err
)
}
}
msg
,
err
:=
server
.
CreateMemo
(
ctx
,
&
protoReq
)
msg
,
err
:=
server
.
CreateMemo
(
ctx
,
&
protoReq
)
...
...
proto/gen/apidocs.swagger.yaml
View file @
97d12db3
This diff is collapsed.
Click to expand it.
server/router/api/v1/memo_service.go
View file @
97d12db3
...
@@ -35,8 +35,8 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
...
@@ -35,8 +35,8 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
create
:=
&
store
.
Memo
{
create
:=
&
store
.
Memo
{
UID
:
shortuuid
.
New
(),
UID
:
shortuuid
.
New
(),
CreatorID
:
user
.
ID
,
CreatorID
:
user
.
ID
,
Content
:
request
.
Content
,
Content
:
request
.
Memo
.
Content
,
Visibility
:
convertVisibilityToStore
(
request
.
Visibility
),
Visibility
:
convertVisibilityToStore
(
request
.
Memo
.
Visibility
),
}
}
workspaceMemoRelatedSetting
,
err
:=
s
.
Store
.
GetWorkspaceMemoRelatedSetting
(
ctx
)
workspaceMemoRelatedSetting
,
err
:=
s
.
Store
.
GetWorkspaceMemoRelatedSetting
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -55,27 +55,27 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
...
@@ -55,27 +55,27 @@ func (s *APIV1Service) CreateMemo(ctx context.Context, request *v1pb.CreateMemoR
if
err
:=
memopayload
.
RebuildMemoPayload
(
create
);
err
!=
nil
{
if
err
:=
memopayload
.
RebuildMemoPayload
(
create
);
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to rebuild memo payload: %v"
,
err
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to rebuild memo payload: %v"
,
err
)
}
}
if
request
.
Location
!=
nil
{
if
request
.
Memo
.
Location
!=
nil
{
create
.
Payload
.
Location
=
convertLocationToStore
(
request
.
Location
)
create
.
Payload
.
Location
=
convertLocationToStore
(
request
.
Memo
.
Location
)
}
}
memo
,
err
:=
s
.
Store
.
CreateMemo
(
ctx
,
create
)
memo
,
err
:=
s
.
Store
.
CreateMemo
(
ctx
,
create
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
request
.
Resources
)
>
0
{
if
len
(
request
.
Memo
.
Resources
)
>
0
{
_
,
err
:=
s
.
SetMemoResources
(
ctx
,
&
v1pb
.
SetMemoResourcesRequest
{
_
,
err
:=
s
.
SetMemoResources
(
ctx
,
&
v1pb
.
SetMemoResourcesRequest
{
Name
:
fmt
.
Sprintf
(
"%s%s"
,
MemoNamePrefix
,
memo
.
UID
),
Name
:
fmt
.
Sprintf
(
"%s%s"
,
MemoNamePrefix
,
memo
.
UID
),
Resources
:
request
.
Resources
,
Resources
:
request
.
Memo
.
Resources
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to set memo resources"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to set memo resources"
)
}
}
}
}
if
len
(
request
.
Relations
)
>
0
{
if
len
(
request
.
Memo
.
Relations
)
>
0
{
_
,
err
:=
s
.
SetMemoRelations
(
ctx
,
&
v1pb
.
SetMemoRelationsRequest
{
_
,
err
:=
s
.
SetMemoRelations
(
ctx
,
&
v1pb
.
SetMemoRelationsRequest
{
Name
:
fmt
.
Sprintf
(
"%s%s"
,
MemoNamePrefix
,
memo
.
UID
),
Name
:
fmt
.
Sprintf
(
"%s%s"
,
MemoNamePrefix
,
memo
.
UID
),
Relations
:
request
.
Relations
,
Relations
:
request
.
Memo
.
Relations
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to set memo relations"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to set memo relations"
)
...
@@ -390,7 +390,7 @@ func (s *APIV1Service) CreateMemoComment(ctx context.Context, request *v1pb.Crea
...
@@ -390,7 +390,7 @@ func (s *APIV1Service) CreateMemoComment(ctx context.Context, request *v1pb.Crea
}
}
// Create the memo comment first.
// Create the memo comment first.
memoComment
,
err
:=
s
.
CreateMemo
(
ctx
,
request
.
Comment
)
memoComment
,
err
:=
s
.
CreateMemo
(
ctx
,
&
v1pb
.
CreateMemoRequest
{
Memo
:
request
.
Comment
}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to create memo"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to create memo"
)
}
}
...
...
web/src/components/MemoEditor/index.tsx
View file @
97d12db3
...
@@ -350,11 +350,13 @@ const MemoEditor = (props: Props) => {
...
@@ -350,11 +350,13 @@ const MemoEditor = (props: Props) => {
// Create memo or memo comment.
// Create memo or memo comment.
const
request
=
!
parentMemoName
const
request
=
!
parentMemoName
?
memoStore
.
createMemo
({
?
memoStore
.
createMemo
({
content
,
memo
:
Memo
.
fromPartial
({
visibility
:
state
.
memoVisibility
,
content
,
resources
:
state
.
resourceList
,
visibility
:
state
.
memoVisibility
,
relations
:
state
.
relationList
,
resources
:
state
.
resourceList
,
location
:
state
.
location
,
relations
:
state
.
relationList
,
location
:
state
.
location
,
}),
})
})
:
memoServiceClient
:
memoServiceClient
.
createMemoComment
({
.
createMemoComment
({
...
...
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