{{template "repo/header" .}}
+ + {{if .PinnedIssues}} +
+ {{range .PinnedIssues}} + +
+ {{if eq $.Project.CardType 1}}{{/* Images and Text*/}} +
+ {{range (index $.issuesAttachmentMap .ID)}} + {{.Name}} + {{end}} +
+ {{end}} +
+
+ + {{if .IsPull}} + {{if .PullRequest.HasMerged}} + {{svg "octicon-git-merge" 16 "text purple"}} + {{else}} + {{if .IsClosed}} + {{svg "octicon-git-pull-request" 16 "text red"}} + {{else}} + {{svg "octicon-git-pull-request" 16 "text green"}} + {{end}} + {{end}} + {{else}} + {{if .IsClosed}} + {{svg "octicon-issue-closed" 16 "text red"}} + {{else}} + {{svg "octicon-issue-opened" 16 "text green"}} + {{end}} + {{end}} + + + {{.Title}} + +
+
+ + #{{.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}} + +
+ {{- if .MilestoneID}} + + {{- end}} +
+ + {{if or .Labels .Assignees}} +
+ {{range .Labels}} + {{RenderLabel $.Context .}} + {{end}} +
+ {{range .Assignees}} + {{avatar $.Context . 28 "mini gt-mr-3"}} + {{end}} +
+
+ {{end}} +
+ + {{end}} +
+ {{end}} +
{{template "repo/issue/navbar" .}} @@ -25,6 +104,7 @@ {{end}} {{end}}
+
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 248fc71b06167..88019d3d4c0e3 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -577,6 +577,25 @@ {{if and .IsRepoAdmin (not .Repository.IsArchived)}}
+ + {{if not .Repository.IsArchived}} +
+
+
+ {{$.CsrfTokenHtml}} + +
+
+
+ {{end}} +
-
From 8b84877fe1d2752c3639b0e244dc380a8c47f48b Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 2 May 2023 10:18:17 +0200 Subject: [PATCH 08/38] Changes requested by silverwind --- options/locale/locale_en-US.ini | 5 +- templates/repo/issue/list.tmpl | 28 +++------- .../repo/issue/view_content/sidebar.tmpl | 4 +- templates/shared/issueicon.tmpl | 18 +++++++ templates/shared/issuelist.tmpl | 22 +------- web_src/css/repository.css | 14 +++++ web_src/js/features/repo-issue-list.js | 51 ++++++++----------- 7 files changed, 64 insertions(+), 78 deletions(-) create mode 100644 templates/shared/issueicon.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 3b2448f0e9fb1..c1275efea0eaa 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -113,6 +113,9 @@ unknown = Unknown rss_feed = RSS Feed +pin = Pin +unpin = Unpin + [aria] navbar = Navigation Bar footer = Footer @@ -1466,8 +1469,6 @@ issues.attachment.open_tab = `Click to see "%s" in a new tab` issues.attachment.download = `Click to download "%s"` issues.subscribe = Subscribe issues.unsubscribe = Unsubscribe -issues.pin = Pin -issues.unpin = Unpin issues.unpin_issue = Unpin Issue issues.lock = Lock conversation issues.unlock = Unlock conversation diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 6410526a591dd..df3d88d7e402a 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -4,7 +4,7 @@
{{if .PinnedIssues}} -
+
{{range .PinnedIssues}}
{{if eq $.Project.CardType 1}} @@ -17,29 +17,13 @@
- {{if .IsPull}} - {{if .PullRequest.HasMerged}} - {{svg "octicon-git-merge" 16 "text purple"}} - {{else}} - {{if .IsClosed}} - {{svg "octicon-git-pull-request" 16 "text red"}} - {{else}} - {{svg "octicon-git-pull-request" 16 "text green"}} - {{end}} - {{end}} - {{else}} - {{if .IsClosed}} - {{svg "octicon-issue-closed" 16 "text red"}} - {{else}} - {{svg "octicon-issue-opened" 16 "text green"}} - {{end}} - {{end}} + {{template "shared/issueicon" .}} - + {{.Title}} {{if $.IsRepoAdmin}} - + {{svg "octicon-x" 16 "gt-mr-3"}} {{end}} @@ -70,11 +54,11 @@ {{if or .Labels .Assignees}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 1ef01f9bf386a..41a016aa85c67 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -549,9 +549,9 @@ diff --git a/templates/shared/issueicon.tmpl b/templates/shared/issueicon.tmpl new file mode 100644 index 0000000000000..5f6ac4673288e --- /dev/null +++ b/templates/shared/issueicon.tmpl @@ -0,0 +1,18 @@ + +{{if .IsPull}} + {{if .PullRequest.HasMerged}} + {{svg "octicon-git-merge" 16 "text purple"}} + {{else}} + {{if .IsClosed}} + {{svg "octicon-git-pull-request" 16 "text red"}} + {{else}} + {{svg "octicon-git-pull-request" 16 "text green"}} + {{end}} + {{end}} +{{else}} + {{if .IsClosed}} + {{svg "octicon-issue-closed" 16 "text red"}} + {{else}} + {{svg "octicon-issue-opened" 16 "text green"}} + {{end}} +{{end}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 3b354710817c8..af9eb70fe83c1 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -7,27 +7,7 @@ {{end}}
- {{if .IsPull}} - {{if .PullRequest.HasMerged}} - {{svg "octicon-git-merge" 16 "text purple"}} - {{else}} - {{if .IsClosed}} - {{svg "octicon-git-pull-request" 16 "text red"}} - {{else}} - {{if .PullRequest.IsWorkInProgress}} - {{svg "octicon-git-pull-request-draft" 16 "text grey"}} - {{else}} - {{svg "octicon-git-pull-request" 16 "text green"}} - {{end}} - {{end}} - {{end}} - {{else}} - {{if .IsClosed}} - {{svg "octicon-issue-closed" 16 "text red"}} - {{else}} - {{svg "octicon-issue-opened" 16 "text green"}} - {{end}} - {{end}} + {{template "shared/issueicon" .}}
diff --git a/web_src/css/repository.css b/web_src/css/repository.css index 9d77cac952526..52374b017b23c 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -3446,6 +3446,12 @@ td.blob-excerpt { color: var(--color-text-light-2); } +#issue-pin-div { + display: flex; + flex-grow: 1; + flex-wrap: wrap; +} + .pinned-issue-card { margin: 4px 2px !important; border-radius: 5px !important; @@ -3457,3 +3463,11 @@ td.blob-excerpt { border-color: var(--color-input-border); border-width: 1px; } + +.pinned-issue-title { + word-break: break-word; +} + +.pinned-issue-unpin-icon { + float: right; +} diff --git a/web_src/js/features/repo-issue-list.js b/web_src/js/features/repo-issue-list.js index d6fe9a52f3669..b371dde1842bc 100644 --- a/web_src/js/features/repo-issue-list.js +++ b/web_src/js/features/repo-issue-list.js @@ -123,21 +123,20 @@ function initRepoIssueListAuthorDropdown() { function initPinRemoveButton() { for (const button of document.getElementsByName('issue-unpin-button')) { button.addEventListener('click', (event) => { - const elem = event.currentTarget; - const id = Number(elem.getAttribute('data-issue-id')); + const el = event.currentTarget; + const id = Number(el.getAttribute('data-issue-id')); // Send the unpin request - $.ajax({ - url: elem.getAttribute('data-unpin-url'), + fetch(el.getAttribute('data-unpin-url'), { + method: 'delete', headers: { 'X-Csrf-Token': window.config.csrfToken, + 'Content-Type': 'application/json', }, - contentType: 'application/json', - type: 'DELETE', - error: (xhr) => { - throw new Error(xhr.responseText); - }, - success: () => { + }).then((response) => { + if (response.ok) { + // Delete the tooltip + el._tippy.destroy(); // Remove the Card document.querySelector(`div[data-issue-id="${id}"]`).remove(); } @@ -146,20 +145,16 @@ function initPinRemoveButton() { } } -function pinMoveEnd(event) { - const url = event.item.getAttribute('data-move-url'); - const id = Number(event.item.getAttribute('data-issue-id')); - $.ajax({ - url, - data: JSON.stringify({id, position: event.newIndex + 1}), +function pinMoveEnd(e) { + const url = e.item.getAttribute('data-move-url'); + const id = Number(e.item.getAttribute('data-issue-id')); + fetch(url, { + method: 'post', + body: JSON.stringify({id, position: e.newIndex + 1}), headers: { 'X-Csrf-Token': window.config.csrfToken, + 'Content-Type': 'application/json', }, - contentType: 'application/json', - type: 'POST', - error: (xhr) => { - throw new Error(xhr.responseText); - } }); initPinRemoveButton(); } @@ -167,27 +162,21 @@ function pinMoveEnd(event) { function initIssuePinSort() { const pinDiv = document.getElementById('issue-pin-div'); - if (pinDiv === null) { - return; - } + if (pinDiv === null) return; // If the User is not a Repo Admin, we don't need to proceed - if (!pinDiv.hasAttribute('data-is-repo-admin')) { - return; - } + if (!pinDiv.hasAttribute('data-is-repo-admin')) return; initPinRemoveButton(); // If only one issue pinned, we don't need to make this Sortable - if (pinDiv.children.length < 2) { - return; - } + if (pinDiv.children.length < 2) return; new Sortable(pinDiv, { group: 'shared', animation: 150, ghostClass: 'card-ghost', - onEnd: pinMoveEnd + onEnd: pinMoveEnd, }); } From 8c941789f9744c55ee6e333f272424a956b115d6 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 2 May 2023 11:35:18 +0200 Subject: [PATCH 09/38] Add limit for pinned Issues --- custom/conf/app.example.ini | 2 + models/issues/issue.go | 17 ++++++ modules/setting/repository.go | 3 ++ modules/structs/repo.go | 6 +++ options/locale/locale_en-US.ini | 1 + routers/api/v1/api.go | 1 + routers/api/v1/repo/issue_pin.go | 39 ++++++++++++++ routers/api/v1/swagger/repo.go | 7 +++ routers/web/repo/issue.go | 12 +++++ .../repo/issue/view_content/sidebar.tmpl | 4 +- templates/swagger/v1_json.tmpl | 54 +++++++++++++++++++ 11 files changed, 144 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index f22d555704bc0..8d876519d60ba 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1070,6 +1070,8 @@ ROUTER = console ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; List of reasons why a Pull Request or Issue can be locked ;LOCK_REASONS = Too heated,Off-topic,Resolved,Spam +;; Maximum number of pinned Issues +;MaxPinned = 6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/models/issues/issue.go b/models/issues/issue.go index afca81adb55f7..32b77840df8a5 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/references" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -2527,6 +2528,11 @@ func (issue *Issue) Pin() error { return err } + // Check if the maximum allowed Pins reached + if maxPin >= setting.Repository.Issue.MaxPinned { + return fmt.Errorf("You have reached the max number of pinned Issues") + } + _, err = db.GetEngine(db.DefaultContext).Table("issue"). Where("id = ?", issue.ID). Update(map[string]interface{}{ @@ -2639,3 +2645,14 @@ func GetPinnedIssues(repoID int64, isPull bool) ([]*Issue, error) { return issues, nil } + +// IsNewPinnedAllowed returns if a new Issue or Pull request can be pinned +func IsNewPinAllowed(repoID int64, isPull bool) (bool, error) { + var maxPin int + _, err := db.GetEngine(db.DefaultContext).SQL("SELECT MAX(pin_order) FROM issue WHERE repo_id = ? AND is_pull = ?", repoID, isPull).Get(&maxPin) + if err != nil { + return false, err + } + + return maxPin < setting.Repository.Issue.MaxPinned, nil +} diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 20ed6d0dcd559..8c5821dc2b439 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -89,6 +89,7 @@ var ( // Issue Setting Issue struct { LockReasons []string + MaxPinned int } `ini:"repository.issue"` Release struct { @@ -226,8 +227,10 @@ var ( // Issue settings Issue: struct { LockReasons []string + MaxPinned int }{ LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","), + MaxPinned: 6, }, Release: struct { diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 259c230571573..d619ae3975705 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -368,3 +368,9 @@ type RepoTransfer struct { Recipient *User `json:"recipient"` Teams []*Team `json:"teams"` } + +// NewIssuePinsAllowed represents an API response that says if new Issue Pins are allowed +type NewIssuePinsAllowed struct { + Issues bool `json:"issues"` + PullRequests bool `json:"pull_requests"` +} diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index c1275efea0eaa..58291c6072581 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1470,6 +1470,7 @@ issues.attachment.download = `Click to download "%s"` issues.subscribe = Subscribe issues.unsubscribe = Unsubscribe issues.unpin_issue = Unpin Issue +issues.max_pinned = "You can't pin more issues" issues.lock = Lock conversation issues.unlock = Unlock conversation issues.lock.unknown_reason = Cannot lock an issue with an unknown reason. diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index bf86cf7af617b..b3fc428f3251b 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1192,6 +1192,7 @@ func Routes(ctx gocontext.Context) *web.Route { m.Get("/issue_config/validate", context.ReferencesGitRepo(), repo.ValidateIssueConfig) m.Get("/languages", reqRepoReader(unit.TypeCode), repo.GetLanguages) m.Get("/activities/feeds", repo.ListRepoActivityFeeds) + m.Get("/new_pin_allowed", repo.AreNewIssuePinsAllowed) }, repoAssignment()) }) diff --git a/routers/api/v1/repo/issue_pin.go b/routers/api/v1/repo/issue_pin.go index 841a8597e1958..d669bc8c7ce4c 100644 --- a/routers/api/v1/repo/issue_pin.go +++ b/routers/api/v1/repo/issue_pin.go @@ -248,3 +248,42 @@ func ListPinnedPullRequests(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiPrs) } + +// AreNewIssuePinsAllowed returns if new issues pins are allowed +func AreNewIssuePinsAllowed(ctx *context.APIContext) { + // swagger:operation GET /repos/{owner}/{repo}/new_pin_allowed repository repoNewPinAllowed + // --- + // summary: Returns if new Issue Pins are allowed + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // responses: + // "200": + // "$ref": "#/responses/RepoNewIssuePinsAllowed" + pinsAllowed := api.NewIssuePinsAllowed{} + var err error + + pinsAllowed.Issues, err = issues_model.IsNewPinAllowed(ctx.Repo.Repository.ID, false) + if err != nil { + ctx.Error(http.StatusInternalServerError, "IsNewIssuePinAllowed", err) + return + } + + pinsAllowed.PullRequests, err = issues_model.IsNewPinAllowed(ctx.Repo.Repository.ID, true) + if err != nil { + ctx.Error(http.StatusInternalServerError, "IsNewPullRequestPinAllowed", err) + return + } + + ctx.JSON(http.StatusOK, pinsAllowed) +} diff --git a/routers/api/v1/swagger/repo.go b/routers/api/v1/swagger/repo.go index e0418e99dc44f..10056ac8cbb89 100644 --- a/routers/api/v1/swagger/repo.go +++ b/routers/api/v1/swagger/repo.go @@ -400,3 +400,10 @@ type swaggerRepoIssueConfigValidation struct { // in:body Body api.IssueConfigValidation `json:"body"` } + +// RepoNewIssuePinsAllowed +// swagger:response RepoNewIssuePinsAllowed +type swaggerRepoNewIssuePinsAllowed struct { + // in:body + Body api.NewIssuePinsAllowed `json:"body"` +} diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index f189fe3930138..31d60c6f15f4a 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1858,6 +1858,17 @@ func ViewIssue(ctx *context.Context) { return } + var pinAllowed bool + if !issue.IsPinned() { + pinAllowed, err = issues_model.IsNewPinAllowed(issue.RepoID, issue.IsPull) + if err != nil { + ctx.ServerError("IsNewPinAllowed", err) + return + } + } else { + pinAllowed = true + } + ctx.Data["Participants"] = participants ctx.Data["NumParticipants"] = len(participants) ctx.Data["Issue"] = issue @@ -1869,6 +1880,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.Doer.IsAdmin) ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons ctx.Data["RefEndName"] = git.RefEndName(issue.Ref) + ctx.Data["NewPinAllowed"] = pinAllowed var hiddenCommentTypes *big.Int if ctx.IsSigned { diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 41a016aa85c67..cad4f2398ead2 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -544,9 +544,9 @@ {{if not .Repository.IsArchived}}
-
+ {{$.CsrfTokenHtml}} - -
-
-
+
+ {{$.CsrfTokenHtml}} + +
{{end}} -
- -
+ - From 688ace168634c32e137a8632c1acd0336a6b8d05 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 9 May 2023 23:20:04 +0200 Subject: [PATCH 20/38] various display and html layout tweaks --- templates/repo/issue/list.tmpl | 30 ++++++++------------- web_src/css/repository.css | 37 +++++++++++++++----------- web_src/js/features/repo-issue-list.js | 4 +-- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 5a9c0ffaa8724..8c7c7f2d01ba0 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -4,9 +4,9 @@
{{if .PinnedIssues}} -
+
{{range .PinnedIssues}} -
+
{{if eq $.Project.CardType 1}}
{{range (index $.issuesAttachmentMap .ID)}} @@ -15,24 +15,16 @@
{{end}}
-
-
-
-
- - {{template "shared/issueicon" .}} - - - {{.Title}} - -
-
- {{if $.IsRepoAdmin}} -
- {{svg "octicon-x" 16 "gt-mr-3"}} -
- {{end}} +
+
+ {{template "shared/issueicon" .}}
+ {{.Title}} + {{if $.IsRepoAdmin}} + + {{svg "octicon-x" 16}} + + {{end}}
diff --git a/web_src/css/repository.css b/web_src/css/repository.css index cf17d98e783d3..fb84a096ca3fe 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -3411,25 +3411,32 @@ td.blob-excerpt { color: var(--color-text-light-2); } -#issue-pin-div { - display: flex; - flex-grow: 1; - flex-wrap: wrap; +#issue-pins { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 8px; + margin-bottom: 8px; } .pinned-issue-card { - margin: 4px 2px !important; - border-radius: 5px !important; - width: calc(100% - 4px) !important; - padding: 0.5rem !important; - min-height: auto !important; - max-width: calc(100% * (1/3) - 10px - 1px); - border-style: solid; - border-color: var(--color-input-border); - border-width: 1px; + border-radius: var(--border-radius); + padding: 7px 12px; + border: 1px solid var(--color-secondary); + background: var(--color-card); +} + +.pinned-issue-card .meta a { + color: inherit; +} + +.pinned-issue-icon, +.pinned-issue-unpin { + margin-top: 1px; + flex-shrink: 0; } .pinned-issue-title { - word-break: break-word; - vertical-align: middle; + flex: 1; + font-size: 18px; + margin-left: 4px; } diff --git a/web_src/js/features/repo-issue-list.js b/web_src/js/features/repo-issue-list.js index 2d4301b30fd8f..cc50ec5f88178 100644 --- a/web_src/js/features/repo-issue-list.js +++ b/web_src/js/features/repo-issue-list.js @@ -121,7 +121,7 @@ function initRepoIssueListAuthorDropdown() { } function initPinRemoveButton() { - for (const button of document.getElementsByName('issue-unpin-button')) { + for (const button of document.getElementsByClassName('pinned-issue-unpin')) { button.addEventListener('click', async (event) => { const el = event.currentTarget; const id = Number(el.getAttribute('data-issue-id')); @@ -158,7 +158,7 @@ async function pinMoveEnd(e) { } function initIssuePinSort() { - const pinDiv = document.getElementById('issue-pin-div'); + const pinDiv = document.getElementById('issue-pins'); if (pinDiv === null) return; From 61a2dc1d38c9498aea775d2d4192d2037136c141 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 9 May 2023 23:36:09 +0200 Subject: [PATCH 21/38] misc fixes --- web_src/css/repository.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web_src/css/repository.css b/web_src/css/repository.css index fb84a096ca3fe..68d5752c4be61 100644 --- a/web_src/css/repository.css +++ b/web_src/css/repository.css @@ -3420,7 +3420,7 @@ td.blob-excerpt { .pinned-issue-card { border-radius: var(--border-radius); - padding: 7px 12px; + padding: 8px 10px; border: 1px solid var(--color-secondary); background: var(--color-card); } @@ -3429,6 +3429,10 @@ td.blob-excerpt { color: inherit; } +.pinned-issue-card .meta a:hover { + color: var(--color-primary); +} + .pinned-issue-icon, .pinned-issue-unpin { margin-top: 1px; From 59a569146dd5d59fda9d95f2dacac3216a6599c3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 10 May 2023 15:09:47 +0200 Subject: [PATCH 22/38] Update templates/shared/issueicon.tmpl --- templates/shared/issueicon.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/shared/issueicon.tmpl b/templates/shared/issueicon.tmpl index 5f6ac4673288e..7cfe5745db4ce 100644 --- a/templates/shared/issueicon.tmpl +++ b/templates/shared/issueicon.tmpl @@ -1,4 +1,3 @@ - {{if .IsPull}} {{if .PullRequest.HasMerged}} {{svg "octicon-git-merge" 16 "text purple"}} From 706c6cc3571e1ce1ae058886d9aeeb3b8aeec6d3 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 12 May 2023 08:16:14 +0200 Subject: [PATCH 23/38] Do requested changes --- routers/web/repo/issue_pin.go | 4 ++-- templates/repo/issue/view_content/comments.tmpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/issue_pin.go b/routers/web/repo/issue_pin.go index bba4885a3b46b..edd01c016263e 100644 --- a/routers/web/repo/issue_pin.go +++ b/routers/web/repo/issue_pin.go @@ -22,7 +22,7 @@ func IssuePinOrUnpin(ctx *context.Context) { return } - err = issue.PinOrUnpin(ctx, ctx.ContextUser) + err = issue.PinOrUnpin(ctx, ctx.Doer) if err != nil { ctx.ServerError("PinOrUnpinIssue", err) return @@ -46,7 +46,7 @@ func IssueUnpin(ctx *context.Context) { return } - err = issue.Unpin(ctx, ctx.ContextUser) + err = issue.Unpin(ctx, ctx.Doer) if err != nil { ctx.JSON(http.StatusInternalServerError, err.Error()) } diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 60762c930ae38..d95afe747232c 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -12,7 +12,7 @@ 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, - 36 = Pin, 37 = Unpin --> + 36 = PIN, 37 = UNPIN --> {{if eq .Type 0}}
{{if .OriginalAuthor}} From 9d38fadda4ed3a5ae821f51de3ed6b73d77d14b6 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 12 May 2023 09:11:29 +0200 Subject: [PATCH 24/38] Use new Unpin Icon --- templates/repo/issue/view_content/sidebar.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index bad575c3083a8..6412f415132c8 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -535,10 +535,11 @@
{{$.CsrfTokenHtml}} From 03761ea44a579915ea53cccd1ee21297fe806265 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 12 May 2023 09:12:28 +0200 Subject: [PATCH 25/38] Fix Style of new Icon --- templates/repo/issue/view_content/sidebar.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 6412f415132c8..e77c91b61528b 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -539,7 +539,7 @@ {{svg "octicon-pin" 16 "gt-mr-3"}} {{.locale.Tr "pin"}} {{else}} - {{svg "octicon-pin-slash"}} + {{svg "octicon-pin-slash" 16 "gt-mr-3"}} {{.locale.Tr "unpin"}} {{end}} From 20356cfd8ee79de898243e59ef6ca63cd3516c64 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 15 May 2023 10:32:11 +0200 Subject: [PATCH 26/38] Do requested changes --- custom/conf/app.example.ini | 1 + routers/web/repo/issue.go | 1 + templates/repo/issue/list.tmpl | 2 +- templates/repo/issue/view_content/sidebar.tmpl | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6ad8fca64bb7b..7d7f97b62e19d 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1068,6 +1068,7 @@ ROUTER = console ;; List of reasons why a Pull Request or Issue can be locked ;LOCK_REASONS = Too heated,Off-topic,Resolved,Spam ;; Maximum number of pinned Issues +;; Set to 0 to disable pinning Issues ;MAX_PINNED = 6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index bdd95a11f11ef..774774457698b 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1882,6 +1882,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons ctx.Data["RefEndName"] = git.RefEndName(issue.Ref) ctx.Data["NewPinAllowed"] = pinAllowed + ctx.Data["PinEnabled"] = setting.Repository.Issue.MaxPinned != 0 var hiddenCommentTypes *big.Int if ctx.IsSigned { diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 2af062b733d48..55651716502cc 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -19,7 +19,7 @@
{{template "shared/issueicon" .}}
- {{.Title}} + {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{if $.IsRepoAdmin}} {{svg "octicon-x" 16}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index e77c91b61528b..15e7ff4c6f032 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -531,7 +531,7 @@ {{if and .IsRepoAdmin (not .Repository.IsArchived)}}
- {{if not .Repository.IsArchived}} + {{if .PinEnabled}} {{$.CsrfTokenHtml}}