From 1a4efa0ee9a49d48549be7479a46be133b9bc260 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Sun, 19 Mar 2023 21:44:48 +0900 Subject: Use `project.IconName` instead of repeated unreadable `if-else` chains (#23538) The project type will be changed in https://github.com/go-gitea/gitea/pull/23353, so the old fix https://github.com/go-gitea/gitea/pull/23325 will not work as well. And I also found that there were some problems in the old fix.... --------- Co-authored-by: Lauris BH --- models/project/project.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'models/project') diff --git a/models/project/project.go b/models/project/project.go index 679d695881..44609e60b2 100644 --- a/models/project/project.go +++ b/models/project/project.go @@ -144,10 +144,21 @@ func (p *Project) Link() string { return "" } +func (p *Project) IconName() string { + if p.IsRepositoryProject() { + return "octicon-project" + } + return "octicon-project-symlink" +} + func (p *Project) IsOrganizationProject() bool { return p.Type == TypeOrganization } +func (p *Project) IsRepositoryProject() bool { + return p.Type == TypeRepository +} + func init() { db.RegisterModel(new(Project)) } -- cgit v1.2.3