Skip to content

Commit 7542db0

Browse files
committed
rename var
1 parent 67cbdad commit 7542db0

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

models/issues/comment.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,30 +182,31 @@ func (t CommentType) HasAttachmentSupport() bool {
182182
return false
183183
}
184184

185-
type Role string
185+
// RoleInRepo presents the user's participation in the repo
186+
type RoleInRepo string
186187

187-
// RoleDescriptor defines comment tag type
188+
// RoleDescriptor defines comment "role" tags
188189
type RoleDescriptor struct {
189-
IsPoster bool
190-
Role Role
190+
IsPoster bool
191+
RoleInRepo RoleInRepo
191192
}
192193

193194
// Enumerate all the role tags.
194195
const (
195-
RoleDescriptorOwner Role = "owner"
196-
RoleDescriptorMember Role = "member"
197-
RoleDescriptorCollaborator Role = "collaborator"
198-
RoleDescriptorFirstTimeContributor Role = "first_time_contributor"
199-
RoleDescriptorContributor Role = "contributor"
196+
RoleRepoOwner RoleInRepo = "owner"
197+
RoleRepoMember RoleInRepo = "member"
198+
RoleRepoCollaborator RoleInRepo = "collaborator"
199+
RoleRepoFirstTimeContributor RoleInRepo = "first_time_contributor"
200+
RoleRepoContributor RoleInRepo = "contributor"
200201
)
201202

202203
// LocaleString returns the locale string name of the Status
203-
func (r Role) LocaleString(lang translation.Locale) string {
204+
func (r RoleInRepo) LocaleString(lang translation.Locale) string {
204205
return lang.Tr("repo.issues.role." + string(r))
205206
}
206207

207208
// LocaleHelper returns the locale string name of the Status
208-
func (r Role) LocaleHelper(lang translation.Locale) string {
209+
func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
209210
return lang.Tr("repo.issues.role." + string(r) + "_helper")
210211
}
211212

routers/web/repo/issue.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ func NewIssuePost(ctx *context.Context) {
12281228
}
12291229
}
12301230

1231-
// roleDescriptor returns the Role Descriptor for a comment in/with the given repo, poster and issue
1231+
// roleDescriptor returns the role descriptor for a comment in/with the given repo, poster and issue
12321232
func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *user_model.User, issue *issues_model.Issue, hasOriginalAuthor bool) (issues_model.RoleDescriptor, error) {
12331233
roleDescriptor := issues_model.RoleDescriptor{}
12341234

@@ -1246,9 +1246,9 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
12461246

12471247
// Check if the poster is owner of the repo.
12481248
if perm.IsOwner() {
1249-
// If the poster isn't a admin, enable the owner role.
1249+
// If the poster isn't an admin, enable the owner role.
12501250
if !poster.IsAdmin {
1251-
roleDescriptor.Role = issues_model.RoleDescriptorOwner
1251+
roleDescriptor.RoleInRepo = issues_model.RoleRepoOwner
12521252
return roleDescriptor, nil
12531253
}
12541254

@@ -1258,7 +1258,7 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
12581258
return roleDescriptor, err
12591259
}
12601260
if ok {
1261-
roleDescriptor.Role = issues_model.RoleDescriptorOwner
1261+
roleDescriptor.RoleInRepo = issues_model.RoleRepoOwner
12621262
return roleDescriptor, nil
12631263
}
12641264
}
@@ -1271,7 +1271,7 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
12711271
if isMember, err := organization.IsOrganizationMember(ctx, repo.Owner.ID, poster.ID); err != nil {
12721272
return roleDescriptor, err
12731273
} else if isMember {
1274-
roleDescriptor.Role = issues_model.RoleDescriptorMember
1274+
roleDescriptor.RoleInRepo = issues_model.RoleRepoMember
12751275
return roleDescriptor, nil
12761276
}
12771277
}
@@ -1280,7 +1280,7 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
12801280
if isCollaborator, err := repo_model.IsCollaborator(ctx, repo.ID, poster.ID); err != nil {
12811281
return roleDescriptor, err
12821282
} else if isCollaborator {
1283-
roleDescriptor.Role = issues_model.RoleDescriptorCollaborator
1283+
roleDescriptor.RoleInRepo = issues_model.RoleRepoCollaborator
12841284
return roleDescriptor, nil
12851285
}
12861286

@@ -1298,10 +1298,10 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
12981298
if _, total, err := issue_indexer.SearchIssues(ctx, searchOpt); err != nil {
12991299
return roleDescriptor, err
13001300
} else if total > 0 {
1301-
roleDescriptor.Role = issues_model.RoleDescriptorContributor
1301+
roleDescriptor.RoleInRepo = issues_model.RoleRepoContributor
13021302
} else if total == 0 && issue.IsPull && !issue.IsClosed {
13031303
// only display first time contributor in the first opening pull request
1304-
roleDescriptor.Role = issues_model.RoleDescriptorFirstTimeContributor
1304+
roleDescriptor.RoleInRepo = issues_model.RoleRepoFirstTimeContributor
13051305
}
13061306

13071307
return roleDescriptor, nil

templates/repo/issue/view_content/show_role.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{{ctx.Locale.Tr "repo.issues.author"}}
44
</div>
55
{{end}}
6-
{{if .ShowRole.Role}}
7-
<div class="ui basic label role-label" data-tooltip-content="{{.ShowRole.Role.LocaleHelper ctx.Locale}}">
8-
{{.ShowRole.Role.LocaleString ctx.Locale}}
6+
{{if .ShowRole.RoleInRepo}}
7+
<div class="ui basic label role-label" data-tooltip-content="{{.ShowRole.RoleInRepo.LocaleHelper ctx.Locale}}">
8+
{{.ShowRole.RoleInRepo.LocaleString ctx.Locale}}
99
</div>
1010
{{end}}

0 commit comments

Comments
 (0)