Skip to content

Commit 75d0b61

Browse files
authored
Fix the display of project type for deleted projects (#31732)
Fix: #31727 After: ![image](https://github.com/user-attachments/assets/1dfb4b31-3bd6-47f7-b126-650f33f453e2)
1 parent 0a11bce commit 75d0b61

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
@@ -103,6 +103,13 @@ type Project struct {
103103
ClosedDateUnix timeutil.TimeStamp
104104
}
105105

106+
// Ghost Project is a project which has been deleted
107+
const GhostProjectID = -1
108+
109+
func (p *Project) IsGhost() bool {
110+
return p.ID == GhostProjectID
111+
}
112+
106113
func (p *Project) LoadOwner(ctx context.Context) (err error) {
107114
if p.Owner != nil {
108115
return nil

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,6 +3705,7 @@ variables.update.failed = Failed to edit variable.
37053705
variables.update.success = The variable has been edited.
37063706
37073707
[projects]
3708+
deleted.display_name = Deleted Project
37083709
type-1.display_name = Individual Project
37093710
type-2.display_name = Repository Project
37103711
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
@@ -1676,7 +1676,7 @@ func ViewIssue(ctx *context.Context) {
16761676
}
16771677

16781678
ghostProject := &project_model.Project{
1679-
ID: -1,
1679+
ID: project_model.GhostProjectID,
16801680
Title: ctx.Locale.TrString("repo.issues.deleted_project"),
16811681
}
16821682

templates/repo/issue/view_content/comments.tmpl

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

0 commit comments

Comments
 (0)