Skip to content

Commit 8591c91

Browse files
GiteaBotyp05327
andauthored
Fix the display of project type for deleted projects (#31732) (#31734)
Backport #31732 by @yp05327 Fix: #31727 After: ![image](https://github.com/user-attachments/assets/1dfb4b31-3bd6-47f7-b126-650f33f453e2) Co-authored-by: yp05327 <[email protected]>
1 parent ec467c3 commit 8591c91

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

models/project/project.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ type Project struct {
109109
ClosedDateUnix timeutil.TimeStamp
110110
}
111111

112+
// Ghost Project is a project which has been deleted
113+
const GhostProjectID = -1
114+
115+
func (p *Project) IsGhost() bool {
116+
return p.ID == GhostProjectID
117+
}
118+
112119
func (p *Project) LoadOwner(ctx context.Context) (err error) {
113120
if p.Owner != nil {
114121
return nil

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,7 @@ variables.update.failed = Failed to edit variable.
36753675
variables.update.success = The variable has been edited.
36763676
36773677
[projects]
3678+
deleted.display_name = Deleted Project
36783679
type-1.display_name = Individual Project
36793680
type-2.display_name = Repository Project
36803681
type-3.display_name = Organization Project

routers/web/repo/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ func ViewIssue(ctx *context.Context) {
16691669
}
16701670

16711671
ghostProject := &project_model.Project{
1672-
ID: -1,
1672+
ID: project_model.GhostProjectID,
16731673
Title: ctx.Locale.TrString("repo.issues.deleted_project"),
16741674
}
16751675

templates/repo/issue/view_content/comments.tmpl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,19 @@
582582
{{template "shared/user/authorlink" .Poster}}
583583
{{$oldProjectDisplayHtml := "Unknown Project"}}
584584
{{if .OldProject}}
585-
{{$trKey := printf "projects.type-%d.display_name" .OldProject.Type}}
586-
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .OldProject.Title}}
585+
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
586+
{{if not .OldProject.IsGhost}}
587+
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type)}}
588+
{{end}}
589+
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .OldProject.Title}}
587590
{{end}}
588591
{{$newProjectDisplayHtml := "Unknown Project"}}
589592
{{if .Project}}
590-
{{$trKey := printf "projects.type-%d.display_name" .Project.Type}}
591-
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .Project.Title}}
593+
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
594+
{{if not .Project.IsGhost}}
595+
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .Project.Type)}}
596+
{{end}}
597+
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .Project.Title}}
592598
{{end}}
593599
{{if and (gt .OldProjectID 0) (gt .ProjectID 0)}}
594600
{{ctx.Locale.Tr "repo.issues.change_project_at" $oldProjectDisplayHtml $newProjectDisplayHtml $createdStr}}

0 commit comments

Comments
 (0)