2017-03-17 01:57:43 -04:00
|
|
|
<div class="four wide column">
|
|
|
|
<div class="ui segment metas">
|
2017-08-24 08:30:27 -04:00
|
|
|
{{template "repo/issue/branch_selector_field" .}}
|
|
|
|
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Issue.IsPull}}
|
2020-04-06 12:33:34 -04:00
|
|
|
|
2021-02-28 09:05:55 -05:00
|
|
|
<input id="reviewer_id" name="reviewer_id" type="hidden" value="{{.reviewer_id}}">
|
|
|
|
<div class="ui {{if or (not .Reviewers) (not .CanChooseReviewer) .Repository.IsArchived}}disabled{{end}} floating jump select-reviewers-modify dropdown">
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="text gt-df gt-ac muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
<strong>{{.locale.Tr "repo.issues.review.reviewers"}}</strong>
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if and .CanChooseReviewer (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-gear" 16 "gt-ml-2"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{end}}
|
2021-05-16 16:18:18 -04:00
|
|
|
</a>
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_reviewer_title"}}</div>
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if .Reviewers}}
|
|
|
|
<div class="ui icon search input">
|
2023-02-13 12:59:59 -05:00
|
|
|
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
|
2022-06-27 16:58:46 -04:00
|
|
|
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_reviewers"}}">
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{if .Reviewers}}
|
|
|
|
{{range .Reviewers}}
|
|
|
|
{{if .User}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<a class="{{if not .CanChange}}ui tooltip{{end}} item {{if .Checked}} checked {{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
2021-02-28 09:05:55 -05:00
|
|
|
<span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
|
|
|
|
<span class="text">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context .User 28 "gt-mr-3"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{.User.GetDisplayName}}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
{{end}}
|
2020-04-06 12:33:34 -04:00
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if .TeamReviewers}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
{{range .TeamReviewers}}
|
|
|
|
{{if .Team}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<a class="{{if not .CanChange}}ui tooltip{{end}} item {{if .Checked}} checked {{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_team_{{.Team.ID}}" {{if not .CanChange}} data-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
|
2021-02-28 09:05:55 -05:00
|
|
|
<span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check" 16}}</span>
|
|
|
|
<span class="text">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-people" 16 "gt-ml-4 gt-mr-2"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
{{end}}
|
2020-10-12 15:55:13 -04:00
|
|
|
{{end}}
|
2020-04-06 12:33:34 -04:00
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
2020-04-06 12:33:34 -04:00
|
|
|
</div>
|
|
|
|
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="ui assignees list">
|
2023-02-18 23:06:14 -05:00
|
|
|
<span class="no-select item {{if or .OriginalReviews .PullReviewers}}gt-hidden{{end}}">{{.locale.Tr "repo.issues.new.no_reviewers"}}</span>
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="selected">
|
|
|
|
{{range .PullReviewers}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="item gt-mb-2">
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if .User}}
|
|
|
|
<a class="muted sidebar-item-link" href="{{.User.HomeLink}}">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context .User 28 "gt-mr-3"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{.User.GetDisplayName}}
|
2020-04-06 12:33:34 -04:00
|
|
|
</a>
|
2021-02-28 09:05:55 -05:00
|
|
|
{{else if .Team}}
|
|
|
|
<span class="text">{{svg "octicon-people" 16 "teamavatar"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}</span>
|
2020-04-06 12:33:34 -04:00
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
<span class="ui right type-icon text {{if eq .Review.Type 1}}green
|
|
|
|
{{- else if eq .Review.Type 2}}grey
|
|
|
|
{{- else if eq .Review.Type 3}}red
|
|
|
|
{{- else if eq .Review.Type 4}}yellow
|
|
|
|
{{- else}}grey{{end}} right ">
|
|
|
|
|
|
|
|
{{if .CanChange}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<a href="#" class="ui tooltip icon re-request-review {{if .Checked}}checked{{end}}" data-content="{{if .Checked}} {{$.locale.Tr "repo.issues.remove_request_review"}} {{else}} {{$.locale.Tr "repo.issues.re_request_review"}} {{end}}" data-issue-id="{{$.Issue.ID}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
|
2021-03-22 00:04:19 -04:00
|
|
|
{{if .Checked}} {{svg "octicon-trash"}} {{else}} {{svg "octicon-sync"}} {{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
{{svg (printf "octicon-%s" .Review.Type.Icon)}}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{range .OriginalReviews}}
|
|
|
|
<div class="item" style="margin-bottom: 10px;">
|
2022-08-31 11:58:54 -04:00
|
|
|
<a href="{{$.Repository.OriginalURL}}" class="ui tooltip" data-content="{{$.locale.Tr "repo.migrated_from_fake" ($.Repository.GetOriginalURLHostname|Escape) | Safe}}">
|
2021-09-18 12:22:51 -04:00
|
|
|
<span class="text black">
|
|
|
|
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
|
2022-08-31 11:58:54 -04:00
|
|
|
{{.OriginalAuthor}}
|
2021-09-18 12:22:51 -04:00
|
|
|
</span>
|
|
|
|
</a>
|
2021-02-28 09:05:55 -05:00
|
|
|
<span class="ui right type-icon text {{if eq .Type 1}}green
|
|
|
|
{{- else if eq .Type 2}}grey
|
|
|
|
{{- else if eq .Type 3}}red
|
|
|
|
{{- else if eq .Type 4}}yellow
|
|
|
|
{{- else}}grey{{end}} right ">
|
|
|
|
{{svg (printf "octicon-%s" .Type.Icon)}}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2020-04-06 12:33:34 -04:00
|
|
|
</div>
|
2021-05-27 16:02:04 -04:00
|
|
|
{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .HasMerged) (not .Issue.IsClosed) (not .IsPullWorkInProgress)}}
|
2021-11-16 13:18:25 -05:00
|
|
|
<div class="toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefix="{{(index .PullRequestWorkInProgressPrefixes 0| Escape)}}" data-update-url="{{.Issue.Link}}/title">
|
2021-05-27 16:02:04 -04:00
|
|
|
<a class="muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.pulls.still_in_progress"}} {{.locale.Tr "repo.pulls.add_prefix" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}
|
2021-05-27 16:02:04 -04:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="ui divider"></div>
|
2020-06-17 10:12:06 -04:00
|
|
|
{{end}}
|
2020-04-06 12:33:34 -04:00
|
|
|
|
2020-04-04 01:39:48 -04:00
|
|
|
<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown">
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="text gt-df gt-ac muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
<strong>{{.locale.Tr "repo.issues.new.labels"}}</strong>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-gear" 16 "gt-ml-2"}}
|
2020-03-17 12:19:03 -04:00
|
|
|
{{end}}
|
2021-05-16 16:18:18 -04:00
|
|
|
</a>
|
2020-02-11 15:40:47 -05:00
|
|
|
<div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/labels">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_labels_title"}}</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if or .Labels .OrgLabels}}
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="ui icon search input">
|
2023-02-13 12:59:59 -05:00
|
|
|
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
|
2022-06-27 16:58:46 -04:00
|
|
|
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_labels"}}">
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="no-select item">{{.locale.Tr "repo.issues.new.clear_labels"}}</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if or .Labels .OrgLabels}}
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
{{$previousExclusiveScope := "_no_scope"}}
|
2020-04-04 01:39:48 -04:00
|
|
|
{{range .Labels}}
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
{{$exclusiveScope := .ExclusiveScope}}
|
|
|
|
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
{{end}}
|
|
|
|
{{$previousExclusiveScope = $exclusiveScope}}
|
|
|
|
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span> {{RenderLabel .}}
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji}}</small>{{end}}</a>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{end}}
|
|
|
|
<div class="ui divider"></div>
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
{{$previousExclusiveScope := "_no_scope"}}
|
2020-04-04 01:39:48 -04:00
|
|
|
{{range .OrgLabels}}
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 14:17:39 -05:00
|
|
|
{{$exclusiveScope := .ExclusiveScope}}
|
|
|
|
{{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
{{end}}
|
|
|
|
{{$previousExclusiveScope = $exclusiveScope}}
|
|
|
|
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span> {{RenderLabel .}}
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Description}}<br><small class="desc">{{.Description | RenderEmoji}}</small>{{end}}</a>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{end}}
|
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header" style="text-transform: none;font-size:14px;">{{.locale.Tr "repo.issues.new.no_items"}}</div>
|
Add Organization Wide Labels (#10814)
* Add organization wide labels
Implement organization wide labels similar to organization wide
webhooks. This lets you create individual labels for organizations that can be used
for all repos under that organization (so being able to reuse the same
label across multiple repos).
This makes it possible for small organizations with many repos to use
labels effectively.
Fixes #7406
* Add migration
* remove comments
* fix tests
* Update options/locale/locale_en-US.ini
Removed unused translation string
* show org labels in issue search label filter
* Use more clear var name
* rename migration after merge from master
* comment typo
* update migration again after rebase with master
* check for orgID <=0 per guillep2k review
* fmt
* Apply suggestions from code review
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* remove unused code
* Make sure RepoID is 0 when searching orgID per code review
* more changes/code review requests
* More descriptive translation var per code review
* func description/delete comment when issue label deleted instead of hiding it
* remove comment
* only use issues in that repo when calculating number of open issues for org label on repo label page
* Add integration test for IssuesSearch API with labels
* remove unused function
* Update models/issue_label.go
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Use subquery in GetLabelIDsInReposByNames
* Fix tests to use correct orgID
* fix more tests
* IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well
* update comment for clarity
* Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition
* Don't sort repos by date in IssuesSearch API
After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures:
SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45
Returns different results for MySQL than other engines. However, the similar query:
SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30
Returns the same results.
This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function.
* linter is back!
* code review
* remove now unused option
* Fix newline at end of files
* more unused code
* update to master
* check for matching ids before query
* Update models/issue_label.go
Co-Authored-By: 6543 <6543@obermui.de>
* Update models/issue_label.go
* update comments
* Update routers/org/setting.go
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2020-04-01 00:14:46 -04:00
|
|
|
{{end}}
|
2017-03-17 01:57:43 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-17 00:02:41 -05:00
|
|
|
{{template "repo/issue/labels/labels_sidebar" dict "root" $ "ctx" .}}
|
2017-03-17 01:57:43 -04:00
|
|
|
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
2020-04-04 01:39:48 -04:00
|
|
|
<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-milestone dropdown">
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="text gt-df gt-ac muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
<strong>{{.locale.Tr "repo.issues.new.milestone"}}</strong>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-gear" 16 "gt-ml-2"}}
|
2020-03-17 12:19:03 -04:00
|
|
|
{{end}}
|
2021-05-16 16:18:18 -04:00
|
|
|
</a>
|
2017-03-17 01:57:43 -04:00
|
|
|
<div class="menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/milestone">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_milestone_title"}}</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if or .OpenMilestones .ClosedMilestones}}
|
|
|
|
<div class="ui icon search input">
|
2023-02-13 12:59:59 -05:00
|
|
|
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
|
2022-06-27 16:58:46 -04:00
|
|
|
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_milestones"}}">
|
2020-04-04 01:39:48 -04:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="no-select item">{{.locale.Tr "repo.issues.new.clear_milestone"}}</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if and (not .OpenMilestones) (not .ClosedMilestones)}}
|
|
|
|
<div class="header" style="text-transform: none;font-size:14px;">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.new.no_items"}}
|
2017-03-17 01:57:43 -04:00
|
|
|
</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{else}}
|
|
|
|
{{if .OpenMilestones}}
|
|
|
|
<div class="divider"></div>
|
|
|
|
<div class="header">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.new.open_milestone"}}
|
2020-04-04 01:39:48 -04:00
|
|
|
</div>
|
|
|
|
{{range .OpenMilestones}}
|
2020-11-29 01:22:04 -05:00
|
|
|
<a class="item" data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-milestone" 16 "gt-mr-2"}}
|
2020-11-29 01:22:04 -05:00
|
|
|
{{.Name}}
|
|
|
|
</a>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{end}}
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if .ClosedMilestones}}
|
|
|
|
<div class="divider"></div>
|
|
|
|
<div class="header">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.new.closed_milestone"}}
|
2020-04-04 01:39:48 -04:00
|
|
|
</div>
|
|
|
|
{{range .ClosedMilestones}}
|
2020-11-29 01:22:04 -05:00
|
|
|
<a class="item" data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-milestone" 16 "gt-mr-2"}}
|
2020-11-29 01:22:04 -05:00
|
|
|
{{.Name}}
|
|
|
|
</a>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{end}}
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui select-milestone list">
|
2023-02-18 23:06:14 -05:00
|
|
|
<span class="no-select item {{if .Issue.Milestone}}gt-hidden{{end}}">{{.locale.Tr "repo.issues.new.no_milestone"}}</span>
|
2017-03-17 01:57:43 -04:00
|
|
|
<div class="selected">
|
|
|
|
{{if .Issue.Milestone}}
|
2020-11-29 01:22:04 -05:00
|
|
|
<a class="item muted sidebar-item-link" href="{{.RepoLink}}/milestone/{{.Issue.Milestone.ID}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-milestone" 18 "gt-mr-3"}}
|
2020-11-29 01:22:04 -05:00
|
|
|
{{.Issue.Milestone.Name}}
|
|
|
|
</a>
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-08-16 23:07:38 -04:00
|
|
|
{{if .IsProjectsEnabled}}
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="ui divider"></div>
|
2020-11-29 01:22:04 -05:00
|
|
|
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-project dropdown">
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="text gt-df gt-ac muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
<strong>{{.locale.Tr "repo.issues.new.projects"}}</strong>
|
2021-03-12 10:14:02 -05:00
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-gear" 16 "gt-ml-2"}}
|
2021-03-12 10:14:02 -05:00
|
|
|
{{end}}
|
2021-05-16 16:18:18 -04:00
|
|
|
</a>
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/projects">
|
2023-01-31 17:40:38 -05:00
|
|
|
<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_project_title"}}</div>
|
|
|
|
{{if or .OpenProjects .ClosedProjects}}
|
|
|
|
<div class="ui icon search input">
|
2023-02-13 12:59:59 -05:00
|
|
|
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
|
2023-01-31 17:40:38 -05:00
|
|
|
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_projects"}}">
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="no-select item">{{.locale.Tr "repo.issues.new.clear_projects"}}</div>
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if .OpenProjects}}
|
|
|
|
<div class="divider"></div>
|
|
|
|
<div class="header">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.new.open_projects"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
{{range .OpenProjects}}
|
2023-01-20 06:42:33 -05:00
|
|
|
<a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "gt-mr-3"}}{{else}}{{svg "octicon-project" 18 "gt-mr-3"}}{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{.Title}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
2020-08-16 23:07:38 -04:00
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if .ClosedProjects}}
|
|
|
|
<div class="divider"></div>
|
|
|
|
<div class="header">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.new.closed_projects"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
{{range .ClosedProjects}}
|
2023-01-20 06:42:33 -05:00
|
|
|
<a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "gt-mr-3"}}{{else}}{{svg "octicon-project" 18 "gt-mr-3"}}{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{.Title}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="ui select-project list">
|
2023-02-18 23:06:14 -05:00
|
|
|
<span class="no-select item {{if .Issue.ProjectID}}gt-hidden{{end}}">{{.locale.Tr "repo.issues.new.no_projects"}}</span>
|
2021-02-28 09:05:55 -05:00
|
|
|
<div class="selected">
|
|
|
|
{{if .Issue.ProjectID}}
|
2023-01-20 06:42:33 -05:00
|
|
|
<a class="item muted sidebar-item-link" href="{{.Issue.Project.Link}}">
|
2023-02-13 12:59:59 -05:00
|
|
|
{{if .IsOrganizationProject}}{{svg "octicon-project-symlink" 18 "gt-mr-3"}}{{else}}{{svg "octicon-project" 18 "gt-mr-3"}}{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{.Issue.Project.Title}}
|
2020-11-29 01:22:04 -05:00
|
|
|
</a>
|
2020-08-16 23:07:38 -04:00
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
2020-08-16 23:07:38 -04:00
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
2017-03-17 01:57:43 -04:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
|
|
<input id="assignee_id" name="assignee_id" type="hidden" value="{{.assignee_id}}">
|
2020-04-04 01:39:48 -04:00
|
|
|
<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-assignees-modify dropdown">
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="text gt-df gt-ac muted">
|
2022-06-27 16:58:46 -04:00
|
|
|
<strong>{{.locale.Tr "repo.issues.new.assignees"}}</strong>
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-gear" 16 "gt-ml-2"}}
|
2020-03-17 12:19:03 -04:00
|
|
|
{{end}}
|
2021-05-16 16:18:18 -04:00
|
|
|
</a>
|
2020-09-02 12:55:13 -04:00
|
|
|
<div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/assignee">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header" style="text-transform: none;font-size:16px;">{{.locale.Tr "repo.issues.new.add_assignees_title"}}</div>
|
2020-04-04 01:39:48 -04:00
|
|
|
<div class="ui icon search input">
|
2023-02-13 12:59:59 -05:00
|
|
|
<i class="icon gt-df gt-ac gt-jc">{{svg "octicon-search" 16}}</i>
|
2022-06-27 16:58:46 -04:00
|
|
|
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_assignees"}}">
|
2020-04-04 01:39:48 -04:00
|
|
|
</div>
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="no-select item">{{.locale.Tr "repo.issues.new.clear_assignees"}}</div>
|
2017-03-17 01:57:43 -04:00
|
|
|
{{range .Assignees}}
|
2018-05-09 12:29:04 -04:00
|
|
|
|
|
|
|
{{$AssigneeID := .ID}}
|
2020-11-12 00:55:34 -05:00
|
|
|
<a class="item{{range $.Issue.Assignees}}{{if eq .ID $AssigneeID}} checked{{end}}{{end}}" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
|
2020-02-11 12:02:41 -05:00
|
|
|
{{$checked := false}}
|
|
|
|
{{range $.Issue.Assignees}}
|
|
|
|
{{if eq .ID $AssigneeID}}
|
|
|
|
{{$checked = true}}
|
|
|
|
{{end}}
|
2018-05-09 12:29:04 -04:00
|
|
|
{{end}}
|
2020-09-11 16:19:00 -04:00
|
|
|
<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
|
2018-05-09 12:29:04 -04:00
|
|
|
<span class="text">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context . 28 "gt-mr-3"}}
|
2020-11-12 00:55:34 -05:00
|
|
|
{{.GetDisplayName}}
|
2018-05-09 12:29:04 -04:00
|
|
|
</span>
|
|
|
|
</a>
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-05-09 12:29:04 -04:00
|
|
|
<div class="ui assignees list">
|
2023-02-18 23:06:14 -05:00
|
|
|
<span class="no-select item {{if .Issue.Assignees}}gt-hidden{{end}}">{{.locale.Tr "repo.issues.new.no_assignees"}}</span>
|
2017-03-17 01:57:43 -04:00
|
|
|
<div class="selected">
|
2018-05-09 12:29:04 -04:00
|
|
|
{{range .Issue.Assignees}}
|
2020-11-29 01:22:04 -05:00
|
|
|
<div class="item">
|
|
|
|
<a class="muted sidebar-item-link" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?assignee={{.ID}}">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context . 28 "gt-mr-3"}}
|
2020-11-12 00:55:34 -05:00
|
|
|
{{.GetDisplayName}}
|
|
|
|
</a>
|
2018-05-09 12:29:04 -04:00
|
|
|
</div>
|
2017-03-17 01:57:43 -04:00
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
2020-12-07 22:20:12 -05:00
|
|
|
{{if .Participants}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "repo.issues.num_participants" .NumParticipants}}</strong></span>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="ui list gt-df gt-fw">
|
2017-03-17 01:57:43 -04:00
|
|
|
{{range .Participants}}
|
2021-11-17 22:26:50 -05:00
|
|
|
<a class="ui tooltip" {{if gt .ID 0}}href="{{.HomeLink}}"{{end}} data-content="{{.GetDisplayName}}" data-position="top center">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context . 28 "gt-my-1 gt-mr-2"}}
|
2017-03-17 01:57:43 -04:00
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2020-12-07 22:20:12 -05:00
|
|
|
{{end}}
|
2017-03-29 19:31:47 -04:00
|
|
|
|
2019-01-23 13:58:38 -05:00
|
|
|
{{if and $.IssueWatch (not .Repository.IsArchived)}}
|
2017-09-12 02:48:13 -04:00
|
|
|
<div class="ui divider"></div>
|
2017-03-29 19:31:47 -04:00
|
|
|
|
2017-09-12 02:48:13 -04:00
|
|
|
<div class="ui watching">
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "notification.notifications"}}</strong></span>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="gt-mt-3">
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" action="{{.Issue.Link}}/watch">
|
2017-09-12 02:48:13 -04:00
|
|
|
<input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}" />
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<button class="fluid ui button gt-df gt-jc">
|
2017-09-12 02:48:13 -04:00
|
|
|
{{if $.IssueWatch.IsWatching}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-mute" 16 "gt-mr-3"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.unsubscribe"}}
|
2017-09-12 02:48:13 -04:00
|
|
|
{{else}}
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-unmute" 16 "gt-mr-3"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.subscribe"}}
|
2017-09-12 02:48:13 -04:00
|
|
|
{{end}}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2022-12-09 21:46:31 -05:00
|
|
|
{{if .Repository.IsTimetrackerEnabled $.Context}}
|
2019-01-23 13:58:38 -05:00
|
|
|
{{if and .CanUseTimetracker (not .Repository.IsArchived)}}
|
2017-09-12 02:48:13 -04:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="ui timetrack">
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "repo.issues.tracker"}}</strong></span>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="gt-mt-3">
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form">
|
2017-09-12 02:48:13 -04:00
|
|
|
{{$.CsrfTokenHtml}}
|
|
|
|
</form>
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form">
|
2017-09-12 02:48:13 -04:00
|
|
|
{{$.CsrfTokenHtml}}
|
|
|
|
</form>
|
|
|
|
{{if $.IsStopwatchRunning}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<button class="ui fluid button issue-stop-time">{{.locale.Tr "repo.issues.stop_tracking"}}</button>
|
2023-02-13 12:59:59 -05:00
|
|
|
<button class="ui fluid negative button issue-cancel-time gt-mt-3">{{.locale.Tr "repo.issues.cancel_tracking"}}</button>
|
2017-03-29 19:31:47 -04:00
|
|
|
{{else}}
|
2017-09-12 02:48:13 -04:00
|
|
|
{{if .HasUserStopwatch}}
|
|
|
|
<div class="ui warning message">
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.tracking_already_started" (.OtherStopwatchURL|Escape) | Safe}}
|
2017-09-12 02:48:13 -04:00
|
|
|
</div>
|
|
|
|
{{end}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<button class="ui fluid button tooltip issue-start-time" data-content='{{.locale.Tr "repo.issues.start_tracking"}}' data-position="top center">{{.locale.Tr "repo.issues.start_tracking_short"}}</button>
|
2021-05-16 16:18:18 -04:00
|
|
|
<div class="ui mini modal issue-start-time-modal">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="header">{{.locale.Tr "repo.issues.add_time"}}</div>
|
2021-05-16 16:18:18 -04:00
|
|
|
<div class="content">
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui action input fluid">
|
2021-05-16 16:18:18 -04:00
|
|
|
{{$.CsrfTokenHtml}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" name="hours">
|
|
|
|
<input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" name="minutes" class="ui compact">
|
2021-05-16 16:18:18 -04:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="ui green approve button">{{.locale.Tr "repo.issues.add_time_short"}}</div>
|
|
|
|
<div class="ui red cancel button">{{.locale.Tr "repo.issues.add_time_cancel"}}</div>
|
2017-09-12 02:48:13 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-13 12:59:59 -05:00
|
|
|
<button class="ui fluid button green tooltip issue-add-time gt-mt-3" data-content='{{.locale.Tr "repo.issues.add_time"}}' data-position="top center">{{.locale.Tr "repo.issues.add_time_short"}}</button>
|
2017-03-29 19:31:47 -04:00
|
|
|
{{end}}
|
2017-09-12 02:48:13 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{if gt (len .WorkingUsers) 0}}
|
|
|
|
<div class="ui divider"></div>
|
2020-12-07 22:20:12 -05:00
|
|
|
<div class="ui comments">
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span>
|
2017-09-12 02:48:13 -04:00
|
|
|
<div>
|
|
|
|
{{range $user, $trackedtime := .WorkingUsers}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="comment gt-mt-3">
|
2017-09-12 02:48:13 -04:00
|
|
|
<a class="avatar">
|
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.
But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.
The core context cache is here. It defines a new context
```go
type cacheContext struct {
ctx context.Context
data map[any]map[any]any
lock sync.RWMutex
}
var cacheContextKey = struct{}{}
func WithCacheContext(ctx context.Context) context.Context {
return context.WithValue(ctx, cacheContextKey, &cacheContext{
ctx: ctx,
data: make(map[any]map[any]any),
})
}
```
Then you can use the below 4 methods to read/write/del the data within
the same context.
```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```
Then let's take a look at how `system.GetString` implement it.
```go
func GetSetting(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key)
if err != nil {
return "", err
}
return res.SettingValue, nil
})
})
}
```
First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.
An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 08:37:34 -05:00
|
|
|
{{avatar $.Context $user}}
|
2017-09-12 02:48:13 -04:00
|
|
|
</a>
|
|
|
|
<div class="content">
|
2022-11-18 23:02:30 -05:00
|
|
|
{{template "shared/user/authorlink" $user}}
|
2017-09-12 02:48:13 -04:00
|
|
|
<div class="text">
|
|
|
|
{{$trackedtime}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2017-04-29 01:52:25 -04:00
|
|
|
{{end}}
|
2018-05-01 15:05:28 -04:00
|
|
|
|
|
|
|
<div class="ui divider"></div>
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "repo.issues.due_date"}}</strong></span>
|
2018-07-16 08:43:00 -04:00
|
|
|
<div class="ui form" id="deadline-loader">
|
2023-02-18 23:06:14 -05:00
|
|
|
<div class="ui negative message gt-hidden" id="deadline-err-invalid-date">
|
2021-05-16 16:18:18 -04:00
|
|
|
{{svg "octicon-x" 16 "close icon"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.due_date_invalid"}}
|
2018-07-16 08:43:00 -04:00
|
|
|
</div>
|
|
|
|
{{if ne .Issue.DeadlineUnix 0}}
|
|
|
|
<p>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="gt-df gt-sb gt-ac">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="due-date tooltip {{if .Issue.IsOverdue}}text red{{end}}" {{if .Issue.IsOverdue}}data-content="{{.locale.Tr "repo.issues.due_date_overdue"}}"{{end}}>
|
2023-02-13 12:59:59 -05:00
|
|
|
{{svg "octicon-calendar" 16 "gt-mr-3"}}
|
2023-01-01 21:49:05 -05:00
|
|
|
<time data-format="date" datetime="{{.Issue.DeadlineUnix.FormatDate}}">{{.Issue.DeadlineUnix.FormatDate}}</time>
|
2021-05-16 16:18:18 -04:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<a class="issue-due-edit tooltip muted" data-content="{{$.locale.Tr "repo.issues.due_date_form_edit"}}">{{svg "octicon-pencil" 16 "gt-mr-2"}}</a>
|
2022-06-27 16:58:46 -04:00
|
|
|
<a class="issue-due-remove tooltip muted" data-content="{{$.locale.Tr "repo.issues.due_date_form_remove"}}">{{svg "octicon-trash"}}</a>
|
2021-05-16 16:18:18 -04:00
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-07-16 08:43:00 -04:00
|
|
|
</p>
|
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<p>{{.locale.Tr "repo.issues.due_date_not_set"}}</p>
|
2018-07-16 08:43:00 -04:00
|
|
|
{{end}}
|
2018-05-01 15:05:28 -04:00
|
|
|
|
2020-04-04 01:39:48 -04:00
|
|
|
{{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
|
2023-02-18 23:06:14 -05:00
|
|
|
<div {{if ne .Issue.DeadlineUnix 0}} class="gt-hidden"{{end}} id="deadlineForm">
|
2022-04-07 14:59:56 -04:00
|
|
|
<form class="ui fluid action input issue-due-form" action="{{AppSubUrl}}/{{PathEscape .Repository.Owner.Name}}/{{PathEscape .Repository.Name}}/issues/{{.Issue.Index}}/deadline" method="post" id="update-issue-deadline-form">
|
2018-07-16 08:43:00 -04:00
|
|
|
{{$.CsrfTokenHtml}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<input required placeholder="{{.locale.Tr "repo.issues.due_date_form"}}" {{if gt .Issue.DeadlineUnix 0}}value="{{.Issue.DeadlineUnix.Format "2006-01-02"}}"{{end}} type="date" name="deadlineDate" id="deadlineDate">
|
2018-07-16 08:43:00 -04:00
|
|
|
<button class="ui green icon button">
|
|
|
|
{{if ne .Issue.DeadlineUnix 0}}
|
2021-05-16 16:18:18 -04:00
|
|
|
{{svg "octicon-pencil"}}
|
2018-07-16 08:43:00 -04:00
|
|
|
{{else}}
|
2021-05-16 16:18:18 -04:00
|
|
|
{{svg "octicon-plus"}}
|
2018-07-16 08:43:00 -04:00
|
|
|
{{end}}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2018-07-17 17:23:58 -04:00
|
|
|
|
2022-12-09 21:46:31 -05:00
|
|
|
{{if .Repository.IsDependenciesEnabled $.Context}}
|
2018-07-17 17:23:58 -04:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
|
|
<div class="ui depending">
|
2018-09-06 22:32:46 -04:00
|
|
|
{{if (and (not .BlockedByDependencies) (not .BlockingDependencies))}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text"><strong>{{.locale.Tr "repo.issues.dependency.title"}}</strong></span>
|
2018-09-06 22:32:46 -04:00
|
|
|
<br>
|
2020-11-10 13:28:07 -05:00
|
|
|
<p>
|
|
|
|
{{if .Issue.IsPull}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.pr_no_dependencies"}}
|
2018-09-06 22:32:46 -04:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.issue_no_dependencies"}}
|
2020-11-10 13:28:07 -05:00
|
|
|
{{end}}
|
|
|
|
</p>
|
2018-09-06 22:32:46 -04:00
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{if .BlockingDependencies}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text tooltip" data-content="{{if .Issue.IsPull}}{{.locale.Tr "repo.issues.dependency.pr_close_blocks"}}{{else}}{{.locale.Tr "repo.issues.dependency.issue_close_blocks"}}{{end}}">
|
|
|
|
<strong>{{.locale.Tr "repo.issues.dependency.blocks_short"}}</strong>
|
2018-07-17 17:23:58 -04:00
|
|
|
</span>
|
|
|
|
<div class="ui relaxed divided list">
|
2018-09-06 22:32:46 -04:00
|
|
|
{{range .BlockingDependencies}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} gt-df gt-ac gt-sb">
|
|
|
|
<div class="item-left gt-df gt-jc gt-fc gt-f1">
|
2022-06-01 15:08:34 -04:00
|
|
|
<a class="title tooltip" href="{{.Issue.Link}}" data-content="#{{.Issue.Index}} {{.Issue.Title | RenderEmoji}}">
|
2020-11-10 13:28:07 -05:00
|
|
|
#{{.Issue.Index}} {{.Issue.Title | RenderEmoji}}
|
|
|
|
</a>
|
|
|
|
<div class="text small">
|
|
|
|
{{.Repository.OwnerName}}/{{.Repository.Name}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="item-right gt-df gt-ac">
|
2019-01-23 13:58:38 -05:00
|
|
|
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<a class="delete-dependency-button tooltip ci muted" data-id="{{.Issue.ID}}" data-type="blocking" data-content="{{$.locale.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
2021-03-22 00:04:19 -04:00
|
|
|
{{svg "octicon-trash" 16}}
|
2018-07-17 17:23:58 -04:00
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
2018-09-06 22:32:46 -04:00
|
|
|
{{if .BlockedByDependencies}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text tooltip" data-content="{{if .Issue.IsPull}}{{.locale.Tr "repo.issues.dependency.pr_closing_blockedby"}}{{else}}{{.locale.Tr "repo.issues.dependency.issue_closing_blockedby"}}{{end}}">
|
|
|
|
<strong>{{.locale.Tr "repo.issues.dependency.blocked_by_short"}}</strong>
|
2018-07-17 17:23:58 -04:00
|
|
|
</span>
|
|
|
|
<div class="ui relaxed divided list">
|
2018-09-06 22:32:46 -04:00
|
|
|
{{range .BlockedByDependencies}}
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} gt-df gt-ac gt-sb">
|
|
|
|
<div class="item-left gt-df gt-jc gt-fc gt-f1">
|
2022-06-01 15:08:34 -04:00
|
|
|
<a class="title tooltip" href="{{.Issue.Link}}" data-content="#{{.Issue.Index}} {{.Issue.Title | RenderEmoji}}">
|
2020-11-10 13:28:07 -05:00
|
|
|
#{{.Issue.Index}} {{.Issue.Title | RenderEmoji}}
|
|
|
|
</a>
|
|
|
|
<div class="text small">
|
|
|
|
{{.Repository.OwnerName}}/{{.Repository.Name}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-13 12:59:59 -05:00
|
|
|
<div class="item-right gt-df gt-ac">
|
Allow cross-repository dependencies on issues (#7901)
* in progress changes for #7405, added ability to add cross-repo dependencies
* removed unused repolink var
* fixed query that was breaking ci tests; fixed check in issue dependency add so that the id of the issue and dependency is checked rather than the indexes
* reverted removal of string in local files becasue these are done via crowdin, not updated manually
* removed 'Select("issue.*")' from getBlockedByDependencies and getBlockingDependencies based on comments in PR review
* changed getBlockedByDependencies and getBlockingDependencies to use a more xorm-like query, also updated the sidebar as a result
* simplified the getBlockingDependencies and getBlockedByDependencies methods; changed the sidebar to show the dependencies in a different format where you can see the name of the repository
* made some changes to the issue view in the dependencies (issue name on top, repo full name on separate line). Change view of issue in the dependency search results (also showing the full repo name on separate line)
* replace call to FindUserAccessibleRepoIDs with SearchRepositoryByName. The former was hardcoded to use isPrivate = false on the repo search, but this code needed it to be true. The SearchRepositoryByName method is used more in the code including on the user's dashboard
* some more tweaks to the layout of the issues when showing dependencies and in the search box when you add new dependencies
* added Name to the RepositoryMeta struct
* updated swagger doc
* fixed total count for link header on SearchIssues
* fixed indentation
* fixed aligment of remove icon on dependencies in issue sidebar
* removed unnecessary nil check (unnecessary because issue.loadRepo is called prior to this block)
* reverting .css change, somehow missed or forgot that less is used
* updated less file and generated css; updated sidebar template with styles to line up delete and issue index
* added ordering to the blocked by/depends on queries
* fixed sorting in issue dependency search and the depends on/blocks views to show issues from the current repo first, then by created date descending; added a "all cross repository dependencies" setting to allow this feature to be turned off, if turned off, the issue dependency search will work the way it did before (restricted to the current repository)
* re-applied my swagger changes after merge
* fixed split string condition in issue search
* changed ALLOW_CROSS_REPOSITORY_DEPENDENCIES description to sound more global than just the issue dependency search; returning 400 in the cross repo issue search api method if not enabled; fixed bug where the issue count did not respect the state parameter
* when adding a dependency to an issue, added a check to make sure the issue and dependency are in the same repo if cross repo dependencies is not enabled
* updated sortIssuesSession call in PullRequests, another commit moved this method from pull.go to pull_list.go so I had to re-apply my change here
* fixed incorrect setting of user id parameter in search repos call
2019-10-31 01:06:10 -04:00
|
|
|
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
2022-06-27 16:58:46 -04:00
|
|
|
<a class="delete-dependency-button tooltip ci muted" data-id="{{.Issue.ID}}" data-type="blockedBy" data-content="{{$.locale.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
2021-03-22 00:04:19 -04:00
|
|
|
{{svg "octicon-trash" 16}}
|
2018-07-17 17:23:58 -04:00
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
2019-01-23 13:58:38 -05:00
|
|
|
{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}}
|
2018-07-17 17:23:58 -04:00
|
|
|
<div>
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm">
|
2018-07-17 17:23:58 -04:00
|
|
|
{{$.CsrfTokenHtml}}
|
|
|
|
<div class="ui fluid action input">
|
2019-05-12 07:10:12 -04:00
|
|
|
<div class="ui search selection dropdown" id="new-dependency-drop-list" data-issue-id="{{.Issue.ID}}">
|
2018-07-17 17:23:58 -04:00
|
|
|
<input name="newDependency" type="hidden">
|
2020-10-31 18:15:11 -04:00
|
|
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
2018-07-17 17:23:58 -04:00
|
|
|
<input type="text" class="search">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="default text">{{.locale.Tr "repo.issues.dependency.add"}}</div>
|
2018-07-17 17:23:58 -04:00
|
|
|
</div>
|
|
|
|
<button class="ui green icon button">
|
2021-05-16 16:18:18 -04:00
|
|
|
{{svg "octicon-plus"}}
|
2018-07-17 17:23:58 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}}
|
|
|
|
<input type="hidden" id="crossRepoSearch" value="{{.AllowCrossRepositoryDependencies}}">
|
|
|
|
|
|
|
|
<div class="ui basic modal remove-dependency">
|
|
|
|
<div class="ui icon header">
|
2021-03-22 00:04:19 -04:00
|
|
|
{{svg "octicon-trash"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.remove_header"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
<div class="content">
|
2021-11-16 13:18:25 -05:00
|
|
|
<form method="POST" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm">
|
2021-02-28 09:05:55 -05:00
|
|
|
{{$.CsrfTokenHtml}}
|
|
|
|
<input type="hidden" value="" name="removeDependencyID" id="removeDependencyID"/>
|
|
|
|
<input type="hidden" value="" name="dependencyType" id="dependencyType"/>
|
|
|
|
</form>
|
|
|
|
<p>{{if .Issue.IsPull}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.pr_remove_text"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.issue_remove_text"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{end}}</p>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
2021-05-16 16:18:18 -04:00
|
|
|
<div class="ui red cancel inverted button">
|
|
|
|
{{svg "octicon-x"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.cancel"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
2021-05-16 16:18:18 -04:00
|
|
|
<div class="ui green ok inverted button">
|
|
|
|
{{svg "octicon-check"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.dependency.remove"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
|
2022-05-05 14:58:37 -04:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="ui equal width compact grid">
|
2023-02-15 06:34:10 -05:00
|
|
|
{{$issueReferenceLink := printf "%s#%d" .Issue.Repo.FullName .Issue.Index}}
|
|
|
|
<div class="row gt-ac tooltip" data-content="{{$issueReferenceLink}}">
|
2022-06-27 16:58:46 -04:00
|
|
|
<span class="text column truncate">{{.locale.Tr "repo.issues.reference_link" $issueReferenceLink}}</span>
|
2023-02-13 12:59:59 -05:00
|
|
|
<button class="ui two wide button column gt-p-3" data-clipboard-text="{{$issueReferenceLink}}">{{svg "octicon-copy" 14}}</button>
|
2022-05-05 14:58:37 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-02-28 09:05:55 -05:00
|
|
|
{{if and .IsRepoAdmin (not .Repository.IsArchived)}}
|
2019-02-18 15:55:04 -05:00
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="ui watching">
|
2022-08-31 11:58:54 -04:00
|
|
|
<button class="fluid ui show-modal button {{if .Issue.IsLocked}} negative {{end}}" data-modal="#lock">
|
2021-01-18 22:02:47 -05:00
|
|
|
{{if .Issue.IsLocked}}
|
|
|
|
{{svg "octicon-key"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.unlock"}}
|
2021-01-18 22:02:47 -05:00
|
|
|
{{else}}
|
|
|
|
{{svg "octicon-lock"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.lock"}}
|
2021-01-18 22:02:47 -05:00
|
|
|
{{end}}
|
|
|
|
</button>
|
2019-02-18 15:55:04 -05:00
|
|
|
</div>
|
|
|
|
<div class="ui tiny modal" id="lock">
|
|
|
|
<div class="header">
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Issue.IsLocked}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.unlock.title"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.lock.title"}}
|
2021-02-28 09:05:55 -05:00
|
|
|
{{end}}
|
2019-02-18 15:55:04 -05:00
|
|
|
</div>
|
2021-03-21 14:58:28 -04:00
|
|
|
<div class="content">
|
|
|
|
<div class="ui warning message text left">
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Issue.IsLocked}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.unlock.notice_1"}}<br>
|
|
|
|
{{.locale.Tr "repo.issues.unlock.notice_2"}}<br>
|
2021-03-21 14:58:28 -04:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.lock.notice_1"}}<br>
|
|
|
|
{{.locale.Tr "repo.issues.lock.notice_2"}}<br>
|
|
|
|
{{.locale.Tr "repo.issues.lock.notice_3"}}<br>
|
2021-03-21 14:58:28 -04:00
|
|
|
{{end}}
|
|
|
|
</div>
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2022-08-31 11:58:54 -04:00
|
|
|
<form class="ui form" action="{{.Issue.Link}}{{if .Issue.IsLocked}}/unlock{{else}}/lock{{end}}"
|
2021-03-21 14:58:28 -04:00
|
|
|
method="post">
|
|
|
|
{{.CsrfTokenHtml}}
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if not .Issue.IsLocked}}
|
2021-03-21 14:58:28 -04:00
|
|
|
<div class="field">
|
2022-08-31 11:58:54 -04:00
|
|
|
<strong> {{.locale.Tr "repo.issues.lock.reason"}} </strong>
|
2021-03-21 14:58:28 -04:00
|
|
|
</div>
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2021-03-21 14:58:28 -04:00
|
|
|
<div class="field">
|
|
|
|
<div class="ui fluid dropdown selection" tabindex="0">
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2021-03-21 14:58:28 -04:00
|
|
|
<select name="reason">
|
|
|
|
<option value=""> </option>
|
|
|
|
{{range .LockReasons}}
|
|
|
|
<option value="{{.}}">{{.}}</option>
|
|
|
|
{{end}}
|
|
|
|
</select>
|
|
|
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2021-03-21 14:58:28 -04:00
|
|
|
<div class="default text"> </div>
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2023-02-14 06:53:54 -05:00
|
|
|
<div class="menu">
|
2021-03-21 14:58:28 -04:00
|
|
|
{{range .LockReasons}}
|
|
|
|
<div class="item" data-value="{{.}}">{{.}}</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
2019-02-18 15:55:04 -05:00
|
|
|
</div>
|
2021-03-21 14:58:28 -04:00
|
|
|
{{end}}
|
2019-02-18 15:55:04 -05:00
|
|
|
|
2021-03-21 14:58:28 -04:00
|
|
|
<div class="text right actions">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="ui cancel button">{{.locale.Tr "settings.cancel"}}</div>
|
2021-03-21 14:58:28 -04:00
|
|
|
<button class="ui red button">
|
2022-08-31 11:58:54 -04:00
|
|
|
{{if .Issue.IsLocked}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.unlock_confirm"}}
|
2021-03-21 14:58:28 -04:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.lock_confirm"}}
|
2021-03-21 14:58:28 -04:00
|
|
|
{{end}}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2018-07-17 17:23:58 -04:00
|
|
|
</div>
|
2023-02-13 12:59:59 -05:00
|
|
|
<button class="fluid ui show-modal button negative gt-mt-3" data-modal="#delete">
|
2022-03-08 19:38:11 -05:00
|
|
|
{{svg "octicon-trash"}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.delete"}}
|
2022-03-08 19:38:11 -05:00
|
|
|
</button>
|
|
|
|
<div class="ui basic modal" id="delete">
|
|
|
|
<div class="ui icon header">
|
2022-06-19 06:05:15 -04:00
|
|
|
{{if .Issue.IsPull}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.pulls.delete.title"}}
|
2022-06-19 06:05:15 -04:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.delete.title"}}
|
2022-06-19 06:05:15 -04:00
|
|
|
{{end}}
|
2022-03-08 19:38:11 -05:00
|
|
|
</div>
|
|
|
|
<div class="content center">
|
|
|
|
<p>
|
2022-06-19 06:05:15 -04:00
|
|
|
{{if .Issue.IsPull}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.pulls.delete.text"}}
|
2022-06-19 06:05:15 -04:00
|
|
|
{{else}}
|
2022-06-27 16:58:46 -04:00
|
|
|
{{.locale.Tr "repo.issues.delete.text"}}
|
2022-06-19 06:05:15 -04:00
|
|
|
{{end}}
|
2022-03-08 19:38:11 -05:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<form action="{{.Issue.Link}}/delete" method="post">
|
|
|
|
{{.CsrfTokenHtml}}
|
|
|
|
<div class="center actions">
|
2022-06-27 16:58:46 -04:00
|
|
|
<div class="ui basic cancel inverted button">{{.locale.Tr "settings.cancel"}}</div>
|
|
|
|
<button class="ui basic red inverted button">{{.locale.Tr "modal.yes"}}</button>
|
2022-03-08 19:38:11 -05:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2018-07-17 17:23:58 -04:00
|
|
|
{{end}}
|
2022-04-28 11:45:33 -04:00
|
|
|
|
|
|
|
{{if and .Issue.IsPull .IsIssuePoster (not .Issue.IsClosed)}}
|
|
|
|
{{if and (not (eq .Issue.PullRequest.HeadRepo.FullName .Issue.PullRequest.BaseRepo.FullName)) .CanWriteToHeadRepo}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="inline field">
|
|
|
|
<div class="ui checkbox" id="allow-edits-from-maintainers"
|
|
|
|
data-url="{{.Issue.Link}}"
|
2022-06-27 16:58:46 -04:00
|
|
|
data-prompt-tip="{{.locale.Tr "repo.pulls.allow_edits_from_maintainers_desc"}}"
|
|
|
|
data-prompt-error="{{.locale.Tr "repo.pulls.allow_edits_from_maintainers_err"}}"
|
2022-04-28 11:45:33 -04:00
|
|
|
>
|
2022-06-27 16:58:46 -04:00
|
|
|
<label><strong>{{.locale.Tr "repo.pulls.allow_edits_from_maintainers"}}</strong></label>
|
2022-04-28 11:45:33 -04:00
|
|
|
<input type="checkbox" {{if .Issue.PullRequest.AllowMaintainerEdit}}checked{{end}}>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2021-02-28 09:05:55 -05:00
|
|
|
</div>
|
|
|
|
</div>
|