Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the display of project type for deleted projects #31732

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions models/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ type Project struct {
ClosedDateUnix timeutil.TimeStamp
}

// Ghost Project is a project which has been deleted
const GhostProjectID = -1

func (p *Project) IsGhost() bool {
return p.ID == GhostProjectID
}

func (p *Project) LoadOwner(ctx context.Context) (err error) {
if p.Owner != nil {
return nil
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3705,6 +3705,7 @@ variables.update.failed = Failed to edit variable.
variables.update.success = The variable has been edited.

[projects]
deleted.display_name = Deleted Project
type-1.display_name = Individual Project
type-2.display_name = Repository Project
type-3.display_name = Organization Project
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ func ViewIssue(ctx *context.Context) {
}

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

Expand Down
14 changes: 10 additions & 4 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,19 @@
{{template "shared/user/authorlink" .Poster}}
{{$oldProjectDisplayHtml := "Unknown Project"}}
{{if .OldProject}}
{{$trKey := printf "projects.type-%d.display_name" .OldProject.Type}}
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .OldProject.Title}}
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
{{if not .OldProject.IsGhost}}
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type)}}
{{end}}
{{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .OldProject.Title}}
{{end}}
{{$newProjectDisplayHtml := "Unknown Project"}}
{{if .Project}}
{{$trKey := printf "projects.type-%d.display_name" .Project.Type}}
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr $trKey) .Project.Title}}
{{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}}
{{if not .Project.IsGhost}}
{{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .Project.Type)}}
{{end}}
{{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .Project.Title}}
{{end}}
{{if and (gt .OldProjectID 0) (gt .ProjectID 0)}}
{{ctx.Locale.Tr "repo.issues.change_project_at" $oldProjectDisplayHtml $newProjectDisplayHtml $createdStr}}
Expand Down