mirror of
https://github.com/go-gitea/gitea
synced 2025-11-03 12:58:29 +00:00
Merge branch 'main' into lunny/issue_dev
This commit is contained in:
@@ -309,6 +309,22 @@ func (s AccessTokenScope) HasScope(scopes ...AccessTokenScope) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// HasAnyScope returns true if any of the scopes is contained in the string
|
||||
func (s AccessTokenScope) HasAnyScope(scopes ...AccessTokenScope) (bool, error) {
|
||||
bitmap, err := s.parse()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, s := range scopes {
|
||||
if has, err := bitmap.hasScope(s); has || err != nil {
|
||||
return has, err
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// hasScope returns true if the string has the given scope
|
||||
func (bitmap accessTokenScopeBitmap) hasScope(scope AccessTokenScope) (bool, error) {
|
||||
expectedBits, ok := allAccessTokenScopeBits[scope]
|
||||
|
||||
@@ -214,9 +214,13 @@ func (r *Review) LoadAttributes(ctx context.Context) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// HTMLTypeColorName returns the color used in the ui indicating the review
|
||||
func (r *Review) HTMLTypeColorName() string {
|
||||
switch r.Type {
|
||||
case ReviewTypeApprove:
|
||||
if !r.Official {
|
||||
return "grey"
|
||||
}
|
||||
if r.Stale {
|
||||
return "yellow"
|
||||
}
|
||||
@@ -231,6 +235,27 @@ func (r *Review) HTMLTypeColorName() string {
|
||||
return "grey"
|
||||
}
|
||||
|
||||
// TooltipContent returns the locale string describing the review type
|
||||
func (r *Review) TooltipContent() string {
|
||||
switch r.Type {
|
||||
case ReviewTypeApprove:
|
||||
if r.Stale {
|
||||
return "repo.issues.review.stale"
|
||||
}
|
||||
if !r.Official {
|
||||
return "repo.issues.review.unofficial"
|
||||
}
|
||||
return "repo.issues.review.official"
|
||||
case ReviewTypeComment:
|
||||
return "repo.issues.review.comment"
|
||||
case ReviewTypeReject:
|
||||
return "repo.issues.review.rejected"
|
||||
case ReviewTypeRequest:
|
||||
return "repo.issues.review.requested"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetReviewByID returns the review by the given ID
|
||||
func GetReviewByID(ctx context.Context, id int64) (*Review, error) {
|
||||
review := new(Review)
|
||||
|
||||
Reference in New Issue
Block a user