Skip to content

Commit d02e83a

Browse files
authored
Fix cancel button in the page of project edit not work (#23655)
Before, in project edit page, the cancel button is not work. https://user-images.githubusercontent.com/33891828/227182731-6478e29f-0e52-48c4-beb0-6a7d1dda6a1d.mov 1. The wrong classname `cancel` was added to the `<a>` tag. That classname caused the default click event of `<a>` tag to be cancelled. Because we have the following settings in the global. So I remove the classname `cancel`. https://github.com/go-gitea/gitea/blob/9be90a58754061171bbd5025d85d2b891364efd3/web_src/js/features/common-global.js#L325-L327 2. Another change is that page will redirect to the previous page. https://user-images.githubusercontent.com/33891828/227187326-c653c6d6-9715-440f-a732-ba0a6f012c81.mov
1 parent a9cceb0 commit d02e83a

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

routers/web/org/projects.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ func EditProject(ctx *context.Context) {
245245
return
246246
}
247247

248+
ctx.Data["projectID"] = p.ID
248249
ctx.Data["title"] = p.Title
249250
ctx.Data["content"] = p.Description
250251
ctx.Data["redirect"] = ctx.FormString("redirect")
252+
ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink()
251253

252254
ctx.HTML(http.StatusOK, tplProjectsNew)
253255
}

routers/web/repo/projects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func EditProject(ctx *context.Context) {
232232
return
233233
}
234234

235+
ctx.Data["projectID"] = p.ID
235236
ctx.Data["title"] = p.Title
236237
ctx.Data["content"] = p.Description
237238
ctx.Data["card_type"] = p.CardType

templates/projects/new.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<div class="ui divider"></div>
5151
<div class="ui left">
5252
{{if .PageIsEditProjects}}
53-
<a class="ui cancel button" href="{{.RepoLink}}/projects">
53+
<a class="ui cancel button" href="{{$.HomeLink}}/-/projects{{if eq .redirect "project"}}/{{.projectID}}{{end}}">
5454
{{.locale.Tr "repo.milestones.cancel"}}
5555
</a>
5656
<button class="ui primary button">

templates/repo/projects/new.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<div class="ui divider"></div>
7373
<div class="ui left">
7474
{{if .PageIsEditProjects}}
75-
<a class="ui cancel button" href="{{.RepoLink}}/projects">
75+
<a class="ui cancel button" href="{{.RepoLink}}/projects{{if eq .redirect "project"}}/{{.projectID}}{{end}}">
7676
{{.locale.Tr "repo.milestones.cancel"}}
7777
</a>
7878
<button class="ui primary button">

web_src/js/features/common-global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export function initGlobalButtons() {
322322
// There are many "cancel button" elements in modal dialogs, Fomantic UI expects they are button-like elements but never submit a form.
323323
// However, Gitea misuses the modal dialog and put the cancel buttons inside forms, so we must prevent the form submission.
324324
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content")
325-
$(document).on('click', 'form .ui.cancel.button', (e) => {
325+
$(document).on('click', 'form button.ui.cancel.button', (e) => {
326326
e.preventDefault();
327327
});
328328

0 commit comments

Comments
 (0)