forked from NYANDEV/forgejo
Repo setting to delete and disable wiki
This commit is contained in:
parent
f946040fa9
commit
f3358f5927
5 changed files with 777 additions and 909 deletions
|
@ -595,6 +595,9 @@ settings.transfer_desc = Transfer this repository to another user or to an organ
|
|||
settings.transfer_notices_1 = - You will lose access if new owner is a individual user.
|
||||
settings.transfer_notices_2 = - You will conserve access if new owner is an organization and if you're one of the owners.
|
||||
settings.transfer_form_title = Please enter following information to confirm your operation:
|
||||
settings.wiki-delete = Erase Wiki Data
|
||||
settings.wiki-delete_desc = Once you erase wiki data there is no going back. Please be certain.
|
||||
settings.wiki-delete_notices_1 = This will delete and disable the wiki for %s
|
||||
settings.delete = Delete This Repository
|
||||
settings.delete_desc = Once you delete a repository, there is no going back. Please be certain.
|
||||
settings.delete_notices_1 = - This operation <strong>CANNOT</strong> be undone.
|
||||
|
|
|
@ -241,6 +241,17 @@ func (repo *Repository) ComposeMetas() map[string]string {
|
|||
return repo.ExternalMetas
|
||||
}
|
||||
|
||||
func DeleteWiki(repo *Repository) {
|
||||
repo.DeleteWiki()
|
||||
}
|
||||
|
||||
func (repo *Repository) DeleteWiki() {
|
||||
wikiPaths := []string{repo.WikiPath(), repo.LocalWikiPath()}
|
||||
for _, wikiPath := range wikiPaths {
|
||||
RemoveAllWithNotice("Delete repository wiki", wikiPath)
|
||||
}
|
||||
}
|
||||
|
||||
// GetAssignees returns all users that have write access of repository.
|
||||
func (repo *Repository) GetAssignees() (_ []*User, err error) {
|
||||
if err = repo.GetOwner(); err != nil {
|
||||
|
@ -1335,10 +1346,7 @@ func DeleteRepository(uid, repoID int64) error {
|
|||
repoPath := repo.repoPath(sess)
|
||||
RemoveAllWithNotice("Delete repository files", repoPath)
|
||||
|
||||
wikiPaths := []string{repo.WikiPath(), repo.LocalWikiPath()}
|
||||
for _, wikiPath := range wikiPaths {
|
||||
RemoveAllWithNotice("Delete repository wiki", wikiPath)
|
||||
}
|
||||
repo.DeleteWiki()
|
||||
|
||||
// Remove attachment files.
|
||||
for i := range attachmentPaths {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -226,6 +226,32 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
|||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
|
||||
ctx.Redirect(ctx.Repo.Owner.DashboardLink())
|
||||
case "delete-wiki":
|
||||
if repo.Name != form.RepoName {
|
||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) {
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
models.DeleteWiki(repo)
|
||||
log.Trace("Repository wiki deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name)
|
||||
|
||||
repo.EnableWiki = false
|
||||
|
||||
if err := models.UpdateRepository(repo, false); err != nil {
|
||||
ctx.Handle(500, "UpdateRepository", err)
|
||||
return
|
||||
}
|
||||
log.Trace("Repository advanced settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{if .Repository.EnableWiki}}
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="item">
|
||||
<div class="ui right">
|
||||
<button class="ui basic red show-modal button" data-modal="#delete-wiki-modal">{{.i18n.Tr "repo.settings.wiki-delete"}}</button>
|
||||
</div>
|
||||
<div>
|
||||
<h5>{{.i18n.Tr "repo.settings.wiki-delete"}}</h5>
|
||||
<p>{{.i18n.Tr "repo.settings.wiki-delete_desc"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="item">
|
||||
|
@ -282,4 +296,36 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui small modal" id="delete-wiki-modal">
|
||||
<div class="header">
|
||||
{{.i18n.Tr "repo.settings.wiki-delete"}}
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="ui warning message text left">
|
||||
{{.i18n.Tr "repo.settings.delete_notices_1" | Safe}}<br>
|
||||
{{.i18n.Tr "repo.settings.wiki-delete_notices_1" .Repository.Name | Safe}}
|
||||
</div>
|
||||
<form class="ui form" action="{{.Link}}" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<input type="hidden" name="action" value="delete-wiki">
|
||||
<div class="field">
|
||||
<label>
|
||||
{{.i18n.Tr "repo.settings.transfer_form_title"}}
|
||||
<span class="text red">{{.Repository.Name}}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="required field">
|
||||
<label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
|
||||
<input id="repo_name" name="repo_name" required>
|
||||
</div>
|
||||
|
||||
<div class="text right actions">
|
||||
<div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
|
||||
<button class="ui red button">{{.i18n.Tr "repo.settings.confirm_delete"}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "base/footer" .}}
|
||||
|
|
Loading…
Reference in a new issue