mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add the ability to pin Issues (#24406)
This adds the ability to pin important Issues and Pull Requests. You can also move pinned Issues around to change their Position. Resolves #2175. ## Screenshots    The Design was mostly copied from the Projects Board. ## Implementation This uses a new `pin_order` Column in the `issue` table. If the value is set to 0, the Issue is not pinned. If it's set to a bigger value, the value is the Position. 1 means it's the first pinned Issue, 2 means it's the second one etc. This is dived into Issues and Pull requests for each Repo. ## TODO - [x] You can currently pin as many Issues as you want. Maybe we should add a Limit, which is configurable. GitHub uses 3, but I prefer 6, as this is better for bigger Projects, but I'm open for suggestions. - [x] Pin and Unpin events need to be added to the Issue history. - [x] Tests - [x] Migration **The feature itself is currently fully working, so tester who may find weird edge cases are very welcome!** --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
@@ -2,6 +2,70 @@
|
||||
<div role="main" aria-label="{{.Title}}" class="page-content repository issue-list">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
|
||||
{{if .PinnedIssues}}
|
||||
<div id="issue-pins" {{if .IsRepoAdmin}}data-is-repo-admin{{end}}>
|
||||
{{range .PinnedIssues}}
|
||||
<div class="pinned-issue-card gt-word-break" data-move-url="{{$.Link}}/pin_move" data-issue-id="{{.ID}}">
|
||||
{{if eq $.Project.CardType 1}}
|
||||
<div class="card-attachment-images">
|
||||
{{range (index $.issuesAttachmentMap .ID)}}
|
||||
<img src="{{.DownloadURL}}" alt="{{.Name}}">
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="content gt-p-0">
|
||||
<div class="header gt-df gt-items-start">
|
||||
<div class="pinned-issue-icon">
|
||||
{{template "shared/issueicon" .}}
|
||||
</div>
|
||||
<a class="pinned-issue-title muted issue-title" href="{{.Link}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a>
|
||||
{{if $.IsRepoAdmin}}
|
||||
<a role="button" class="pinned-issue-unpin muted gt-df gt-ac" data-tooltip-content={{$.locale.Tr "repo.issues.unpin_issue"}} data-issue-id="{{.ID}}" data-unpin-url="{{$.Link}}/unpin/{{.ID}}">
|
||||
{{svg "octicon-x" 16}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="meta gt-my-2">
|
||||
<span class="text light grey">
|
||||
#{{.Index}}
|
||||
{{$timeStr := TimeSinceUnix .GetLastEventTimestamp $.locale}}
|
||||
{{if .OriginalAuthor}}
|
||||
{{$.locale.Tr .GetLastEventLabelFake $timeStr (.OriginalAuthor|Escape) | Safe}}
|
||||
{{else if gt .Poster.ID 0}}
|
||||
{{$.locale.Tr .GetLastEventLabel $timeStr (.Poster.HomeLink|Escape) (.Poster.GetDisplayName | Escape) | Safe}}
|
||||
{{else}}
|
||||
{{$.locale.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}}
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{- if .MilestoneID}}
|
||||
<div class="meta gt-my-2">
|
||||
<a class="milestone" href="{{$.RepoLink}}/milestone/{{.MilestoneID}}">
|
||||
{{svg "octicon-milestone" 16 "gt-mr-2 gt-vm"}}
|
||||
<span class="gt-vm">{{.Milestone.Name}}</span>
|
||||
</a>
|
||||
</div>
|
||||
{{- end}}
|
||||
</div>
|
||||
|
||||
{{if or .Labels .Assignees}}
|
||||
<div class="extra content labels-list gt-p-0 gt-pt-2">
|
||||
{{range .Labels}}
|
||||
<a href="{{$.RepoLink}}/issues?labels={{.ID}}">{{RenderLabel $.Context .}}</a>
|
||||
{{end}}
|
||||
<div class="right floated">
|
||||
{{range .Assignees}}
|
||||
<a href="{{.HomeLink}}" data-tooltip-content="{{$.locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{avatar $.Context . 28 "mini gt-mr-3"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="list-header">
|
||||
{{template "repo/issue/navbar" .}}
|
||||
{{template "repo/issue/search" .}}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST, 28 = MERGE_PULL_REQUEST,
|
||||
29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED
|
||||
32 = DISMISSED_REVIEW, 33 = COMMENT_TYPE_CHANGE_ISSUE_REF, 34 = PR_SCHEDULE_TO_AUTO_MERGE,
|
||||
35 = CANCEL_SCHEDULED_AUTO_MERGE_PR -->
|
||||
35 = CANCEL_SCHEDULED_AUTO_MERGE_PR, 36 = PIN_ISSUE, 37 = UNPIN_ISSUE -->
|
||||
{{if eq .Type 0}}
|
||||
<div class="timeline-item comment" id="{{.HashTag}}">
|
||||
{{if .OriginalAuthor}}
|
||||
@@ -835,6 +835,16 @@
|
||||
{{else}}{{$.locale.Tr "repo.pulls.auto_merge_canceled_schedule_comment" $createdStr | Safe}}{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{else if or (eq .Type 36) (eq .Type 37)}}
|
||||
<div class="timeline-item event" id="{{.HashTag}}">
|
||||
<span class="badge">{{svg "octicon-pin" 16}}</span>
|
||||
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
|
||||
<span class="text grey muted-links">
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{if eq .Type 36}}{{$.locale.Tr "repo.issues.pin_comment" $createdStr | Safe}}
|
||||
{{else}}{{$.locale.Tr "repo.issues.unpin_comment" $createdStr | Safe}}{{end}}
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
@@ -530,17 +530,31 @@
|
||||
|
||||
{{if and .IsRepoAdmin (not .Repository.IsArchived)}}
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui watching">
|
||||
<button class="fluid ui show-modal button {{if .Issue.IsLocked}} negative {{end}}" data-modal="#lock">
|
||||
{{if .Issue.IsLocked}}
|
||||
{{svg "octicon-key"}}
|
||||
{{.locale.Tr "repo.issues.unlock"}}
|
||||
{{else}}
|
||||
{{svg "octicon-lock"}}
|
||||
{{.locale.Tr "repo.issues.lock"}}
|
||||
{{end}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{{if or .PinEnabled .Issue.IsPinned}}
|
||||
<form class="gt-mt-2" method="POST" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{.locale.Tr "repo.issues.max_pinned"}}"{{end}}>
|
||||
{{$.CsrfTokenHtml}}
|
||||
<button class="fluid ui button gt-df gt-jc {{if not $.NewPinAllowed}}disabled{{end}}">
|
||||
{{if not .Issue.IsPinned}}
|
||||
{{svg "octicon-pin" 16 "gt-mr-3"}}
|
||||
{{.locale.Tr "pin"}}
|
||||
{{else}}
|
||||
{{svg "octicon-pin-slash" 16 "gt-mr-3"}}
|
||||
{{.locale.Tr "unpin"}}
|
||||
{{end}}
|
||||
</button>
|
||||
</form>
|
||||
{{end}}
|
||||
|
||||
<button class="gt-mt-2 fluid ui show-modal button {{if .Issue.IsLocked}} negative {{end}}" data-modal="#lock">
|
||||
{{if .Issue.IsLocked}}
|
||||
{{svg "octicon-key"}}
|
||||
{{.locale.Tr "repo.issues.unlock"}}
|
||||
{{else}}
|
||||
{{svg "octicon-lock"}}
|
||||
{{.locale.Tr "repo.issues.lock"}}
|
||||
{{end}}
|
||||
</button>
|
||||
<div class="ui tiny modal" id="lock">
|
||||
<div class="header">
|
||||
{{if .Issue.IsLocked}}
|
||||
@@ -605,7 +619,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<button class="fluid ui show-modal button negative gt-mt-3" data-modal="#delete">
|
||||
<button class="gt-mt-2 fluid ui show-modal button negative" data-modal="#delete">
|
||||
{{svg "octicon-trash"}}
|
||||
{{.locale.Tr "repo.issues.delete"}}
|
||||
</button>
|
||||
|
268
templates/swagger/v1_json.tmpl
generated
268
templates/swagger/v1_json.tmpl
generated
@@ -6191,6 +6191,39 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/pinned": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "List a repo's pinned issues",
|
||||
"operationId": "repoListPinnedIssues",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/IssueList"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -7419,6 +7452,144 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}/pin": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"issue"
|
||||
],
|
||||
"summary": "Pin an Issue",
|
||||
"operationId": "pinIssue",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "index of issue to pin",
|
||||
"name": "index",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/responses/empty"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"issue"
|
||||
],
|
||||
"summary": "Unpin an Issue",
|
||||
"operationId": "unpinIssue",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "index of issue to unpin",
|
||||
"name": "index",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/responses/empty"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}/pin/{position}": {
|
||||
"patch": {
|
||||
"tags": [
|
||||
"issue"
|
||||
],
|
||||
"summary": "Moves the Pin to the given Position",
|
||||
"operationId": "moveIssuePin",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "index of issue",
|
||||
"name": "index",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "the new position",
|
||||
"name": "position",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"$ref": "#/responses/empty"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
},
|
||||
"404": {
|
||||
"$ref": "#/responses/notFound"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/issues/{index}/reactions": {
|
||||
"get": {
|
||||
"consumes": [
|
||||
@@ -9010,6 +9181,39 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/new_pin_allowed": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Returns if new Issue Pins are allowed",
|
||||
"operationId": "repoNewPinAllowed",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/RepoNewIssuePinsAllowed"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/notifications": {
|
||||
"get": {
|
||||
"consumes": [
|
||||
@@ -9302,6 +9506,39 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/pulls/pinned": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "List a repo's pinned pull requests",
|
||||
"operationId": "repoListPinnedPullRequests",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repo",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repo",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"$ref": "#/responses/PullRequestList"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/pulls/{index}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -18664,6 +18901,11 @@
|
||||
"format": "int64",
|
||||
"x-go-name": "OriginalAuthorID"
|
||||
},
|
||||
"pin_order": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "PinOrder"
|
||||
},
|
||||
"pull_request": {
|
||||
"$ref": "#/definitions/PullRequestMeta"
|
||||
},
|
||||
@@ -19224,6 +19466,21 @@
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"NewIssuePinsAllowed": {
|
||||
"description": "NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"issues": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "Issues"
|
||||
},
|
||||
"pull_requests": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "PullRequests"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"NodeInfo": {
|
||||
"description": "NodeInfo contains standardized way of exposing metadata about a server running one of the distributed social networks",
|
||||
"type": "object",
|
||||
@@ -19934,6 +20191,11 @@
|
||||
"type": "string",
|
||||
"x-go-name": "PatchURL"
|
||||
},
|
||||
"pin_order": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "PinOrder"
|
||||
},
|
||||
"requested_reviewers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -22176,6 +22438,12 @@
|
||||
"$ref": "#/definitions/IssueConfigValidation"
|
||||
}
|
||||
},
|
||||
"RepoNewIssuePinsAllowed": {
|
||||
"description": "RepoNewIssuePinsAllowed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/NewIssuePinsAllowed"
|
||||
}
|
||||
},
|
||||
"Repository": {
|
||||
"description": "Repository",
|
||||
"schema": {
|
||||
|
Reference in New Issue
Block a user