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
b366ce75
Unverified
Commit
b366ce75
authored
Feb 10, 2023
by
boojack
Committed by
GitHub
Feb 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: delete tag (#1062)
parent
1eacf536
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
tag.go
api/tag.go
+1
-1
tag.go
server/tag.go
+10
-13
api.ts
web/src/helpers/api.ts
+3
-1
No files found.
api/tag.go
View file @
b366ce75
...
...
@@ -15,6 +15,6 @@ type TagFind struct {
}
type
TagDelete
struct
{
Name
string
Name
string
`json:"name"`
CreatorID
int
}
server/tag.go
View file @
b366ce75
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"regexp"
"sort"
...
...
@@ -127,29 +126,27 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
return
nil
})
g
.
DELETE
(
"/tag/:tagNam
e"
,
func
(
c
echo
.
Context
)
error
{
g
.
POST
(
"/tag/delet
e"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
userID
,
ok
:=
c
.
Get
(
getUserIDContextKey
())
.
(
int
)
if
!
ok
{
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Missing user in session"
)
}
tagName
,
err
:=
url
.
QueryUnescape
(
c
.
Param
(
"tagName"
))
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Invalid tag name"
)
.
SetInternal
(
err
)
}
else
if
tagName
==
""
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Tag name cannot be empty"
)
tagDelete
:=
&
api
.
TagDelete
{}
if
err
:=
json
.
NewDecoder
(
c
.
Request
()
.
Body
)
.
Decode
(
tagDelete
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Malformatted post tag request"
)
.
SetInternal
(
err
)
}
tagDelete
:=
&
api
.
TagDelete
{
Name
:
tagName
,
CreatorID
:
userID
,
if
tagDelete
.
Name
==
""
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Tag name shouldn't be empty"
)
}
tagDelete
.
CreatorID
=
userID
if
err
:=
s
.
Store
.
DeleteTag
(
ctx
,
tagDelete
);
err
!=
nil
{
if
common
.
ErrorCode
(
err
)
==
common
.
NotFound
{
return
echo
.
NewHTTPError
(
http
.
StatusNotFound
,
fmt
.
Sprintf
(
"Tag name not found: %s"
,
tagName
))
return
echo
.
NewHTTPError
(
http
.
StatusNotFound
,
fmt
.
Sprintf
(
"Tag name not found: %s"
,
tag
Delete
.
Name
))
}
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"Failed to delete tag name: %v"
,
tagName
))
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"Failed to delete tag name: %v"
,
tag
Delete
.
Name
))
.
SetInternal
(
err
)
}
return
c
.
JSON
(
http
.
StatusOK
,
true
)
...
...
web/src/helpers/api.ts
View file @
b366ce75
...
...
@@ -202,7 +202,9 @@ export function upsertTag(tagName: string) {
}
export
function
deleteTag
(
tagName
:
string
)
{
return
axios
.
delete
<
ResponseObject
<
string
>>
(
`/api/tag/
${
encodeURIComponent
(
tagName
)}
`
);
return
axios
.
post
<
ResponseObject
<
boolean
>>
(
`/api/tag/delete`
,
{
name
:
tagName
,
});
}
export
async
function
getRepoStarCount
()
{
...
...
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