Skip to content

Commit c189964

Browse files
committed
linters
1 parent 6693437 commit c189964

File tree

16 files changed

+128
-116
lines changed

16 files changed

+128
-116
lines changed

models/issues/weight.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
14
package issues
25

36
import (

modules/structs/issue.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type CreateIssueOption struct {
9999
// list of label ids
100100
Labels []int64 `json:"labels"`
101101
Closed bool `json:"closed"`
102-
Weight int `json:"weight`
102+
Weight int `json:"weight"`
103103
}
104104

105105
// EditIssueOption options for editing an issue

routers/web/repo/issue.go

-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
272272
return
273273
}
274274

275-
fmt.Println(totalWeight, totalWeightClosed)
276275
ctx.Data["TotalWeight"] = totalWeight
277276
ctx.Data["WeightedCompleteness"] = totalWeightClosed * 100 / totalWeight
278277
}

services/issue/issue.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
activities_model "code.gitea.io/gitea/models/activities"
1111
"code.gitea.io/gitea/models/db"
12-
issue_model "code.gitea.io/gitea/models/issues"
1312
issues_model "code.gitea.io/gitea/models/issues"
1413
access_model "code.gitea.io/gitea/models/perm/access"
1514
project_model "code.gitea.io/gitea/models/project"
@@ -49,7 +48,7 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_mo
4948
}
5049

5150
if weight != 0 {
52-
if _, err := issue_model.CreateWeightComment(ctx, issue.Poster, issue, weight); err != nil {
51+
if _, err := issues_model.CreateWeightComment(ctx, issue.Poster, issue, weight); err != nil {
5352
return err
5453
}
5554
}
@@ -132,11 +131,7 @@ func ChangeIssueWeight(ctx context.Context, issue *issues_model.Issue, doer *use
132131
return nil
133132
}
134133

135-
if err := issues_model.UpdateIssueWeight(ctx, issue, weight, doer); err != nil {
136-
return err
137-
}
138-
139-
return nil
134+
return issues_model.UpdateIssueWeight(ctx, issue, weight, doer)
140135
}
141136

142137
// UpdateAssignees is a helper function to add or delete one or multiple issue assignee(s)

templates/projects/view.tmpl

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@
145145
<div class="project-column"{{if .Color}} style="background: {{.Color}} !important; color: {{ContrastColor .Color}} !important"{{end}} data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.Link}}/{{.ID}}">
146146
<div class="project-column-header{{if $canWriteProject}} tw-cursor-grab{{end}}">
147147
<div class="ui circular label project-column-issue-count">
148-
{{len (index $.IssuesMap .ID)}}
148+
{{len (index $.IssuesMap .ID)}}
149149
</div>
150150
<div class="project-column-title-label gt-ellipsis">{{.Title}}</div>
151-
{{if $.IsWeightEnabled }}
152-
<div class="flex-text-block tw-hidden">
153-
{{svg "octicon-briefcase"}}
154-
<span class="project-column-weight"></span>
155-
</div>
156-
{{end}}
151+
{{if $.IsWeightEnabled}}
152+
<div class="flex-text-block tw-hidden">
153+
{{svg "octicon-briefcase"}}
154+
<span class="project-column-weight"></span>
155+
</div>
156+
{{end}}
157157
{{if $canWriteProject}}
158158
<div class="ui dropdown tw-p-1">
159159
{{svg "octicon-kebab-horizontal"}}

templates/repo/issue/card.tmpl

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
<span class="tw-align-middle">{{.GetTasksDone}} / {{$tasks}}</span>
6060
</div>
6161
{{end}}
62-
{{if .Repo.IsWeightEnabled ctx}}
63-
<div class="meta tw-my-1">
64-
{{svg "octicon-briefcase" 16 "tw-mr-1 tw-align-middle"}}
65-
<span class="tw-align-middle" data-weight={{.Weight}}>{{.Weight}}</span>
66-
</div>
67-
{{end}}
62+
{{if .Repo.IsWeightEnabled ctx}}
63+
<div class="meta tw-my-1">
64+
{{svg "octicon-briefcase" 16 "tw-mr-1 tw-align-middle"}}
65+
<span class="tw-align-middle" data-weight={{.Weight}}>{{.Weight}}</span>
66+
</div>
67+
{{end}}
6868
</div>
6969

7070
{{if or .Labels .Assignees}}

templates/repo/issue/milestone_issues.tmpl

+15-15
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
</div>
2828
{{end}}
2929
<div class="tw-flex tw-flex-col tw-gap-2">
30-
{{ $completeness := .Milestone.Completeness }}
31-
{{ if .Repository.IsWeightEnabled ctx }}
32-
{{ $completeness = .WeightedCompleteness }}
33-
{{ end }}
34-
<progress class="milestone-progress-big" value="{{$completeness}}" max="100"></progress>
30+
{{$completeness := .Milestone.Completeness}}
31+
{{if .Repository.IsWeightEnabled ctx}}
32+
{{$completeness = .WeightedCompleteness}}
33+
{{end}}
34+
<progress class="milestone-progress-big" value="{{$completeness}}" max="100"></progress>
3535
<div class="tw-flex tw-gap-4">
3636
<div classs="tw-flex tw-items-center">
3737
{{$closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix ctx.Locale}}
@@ -41,8 +41,8 @@
4141

4242
{{if .Milestone.DeadlineString}}
4343
<span{{if .IsOverdue}} class="text red"{{end}}>
44-
{{svg "octicon-calendar"}}
45-
{{DateTime "short" .Milestone.DeadlineString}}
44+
{{svg "octicon-calendar"}}
45+
{{DateTime "short" .Milestone.DeadlineString}}
4646
</span>
4747
{{else}}
4848
{{svg "octicon-calendar"}}
@@ -51,20 +51,20 @@
5151
{{end}}
5252
</div>
5353
<div class="tw-mr-2">
54-
{{ctx.Locale.Tr "repo.milestones.completeness" $completeness}}
55-
</div>
54+
{{ctx.Locale.Tr "repo.milestones.completeness" $completeness}}
55+
</div>
5656
{{if .TotalTrackedTime}}
5757
<div data-tooltip-content='{{ctx.Locale.Tr "tracked_time_summary"}}'>
5858
{{svg "octicon-clock"}}
5959
{{.TotalTrackedTime | Sec2Time}}
6060
</div>
6161
{{end}}
62-
{{if .TotalWeight}}
63-
<div class="flex-text-block" data-tooltip-content='{{ctx.Locale.Tr "weight_summary"}}'>
64-
{{svg "octicon-briefcase"}}
65-
{{.TotalWeight}}
66-
</div>
67-
{{end}}
62+
{{if .TotalWeight}}
63+
<div class="flex-text-block" data-tooltip-content='{{ctx.Locale.Tr "weight_summary"}}'>
64+
{{svg "octicon-briefcase"}}
65+
{{.TotalWeight}}
66+
</div>
67+
{{end}}
6868
</div>
6969
</div>
7070
<div class="divider"></div>

templates/repo/issue/milestones.tmpl

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
<div class="milestone-list">
1919
{{range .Milestones}}
2020
<li class="milestone-card">
21-
{{ $completeness := .Completeness }}
22-
{{ if $.Repository.IsWeightEnabled ctx }}
23-
{{ $completeness = .WeightedCompleteness }}
24-
{{ end }}
21+
{{$completeness := .Completeness}}
22+
{{if $.Repository.IsWeightEnabled ctx}}
23+
{{$completeness = .WeightedCompleteness}}
24+
{{end}}
2525
<div class="milestone-header">
2626
<h3 class="flex-text-block tw-m-0">
2727
{{svg "octicon-milestone" 16}}
2828
<a class="muted" href="{{$.RepoLink}}/milestone/{{.ID}}">{{.Name}}</a>
2929
</h3>
30-
<div class="tw-flex tw-items-center">
30+
<div class="tw-flex tw-items-center">
3131
<span class="tw-mr-2">{{$completeness}}%</span>
3232
<progress value="{{$completeness}}" max="100"></progress>
3333
</div>
@@ -48,7 +48,7 @@
4848
{{.TotalTrackedTime|Sec2Time}}
4949
</div>
5050
{{end}}
51-
{{if .TotalWeight}}
51+
{{if .TotalWeight}}
5252
<div class="flex-text-block">
5353
{{svg "octicon-briefcase"}}
5454
{{.TotalWeight}}

templates/repo/issue/new_form.tmpl

+9-9
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@
185185
</div>
186186
</div>
187187
{{end}}
188-
<div class="divider"></div>
189-
<div class="ui floating jump">
190-
<span class="text flex-text-block">
191-
<strong>Weight</strong>
192-
</span>
193-
</div>
194-
<div class="ui list">
195-
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issue_weight" type="number" value="{{.Issue.Weight}}" min="1" autocomplete="off">
196-
</div>
188+
<div class="divider"></div>
189+
<div class="ui floating jump">
190+
<span class="text flex-text-block">
191+
<strong>Weight</strong>
192+
</span>
193+
</div>
194+
<div class="ui list">
195+
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issue_weight" type="number" value="{{.Issue.Weight}}" min="1" autocomplete="off">
196+
</div>
197197
</div>
198198
<input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
199199
</form>

templates/repo/issue/view_content/comments.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{range .Issue.Comments}}
33
{{if call $.ShouldShowCommentType .Type}}
44
{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
5-
{{$isWeightEnabled:= $.Repository.IsWeightEnabled ctx}}
5+
{{$isWeightEnabled:= $.Repository.IsWeightEnabled ctx}}
66

77
<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF,
88
5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 8 = MILESTONE_CHANGE,
@@ -701,7 +701,7 @@
701701
{{else}}{{ctx.Locale.Tr "repo.issues.unpin_comment" $createdStr}}{{end}}
702702
</span>
703703
</div>
704-
{{else if and (eq .Type 38) ($isWeightEnabled)}}
704+
{{else if and (eq .Type 38) ($isWeightEnabled)}}
705705
<div class="timeline-item event" id="{{.HashTag}}">
706706
<span class="badge">{{svg "octicon-clock"}}</span>
707707
{{template "shared/user/avatarlink" dict "user" .Poster}}
@@ -710,13 +710,13 @@
710710
{{ctx.Locale.Tr "repo.issues.weight_added" .Content $createdStr}}
711711
</span>
712712
</div>
713-
{{else if and (eq .Type 39) ($isWeightEnabled)}}
713+
{{else if and (eq .Type 39) ($isWeightEnabled)}}
714714
<div class="timeline-item event" id="{{.HashTag}}">
715715
<span class="badge">{{svg "octicon-clock"}}</span>
716716
{{template "shared/user/avatarlink" dict "user" .Poster}}
717717
<span class="text grey muted-links">
718718
{{template "shared/user/authorlink" .Poster}}
719-
{{$splitWeight := StringUtils.Split .Content "|"}}
719+
{{$splitWeight := StringUtils.Split .Content "|"}}
720720
{{if eq (len $splitWeight) 2}}
721721
{{$to := (index $splitWeight 0)}}
722722
{{$from := (index $splitWeight 1)}}

templates/repo/issue/view_content/sidebar.tmpl

+33-37
Original file line numberDiff line numberDiff line change
@@ -257,47 +257,43 @@
257257
</div>
258258
</div>
259259

260+
{{if .Repository.IsWeightEnabled $.Context}}
261+
<div class="divider"></div>
262+
263+
<div class="ui floating jump">
264+
<a class="text muted flex-text-block issue-weight-edit">
265+
<strong>{{ctx.Locale.Tr "repo.issues.weight.title"}}</strong>
266+
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
267+
{{svg "octicon-pencil" 16 "tw-ml-1"}}
268+
{{end}}
269+
</a>
270+
</div>
260271

261-
{{if .Repository.IsWeightEnabled $.Context}}
262-
<div class="divider"></div>
263-
264-
<div class="ui floating jump">
265-
<a class="text muted flex-text-block issue-weight-edit">
266-
<strong>{{ctx.Locale.Tr "repo.issues.weight.title"}}</strong>
267-
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
268-
{{svg "octicon-pencil" 16 "tw-ml-1"}}
269-
{{end}}
270-
</a>
271-
</div>
272-
273-
<div class="ui list">
274-
{{if eq .Issue.Weight 0}}
275-
<span class="issue-weight-view item">{{ctx.Locale.Tr "repo.issues.weight.no_weight"}}</span>
276-
{{end}}
277-
278-
{{if gt .Issue.Weight 0}}
279-
<div class="tw-flex issue-weight-view">
280-
281-
<strong class="item">{{ .Issue.Weight }} -</strong>
282-
<form action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
283-
{{$.CsrfTokenHtml}}
284-
<input name="weight" type="hidden" value="0" autocomplete="off">
285-
<button class="tw-bg-transparent hover:tw-underline" style="color: var(--color-text)">
286-
{{ctx.Locale.Tr "repo.issues.weight.remove_weight"}}
287-
</button>
288-
</form>
289-
</div>
290-
{{end}}
291-
292-
<form class="ui tw-hidden fluid input issue-weight-form" action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
293-
{{$.CsrfTokenHtml}}
294-
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issueWeight" type="number" value="{{if gt .Issue.Weight 0}}{{.Issue.Weight}}{{end}}" min="0" autocomplete="off">
295-
</form>
296-
</div>
297-
{{end}}
272+
<div class="ui list">
273+
{{if eq .Issue.Weight 0}}
274+
<span class="issue-weight-view item">{{ctx.Locale.Tr "repo.issues.weight.no_weight"}}</span>
275+
{{end}}
298276

277+
{{if gt .Issue.Weight 0}}
278+
<div class="tw-flex issue-weight-view">
299279

280+
<strong class="item">{{.Issue.Weight}} -</strong>
281+
<form action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
282+
{{$.CsrfTokenHtml}}
283+
<input name="weight" type="hidden" value="0" autocomplete="off">
284+
<button class="tw-bg-transparent hover:tw-underline" style="color: var(--color-text)">
285+
{{ctx.Locale.Tr "repo.issues.weight.remove_weight"}}
286+
</button>
287+
</form>
288+
</div>
289+
{{end}}
300290

291+
<form class="ui tw-hidden fluid input issue-weight-form" action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
292+
{{$.CsrfTokenHtml}}
293+
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issueWeight" type="number" value="{{if gt .Issue.Weight 0}}{{.Issue.Weight}}{{end}}" min="0" autocomplete="off">
294+
</form>
295+
</div>
296+
{{end}}
301297

302298
<div class="divider"></div>
303299

templates/repo/settings/options.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
</div>
389389
</div>
390390
{{end}}
391-
{{if .Repository.CanEnableWeight}}
391+
{{if .Repository.CanEnableWeight}}
392392
<div class="field">
393393
<div class="ui checkbox">
394394
<input name="enable_issue_weight" class="enable-system" type="checkbox" {{if .Repository.IsWeightEnabled $.Context}}checked{{end}}>

templates/shared/issuelist.tmpl

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
</div>
2828
{{if or .TotalTrackedTime .Assignees .NumComments .Weight}}
2929
<div class="flex-item-trailing">
30-
{{if .TotalTrackedTime}}
31-
<div class="text grey flex-text-block">
32-
{{svg "octicon-clock" 16}}
33-
{{.TotalTrackedTime | Sec2Time}}
34-
</div>
30+
{{if .TotalTrackedTime}}
31+
<div class="text grey flex-text-block">
32+
{{svg "octicon-clock" 16}}
33+
{{.TotalTrackedTime | Sec2Time}}
34+
</div>
35+
{{end}}
36+
{{if .Repo.IsWeightEnabled ctx}}
37+
<div class="text grey flex-text-block">
38+
{{svg "octicon-briefcase" 16}}
39+
{{.Weight}}
40+
</div>
3541
{{end}}
36-
{{if .Repo.IsWeightEnabled ctx}}
37-
<div class="text grey flex-text-block">
38-
{{svg "octicon-briefcase" 16}}
39-
{{.Weight}}
40-
</div>
41-
{{end}}
4242
{{if .Assignees}}
4343
<div class="text grey">
4444
{{range .Assignees}}

0 commit comments

Comments
 (0)