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
b9cbe662
Commit
b9cbe662
authored
Jan 26, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update tag rename
parent
56617178
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
11 deletions
+15
-11
resource.go
api/v1/resource.go
+1
-0
resource_service.go
api/v2/resource_service.go
+3
-0
tag_service.go
api/v2/tag_service.go
+1
-1
EmbeddedMemo.tsx
...c/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
+2
-2
RenameTagDialog.tsx
web/src/components/RenameTagDialog.tsx
+8
-8
No files found.
api/v1/resource.go
View file @
b9cbe662
...
@@ -233,6 +233,7 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
...
@@ -233,6 +233,7 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
}
}
metric
.
Enqueue
(
"resource create"
)
return
c
.
JSON
(
http
.
StatusOK
,
convertResourceFromStore
(
resource
))
return
c
.
JSON
(
http
.
StatusOK
,
convertResourceFromStore
(
resource
))
}
}
...
...
api/v2/resource_service.go
View file @
b9cbe662
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/timestamppb"
apiv2pb
"github.com/usememos/memos/proto/gen/api/v2"
apiv2pb
"github.com/usememos/memos/proto/gen/api/v2"
"github.com/usememos/memos/server/service/metric"
"github.com/usememos/memos/store"
"github.com/usememos/memos/store"
)
)
...
@@ -44,6 +45,8 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea
...
@@ -44,6 +45,8 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to create resource: %v"
,
err
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to create resource: %v"
,
err
)
}
}
metric
.
Enqueue
(
"resource create"
)
return
&
apiv2pb
.
CreateResourceResponse
{
return
&
apiv2pb
.
CreateResourceResponse
{
Resource
:
s
.
convertResourceFromStore
(
ctx
,
resource
),
Resource
:
s
.
convertResourceFromStore
(
ctx
,
resource
),
},
nil
},
nil
...
...
api/v2/tag_service.go
View file @
b9cbe662
...
@@ -104,7 +104,7 @@ func (s *APIV2Service) RenameTag(ctx context.Context, request *apiv2pb.RenameTag
...
@@ -104,7 +104,7 @@ func (s *APIV2Service) RenameTag(ctx context.Context, request *apiv2pb.RenameTag
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to parse memo: %v"
,
err
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to parse memo: %v"
,
err
)
}
}
traverseASTNodes
(
nodes
,
func
(
node
ast
.
Node
)
{
traverseASTNodes
(
nodes
,
func
(
node
ast
.
Node
)
{
if
tag
,
ok
:=
node
.
(
*
ast
.
Tag
);
ok
{
if
tag
,
ok
:=
node
.
(
*
ast
.
Tag
);
ok
&&
tag
.
Content
==
request
.
OldName
{
tag
.
Content
=
request
.
NewName
tag
.
Content
=
request
.
NewName
}
}
})
})
...
...
web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
View file @
b9cbe662
...
@@ -38,8 +38,8 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
...
@@ -38,8 +38,8 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
// Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
// Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
context
.
embeddedMemos
.
add
(
resourceName
);
context
.
embeddedMemos
.
add
(
resourceName
);
const
params
=
new
URLSearchParams
(
paramsStr
);
const
params
=
new
URLSearchParams
(
paramsStr
);
const
useI
nlineMode
=
params
.
has
(
"inline"
);
const
i
nlineMode
=
params
.
has
(
"inline"
);
if
(
useI
nlineMode
)
{
if
(
i
nlineMode
)
{
return
(
return
(
<
div
className=
"w-full"
>
<
div
className=
"w-full"
>
<
MemoContent
nodes=
{
memo
.
nodes
}
memoId=
{
memo
.
id
}
embeddedMemos=
{
context
.
embeddedMemos
}
/>
<
MemoContent
nodes=
{
memo
.
nodes
}
memoId=
{
memo
.
id
}
embeddedMemos=
{
context
.
embeddedMemos
}
/>
...
...
web/src/components/RenameTagDialog.tsx
View file @
b9cbe662
...
@@ -4,6 +4,7 @@ import { toast } from "react-hot-toast";
...
@@ -4,6 +4,7 @@ import { toast } from "react-hot-toast";
import
{
tagServiceClient
}
from
"@/grpcweb"
;
import
{
tagServiceClient
}
from
"@/grpcweb"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useLoading
from
"@/hooks/useLoading"
;
import
useLoading
from
"@/hooks/useLoading"
;
import
{
useFilterStore
}
from
"@/store/module"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
...
@@ -15,6 +16,7 @@ interface Props extends DialogProps {
...
@@ -15,6 +16,7 @@ interface Props extends DialogProps {
const
RenameTagDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
RenameTagDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
tag
,
destroy
}
=
props
;
const
{
tag
,
destroy
}
=
props
;
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
filterStore
=
useFilterStore
();
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
[
newName
,
setNewName
]
=
useState
(
tag
);
const
[
newName
,
setNewName
]
=
useState
(
tag
);
const
requestState
=
useLoading
(
false
);
const
requestState
=
useLoading
(
false
);
...
@@ -24,8 +26,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -24,8 +26,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
};
};
const
handleConfirm
=
async
()
=>
{
const
handleConfirm
=
async
()
=>
{
if
(
!
newName
)
{
if
(
!
newName
||
newName
.
includes
(
" "
)
)
{
toast
.
error
(
"
Please fill all required field
s"
);
toast
.
error
(
"
Tag name cannot be empty or contain space
s"
);
return
;
return
;
}
}
if
(
newName
===
tag
)
{
if
(
newName
===
tag
)
{
...
@@ -40,13 +42,12 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -40,13 +42,12 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
newName
:
newName
,
newName
:
newName
,
});
});
toast
.
success
(
"Rename tag successfully"
);
toast
.
success
(
"Rename tag successfully"
);
setTimeout
(()
=>
{
filterStore
.
setTagFilter
(
newName
);
window
.
location
.
reload
();
},
300
);
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
console
.
error
(
error
);
console
.
error
(
error
);
toast
.
error
(
error
.
details
);
toast
.
error
(
error
.
details
);
}
}
destroy
();
};
};
return
(
return
(
...
@@ -75,9 +76,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
...
@@ -75,9 +76,8 @@ const RenameTagDialog: React.FC<Props> = (props: Props) => {
/>
/>
</
div
>
</
div
>
<
List
className=
"!leading-5"
size=
"sm"
marker=
"disc"
>
<
List
className=
"!leading-5"
size=
"sm"
marker=
"disc"
>
<
ListItem
>
All memes with this tag will be updated.
</
ListItem
>
<
ListItem
>
All your memos with this tag will be updated.
</
ListItem
>
<
ListItem
>
If the amount of data is large, it will take longer and the server load will become higher.
</
ListItem
>
<
ListItem
>
If the number of related memos is large, it will take longer and the server load will become higher.
</
ListItem
>
<
ListItem
>
The page will be automatically refreshed when the task is completed
</
ListItem
>
</
List
>
</
List
>
</
div
>
</
div
>
<
div
className=
"w-full flex flex-row justify-end items-center mt-2 space-x-2"
>
<
div
className=
"w-full flex flex-row justify-end items-center mt-2 space-x-2"
>
...
...
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