Skip to content

Commit

Permalink
Disable unnecessary mirroring elements (go-gitea#18527)
Browse files Browse the repository at this point in the history
* Disable unnecessary mirroring elements

This mod fixes disabling unnecessary mirroring elements.

Related: go-gitea#16957
Related: go-gitea#13084
Author-Change-Id: IB#1105104

* Checkbox rendering disabled instead of hiding it

Fixes: 02b4505
Related: go-gitea#18527 (review)
Author-Change-Id: IB#1105104

* Update custom/conf/app.example.ini

Co-authored-by: silverwind <[email protected]>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: silverwind <[email protected]>

* Mirror filter removed only when whole mirroring feature is disabled

Fixes: 02b4505
Related: go-gitea#18527 (comment)
Author-Change-Id: IB#1105104

Co-authored-by: silverwind <[email protected]>
  • Loading branch information
2 people authored and AbdulrhmnGhanem committed Aug 23, 2022
1 parent fa81df0 commit 8a45181
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ PATH =
;[mirror]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Enables the mirror functionality. Set to **false** to disable all mirrors.
;; Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
;ENABLED = true
;; Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
;DISABLE_NEW_PULL = false
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf

## Mirror (`mirror`)

- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.
- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo.
- `DISABLE_NEW_PULL`: **false**: Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
- `DISABLE_NEW_PUSH`: **false**: Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`.
- `DEFAULT_INTERVAL`: **8h**: Default interval between each check
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,6 @@ need_auth = Authorization
migrate_options = Migration Options
migrate_service = Migration Service
migrate_options_mirror_helper = This repository will be a <span class="text blue">mirror</span>
migrate_options_mirror_disabled = Your site administrator has disabled new mirrors.
migrate_options_lfs = Migrate LFS files
migrate_options_lfs_endpoint.label = LFS Endpoint
migrate_options_lfs_endpoint.description = Migration will attempt to use your Git remote to <a target="_blank" rel="noopener noreferrer" href="%s">determine the LFS server</a>. You can also specify a custom endpoint if the repository LFS data is stored somewhere else.
Expand Down
1 change: 1 addition & 0 deletions routers/web/user/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func Dashboard(ctx *context.Context) {
ctx.Data["PageIsNews"] = true
cnt, _ := organization.GetOrganizationCount(ctx, ctxUser)
ctx.Data["UserOrgsCount"] = cnt
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled

var uid int64
if ctxUser != nil {
Expand Down
4 changes: 3 additions & 1 deletion services/cron/tasks_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func registerCleanupPackages() {
}

func initBasicTasks() {
registerUpdateMirrorTask()
if setting.Mirror.Enabled {
registerUpdateMirrorTask()
}
registerRepoHealthCheck()
registerCheckRepoStats()
registerArchiveCleanup()
Expand Down
11 changes: 4 additions & 7 deletions templates/repo/migrate/options.tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{{if not .DisableNewPullMirrors}}
<div class="inline field">
<label>{{.i18n.Tr "repo.migrate_options"}}</label>
<div class="ui checkbox">
{{if .DisableNewPullMirrors}}
<input id="mirror" name="mirror" type="checkbox" readonly>
<label>{{.i18n.Tr "repo.migrate_options_mirror_disabled"}}</label>
{{else}}
<input id="mirror" name="mirror" type="checkbox" {{if .mirror}} checked{{end}}>
<label>{{.i18n.Tr "repo.migrate_options_mirror_helper" | Safe}}</label>
{{end}}
<input id="mirror" name="mirror" type="checkbox" {{if .mirror}} checked{{end}}>
<label>{{.i18n.Tr "repo.migrate_options_mirror_helper" | Safe}}</label>
</div>
</div>
{{end}}
{{if .LFSActive}}
<div class="inline field">
<label></label>
Expand Down
2 changes: 2 additions & 0 deletions templates/user/dashboard/repolist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@
{{.i18n.Tr "forks"}}
<div v-show="reposFilter === 'forks'" class="ui circular mini grey label">${repoTypeCount}</div>
</a>
{{if .MirrorsEnabled}}
<a class="item" :class="{active: reposFilter === 'mirrors'}" @click="changeReposFilter('mirrors')">
{{.i18n.Tr "mirrors"}}
<div v-show="reposFilter === 'mirrors'" class="ui circular mini grey label">${repoTypeCount}</div>
</a>
{{end}}
<a class="item" :class="{active: reposFilter === 'collaborative'}" @click="changeReposFilter('collaborative')">
{{.i18n.Tr "collaborative"}}
<div v-show="reposFilter === 'collaborative'" class="ui circular mini grey label">${repoTypeCount}</div>
Expand Down

0 comments on commit 8a45181

Please sign in to comment.