Skip to content

Commit 2dc74ef

Browse files
authored
Merge branch 'main' into lunny/use_link_ui
2 parents 1ec019c + 8574a64 commit 2dc74ef

File tree

5 files changed

+65
-20
lines changed

5 files changed

+65
-20
lines changed

Diff for: models/db/search.go

+6
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ const (
2727
SearchOrderByForks SearchOrderBy = "num_forks ASC"
2828
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
2929
)
30+
31+
const (
32+
// Which means a condition to filter the records which don't match any id.
33+
// It's different from zero which means the condition could be ignored.
34+
NoneID = -1
35+
)

Diff for: models/issues/issue.go

+2
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,8 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
12511251
if opts.ProjectID > 0 {
12521252
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
12531253
And("project_issue.project_id=?", opts.ProjectID)
1254+
} else if opts.ProjectID == db.NoneID { // show those that are in no project
1255+
sess.And(builder.NotIn("issue.id", builder.Select("issue_id").From("project_issue")))
12541256
}
12551257

12561258
if opts.ProjectBoardID != 0 {

Diff for: options/locale/locale_en-US.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,8 @@ issues.filter_label_no_select = All labels
13061306
issues.filter_milestone = Milestone
13071307
issues.filter_milestone_no_select = All milestones
13081308
issues.filter_project = Project
1309-
issues.filter_project_no_select = All projects
1309+
issues.filter_project_all = All projects
1310+
issues.filter_project_none = No project
13101311
issues.filter_assignee = Assignee
13111312
issues.filter_assginee_no_select = All assignees
13121313
issues.filter_poster = Author

Diff for: routers/web/repo/issue.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
363363
return 0
364364
}
365365

366-
projects, _, err := project_model.FindProjects(ctx, project_model.SearchOptions{
367-
RepoID: repo.ID,
368-
Type: project_model.TypeRepository,
369-
IsClosed: util.OptionalBoolOf(isShowClosed),
370-
})
371-
if err != nil {
372-
ctx.ServerError("FindProjects", err)
366+
retrieveProjects(ctx, repo)
367+
if ctx.Written() {
373368
return
374369
}
375-
ctx.Data["Projects"] = projects
376370

377371
ctx.Data["IssueStats"] = issueStats
378372
ctx.Data["SelLabelIDs"] = labelIDs

Diff for: templates/repo/issue/list.tmpl

+53-11
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,41 @@
7575
</div>
7676

7777
<!-- Project -->
78-
<div class="ui {{if not .Projects}}disabled{{end}} dropdown jump item">
78+
<div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item">
7979
<span class="text">
80-
{{.locale.Tr "repo.issues.filter_project"}}
80+
{{.locale.Tr "repo.issues.filter_projects"}}
8181
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
8282
</span>
8383
<div class="menu">
8484
<div class="ui icon search input">
8585
<i class="icon df ac jc">{{svg "octicon-search" 16}}</i>
86-
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_project"}}">
86+
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_projects"}}">
8787
</div>
88-
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_project_no_select"}}</a>
89-
{{range .Projects}}
90-
<a class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.Title}}</a>
88+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_project_all"}}</a>
89+
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&project=-1&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_project_none"}}</a>
90+
{{if .OpenProjects}}
91+
<div class="divider"></div>
92+
<div class="header">
93+
{{.locale.Tr "repo.issues.new.open_projects"}}
94+
</div>
95+
{{range .OpenProjects}}
96+
<a class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
97+
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "mr-3"}}{{else}}{{svg "octicon-project" 18 "mr-3"}}{{end}}
98+
{{.Title}}
99+
</a>
100+
{{end}}
101+
{{end}}
102+
{{if .ClosedProjects}}
103+
<div class="divider"></div>
104+
<div class="header">
105+
{{.locale.Tr "repo.issues.new.closed_projects"}}
106+
</div>
107+
{{range .ClosedProjects}}
108+
<a class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}">
109+
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "mr-3"}}{{else}}{{svg "octicon-project" 18 "mr-3"}}{{end}}
110+
{{.Title}}
111+
</a>
112+
{{end}}
91113
{{end}}
92114
</div>
93115
</div>
@@ -222,18 +244,38 @@
222244
</div>
223245

224246
<!-- Projects -->
225-
<div class="ui {{if not .Projects}}disabled{{end}} dropdown jump item">
247+
<div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item">
226248
<span class="text">
227249
{{.locale.Tr "repo.project_board"}}
228250
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
229251
</span>
230252
<div class="menu">
231253
<div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/projects">
232-
{{.locale.Tr "repo.issues.new.no_projects"}}
254+
{{.locale.Tr "repo.issues.new.clear_projects"}}
233255
</div>
234-
{{range .Projects}}
235-
<div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects">
236-
{{.Title}}
256+
{{if .OpenProjects}}
257+
<div class="divider"></div>
258+
<div class="header">
259+
{{.locale.Tr "repo.issues.new.open_projects"}}
260+
</div>
261+
{{range .OpenProjects}}
262+
<div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects">
263+
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "mr-3"}}{{else}}{{svg "octicon-project" 18 "mr-3"}}{{end}}
264+
{{.Title}}
265+
</div>
266+
{{end}}
267+
{{end}}
268+
{{if .ClosedProjects}}
269+
<div class="divider"></div>
270+
<div class="header">
271+
{{.locale.Tr "repo.issues.new.closed_projects"}}
272+
</div>
273+
{{range .ClosedProjects}}
274+
<div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects">
275+
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "mr-3"}}{{else}}{{svg "octicon-project" 18 "mr-3"}}{{end}}
276+
{{.Title}}
277+
</div>
278+
{{end}}
237279
</div>
238280
{{end}}
239281
</div>

0 commit comments

Comments
 (0)