Skip to content
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

Feature: Archive repos #5009

Merged
merged 94 commits into from
Jan 23, 2019
Merged
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
16a96f3
Rebased to gitea-master
kolaente Oct 3, 2018
232f71e
Updated gitea/go-sdk
kolaente Oct 5, 2018
fbf39fe
Removed unused setting of status code
kolaente Oct 5, 2018
8655d0e
Added error message if archiving fails
kolaente Oct 5, 2018
6f53048
updated gitea go-sdk
kolaente Oct 5, 2018
b365cd9
Prevent adding/editing/removing of files via web ui when a repo is ar…
kolaente Oct 5, 2018
34c1419
generated swagger
kolaente Oct 5, 2018
a7cc8fa
fmt
kolaente Oct 5, 2018
3877a2d
trigger ci
kolaente Oct 5, 2018
9c366eb
trigger ci
kolaente Oct 5, 2018
4b38053
fixed fmt (make fmt does not work)
kolaente Oct 6, 2018
d94b479
fixed fmt (make fmt does not work)
kolaente Oct 6, 2018
b4fb9cd
Moved check if a repo is archived to appropriate function
kolaente Oct 11, 2018
afa879a
Moved functions to restrict upload/editing of files to a middleware
kolaente Oct 11, 2018
88a916e
Removed deleting repo units to disable issues/pull requests
kolaente Oct 12, 2018
365217a
Fixed lint
kolaente Oct 12, 2018
be792b5
Disabled all possibilities of editing/adding an issue or pull request…
kolaente Oct 12, 2018
0b3a040
Merge branch 'master' into feature/archive-repos
kolaente Oct 12, 2018
88ed10a
Merge branch 'master' into feature/archive-repos
kolaente Oct 13, 2018
5564126
Merge branch 'master' into feature/archive-repos
kolaente Oct 15, 2018
376cb8a
Disabled archiving if the repo is a mirror
kolaente Oct 15, 2018
fa5e308
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
f522479
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
ffed84e
Merge branch 'master' into feature/archive-repos
kolaente Oct 17, 2018
3cee9db
Merge branch 'master' into feature/archive-repos
kolaente Oct 18, 2018
badaed3
Merge branch 'master' into feature/archive-repos
kolaente Oct 18, 2018
587c539
Merge branch 'master' into feature/archive-repos
kolaente Oct 20, 2018
4e51555
Refactored the function a repo is archived
kolaente Oct 20, 2018
7e9928b
Merge branch 'master' into feature/archive-repos
kolaente Oct 20, 2018
35168a2
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Oct 20, 2018
e85bde0
Reset to gitea/master
kolaente Oct 23, 2018
3de3a52
Merge branch 'master' into feature/archive-repos
kolaente Oct 25, 2018
8125e5c
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Oct 25, 2018
d7540c3
regenerated css
kolaente Oct 25, 2018
3717807
Made more clear what its doing by renaming the actions
kolaente Oct 25, 2018
33b1100
merge with gitea-master
kolaente Oct 29, 2018
5b6d3ab
Merge branch 'master' into feature/archive-repos
kolaente Oct 31, 2018
4875328
Merge remote-tracking branch 'origin/feature/archive-repos' into feat…
kolaente Nov 1, 2018
4ba0284
Fixed flash message when archiving a repo
kolaente Nov 1, 2018
427a19d
removed uneeded check
kolaente Nov 3, 2018
abc4769
Merge branch 'master' into feature/archive-repos
kolaente Nov 3, 2018
1845c55
Merge branch 'master' into feature/archive-repos
kolaente Nov 4, 2018
1d4743e
Merge branch 'master' into feature/archive-repos
lunny Nov 5, 2018
e6e6514
Merge branch 'master' into feature/archive-repos
kolaente Nov 5, 2018
52c423a
Merge branch 'master' into feature/archive-repos
kolaente Nov 9, 2018
a907901
Merge branch 'master' into feature/archive-repos
kolaente Nov 21, 2018
ea44530
merge with gitea-master
kolaente Nov 22, 2018
35c043b
update css
kolaente Nov 22, 2018
d839ef3
Merge branch 'master' into feature/archive-repos
kolaente Nov 23, 2018
a1cdf69
Merge branch 'master' into feature/archive-repos
kolaente Nov 23, 2018
5a51757
merge with gitea master
kolaente Nov 29, 2018
d6769d9
update css
kolaente Nov 29, 2018
9ac5878
Merge branch 'master' into feature/archive-repos
kolaente Nov 29, 2018
f14bf50
Merge branch 'master' into feature/archive-repos
kolaente Nov 30, 2018
9c02656
Merge branch 'master' into feature/archive-repos
kolaente Dec 2, 2018
9f79370
Merge branch 'master' into feature/archive-repos
kolaente Dec 2, 2018
21a6ee9
Merge branch 'master' into feature/archive-repos
kolaente Dec 3, 2018
f0558ad
Moved check for being able to edit a file to CanEnableEditor()
kolaente Dec 3, 2018
ff9b36d
language improvements
kolaente Dec 3, 2018
e0ba3c3
should disable all reply buttons on pull requests
kolaente Dec 3, 2018
06b57c4
disable wiki
kolaente Dec 3, 2018
3e3ef92
disable new releases
kolaente Dec 3, 2018
5a2d7a0
disabled repo actions
kolaente Dec 3, 2018
b9e4ef2
Merge branch 'master' into feature/archive-repos
kolaente Dec 8, 2018
f56ebf1
merge with master
kolaente Dec 13, 2018
ee1460c
Merge branch 'master' into feature/archive-repos
kolaente Dec 18, 2018
f58ed26
Merge branch 'master' into feature/archive-repos
kolaente Dec 21, 2018
24cc9a6
Merge branch 'master' into feature/archive-repos
kolaente Dec 22, 2018
14f176e
Merge branch 'master' into feature/archive-repos
kolaente Dec 27, 2018
3f3d4bf
Fix issue unwatch button being displayed
kolaente Dec 27, 2018
6f15e7f
Fix labels or milestone page resulting in 500 error
kolaente Dec 27, 2018
39c9cd5
Fixed milestone not viewable
kolaente Dec 27, 2018
de0c4e0
Disabled branch settings
kolaente Dec 27, 2018
5095950
Added archived icon in repo header
kolaente Dec 27, 2018
d40cbde
merge with gitea-master
kolaente Jan 3, 2019
d1f9402
Merge branch 'master' into feature/archive-repos
kolaente Jan 4, 2019
212b21f
Merge branch 'master' into feature/archive-repos
kolaente Jan 6, 2019
36b947b
Add message if a bare repo is archived
kolaente Jan 6, 2019
feb2c74
Disabled new labels from set if a repo is archived
kolaente Jan 6, 2019
dce82f5
Merge branch 'master' into feature/archive-repos
kolaente Jan 7, 2019
a07b36b
Merge branch 'master' into feature/archive-repos
kolaente Jan 8, 2019
dcaefdb
Merge branch 'master' into feature/archive-repos
kolaente Jan 11, 2019
4cf4278
Merge branch 'master' into feature/archive-repos
kolaente Jan 11, 2019
b4de2fe
Merge branch 'master' into feature/archive-repos
kolaente Jan 12, 2019
8af6f25
Merge branch 'master' into feature/archive-repos
kolaente Jan 13, 2019
37977a2
Merge branch 'master' into feature/archive-repos
kolaente Jan 14, 2019
8bb4bb2
Merge branch 'master' into feature/archive-repos
kolaente Jan 14, 2019
c60da13
Merge branch 'master' into feature/archive-repos
kolaente Jan 16, 2019
559b4cf
Merge branch 'master' into feature/archive-repos
kolaente Jan 17, 2019
06b99c9
merge with master
kolaente Jan 20, 2019
280baa5
merge with master
kolaente Jan 22, 2019
0a118f0
Merge branch 'master' into feature/archive-repos
kolaente Jan 22, 2019
71d9305
Fixed wrong order of ignerr
kolaente Jan 22, 2019
746f9a9
merge with gitea-master
kolaente Jan 23, 2019
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
13 changes: 11 additions & 2 deletions models/repo.go
Original file line number Diff line number Diff line change
@@ -186,8 +186,9 @@ type Repository struct {
NumOpenMilestones int `xorm:"-"`
NumReleases int `xorm:"-"`

IsPrivate bool `xorm:"INDEX"`
IsEmpty bool `xorm:"INDEX"`
IsPrivate bool `xorm:"INDEX"`
IsEmpty bool `xorm:"INDEX"`
IsArchived bool `xorm:"INDEX"`

IsMirror bool `xorm:"INDEX"`
*Mirror `xorm:"-"`
@@ -292,6 +293,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
Description: repo.Description,
Private: repo.IsPrivate,
Empty: repo.IsEmpty,
Archived: repo.IsArchived,
Size: int(repo.Size / 1024),
Fork: repo.IsFork,
Parent: parent,
@@ -2341,6 +2343,13 @@ func CheckRepoStats() {
// ***** END: Repository.NumForks *****
}

// SetArchiveRepoState sets if a repo is archived
func (repo *Repository) SetArchiveRepoState(isArchived bool) (err error) {
repo.IsArchived = isArchived
_, err = x.Where("id = ?", repo.ID).Cols("is_archived").Update(repo)
return
}

// ___________ __
// \_ _____/__________| | __
// | __)/ _ \_ __ \ |/ /
1 change: 1 addition & 0 deletions modules/auth/repo_form.go
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@ type RepoSettingForm struct {
EnableTimetracker bool
AllowOnlyContributorsToTrackTime bool
EnableIssueDependencies bool
IsArchived bool

// Admin settings
EnableHealthCheck bool
11 changes: 10 additions & 1 deletion modules/context/repo.go
Original file line number Diff line number Diff line change
@@ -56,14 +56,23 @@ type Repository struct {

// CanEnableEditor returns true if repository is editable and user has proper access level.
func (r *Repository) CanEnableEditor() bool {
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanEnableEditor() && r.IsViewBranch && !r.Repository.IsArchived
}

// CanCreateBranch returns true if repository is editable and user has proper access level.
func (r *Repository) CanCreateBranch() bool {
return r.Permission.CanWrite(models.UnitTypeCode) && r.Repository.CanCreateBranch()
}

// RepoMustNotBeArchived checks if a repo is archived
func RepoMustNotBeArchived() macaron.Handler {
return func(ctx *Context) {
if ctx.Repo.Repository.IsArchived {
ctx.NotFound("IsArchived", fmt.Errorf(ctx.Tr("repo.archive.title")))
}
}
}

// CanCommitToBranch returns true if repository is editable and user has proper access level
// and branch is not protected for push
func (r *Repository) CanCommitToBranch(doer *models.User) (bool, error) {
16 changes: 16 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
@@ -542,6 +542,10 @@ forks = Forks
pick_reaction = Pick your reaction
reactions_more = and %d more

archive.title = This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
archive.issue.nocomment = This repo is archived. You cannot comment on issues.
archive.pull.nocomment = This repo is archived. You cannot comment on pull requests.

form.reach_limit_of_creation = You have already reached your limit of %d repositories.
form.name_reserved = The repository name '%s' is reserved.
form.name_pattern_not_allowed = The pattern '%s' is not allowed in a repository name.
@@ -1176,6 +1180,18 @@ settings.choose_branch = Choose a branch…
settings.no_protected_branch = There are no protected branches.
settings.edit_protected_branch = Edit
settings.protected_branch_required_approvals_min = Required approvals cannot be negative.
settings.archive.button = Archive Repo
settings.archive.header = Archive This Repo
settings.archive.text = Archiving the repo will make it entirely read-only. It is hidden from the dashboard, cannot be committed to and no issues or pull-requests can be created.
settings.archive.success = The repo was successfully archived.
settings.archive.error = An error occured while trying to archive the repo. See the log for more details.
settings.archive.error_ismirror = You cannot archive a mirrored repo.
settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived.
settings.unarchive.button = Un-Archive Repo
settings.unarchive.header = Un-Archive This Repo
settings.unarchive.text = Un-Archiving the repo will restore its ability to recieve commits and pushes, as well as new issues and pull-requests.
settings.unarchive.success = The repo was successfully un-archived.
settings.unarchive.error = An error occured while trying to un-archive the repo. See the log for more details.

diff.browse_source = Browse Source
diff.parent = parent
2 changes: 1 addition & 1 deletion public/css/index.css

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions public/less/_base.less
Original file line number Diff line number Diff line change
@@ -629,3 +629,11 @@ footer {
.heatmap-color-5 {
background-color: #2f6b1b;
}

.archived-icon{
color: lighten(#000, 70%) !important;
}

.archived-icon{
color: lighten(#000, 70%) !important;
}
6 changes: 6 additions & 0 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
@@ -95,6 +95,12 @@ func HTTP(ctx *context.Context) {
return
}

// Don't allow pushing if the repo is archived
if repo.IsArchived && !isPull {
ctx.HandleText(http.StatusForbidden, "This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.")
return
}

// Only public pull don't need auth.
isPublicPull := !repo.IsPrivate && isPull
var (
2 changes: 1 addition & 1 deletion routers/repo/release.go
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ func Releases(ctx *context.Context) {
}

writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases)
ctx.Data["CanCreateRelease"] = writeAccess
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived

opts := models.FindReleasesOptions{
IncludeDrafts: writeAccess,
41 changes: 41 additions & 0 deletions routers/repo/setting.go
Original file line number Diff line number Diff line change
@@ -354,6 +354,47 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
ctx.Flash.Success(ctx.Tr("repo.settings.wiki_deletion_success"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")

case "archive":
if !ctx.Repo.IsOwner() {
ctx.Error(403)
return
}

if repo.IsMirror {
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error_ismirror"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

if err := repo.SetArchiveRepoState(true); err != nil {
log.Error(4, "Tried to archive a repo: %s", err)
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

ctx.Flash.Success(ctx.Tr("repo.settings.archive.success"))

log.Trace("Repository was archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
case "unarchive":
if !ctx.Repo.IsOwner() {
ctx.Error(403)
return
}

if err := repo.SetArchiveRepoState(false); err != nil {
log.Error(4, "Tried to unarchive a repo: %s", err)
ctx.Flash.Error(ctx.Tr("repo.settings.unarchive.error"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
return
}

ctx.Flash.Success(ctx.Tr("repo.settings.unarchive.success"))

log.Trace("Repository was un-archived: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Redirect(ctx.Repo.RepoLink + "/settings")

default:
ctx.NotFound("", nil)
}
4 changes: 2 additions & 2 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
@@ -151,8 +151,8 @@ func renderDirectory(ctx *context.Context, treeLink string) {

// Check permission to add or upload new file.
if ctx.Repo.CanWrite(models.UnitTypeCode) && ctx.Repo.IsViewBranch {
ctx.Data["CanAddFile"] = true
ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled
ctx.Data["CanAddFile"] = !ctx.Repo.Repository.IsArchived
ctx.Data["CanUploadFile"] = setting.Repository.Upload.Enabled && !ctx.Repo.Repository.IsArchived
}
}

4 changes: 2 additions & 2 deletions routers/repo/wiki.go
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
// Wiki renders single wiki page
func Wiki(ctx *context.Context) {
ctx.Data["PageIsWiki"] = true
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki)
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki) && !ctx.Repo.Repository.IsArchived

if !ctx.Repo.Repository.HasWiki() {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
@@ -246,7 +246,7 @@ func WikiPages(ctx *context.Context) {

ctx.Data["Title"] = ctx.Tr("repo.wiki.pages")
ctx.Data["PageIsWiki"] = true
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki)
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(models.UnitTypeWiki) && !ctx.Repo.Repository.IsArchived

wikiRepo, commit, err := findWikiRepoCommit(ctx)
if err != nil {
34 changes: 17 additions & 17 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
@@ -492,7 +492,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/branches", func() {
m.Combo("").Get(repo.ProtectedBranch).Post(repo.ProtectedBranchPost)
m.Combo("/*").Get(repo.SettingsProtectedBranch).
Post(bindIgnErr(auth.ProtectBranchForm{}), repo.SettingsProtectedBranchPost)
Post(bindIgnErr(auth.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo.SettingsProtectedBranchPost)
}, repo.MustBeNotEmpty)

m.Group("/hooks", func() {
@@ -530,13 +530,13 @@ func RegisterRoutes(m *macaron.Macaron) {
})
}, reqSignIn, context.RepoAssignment(), reqRepoAdmin, context.UnitTypes(), context.RepoRef())

m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), repo.Action)
m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.RepoMustNotBeArchived(), repo.Action)

m.Group("/:username/:reponame", func() {
m.Group("/issues", func() {
m.Combo("/new").Get(context.RepoRef(), repo.NewIssue).
Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)
}, reqRepoIssueReader)
}, context.RepoMustNotBeArchived(), reqRepoIssueReader)
// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
// So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() {
@@ -557,32 +557,32 @@ func RegisterRoutes(m *macaron.Macaron) {
})
})
m.Post("/reactions/:action", bindIgnErr(auth.ReactionForm{}), repo.ChangeIssueReaction)
})
}, context.RepoMustNotBeArchived())

m.Post("/labels", reqRepoIssuesOrPullsWriter, repo.UpdateIssueLabel)
m.Post("/milestone", reqRepoIssuesOrPullsWriter, repo.UpdateIssueMilestone)
m.Post("/assignee", reqRepoIssuesOrPullsWriter, repo.UpdateIssueAssignee)
m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus)
})
}, context.RepoMustNotBeArchived())
m.Group("/comments/:id", func() {
m.Post("", repo.UpdateCommentContent)
m.Post("/delete", repo.DeleteComment)
m.Post("/reactions/:action", bindIgnErr(auth.ReactionForm{}), repo.ChangeCommentReaction)
})
}, context.RepoMustNotBeArchived())
m.Group("/labels", func() {
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
m.Post("/delete", repo.DeleteLabel)
m.Post("/initialize", bindIgnErr(auth.InitializeLabelsForm{}), repo.InitializeLabels)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
m.Group("/milestones", func() {
m.Combo("/new").Get(repo.NewMilestone).
Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
m.Get("/:id/edit", repo.EditMilestone)
m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
m.Get("/:id/:action", repo.ChangeMilestonStatus)
m.Post("/delete", repo.DeleteMilestone)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
m.Group("/milestone", func() {
m.Get("/:id", repo.MilestoneIssuesAndPulls)
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
@@ -607,7 +607,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/upload-file", repo.UploadFileToServer)
m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
}, context.RepoRef(), repo.MustBeEditable, repo.MustBeAbleToUpload)
}, reqRepoCodeWriter, repo.MustBeNotEmpty)
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty)

m.Group("/branches", func() {
m.Group("/_new/", func() {
@@ -617,7 +617,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, bindIgnErr(auth.NewBranchForm{}))
m.Post("/delete", repo.DeleteBranchPost)
m.Post("/restore", repo.RestoreBranchPost)
}, reqRepoCodeWriter, repo.MustBeNotEmpty)
}, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty)

}, reqSignIn, context.RepoAssignment(), context.UnitTypes())

@@ -630,11 +630,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/new", repo.NewRelease)
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
m.Post("/delete", repo.DeleteRelease)
}, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, context.RepoRef())
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef())
m.Group("/releases", func() {
m.Get("/edit/*", repo.EditRelease)
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
}, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, func(ctx *context.Context) {
}, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, func(ctx *context.Context) {
var err error
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
if err != nil {
@@ -652,7 +652,7 @@ func RegisterRoutes(m *macaron.Macaron) {

m.Group("/:username/:reponame", func() {
m.Post("/topics", repo.TopicsPost)
}, context.RepoAssignment(), reqRepoAdmin)
}, context.RepoMustNotBeArchived(), context.RepoAssignment(), reqRepoAdmin)

m.Group("/:username/:reponame", func() {
m.Group("", func() {
@@ -672,7 +672,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Combo("/:page/_edit").Get(repo.EditWiki).
Post(bindIgnErr(auth.NewWikiForm{}), repo.EditWikiPost)
m.Post("/:page/delete", repo.DeleteWikiPagePost)
}, reqSignIn, reqRepoWikiWriter)
}, context.RepoMustNotBeArchived(), reqSignIn, reqRepoWikiWriter)
}, repo.MustEnableWiki, context.RepoRef())

m.Group("/wiki", func() {
@@ -694,14 +694,14 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get(".diff", repo.DownloadPullDiff)
m.Get(".patch", repo.DownloadPullPatch)
m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
m.Post("/merge", reqRepoPullsWriter, bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/cleanup", context.RepoRef(), repo.CleanUpPullRequest)
m.Post("/merge", context.RepoMustNotBeArchived(), reqRepoPullsWriter, bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this will delete the branch on the head repository not the base repository. For example. there are some pull requests merged but not clean up on the base repository, but then it's archived. Then should user delete head repository's branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean we should still enable the possiblity to still clean it when its archived?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, need more discuss.

m.Group("/files", func() {
m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.ViewPullFiles)
m.Group("/reviews", func() {
m.Post("/comments", bindIgnErr(auth.CodeCommentForm{}), repo.CreateCodeComment)
m.Post("/submit", bindIgnErr(auth.SubmitReviewForm{}), repo.SubmitReview)
})
}, context.RepoMustNotBeArchived())
})
}, repo.MustAllowPulls)

5 changes: 4 additions & 1 deletion templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
@@ -2,7 +2,10 @@
{{range .Repos}}
<div class="item">
<div class="ui header">
<a class="name" href="{{.Link}}">{{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}}</a>
<a class="name" href="{{.Link}}">
{{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}}
{{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}}
</a>
{{if .IsPrivate}}
<span class="text gold"><i class="octicon octicon-lock"></i></span>
{{else if .IsFork}}
48 changes: 25 additions & 23 deletions templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
{{end}}
<a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
{{if and .PageIsPullFiles $.SignedUserID}}
{{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
{{template "repo/diff/new_review" .}}
{{end}}
</div>
@@ -27,7 +27,7 @@
<a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
{{end}}
<a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
{{if and .PageIsPullFiles $.SignedUserID}}
{{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
{{template "repo/diff/new_review" .}}
{{end}}
</div>
@@ -194,27 +194,29 @@
</div>
{{end}}

<div id="pull_review_add_comment" class="hide">
{{template "repo/diff/new_comment" dict "root" .}}
</div>
<div class="hide" id="edit-content-form">
<div class="ui comment form">
<div class="ui top attached tabular menu">
<a class="active write item">{{$.i18n.Tr "write"}}</a>
<a class="preview item" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
</div>
<div class="ui bottom attached active write tab segment">
<textarea tabindex="1" name="content"></textarea>
</div>
<div class="ui bottom attached tab preview segment markdown">
{{$.i18n.Tr "loading"}}
</div>
<div class="text right edit buttons">
<div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
<div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
</div>
</div>
</div>
{{if not $.Repository.IsArchived}}
<div id="pull_review_add_comment" class="hide">
{{template "repo/diff/new_comment" dict "root" .}}
</div>
<div class="hide" id="edit-content-form">
<div class="ui comment form">
<div class="ui top attached tabular menu">
<a class="active write item">{{$.i18n.Tr "write"}}</a>
<a class="preview item" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
</div>
<div class="ui bottom attached active write tab segment">
<textarea tabindex="1" name="content"></textarea>
</div>
<div class="ui bottom attached tab preview segment markdown">
{{$.i18n.Tr "loading"}}
</div>
<div class="text right edit buttons">
<div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
<div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
</div>
</div>
</div>
{{end}}

{{if .IsSplitStyle}}
<script>
2 changes: 1 addition & 1 deletion templates/repo/diff/comment_form.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{if $.root.SignedUserID}}
{{if and $.root.SignedUserID (not $.Repository.IsArchived)}}
{{if $.hidden}}
<button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> {{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>
{{end}}
32 changes: 20 additions & 12 deletions templates/repo/empty.tmpl
Original file line number Diff line number Diff line change
@@ -5,6 +5,11 @@
<div class="ui grid">
<div class="sixteen wide column content">
{{template "base/alert" .}}
{{if .Repository.IsArchived}}
<div class="ui warning message">
{{.i18n.Tr "repo.archive.title"}}
</div>
{{end}}
{{if .CanWriteCode}}
<h4 class="ui top attached header">
{{.i18n.Tr "repo.quick_guide"}}
@@ -35,28 +40,31 @@
{{end}}
</div>
</div>
<div class="ui divider"></div>

<div class="item">
<h3>{{.i18n.Tr "repo.create_new_repo_command"}}</h3>
<div class="markdown">
<pre><code>touch README.md
{{if not .Repository.IsArchived}}
<div class="ui divider"></div>

<div class="item">
<h3>{{.i18n.Tr "repo.create_new_repo_command"}}</h3>
<div class="markdown">
<pre><code>touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
git push -u origin master</code></pre>
</div>
</div>
</div>
<div class="ui divider"></div>
<div class="ui divider"></div>

<div class="item">
<h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
<div class="markdown">
<pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
<div class="item">
<h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
<div class="markdown">
<pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
git push -u origin master</code></pre>
</div>
</div>
</div>
{{end}}
{{else}}
<div class="ui segment center">
{{.i18n.Tr "repo.empty_message"}}
1 change: 1 addition & 0 deletions templates/repo/header.tmpl
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
<div class="divider"> / </div>
<a href="{{$.RepoLink}}">{{.Name}}</a>
{{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}}
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}}
</div>
5 changes: 5 additions & 0 deletions templates/repo/home.tmpl
Original file line number Diff line number Diff line change
@@ -50,6 +50,11 @@
<span id="count_prompt">{{.i18n.Tr "repo.topic.count_prompt"}}</span>
<span id="format_prompt">{{.i18n.Tr "repo.topic.format_prompt"}}</span>
</div>
{{if .Repository.IsArchived}}
<div class="ui warning message">
{{.i18n.Tr "repo.archive.title"}}
</div>
{{end}}
{{template "repo/sub_menu" .}}
<div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
{{if and .PullRequestCtx.Allowed .IsViewBranch}}
58 changes: 30 additions & 28 deletions templates/repo/issue/labels.tmpl
Original file line number Diff line number Diff line change
@@ -4,39 +4,41 @@
<div class="ui container">
<div class="navbar">
{{template "repo/issue/navbar" .}}
{{if or .CanWriteIssues .CanWritePulls}}
{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}}
<div class="ui right">
<div class="ui green new-label button">{{.i18n.Tr "repo.issues.new_label"}}</div>
</div>
{{end}}
</div>
<div class="ui new-label segment hide">
<form class="ui form" action="{{$.RepoLink}}/labels/new" method="post">
{{.CsrfTokenHtml}}
<div class="ui grid">
<div class="three wide column">
<div class="ui small input">
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
{{if not .Repository.IsArchived}}
<div class="ui new-label segment hide">
<form class="ui form" action="{{$.RepoLink}}/labels/new" method="post">
{{.CsrfTokenHtml}}
<div class="ui grid">
<div class="three wide column">
<div class="ui small input">
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
</div>
</div>
</div>
<div class="five wide column">
<div class="ui small fluid input">
<input class="new-label-desc-input" name="description" placeholder="{{.i18n.Tr "repo.issues.new_label_desc_placeholder"}}">
<div class="five wide column">
<div class="ui small fluid input">
<input class="new-label-desc-input" name="description" placeholder="{{.i18n.Tr "repo.issues.new_label_desc_placeholder"}}">
</div>
</div>
<div class="color picker column">
<input class="color-picker" name="color" value="#70c24a" required>
</div>
<div class="column precolors">
{{template "repo/issue/label_precolors"}}
</div>
<div class="buttons">
<div class="ui blue small basic cancel button">{{.i18n.Tr "repo.milestones.cancel"}}</div>
<button class="ui green small button">{{.i18n.Tr "repo.issues.create_label"}}</button>
</div>
</div>
<div class="color picker column">
<input class="color-picker" name="color" value="#70c24a" required>
</div>
<div class="column precolors">
{{template "repo/issue/label_precolors"}}
</div>
<div class="buttons">
<div class="ui blue small basic cancel button">{{.i18n.Tr "repo.milestones.cancel"}}</div>
<button class="ui green small button">{{.i18n.Tr "repo.issues.create_label"}}</button>
</div>
</div>
</form>
</div>
</form>
</div>
{{end}}
<div class="ui divider"></div>

<div class="ui right floated secondary filter menu">
@@ -57,7 +59,7 @@
{{template "base/alert" .}}
<div class="ui black label">{{.i18n.Tr "repo.issues.label_count" .NumLabels}}</div>
<div class="label list">
{{if and (or $.CanWriteIssues $.CanWritePulls) (eq .NumLabels 0)}}
{{if and (or $.CanWriteIssues $.CanWritePulls) (eq .NumLabels 0) (not $.Repository.IsArchived) }}
<div class="ui centered grid">
<div class="twelve wide column eight wide computer column">
<div class="ui attached left aligned segment">
@@ -105,7 +107,7 @@
<a class="ui right open-issues" href="{{$.RepoLink}}/issues?labels={{.ID}}"><i class="octicon octicon-issue-opened"></i> {{$.i18n.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a>
</div>
<div class="three wide column">
{{if or $.CanWriteIssues $.CanWritePulls}}
{{if and (not $.Repository.IsArchived) (or $.CanWriteIssues $.CanWritePulls)}}
<a class="ui right delete-button" href="#" data-url="{{$.RepoLink}}/labels/delete" data-id="{{.ID}}"><i class="octicon octicon-trashcan"></i> {{$.i18n.Tr "repo.issues.label_delete"}}</a>
<a class="ui right edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" data-description="{{.Description}}" data-color={{.Color}}><i class="octicon octicon-pencil"></i> {{$.i18n.Tr "repo.issues.label_edit"}}</a>
{{end}}
@@ -117,7 +119,7 @@
</div>
</div>

{{if or $.CanWriteIssues $.CanWritePulls}}
{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}}
<div class="ui small basic delete modal">
<div class="ui icon header">
<i class="trash icon"></i>
16 changes: 9 additions & 7 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
@@ -9,13 +9,15 @@
<div class="column center aligned">
{{template "repo/issue/search" .}}
</div>
<div class="column right aligned">
{{if .PageIsIssueList}}
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
{{else}}
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.PullRequestCtx.BaseRepo.Link}}/compare/{{.Repository.DefaultBranch}}...{{.PullRequestCtx.HeadInfo}}{{end}}">{{.i18n.Tr "repo.pulls.new"}}</a>
{{end}}
</div>
{{if not .Repository.IsArchived}}
<div class="column right aligned">
{{if .PageIsIssueList}}
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
{{else}}
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.PullRequestCtx.BaseRepo.Link}}/compare/{{.Repository.DefaultBranch}}...{{.PullRequestCtx.HeadInfo}}{{end}}">{{.i18n.Tr "repo.pulls.new"}}</a>
{{end}}
</div>
{{end}}
</div>
<div class="ui divider"></div>
<div id="issue-filters" class="ui stackable grid">
10 changes: 6 additions & 4 deletions templates/repo/issue/milestone_issues.tmpl
Original file line number Diff line number Diff line change
@@ -9,10 +9,12 @@
<div class="column center aligned">

</div>
<div class="column right aligned">
<a class="ui grey button" href="{{.RepoLink}}/milestones/{{.MilestoneID}}/edit">{{.i18n.Tr "repo.milestones.edit"}}</a>
<a class="ui green button" href="{{.RepoLink}}/issues/new?milestone={{.MilestoneID}}">{{.i18n.Tr "repo.issues.new"}}</a>
</div>
{{if not .Repository.IsArchived}}
<div class="column right aligned">
<a class="ui grey button" href="{{.RepoLink}}/milestones/{{.MilestoneID}}/edit">{{.i18n.Tr "repo.milestones.edit"}}</a>
<a class="ui green button" href="{{.RepoLink}}/issues/new?milestone={{.MilestoneID}}">{{.i18n.Tr "repo.issues.new"}}</a>
</div>
{{end}}
</div>
<div class="ui one column stackable grid">
<div class="column">
4 changes: 2 additions & 2 deletions templates/repo/issue/milestones.tmpl
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<div class="ui container">
<div class="navbar">
{{template "repo/issue/navbar" .}}
{{if or .CanWriteIssues .CanWritePulls}}
{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}}
<div class="ui right">
<a class="ui green button" href="{{$.Link}}/new">{{.i18n.Tr "repo.milestones.new"}}</a>
</div>
@@ -67,7 +67,7 @@
{{if .TotalTrackedTime}}<i class="octicon octicon-clock"></i> {{.TotalTrackedTime|Sec2Time}}{{end}}
</span>
</div>
{{if or $.CanWriteIssues $.CanWritePulls}}
{{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}}
<div class="ui right operate">
<a href="{{$.Link}}/{{.ID}}/edit" data-id={{.ID}} data-title={{.Name}}><i class="octicon octicon-pencil"></i> {{$.i18n.Tr "repo.issues.label_edit"}}</a>
{{if .IsClosed}}
16 changes: 9 additions & 7 deletions templates/repo/issue/view.tmpl
Original file line number Diff line number Diff line change
@@ -6,13 +6,15 @@
<div class="column">
{{template "repo/issue/navbar" .}}
</div>
<div class="column right aligned">
{{if .PageIsIssueList}}
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
{{else}}
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName | EscapePound}}...{{.PullRequestCtx.HeadInfo | EscapePound}}">{{.i18n.Tr "repo.pulls.new"}}</a>
{{end}}
</div>
{{if not .Repository.IsArchived}}
<div class="column right aligned">
{{if .PageIsIssueList}}
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
{{else}}
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName | EscapePound}}...{{.PullRequestCtx.HeadInfo | EscapePound}}">{{.i18n.Tr "repo.pulls.new"}}</a>
{{end}}
</div>
{{end}}
</div>
<div class="ui divider"></div>
{{if .Issue.IsPull}}
92 changes: 52 additions & 40 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
@@ -18,14 +18,16 @@
<div class="content">
<div class="ui top attached header">
<span class="text grey"><a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span>
<div class="ui right actions">
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }}
{{if or .IsIssueWriter .IsIssuePoster}}
<div class="item action">
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
</div>
{{end}}
</div>
{{if not $.Repository.IsArchived}}
<div class="ui right actions">
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }}
{{if or .IsIssueWriter .IsIssuePoster}}
<div class="item action">
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
</div>
{{end}}
</div>
{{end}}
</div>
<div class="ui attached segment">
<div class="render-content markdown has-emoji">
@@ -64,43 +66,53 @@

{{ template "repo/issue/view_content/comments" . }}

{{if .Issue.IsPull}}
{{if and .Issue.IsPull (not $.Repository.IsArchived)}}
{{ template "repo/issue/view_content/pull". }}
{{end}}

{{if .IsSigned}}
<div class="comment form">
<a class="avatar" href="{{.SignedUser.HomeLink}}">
<img src="{{.SignedUser.RelAvatarLink}}">
</a>
<div class="content">
<form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
{{template "repo/issue/comment_tab" .}}
{{.CsrfTokenHtml}}
<input id="status" name="status" type="hidden">
<div class="text right">
{{if and (or .IsIssueWriter .IsIssuePoster) (not .DisableStatusChange)}}
{{if .Issue.IsClosed}}
<div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen">
{{.i18n.Tr "repo.issues.reopen_issue"}}
</div>
{{else}}
<div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.close_comment_issue"}}" data-status-val="close">
{{.i18n.Tr "repo.issues.close_issue"}}
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>
</form>
</div>
</div>
{{else}}
{{if .Repository.IsArchived}}
<div class="ui warning message">
{{.i18n.Tr "repo.issues.sign_in_require_desc" .SignInLink | Safe}}
{{if .Issue.IsPull}}
{{.i18n.Tr "repo.archive.pull.nocomment"}}
{{else}}
{{.i18n.Tr "repo.archive.issue.nocomment"}}
{{end}}
</div>
{{else}}
{{if .IsSigned}}
<div class="comment form">
<a class="avatar" href="{{.SignedUser.HomeLink}}">
<img src="{{.SignedUser.RelAvatarLink}}">
</a>
<div class="content">
<form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
{{template "repo/issue/comment_tab" .}}
{{.CsrfTokenHtml}}
<input id="status" name="status" type="hidden">
<div class="text right">
{{if and (or .IsIssueWriter .IsIssuePoster) (not .DisableStatusChange)}}
{{if .Issue.IsClosed}}
<div id="status-button" class="ui green basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.reopen_comment_issue"}}" data-status-val="reopen">
{{.i18n.Tr "repo.issues.reopen_issue"}}
</div>
{{else}}
<div id="status-button" class="ui red basic button" tabindex="6" data-status="{{.i18n.Tr "repo.issues.close_issue"}}" data-status-and-comment="{{.i18n.Tr "repo.issues.close_comment_issue"}}" data-status-val="close">
{{.i18n.Tr "repo.issues.close_issue"}}
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>
</form>
</div>
</div>
{{else}}
<div class="ui warning message">
{{.i18n.Tr "repo.issues.sign_in_require_desc" .SignInLink | Safe}}
</div>
{{end}}
{{end}}
</ui>
</div>
42 changes: 22 additions & 20 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
@@ -10,26 +10,28 @@
<div class="content">
<div class="ui top attached header">
<span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
<div class="ui right actions">
{{if gt .ShowTag 0}}
<div class="item tag">
{{if eq .ShowTag 1}}
{{$.i18n.Tr "repo.issues.poster"}}
{{else if eq .ShowTag 2}}
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .ShowTag 3}}
{{$.i18n.Tr "repo.issues.owner"}}
{{end}}
</div>
{{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
{{if or $.Permission.IsAdmin (eq .Poster.ID $.SignedUserID)}}
<div class="item action">
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
<a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a>
</div>
{{end}}
</div>
{{if not $.Repository.IsArchived}}
<div class="ui right actions">
{{if gt .ShowTag 0}}
<div class="item tag">
{{if eq .ShowTag 1}}
{{$.i18n.Tr "repo.issues.poster"}}
{{else if eq .ShowTag 2}}
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .ShowTag 3}}
{{$.i18n.Tr "repo.issues.owner"}}
{{end}}
</div>
{{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
{{if or $.Permission.IsAdmin (eq .Poster.ID $.SignedUserID)}}
<div class="item action">
<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
<a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a>
</div>
{{end}}
</div>
{{end}}
</div>
<div class="ui attached segment">
<div class="render-content markdown has-emoji">
22 changes: 11 additions & 11 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<div class="ui segment metas">
{{template "repo/issue/branch_selector_field" .}}

<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-label dropdown">
<div class="ui {{if or (not .IsIssueWriter) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown">
<span class="text">
<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
<span class="octicon octicon-gear"></span>
@@ -27,7 +27,7 @@

<div class="ui divider"></div>

<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-milestone dropdown">
<div class="ui {{if or (not .IsIssueWriter) .Repository.IsArchived}}disabled{{end}} floating jump select-milestone dropdown">
<span class="text">
<strong>{{.i18n.Tr "repo.issues.new.milestone"}}</strong>
<span class="octicon octicon-gear"></span>
@@ -68,7 +68,7 @@
<div class="ui divider"></div>

<input id="assignee_id" name="assignee_id" type="hidden" value="{{.assignee_id}}">
<div class="ui {{if not .IsIssueWriter}}disabled{{end}} floating jump select-assignees-modify dropdown">
<div class="ui {{if or (not .IsIssueWriter) .Repository.IsArchived}}disabled{{end}} floating jump select-assignees-modify dropdown">
<span class="text">
<strong>{{.i18n.Tr "repo.issues.new.assignees"}}</strong>
<span class="octicon octicon-gear"></span>
@@ -119,7 +119,7 @@
</div>
</div>

{{if $.IssueWatch}}
{{if and $.IssueWatch (not .Repository.IsArchived)}}
<div class="ui divider"></div>

<div class="ui watching">
@@ -142,7 +142,7 @@
</div>
{{end}}
{{if .Repository.IsTimetrackerEnabled }}
{{if .CanUseTimetracker }}
{{if and .CanUseTimetracker (not .Repository.IsArchived)}}
<div class="ui divider"></div>
<div class="ui timetrack">
<span class="text"><strong>{{.i18n.Tr "repo.issues.tracker"}}</strong></span>
@@ -223,7 +223,7 @@
{{if .Issue.IsOverdue}}
<span style="color: red;">{{.i18n.Tr "repo.issues.due_date_overdue"}}</span>
{{end}}
{{if .IsIssueWriter}}
{{if and .IsIssueWriter (not .Repository.IsArchived)}}
<br/>
<a style="cursor:pointer;" onclick="toggleDeadlineForm();"><i class="edit icon"></i>{{$.i18n.Tr "repo.issues.due_date_form_edit"}}</a> -
<a style="cursor:pointer;" onclick="updateDeadline('');"><i class="remove icon"></i>{{$.i18n.Tr "repo.issues.due_date_form_remove"}}</a>
@@ -233,7 +233,7 @@
<p><i>{{.i18n.Tr "repo.issues.due_date_not_set"}}</i></p>
{{end}}

{{if .IsIssueWriter}}
{{if and .IsIssueWriter (not .Repository.IsArchived)}}
<div {{if ne .Issue.DeadlineUnix 0}} style="display: none;"{{end}} id="deadlineForm">
<form class="ui fluid action input" action="{{AppSubUrl}}/api/v1/repos/{{.Repository.Owner.Name}}/{{.Repository.Name}}/issues/{{.Issue.Index}}" method="post" id="update-issue-deadline-form" onsubmit="setDeadline();return false;">
{{$.CsrfTokenHtml}}
@@ -278,7 +278,7 @@
<div class="ui black label">#{{.Index}}</div>
<a class="title has-emoji" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title}}</a>
<div class="ui transparent label right floated">
{{if $.CanCreateIssueDependencies}}
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.ID}}, 'blocking');"
data-tooltip="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
<i class="delete icon text red"></i>
@@ -304,7 +304,7 @@
<div class="ui black label">#{{.Index}}</div>
<a class="title has-emoji" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title}}</a>
<div class="ui transparent label right floated">
{{if $.CanCreateIssueDependencies}}
{{if and $.CanCreateIssueDependencies (not $.IsArchived)}}
<a class="delete-dependency-button" onclick="deleteDependencyModal({{.ID}}, 'blockedBy');"
data-tooltip="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
<i class="delete icon text red"></i>
@@ -316,7 +316,7 @@
</div>
{{end}}

{{if .CanCreateIssueDependencies}}
{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}}
<div>
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/dependency/add" id="addDependencyForm">
{{$.CsrfTokenHtml}}
@@ -337,7 +337,7 @@
</div>
</div>
</div>
{{if .CanCreateIssueDependencies}}
{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}}
<input type="hidden" id="repolink" value="{{$.RepoRelPath}}">
<!-- I know, there is probably a better way to do this -->
<input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/>
2 changes: 1 addition & 1 deletion templates/repo/issue/view_title.tmpl
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<input value="{{.Issue.Title}}">
</div>
</h1>
{{if or .IsIssueWriter .IsIssuePoster}}
{{if and (or .IsIssueWriter .IsIssuePoster) (not .Repository.IsArchived)}}
<div class="four wide column">
<div class="edit-zone text right">
<div id="edit-title" class="ui basic green not-in-edit button">{{.i18n.Tr "repo.issues.edit"}}</div>
126 changes: 66 additions & 60 deletions templates/repo/settings/branches.tmpl
Original file line number Diff line number Diff line change
@@ -4,74 +4,80 @@
{{template "repo/settings/navbar" .}}
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "repo.default_branch"}}
</h4>
<div class="ui attached segment">
<p>
{{.i18n.Tr "repo.settings.default_branch_desc"}}
</p>
<form class="ui form" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="default_branch">
{{if not .Repository.IsEmpty}}
<div class="required inline field">
<div class="ui dropdown selection" tabindex="0">
<select name="branch">
<option value="{{.Repository.DefaultBranch}}">{{.Repository.DefaultBranch}}</option>
{{range .Branches}}
<option value="{{.}}">{{.}}</option>
{{end}}
</select><i class="dropdown icon"></i>
<div class="default text">{{.Repository.DefaultBranch}}</div>
<div class="menu transition hidden" tabindex="-1" style="display: block !important;">
{{range .Branches}}
<div class="item" data-value="{{.}}">{{.}}</div>
{{end}}
</div>
</div>
<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
</div>
{{end}}
</form>
</div>
{{if .Repository.IsArchived}}
<div class="ui warning message">
{{.i18n.Tr "repo.settings.archive.branchsettings_unavailable"}}
</div>
{{else}}
<h4 class="ui top attached header">
{{.i18n.Tr "repo.default_branch"}}
</h4>
<div class="ui attached segment">
<p>
{{.i18n.Tr "repo.settings.default_branch_desc"}}
</p>
<form class="ui form" action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="default_branch">
{{if not .Repository.IsEmpty}}
<div class="required inline field">
<div class="ui dropdown selection" tabindex="0">
<select name="branch">
<option value="{{.Repository.DefaultBranch}}">{{.Repository.DefaultBranch}}</option>
{{range .Branches}}
<option value="{{.}}">{{.}}</option>
{{end}}
</select><i class="dropdown icon"></i>
<div class="default text">{{.Repository.DefaultBranch}}</div>
<div class="menu transition hidden" tabindex="-1" style="display: block !important;">
{{range .Branches}}
<div class="item" data-value="{{.}}">{{.}}</div>
{{end}}
</div>
</div>
<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
</div>
{{end}}
</form>
</div>

<h4 class="ui top attached header">
{{.i18n.Tr "repo.settings.protected_branch"}}
</h4>
<h4 class="ui top attached header">
{{.i18n.Tr "repo.settings.protected_branch"}}
</h4>

<div class="ui attached table segment">
<div class="ui grid padded">
<div class="eight wide column">
<div class="ui fluid dropdown selection" tabindex="0">
<i class="dropdown icon"></i>
<div class="default text">{{.i18n.Tr "repo.settings.choose_branch"}}</div>
<div class="menu transition hidden" tabindex="-1" style="display: block !important;">
{{range .LeftBranches}}
<a class="item" href="{{$.Repository.Link}}/settings/branches/{{. | EscapePound}}">{{.}}</a>
{{end}}
<div class="ui attached table segment">
<div class="ui grid padded">
<div class="eight wide column">
<div class="ui fluid dropdown selection" tabindex="0">
<i class="dropdown icon"></i>
<div class="default text">{{.i18n.Tr "repo.settings.choose_branch"}}</div>
<div class="menu transition hidden" tabindex="-1" style="display: block !important;">
{{range .LeftBranches}}
<a class="item" href="{{$.Repository.Link}}/settings/branches/{{. | EscapePound}}">{{.}}</a>
{{end}}
</div>
</div>
</div>
</div>
</div>

<div class="ui grid padded">
<div class="sixteen wide column">
<table class="ui single line table padded">
<tbody>
{{range .ProtectedBranches}}
<tr>
<td><div class="ui basic label blue">{{.BranchName}}</div></td>
<td class="right aligned"><a class="rm ui button" href="{{$.Repository.Link}}/settings/branches/{{.BranchName | EscapePound}}">{{$.i18n.Tr "repo.settings.edit_protected_branch"}}</a></td>
</tr>
{{else}}
<tr class="center aligned"><td>{{.i18n.Tr "repo.settings.no_protected_branch"}}</td></tr>
{{end}}
</tbody>
</table>
<div class="ui grid padded">
<div class="sixteen wide column">
<table class="ui single line table padded">
<tbody>
{{range .ProtectedBranches}}
<tr>
<td><div class="ui basic label blue">{{.BranchName}}</div></td>
<td class="right aligned"><a class="rm ui button" href="{{$.Repository.Link}}/settings/branches/{{.BranchName | EscapePound}}">{{$.i18n.Tr "repo.settings.edit_protected_branch"}}</a></td>
</tr>
{{else}}
<tr class="center aligned"><td>{{.i18n.Tr "repo.settings.no_protected_branch"}}</td></tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
</div>
{{end}}
</div>
</div>
{{template "base/footer" .}}
55 changes: 55 additions & 0 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
@@ -325,6 +325,31 @@
<p>{{.i18n.Tr "repo.settings.delete_desc"}}</p>
</div>
</div>

{{if not .Repository.IsMirror}}
<div class="ui divider"></div>

<div class="item">
<div class="ui right">
<button class="ui basic red show-modal button" data-modal="#archive-repo-modal">
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.button"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.button"}}
{{end}}
</button>
</div>
<div>
{{if .Repository.IsArchived}}
<h5>{{.i18n.Tr "repo.settings.unarchive.header"}}</h5>
<p>{{.i18n.Tr "repo.settings.unarchive.text"}}</p>
{{else}}
<h5>{{.i18n.Tr "repo.settings.archive.header"}}</h5>
<p>{{.i18n.Tr "repo.settings.archive.text"}}</p>
{{end}}
</div>
</div>
{{end}}
</div>
{{end}}
</div>
@@ -464,6 +489,36 @@
</div>
</div>
{{end}}

{{if not .Repository.IsMirror}}
<div class="ui basic modal" id="archive-repo-modal">
<div class="ui icon header">
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.header"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.header"}}
{{end}}
</div>
<div class="content center">
<p>
{{if .Repository.IsArchived}}
{{.i18n.Tr "repo.settings.unarchive.text"}}
{{else}}
{{.i18n.Tr "repo.settings.archive.text"}}
{{end}}
</p>
</div>
<form action="{{.Link}}" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="{{if .Repository.IsArchived}}unarchive{{else}}archive{{end}}">
<input type="hidden" name="repo_id" value="{{.Repository.ID}}">
<div class="center actions">
<div class="ui basic cancel inverted button">{{.i18n.Tr "settings.cancel"}}</div>
<button class="ui basic inverted yellow button">{{.i18n.Tr "modal.yes"}}</button>
</div>
</form>
</div>
{{end}}
{{end}}

{{template "base/footer" .}}
1 change: 1 addition & 0 deletions templates/user/dashboard/dashboard.tmpl
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@
<a :href="suburl + '/' + repo.full_name">
<i :class="repoClass(repo)"></i>
<strong class="text truncate item-name">${repo.full_name}</strong>
<i v-if="repo.archived" class="archive icon archived-icon"></i>
<span class="ui right text light grey">
${repo.stars_count} <i class="octicon octicon-star rear"></i>
</span>