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

Add project type descriptions in issue badge and improve project icons #23437

Merged
merged 15 commits into from
Apr 21, 2023
Merged
13 changes: 13 additions & 0 deletions models/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/util"

"xorm.io/builder"
Expand Down Expand Up @@ -46,6 +47,18 @@ const (
TypeOrganization
)

func (p Type) DisplayName(locale translation.Locale) string {
switch p {
case TypeIndividual:
return locale.Tr("projects.type.individual.displayname")
case TypeRepository:
return locale.Tr("projects.type.repository.displayname")
case TypeOrganization:
return locale.Tr("projects.type.organization.displayname")
}
return fmt.Sprintf("Unknown Type %d", p)
}

// ErrProjectNotExist represents a "ProjectNotExist" kind of error.
type ErrProjectNotExist struct {
ID int64
Expand Down
11 changes: 8 additions & 3 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1320,11 +1320,11 @@ issues.remove_label = removed the %s label %s
issues.remove_labels = removed the %s labels %s
issues.add_remove_labels = added %s and removed %s labels %s
issues.add_milestone_at = `added this to the <b>%s</b> milestone %s`
issues.add_project_at = `added this to the <b>%s</b> project %s`
issues.add_project_at = `added this to the <span class="tooltip" data-content="%s"><b>%s</b></span> project %s`
issues.change_milestone_at = `modified the milestone from <b>%s</b> to <b>%s</b> %s`
issues.change_project_at = `modified the project from <b>%s</b> to <b>%s</b> %s`
issues.change_project_at = `modified the project from <span class="tooltip" data-content="%s"><b>%s</b></span> to <span class="tooltip" data-content="%s"><b>%s</b></span> %s`
issues.remove_milestone_at = `removed this from the <b>%s</b> milestone %s`
issues.remove_project_at = `removed this from the <b>%s</b> project %s`
issues.remove_project_at = `removed this from the <span class="tooltip" data-content="%s"><b>%s</b></span> project %s`
issues.deleted_milestone = `(deleted)`
issues.deleted_project = `(deleted)`
issues.self_assign_at = `self-assigned this %s`
Expand Down Expand Up @@ -3407,3 +3407,8 @@ runs.valid_workflow_helper = Workflow config file is valid.
runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s

need_approval_desc = Need approval to run workflows for fork pull request.

[projects]
type.individual.displayname = Individual Project
type.repository.displayname = Repository Project
type.organization.displayname = Organization Project
6 changes: 3 additions & 3 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,12 @@
{{template "shared/user/authorlink" .Poster}}
{{if gt .OldProjectID 0}}
{{if gt .ProjectID 0}}
{{$.locale.Tr "repo.issues.change_project_at" (.OldProject.Title|Escape) (.Project.Title|Escape) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.change_project_at" (.OldProject.Type.DisplayName $.locale) (.OldProject.Title|Escape) (.Project.Type.DisplayName $.locale) (.Project.Title|Escape) $createdStr | Safe}}
{{else}}
{{$.locale.Tr "repo.issues.remove_project_at" (.OldProject.Title|Escape) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.remove_project_at" (.OldProject.Type.DisplayName $.locale) (.OldProject.Title|Escape) $createdStr | Safe}}
{{end}}
{{else if gt .ProjectID 0}}
{{$.locale.Tr "repo.issues.add_project_at" (.Project.Title|Escape) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.add_project_at" (.Project.Type.DisplayName $.locale) (.Project.Title|Escape) $createdStr | Safe}}
{{end}}
</span>
</div>
Expand Down