Skip to content

[wip] Pin repositories #17952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type Repository struct {
IsEmpty bool `xorm:"INDEX"`
IsArchived bool `xorm:"INDEX"`
IsMirror bool `xorm:"INDEX"`
IsPinned bool
*Mirror `xorm:"-"`
Status RepositoryStatus `xorm:"NOT NULL DEFAULT 0"`

Expand Down
6 changes: 6 additions & 0 deletions modules/structs/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ type Repository struct {
AvatarURL string `json:"avatar_url"`
Internal bool `json:"internal"`
MirrorInterval string `json:"mirror_interval"`
Pinned bool `json:"pinned"`
PinnedOrder int `json:"pinned_order"`
}

// CreateRepoOption options when creating repository
Expand Down Expand Up @@ -180,6 +182,10 @@ type EditRepoOption struct {
Archived *bool `json:"archived,omitempty"`
// set to a string like `8h30m0s` to set the mirror interval time
MirrorInterval *string `json:"mirror_interval,omitempty"`
// pins the repo on the start of the user home page
Pinned *bool `json:"pinned"`
// defines in which order the repo will shown up at the pinned list
PinnedOrder *int `json:"pinned_order"`
}

// GenerateRepoOption options when creating repository using a template
Expand Down
1 change: 1 addition & 0 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ func GetByID(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, convert.ToRepo(repo, perm.AccessMode))
}

//TODO pin repo
// Edit edit repository properties
func Edit(ctx *context.APIContext) {
// swagger:operation PATCH /repos/{owner}/{repo} repository repoEdit
Expand Down
9 changes: 9 additions & 0 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
<label for="website">{{.i18n.Tr "repo.settings.site"}}</label>
<input id="website" name="website" type="url" value="{{.Repository.Website}}">
</div>


<div class="inline field {{if .Err_Pinned}}error{{end}}">
<div class="ui checkbox">
<input name="pinned" type="checkbox" {{if .Repository.IsPinned}}checked{{end}}>
<label>{{.i18n.Tr "repo.PinRepo"}}</label>
</div>
</div>


<div class="field">
<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
Expand Down