Disable Stars config option (#14653)
* Add config option to disable stars * Replace "stars" with watched in user profile * Add documentation
This commit is contained in:
parent
af2adb4e35
commit
f44543a1bb
16 changed files with 83 additions and 27 deletions
|
@ -70,6 +70,8 @@ PREFIX_ARCHIVE_FILES = true
|
||||||
DISABLE_MIRRORS = false
|
DISABLE_MIRRORS = false
|
||||||
; Disable migrating feature.
|
; Disable migrating feature.
|
||||||
DISABLE_MIGRATIONS = false
|
DISABLE_MIGRATIONS = false
|
||||||
|
; Disable stars feature.
|
||||||
|
DISABLE_STARS = false
|
||||||
; The default branch name of new repositories
|
; The default branch name of new repositories
|
||||||
DEFAULT_BRANCH = master
|
DEFAULT_BRANCH = master
|
||||||
; Allow adoption of unadopted repositories
|
; Allow adoption of unadopted repositories
|
||||||
|
|
|
@ -75,6 +75,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
|
||||||
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
|
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
|
||||||
- `DISABLE_MIRRORS`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
|
- `DISABLE_MIRRORS`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
|
||||||
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
|
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
|
||||||
|
- `DISABLE_STARS`: **false**: Disable stars feature.
|
||||||
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
|
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
|
||||||
- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to adopt unadopted repositories
|
- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to adopt unadopted repositories
|
||||||
- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to delete unadopted repositories
|
- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to delete unadopted repositories
|
||||||
|
|
|
@ -143,6 +143,7 @@ type SearchRepoOptions struct {
|
||||||
OrderBy SearchOrderBy
|
OrderBy SearchOrderBy
|
||||||
Private bool // Include private repositories in results
|
Private bool // Include private repositories in results
|
||||||
StarredByID int64
|
StarredByID int64
|
||||||
|
WatchedByID int64
|
||||||
AllPublic bool // Include also all public repositories of users and public organisations
|
AllPublic bool // Include also all public repositories of users and public organisations
|
||||||
AllLimited bool // Include also all public repositories of limited organisations
|
AllLimited bool // Include also all public repositories of limited organisations
|
||||||
// None -> include public and private
|
// None -> include public and private
|
||||||
|
@ -241,6 +242,11 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
|
||||||
cond = cond.And(builder.In("id", builder.Select("repo_id").From("star").Where(builder.Eq{"uid": opts.StarredByID})))
|
cond = cond.And(builder.In("id", builder.Select("repo_id").From("star").Where(builder.Eq{"uid": opts.StarredByID})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restrict to watched repositories
|
||||||
|
if opts.WatchedByID > 0 {
|
||||||
|
cond = cond.And(builder.In("id", builder.Select("repo_id").From("watch").Where(builder.Eq{"user_id": opts.WatchedByID})))
|
||||||
|
}
|
||||||
|
|
||||||
// Restrict repositories to those the OwnerID owns or contributes to as per opts.Collaborate
|
// Restrict repositories to those the OwnerID owns or contributes to as per opts.Collaborate
|
||||||
if opts.OwnerID > 0 {
|
if opts.OwnerID > 0 {
|
||||||
accessCond := builder.NewCond()
|
accessCond := builder.NewCond()
|
||||||
|
|
|
@ -704,6 +704,7 @@ func Contexter() func(next http.Handler) http.Handler {
|
||||||
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
|
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
|
||||||
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
|
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
|
||||||
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
|
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
|
||||||
|
ctx.Data["DisableStars"] = setting.Repository.DisableStars
|
||||||
|
|
||||||
ctx.Data["ManifestData"] = setting.ManifestData
|
ctx.Data["ManifestData"] = setting.ManifestData
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ var (
|
||||||
PrefixArchiveFiles bool
|
PrefixArchiveFiles bool
|
||||||
DisableMirrors bool
|
DisableMirrors bool
|
||||||
DisableMigrations bool
|
DisableMigrations bool
|
||||||
|
DisableStars bool `ini:"DISABLE_STARS"`
|
||||||
DefaultBranch string
|
DefaultBranch string
|
||||||
AllowAdoptionOfUnadoptedRepositories bool
|
AllowAdoptionOfUnadoptedRepositories bool
|
||||||
AllowDeleteOfUnadoptedRepositories bool
|
AllowDeleteOfUnadoptedRepositories bool
|
||||||
|
@ -154,6 +155,7 @@ var (
|
||||||
PrefixArchiveFiles: true,
|
PrefixArchiveFiles: true,
|
||||||
DisableMirrors: false,
|
DisableMirrors: false,
|
||||||
DisableMigrations: false,
|
DisableMigrations: false,
|
||||||
|
DisableStars: false,
|
||||||
DefaultBranch: "master",
|
DefaultBranch: "master",
|
||||||
|
|
||||||
// Repository editor settings
|
// Repository editor settings
|
||||||
|
|
|
@ -9,6 +9,7 @@ type GeneralRepoSettings struct {
|
||||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||||
MigrationsDisabled bool `json:"migrations_disabled"`
|
MigrationsDisabled bool `json:"migrations_disabled"`
|
||||||
|
StarsDisabled bool `json:"stars_disabled"`
|
||||||
TimeTrackingDisabled bool `json:"time_tracking_disabled"`
|
TimeTrackingDisabled bool `json:"time_tracking_disabled"`
|
||||||
LFSDisabled bool `json:"lfs_disabled"`
|
LFSDisabled bool `json:"lfs_disabled"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,6 +421,7 @@ repositories = Repositories
|
||||||
activity = Public Activity
|
activity = Public Activity
|
||||||
followers = Followers
|
followers = Followers
|
||||||
starred = Starred Repositories
|
starred = Starred Repositories
|
||||||
|
watched = Watched Repositories
|
||||||
projects = Projects
|
projects = Projects
|
||||||
following = Following
|
following = Following
|
||||||
follow = Follow
|
follow = Follow
|
||||||
|
|
|
@ -60,6 +60,7 @@ func GetGeneralRepoSettings(ctx *context.APIContext) {
|
||||||
MirrorsDisabled: setting.Repository.DisableMirrors,
|
MirrorsDisabled: setting.Repository.DisableMirrors,
|
||||||
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
||||||
MigrationsDisabled: setting.Repository.DisableMigrations,
|
MigrationsDisabled: setting.Repository.DisableMigrations,
|
||||||
|
StarsDisabled: setting.Repository.DisableStars,
|
||||||
TimeTrackingDisabled: !setting.Service.EnableTimetracking,
|
TimeTrackingDisabled: !setting.Service.EnableTimetracking,
|
||||||
LFSDisabled: !setting.LFS.StartServer,
|
LFSDisabled: !setting.LFS.StartServer,
|
||||||
})
|
})
|
||||||
|
|
|
@ -238,6 +238,27 @@ func Profile(ctx *context.Context) {
|
||||||
ctx.ServerError("GetProjects", err)
|
ctx.ServerError("GetProjects", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case "watching":
|
||||||
|
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
|
||||||
|
ListOptions: models.ListOptions{
|
||||||
|
PageSize: setting.UI.User.RepoPagingNum,
|
||||||
|
Page: page,
|
||||||
|
},
|
||||||
|
Actor: ctx.User,
|
||||||
|
Keyword: keyword,
|
||||||
|
OrderBy: orderBy,
|
||||||
|
Private: ctx.IsSigned,
|
||||||
|
WatchedByID: ctxUser.ID,
|
||||||
|
Collaborate: util.OptionalBoolFalse,
|
||||||
|
TopicOnly: topicOnly,
|
||||||
|
IncludeDescription: setting.UI.SearchRepoDescription,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("SearchRepository", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
total = int(count)
|
||||||
default:
|
default:
|
||||||
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
|
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
|
||||||
ListOptions: models.ListOptions{
|
ListOptions: models.ListOptions{
|
||||||
|
|
|
@ -157,10 +157,12 @@
|
||||||
{{svg "octicon-person"}}
|
{{svg "octicon-person"}}
|
||||||
{{.i18n.Tr "your_profile"}}<!-- Your profile -->
|
{{.i18n.Tr "your_profile"}}<!-- Your profile -->
|
||||||
</a>
|
</a>
|
||||||
|
{{if not .DisableStars}}
|
||||||
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}?tab=stars">
|
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}?tab=stars">
|
||||||
{{svg "octicon-star"}}
|
{{svg "octicon-star"}}
|
||||||
{{.i18n.Tr "your_starred"}}
|
{{.i18n.Tr "your_starred"}}
|
||||||
</a>
|
</a>
|
||||||
|
{{end}}
|
||||||
<a class="{{if .PageIsUserSettings}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
|
<a class="{{if .PageIsUserSettings}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
|
||||||
{{svg "octicon-tools"}}
|
{{svg "octicon-tools"}}
|
||||||
{{.i18n.Tr "your_settings"}}<!-- Your settings -->
|
{{.i18n.Tr "your_settings"}}<!-- Your settings -->
|
||||||
|
|
|
@ -42,7 +42,9 @@
|
||||||
{{if .PrimaryLanguage }}
|
{{if .PrimaryLanguage }}
|
||||||
<span class="text grey df ac mr-3"><i class="color-icon mr-3" style="background-color: {{.PrimaryLanguage.Color}}"></i>{{ .PrimaryLanguage.Language }}</span>
|
<span class="text grey df ac mr-3"><i class="color-icon mr-3" style="background-color: {{.PrimaryLanguage.Color}}"></i>{{ .PrimaryLanguage.Language }}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if not $.DisableStars}}
|
||||||
<span class="text grey df ac mr-3">{{svg "octicon-star" 16 "mr-3"}}{{.NumStars}}</span>
|
<span class="text grey df ac mr-3">{{svg "octicon-star" 16 "mr-3"}}{{.NumStars}}</span>
|
||||||
|
{{end}}
|
||||||
<span class="text grey df ac mr-3">{{svg "octicon-git-branch" 16 "mr-3"}}{{.NumForks}}</span>
|
<span class="text grey df ac mr-3">{{svg "octicon-git-branch" 16 "mr-3"}}{{.NumForks}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
|
<a class="{{if eq .SortType "reversealphabetically"}}active{{end}} item" href="{{$.Link}}?sort=reversealphabetically&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a>
|
||||||
<a class="{{if eq .SortType "recentupdate"}}active{{end}} item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
|
<a class="{{if eq .SortType "recentupdate"}}active{{end}} item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
|
||||||
<a class="{{if eq .SortType "leastupdate"}}active{{end}} item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
|
<a class="{{if eq .SortType "leastupdate"}}active{{end}} item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
|
||||||
|
{{if not .DisableStars}}
|
||||||
<a class="{{if eq .SortType "moststars"}}active{{end}} item" href="{{$.Link}}?sort=moststars&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.moststars"}}</a>
|
<a class="{{if eq .SortType "moststars"}}active{{end}} item" href="{{$.Link}}?sort=moststars&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.moststars"}}</a>
|
||||||
<a class="{{if eq .SortType "feweststars"}}active{{end}} item" href="{{$.Link}}?sort=feweststars&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.feweststars"}}</a>
|
<a class="{{if eq .SortType "feweststars"}}active{{end}} item" href="{{$.Link}}?sort=feweststars&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.feweststars"}}</a>
|
||||||
|
{{end}}
|
||||||
<a class="{{if eq .SortType "mostforks"}}active{{end}} item" href="{{$.Link}}?sort=mostforks&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.mostforks"}}</a>
|
<a class="{{if eq .SortType "mostforks"}}active{{end}} item" href="{{$.Link}}?sort=mostforks&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.mostforks"}}</a>
|
||||||
<a class="{{if eq .SortType "fewestforks"}}active{{end}} item" href="{{$.Link}}?sort=fewestforks&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.fewestforks"}}</a>
|
<a class="{{if eq .SortType "fewestforks"}}active{{end}} item" href="{{$.Link}}?sort=fewestforks&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.fewestforks"}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{{if not $.DisableStars}}
|
||||||
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star?redirect_to={{$.Link}}">
|
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star?redirect_to={{$.Link}}">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<div class="ui labeled button{{if not $.IsSigned}} poping up{{end}}" tabindex="0"{{if not $.IsSigned}} data-content="{{$.i18n.Tr "repo.star_guest_user" }}" data-position="top center" data-variation="tiny"{{end}}>
|
<div class="ui labeled button{{if not $.IsSigned}} poping up{{end}}" tabindex="0"{{if not $.IsSigned}} data-content="{{$.i18n.Tr "repo.star_guest_user" }}" data-position="top center" data-variation="tiny"{{end}}>
|
||||||
|
@ -82,6 +83,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{{end}}
|
||||||
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
|
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
|
||||||
<div class="ui labeled button{{if not $.CanSignedUserFork}} poping up disabled{{end}}"{{if and (not $.CanSignedUserFork) $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" {{else if not $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_guest_user"}}"{{end}} data-position="top center" data-variation="tiny" tabindex="0">
|
<div class="ui labeled button{{if not $.CanSignedUserFork}} poping up disabled{{end}}"{{if and (not $.CanSignedUserFork) $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" {{else if not $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_guest_user"}}"{{end}} data-position="top center" data-variation="tiny" tabindex="0">
|
||||||
<a class="ui compact small basic button"{{if $.CanSignedUserFork}} href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}>
|
<a class="ui compact small basic button"{{if $.CanSignedUserFork}} href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{end}}>
|
||||||
|
|
|
@ -14151,6 +14151,10 @@
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "MirrorsDisabled"
|
"x-go-name": "MirrorsDisabled"
|
||||||
},
|
},
|
||||||
|
"stars_disabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"x-go-name": "StarsDisabled"
|
||||||
|
},
|
||||||
"time_tracking_disabled": {
|
"time_tracking_disabled": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "TimeTrackingDisabled"
|
"x-go-name": "TimeTrackingDisabled"
|
||||||
|
|
|
@ -130,10 +130,12 @@
|
||||||
{{svg "octicon-archive" 16 "ml-2"}}
|
{{svg "octicon-archive" 16 "ml-2"}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
{{if not .DisableStars}}
|
||||||
<div class="text light grey df ac">
|
<div class="text light grey df ac">
|
||||||
${repo.stars_count}
|
${repo.stars_count}
|
||||||
{{svg "octicon-star" 16 "ml-2"}}
|
{{svg "octicon-star" 16 "ml-2"}}
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -84,16 +84,22 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ui eleven wide column">
|
<div class="ui eleven wide column">
|
||||||
<div class="ui secondary stackable pointing tight menu">
|
<div class="ui secondary stackable pointing tight menu">
|
||||||
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "projects")}}active{{end}} item' href="{{.Owner.HomeLink}}">
|
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "watching") (ne .TabName "projects")}}active{{end}} item' href="{{.Owner.HomeLink}}">
|
||||||
{{svg "octicon-repo"}} {{.i18n.Tr "user.repositories"}}
|
{{svg "octicon-repo"}} {{.i18n.Tr "user.repositories"}}
|
||||||
</a>
|
</a>
|
||||||
<a class='{{if eq .TabName "activity"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=activity">
|
<a class='{{if eq .TabName "activity"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=activity">
|
||||||
{{svg "octicon-rss"}} {{.i18n.Tr "user.activity"}}
|
{{svg "octicon-rss"}} {{.i18n.Tr "user.activity"}}
|
||||||
</a>
|
</a>
|
||||||
|
{{if not .DisableStars}}
|
||||||
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
|
<a class='{{if eq .TabName "stars"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=stars">
|
||||||
{{svg "octicon-star"}} {{.i18n.Tr "user.starred"}}
|
{{svg "octicon-star"}} {{.i18n.Tr "user.starred"}}
|
||||||
<div class="ui label">{{.Owner.NumStars}}</div>
|
<div class="ui label">{{.Owner.NumStars}}</div>
|
||||||
</a>
|
</a>
|
||||||
|
{{else}}
|
||||||
|
<a class='{{if eq .TabName "watching"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=watching">
|
||||||
|
{{svg "octicon-eye"}} {{.i18n.Tr "user.watched"}}
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
<a class='{{if eq .TabName "following"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=following">
|
<a class='{{if eq .TabName "following"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=following">
|
||||||
{{svg "octicon-person"}} {{.i18n.Tr "user.following"}}
|
{{svg "octicon-person"}} {{.i18n.Tr "user.following"}}
|
||||||
<div class="ui label">{{.Owner.NumFollowing}}</div>
|
<div class="ui label">{{.Owner.NumFollowing}}</div>
|
||||||
|
|
Reference in a new issue