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
fae0b64a
Unverified
Commit
fae0b64a
authored
Jan 14, 2023
by
boojack
Committed by
GitHub
Jan 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: delete tag api (#950)
* fix: delete tag api * chore: update
parent
677750ef
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
17 deletions
+20
-17
tag.go
server/tag.go
+5
-2
MemoResource.tsx
web/src/components/MemoResource.tsx
+2
-1
MemoResources.tsx
web/src/components/MemoResources.tsx
+3
-2
ResourcesDialog.tsx
web/src/components/ResourcesDialog.tsx
+4
-6
ResourcesSelectorDialog.tsx
web/src/components/ResourcesSelectorDialog.tsx
+2
-5
api.ts
web/src/helpers/api.ts
+1
-1
resource.ts
web/src/utils/resource.ts
+3
-0
No files found.
server/tag.go
View file @
fae0b64a
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"net/http"
"net/http"
"net/url"
"regexp"
"regexp"
"sort"
"sort"
...
@@ -133,8 +134,10 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
...
@@ -133,8 +134,10 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Missing user in session"
)
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"Missing user in session"
)
}
}
tagName
:=
c
.
Param
(
"tagName"
)
tagName
,
err
:=
url
.
QueryUnescape
(
c
.
Param
(
"tagName"
))
if
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"
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Tag name cannot be empty"
)
}
}
...
...
web/src/components/MemoResource.tsx
View file @
fae0b64a
import
{
getResourceUrl
}
from
"../utils/resource"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
interface
Props
{
interface
Props
{
...
@@ -7,7 +8,7 @@ interface Props {
...
@@ -7,7 +8,7 @@ interface Props {
const
MemoResource
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
MemoResource
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
className
,
resource
}
=
props
;
const
{
className
,
resource
}
=
props
;
const
resourceUrl
=
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
;
const
resourceUrl
=
getResourceUrl
(
resource
)
;
const
handlePreviewBtnClick
=
()
=>
{
const
handlePreviewBtnClick
=
()
=>
{
window
.
open
(
resourceUrl
);
window
.
open
(
resourceUrl
);
...
...
web/src/components/MemoResources.tsx
View file @
fae0b64a
import
{
absolutifyLink
}
from
"../helpers/utils"
;
import
{
absolutifyLink
}
from
"../helpers/utils"
;
import
{
getResourceUrl
}
from
"../utils/resource"
;
import
SquareDiv
from
"./common/SquareDiv"
;
import
SquareDiv
from
"./common/SquareDiv"
;
import
showPreviewImageDialog
from
"./PreviewImageDialog"
;
import
showPreviewImageDialog
from
"./PreviewImageDialog"
;
import
MemoResource
from
"./MemoResource"
;
import
MemoResource
from
"./MemoResource"
;
...
@@ -27,7 +28,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
...
@@ -27,7 +28,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
const
imgUrls
=
availableResourceList
const
imgUrls
=
availableResourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
))
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"image"
))
.
map
((
resource
)
=>
{
.
map
((
resource
)
=>
{
return
`/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
;
return
getResourceUrl
(
resource
)
;
});
});
const
handleImageClick
=
(
imgUrl
:
string
)
=>
{
const
handleImageClick
=
(
imgUrl
:
string
)
=>
{
...
@@ -41,7 +42,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
...
@@ -41,7 +42,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
{
availableResourceList
.
length
>
0
&&
(
{
availableResourceList
.
length
>
0
&&
(
<
div
className=
"images-wrapper"
>
<
div
className=
"images-wrapper"
>
{
availableResourceList
.
map
((
resource
)
=>
{
{
availableResourceList
.
map
((
resource
)
=>
{
const
url
=
`/o/r/${resource.id}/${resource.filename}`
;
const
url
=
getResourceUrl
(
resource
)
;
if
(
resource
.
type
.
startsWith
(
"image"
))
{
if
(
resource
.
type
.
startsWith
(
"image"
))
{
return
(
return
(
<
SquareDiv
key=
{
resource
.
id
}
className=
"memo-resource"
>
<
SquareDiv
key=
{
resource
.
id
}
className=
"memo-resource"
>
...
...
web/src/components/ResourcesDialog.tsx
View file @
fae0b64a
import
{
Tooltip
}
from
"@mui/joy"
;
import
{
Tooltip
}
from
"@mui/joy"
;
import
copy
from
"copy-to-clipboard"
;
import
copy
from
"copy-to-clipboard"
;
import
{
use
Callback
,
use
Effect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
useLoading
from
"../hooks/useLoading"
;
import
useLoading
from
"../hooks/useLoading"
;
import
{
useResourceStore
}
from
"../store/module"
;
import
{
useResourceStore
}
from
"../store/module"
;
import
{
getResourceUrl
}
from
"../utils/resource"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
import
toastHelper
from
"./Toast"
;
import
toastHelper
from
"./Toast"
;
import
Dropdown
from
"./common/Dropdown"
;
import
Dropdown
from
"./common/Dropdown"
;
...
@@ -83,10 +84,6 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -83,10 +84,6 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
inputEl
.
click
();
inputEl
.
click
();
};
};
const
getResourceUrl
=
useCallback
((
resource
:
Resource
)
=>
{
return
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
;
},
[]);
const
handlePreviewBtnClick
=
(
resource
:
Resource
)
=>
{
const
handlePreviewBtnClick
=
(
resource
:
Resource
)
=>
{
const
resourceUrl
=
getResourceUrl
(
resource
);
const
resourceUrl
=
getResourceUrl
(
resource
);
if
(
resource
.
type
.
startsWith
(
"image"
))
{
if
(
resource
.
type
.
startsWith
(
"image"
))
{
...
@@ -104,7 +101,8 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -104,7 +101,8 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
};
};
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
copy
(
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
);
const
url
=
getResourceUrl
(
resource
);
copy
(
url
);
toastHelper
.
success
(
t
(
"message.succeed-copy-resource-link"
));
toastHelper
.
success
(
t
(
"message.succeed-copy-resource-link"
));
};
};
...
...
web/src/components/ResourcesSelectorDialog.tsx
View file @
fae0b64a
import
{
Checkbox
,
Tooltip
}
from
"@mui/joy"
;
import
{
Checkbox
,
Tooltip
}
from
"@mui/joy"
;
import
{
use
Callback
,
use
Effect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
useLoading
from
"../hooks/useLoading"
;
import
useLoading
from
"../hooks/useLoading"
;
import
{
useEditorStore
,
useResourceStore
}
from
"../store/module"
;
import
{
useEditorStore
,
useResourceStore
}
from
"../store/module"
;
import
{
getResourceUrl
}
from
"../utils/resource"
;
import
Icon
from
"./Icon"
;
import
Icon
from
"./Icon"
;
import
toastHelper
from
"./Toast"
;
import
toastHelper
from
"./Toast"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
{
generateDialog
}
from
"./Dialog"
;
...
@@ -47,10 +48,6 @@ const ResourcesSelectorDialog: React.FC<Props> = (props: Props) => {
...
@@ -47,10 +48,6 @@ const ResourcesSelectorDialog: React.FC<Props> = (props: Props) => {
});
});
},
[
resources
]);
},
[
resources
]);
const
getResourceUrl
=
useCallback
((
resource
:
Resource
)
=>
{
return
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
;
},
[]);
const
handlePreviewBtnClick
=
(
resource
:
Resource
)
=>
{
const
handlePreviewBtnClick
=
(
resource
:
Resource
)
=>
{
const
resourceUrl
=
getResourceUrl
(
resource
);
const
resourceUrl
=
getResourceUrl
(
resource
);
if
(
resource
.
type
.
startsWith
(
"image"
))
{
if
(
resource
.
type
.
startsWith
(
"image"
))
{
...
...
web/src/helpers/api.ts
View file @
fae0b64a
...
@@ -198,7 +198,7 @@ export function upsertTag(tagName: string) {
...
@@ -198,7 +198,7 @@ export function upsertTag(tagName: string) {
}
}
export
function
deleteTag
(
tagName
:
string
)
{
export
function
deleteTag
(
tagName
:
string
)
{
return
axios
.
delete
<
ResponseObject
<
string
>>
(
`/api/tag/
${
tagName
}
`
);
return
axios
.
delete
<
ResponseObject
<
string
>>
(
`/api/tag/
${
encodeURI
(
tagName
)
}
`
);
}
}
export
async
function
getRepoStarCount
()
{
export
async
function
getRepoStarCount
()
{
...
...
web/src/utils/resource.ts
0 → 100644
View file @
fae0b64a
export
const
getResourceUrl
=
(
resource
:
Resource
,
withOrigin
=
true
)
=>
{
return
`
${
withOrigin
?
window
.
location
.
origin
:
""
}
/o/r/
${
resource
.
id
}
/
${
encodeURI
(
resource
.
filename
)}
`
;
};
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