Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
maantje committed Sep 19, 2024
1 parent 6693437 commit c189964
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 116 deletions.
3 changes: 3 additions & 0 deletions models/issues/weight.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package issues

import (
Expand Down
2 changes: 1 addition & 1 deletion modules/structs/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type CreateIssueOption struct {
// list of label ids
Labels []int64 `json:"labels"`
Closed bool `json:"closed"`
Weight int `json:"weight`
Weight int `json:"weight"`
}

// EditIssueOption options for editing an issue
Expand Down
1 change: 0 additions & 1 deletion routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
return
}

fmt.Println(totalWeight, totalWeightClosed)
ctx.Data["TotalWeight"] = totalWeight
ctx.Data["WeightedCompleteness"] = totalWeightClosed * 100 / totalWeight
}
Expand Down
9 changes: 2 additions & 7 deletions services/issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/db"
issue_model "code.gitea.io/gitea/models/issues"
issues_model "code.gitea.io/gitea/models/issues"
access_model "code.gitea.io/gitea/models/perm/access"
project_model "code.gitea.io/gitea/models/project"
Expand Down Expand Up @@ -49,7 +48,7 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_mo
}

if weight != 0 {
if _, err := issue_model.CreateWeightComment(ctx, issue.Poster, issue, weight); err != nil {
if _, err := issues_model.CreateWeightComment(ctx, issue.Poster, issue, weight); err != nil {
return err
}
}
Expand Down Expand Up @@ -132,11 +131,7 @@ func ChangeIssueWeight(ctx context.Context, issue *issues_model.Issue, doer *use
return nil
}

if err := issues_model.UpdateIssueWeight(ctx, issue, weight, doer); err != nil {
return err
}

return nil
return issues_model.UpdateIssueWeight(ctx, issue, weight, doer)
}

// UpdateAssignees is a helper function to add or delete one or multiple issue assignee(s)
Expand Down
14 changes: 7 additions & 7 deletions templates/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@
<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}}">
<div class="project-column-header{{if $canWriteProject}} tw-cursor-grab{{end}}">
<div class="ui circular label project-column-issue-count">
{{len (index $.IssuesMap .ID)}}
{{len (index $.IssuesMap .ID)}}
</div>
<div class="project-column-title-label gt-ellipsis">{{.Title}}</div>
{{if $.IsWeightEnabled }}
<div class="flex-text-block tw-hidden">
{{svg "octicon-briefcase"}}
<span class="project-column-weight"></span>
</div>
{{end}}
{{if $.IsWeightEnabled}}
<div class="flex-text-block tw-hidden">
{{svg "octicon-briefcase"}}
<span class="project-column-weight"></span>
</div>
{{end}}
{{if $canWriteProject}}
<div class="ui dropdown tw-p-1">
{{svg "octicon-kebab-horizontal"}}
Expand Down
12 changes: 6 additions & 6 deletions templates/repo/issue/card.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
<span class="tw-align-middle">{{.GetTasksDone}} / {{$tasks}}</span>
</div>
{{end}}
{{if .Repo.IsWeightEnabled ctx}}
<div class="meta tw-my-1">
{{svg "octicon-briefcase" 16 "tw-mr-1 tw-align-middle"}}
<span class="tw-align-middle" data-weight={{.Weight}}>{{.Weight}}</span>
</div>
{{end}}
{{if .Repo.IsWeightEnabled ctx}}
<div class="meta tw-my-1">
{{svg "octicon-briefcase" 16 "tw-mr-1 tw-align-middle"}}
<span class="tw-align-middle" data-weight={{.Weight}}>{{.Weight}}</span>
</div>
{{end}}
</div>

{{if or .Labels .Assignees}}
Expand Down
30 changes: 15 additions & 15 deletions templates/repo/issue/milestone_issues.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
</div>
{{end}}
<div class="tw-flex tw-flex-col tw-gap-2">
{{ $completeness := .Milestone.Completeness }}
{{ if .Repository.IsWeightEnabled ctx }}
{{ $completeness = .WeightedCompleteness }}
{{ end }}
<progress class="milestone-progress-big" value="{{$completeness}}" max="100"></progress>
{{$completeness := .Milestone.Completeness}}
{{if .Repository.IsWeightEnabled ctx}}
{{$completeness = .WeightedCompleteness}}
{{end}}
<progress class="milestone-progress-big" value="{{$completeness}}" max="100"></progress>
<div class="tw-flex tw-gap-4">
<div classs="tw-flex tw-items-center">
{{$closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix ctx.Locale}}
Expand All @@ -41,8 +41,8 @@

{{if .Milestone.DeadlineString}}
<span{{if .IsOverdue}} class="text red"{{end}}>
{{svg "octicon-calendar"}}
{{DateTime "short" .Milestone.DeadlineString}}
{{svg "octicon-calendar"}}
{{DateTime "short" .Milestone.DeadlineString}}
</span>
{{else}}
{{svg "octicon-calendar"}}
Expand All @@ -51,20 +51,20 @@
{{end}}
</div>
<div class="tw-mr-2">
{{ctx.Locale.Tr "repo.milestones.completeness" $completeness}}
</div>
{{ctx.Locale.Tr "repo.milestones.completeness" $completeness}}
</div>
{{if .TotalTrackedTime}}
<div data-tooltip-content='{{ctx.Locale.Tr "tracked_time_summary"}}'>
{{svg "octicon-clock"}}
{{.TotalTrackedTime | Sec2Time}}
</div>
{{end}}
{{if .TotalWeight}}
<div class="flex-text-block" data-tooltip-content='{{ctx.Locale.Tr "weight_summary"}}'>
{{svg "octicon-briefcase"}}
{{.TotalWeight}}
</div>
{{end}}
{{if .TotalWeight}}
<div class="flex-text-block" data-tooltip-content='{{ctx.Locale.Tr "weight_summary"}}'>
{{svg "octicon-briefcase"}}
{{.TotalWeight}}
</div>
{{end}}
</div>
</div>
<div class="divider"></div>
Expand Down
12 changes: 6 additions & 6 deletions templates/repo/issue/milestones.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
<div class="milestone-list">
{{range .Milestones}}
<li class="milestone-card">
{{ $completeness := .Completeness }}
{{ if $.Repository.IsWeightEnabled ctx }}
{{ $completeness = .WeightedCompleteness }}
{{ end }}
{{$completeness := .Completeness}}
{{if $.Repository.IsWeightEnabled ctx}}
{{$completeness = .WeightedCompleteness}}
{{end}}
<div class="milestone-header">
<h3 class="flex-text-block tw-m-0">
{{svg "octicon-milestone" 16}}
<a class="muted" href="{{$.RepoLink}}/milestone/{{.ID}}">{{.Name}}</a>
</h3>
<div class="tw-flex tw-items-center">
<div class="tw-flex tw-items-center">
<span class="tw-mr-2">{{$completeness}}%</span>
<progress value="{{$completeness}}" max="100"></progress>
</div>
Expand All @@ -48,7 +48,7 @@
{{.TotalTrackedTime|Sec2Time}}
</div>
{{end}}
{{if .TotalWeight}}
{{if .TotalWeight}}
<div class="flex-text-block">
{{svg "octicon-briefcase"}}
{{.TotalWeight}}
Expand Down
18 changes: 9 additions & 9 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@
</div>
</div>
{{end}}
<div class="divider"></div>
<div class="ui floating jump">
<span class="text flex-text-block">
<strong>Weight</strong>
</span>
</div>
<div class="ui list">
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issue_weight" type="number" value="{{.Issue.Weight}}" min="1" autocomplete="off">
</div>
<div class="divider"></div>
<div class="ui floating jump">
<span class="text flex-text-block">
<strong>Weight</strong>
</span>
</div>
<div class="ui list">
<input name="weight" {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} id="issue_weight" type="number" value="{{.Issue.Weight}}" min="1" autocomplete="off">
</div>
</div>
<input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
</form>
8 changes: 4 additions & 4 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{range .Issue.Comments}}
{{if call $.ShouldShowCommentType .Type}}
{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
{{$isWeightEnabled:= $.Repository.IsWeightEnabled ctx}}
{{$isWeightEnabled:= $.Repository.IsWeightEnabled ctx}}

<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF,
5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 8 = MILESTONE_CHANGE,
Expand Down Expand Up @@ -701,7 +701,7 @@
{{else}}{{ctx.Locale.Tr "repo.issues.unpin_comment" $createdStr}}{{end}}
</span>
</div>
{{else if and (eq .Type 38) ($isWeightEnabled)}}
{{else if and (eq .Type 38) ($isWeightEnabled)}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
{{template "shared/user/avatarlink" dict "user" .Poster}}
Expand All @@ -710,13 +710,13 @@
{{ctx.Locale.Tr "repo.issues.weight_added" .Content $createdStr}}
</span>
</div>
{{else if and (eq .Type 39) ($isWeightEnabled)}}
{{else if and (eq .Type 39) ($isWeightEnabled)}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
{{template "shared/user/avatarlink" dict "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$splitWeight := StringUtils.Split .Content "|"}}
{{$splitWeight := StringUtils.Split .Content "|"}}
{{if eq (len $splitWeight) 2}}
{{$to := (index $splitWeight 0)}}
{{$from := (index $splitWeight 1)}}
Expand Down
70 changes: 33 additions & 37 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -257,47 +257,43 @@
</div>
</div>

{{if .Repository.IsWeightEnabled $.Context}}
<div class="divider"></div>

<div class="ui floating jump">
<a class="text muted flex-text-block issue-weight-edit">
<strong>{{ctx.Locale.Tr "repo.issues.weight.title"}}</strong>
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
{{svg "octicon-pencil" 16 "tw-ml-1"}}
{{end}}
</a>
</div>

{{if .Repository.IsWeightEnabled $.Context}}
<div class="divider"></div>

<div class="ui floating jump">
<a class="text muted flex-text-block issue-weight-edit">
<strong>{{ctx.Locale.Tr "repo.issues.weight.title"}}</strong>
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
{{svg "octicon-pencil" 16 "tw-ml-1"}}
{{end}}
</a>
</div>

<div class="ui list">
{{if eq .Issue.Weight 0}}
<span class="issue-weight-view item">{{ctx.Locale.Tr "repo.issues.weight.no_weight"}}</span>
{{end}}

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

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

<form class="ui tw-hidden fluid input issue-weight-form" action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
{{$.CsrfTokenHtml}}
<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">
</form>
</div>
{{end}}
<div class="ui list">
{{if eq .Issue.Weight 0}}
<span class="issue-weight-view item">{{ctx.Locale.Tr "repo.issues.weight.no_weight"}}</span>
{{end}}

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

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

<form class="ui tw-hidden fluid input issue-weight-form" action="{{.Issue.Link}}/weight" method="post" id="update-issue-weight-form">
{{$.CsrfTokenHtml}}
<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">
</form>
</div>
{{end}}

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

Expand Down
2 changes: 1 addition & 1 deletion templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
</div>
</div>
{{end}}
{{if .Repository.CanEnableWeight}}
{{if .Repository.CanEnableWeight}}
<div class="field">
<div class="ui checkbox">
<input name="enable_issue_weight" class="enable-system" type="checkbox" {{if .Repository.IsWeightEnabled $.Context}}checked{{end}}>
Expand Down
22 changes: 11 additions & 11 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
</div>
{{if or .TotalTrackedTime .Assignees .NumComments .Weight}}
<div class="flex-item-trailing">
{{if .TotalTrackedTime}}
<div class="text grey flex-text-block">
{{svg "octicon-clock" 16}}
{{.TotalTrackedTime | Sec2Time}}
</div>
{{if .TotalTrackedTime}}
<div class="text grey flex-text-block">
{{svg "octicon-clock" 16}}
{{.TotalTrackedTime | Sec2Time}}
</div>
{{end}}
{{if .Repo.IsWeightEnabled ctx}}
<div class="text grey flex-text-block">
{{svg "octicon-briefcase" 16}}
{{.Weight}}
</div>
{{end}}
{{if .Repo.IsWeightEnabled ctx}}
<div class="text grey flex-text-block">
{{svg "octicon-briefcase" 16}}
{{.Weight}}
</div>
{{end}}
{{if .Assignees}}
<div class="text grey">
{{range .Assignees}}
Expand Down
Loading

0 comments on commit c189964

Please sign in to comment.