summaryrefslogtreecommitdiffstats
path: root/templates/package/shared/cleanup_rules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-10-18 20:33:49 +0200
committerDaniel Baumann <daniel@debian.org>2024-12-12 23:57:56 +0100
commite68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch)
tree97775d6c13b0f416af55314eb6a89ef792474615 /templates/package/shared/cleanup_rules
parentInitial commit. (diff)
downloadforgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz
forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to '')
-rw-r--r--templates/package/shared/cleanup_rules/edit.tmpl73
-rw-r--r--templates/package/shared/cleanup_rules/list.tmpl56
-rw-r--r--templates/package/shared/cleanup_rules/preview.tmpl34
3 files changed, 163 insertions, 0 deletions
diff --git a/templates/package/shared/cleanup_rules/edit.tmpl b/templates/package/shared/cleanup_rules/edit.tmpl
new file mode 100644
index 0000000..138a907
--- /dev/null
+++ b/templates/package/shared/cleanup_rules/edit.tmpl
@@ -0,0 +1,73 @@
+<h4 class="ui top attached header">{{if .IsEditRule}}{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.edit"}}{{else}}{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.add"}}{{end}}</h4>
+<div class="ui attached segment">
+ <form class="ui form" action="{{.Link}}" method="post">
+ {{.CsrfTokenHtml}}
+ <input name="id" type="hidden" value="{{.CleanupRule.ID}}">
+ <div class="field">
+ <div class="ui checkbox">
+ <label>{{ctx.Locale.Tr "enabled"}}</label>
+ <input type="checkbox" name="enabled" {{if .CleanupRule.Enabled}}checked{{end}}>
+ </div>
+ </div>
+ <div class="{{if .IsEditRule}}disabled {{end}}field {{if .Err_Type}}error{{end}}">
+ <label>{{ctx.Locale.Tr "packages.filter.type"}}</label>
+ <select class="ui selection dropdown" name="type">
+ {{range $type := .AvailableTypes}}
+ <option{{if eq $.CleanupRule.Type $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
+ {{end}}
+ </select>
+ </div>
+ <div class="field">
+ <div class="ui checkbox">
+ <label>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.pattern_full_match"}}</label>
+ <input type="checkbox" name="match_full_name" {{if .CleanupRule.MatchFullName}}checked{{end}}>
+ </div>
+ </div>
+ <div class="divider"></div>
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.title"}}</p>
+ <div class="field {{if .Err_KeepCount}}error{{end}}">
+ <label>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count"}}:</label>
+ <select class="ui selection dropdown" name="keep_count">
+ <option{{if eq .CleanupRule.KeepCount 0}} selected="selected"{{end}} value="0"></option>
+ <option{{if eq .CleanupRule.KeepCount 1}} selected="selected"{{end}} value="1">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.1"}}</option>
+ <option{{if eq .CleanupRule.KeepCount 5}} selected="selected"{{end}} value="5">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" 5}}</option>
+ <option{{if eq .CleanupRule.KeepCount 10}} selected="selected"{{end}} value="10">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" 10}}</option>
+ <option{{if eq .CleanupRule.KeepCount 25}} selected="selected"{{end}} value="25">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" 25}}</option>
+ <option{{if eq .CleanupRule.KeepCount 50}} selected="selected"{{end}} value="50">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" 50}}</option>
+ <option{{if eq .CleanupRule.KeepCount 100}} selected="selected"{{end}} value="100">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" 100}}</option>
+ </select>
+ </div>
+ <div class="field {{if .Err_KeepPattern}}error{{end}}">
+ <label>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.pattern"}}:</label>
+ <input name="keep_pattern" type="text" value="{{.CleanupRule.KeepPattern}}">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.pattern.container"}}</p>
+ </div>
+ <div class="divider"></div>
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.remove.title"}}</p>
+ <div class="field {{if .Err_RemoveDays}}error{{end}}">
+ <label>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.remove.days"}}:</label>
+ <select class="ui selection dropdown" name="remove_days">
+ <option{{if eq .CleanupRule.RemoveDays 0}} selected="selected"{{end}} value="0"></option>
+ <option{{if eq .CleanupRule.RemoveDays 7}} selected="selected"{{end}} value="7">{{ctx.Locale.Tr "tool.days" 7}}</option>
+ <option{{if eq .CleanupRule.RemoveDays 14}} selected="selected"{{end}} value="14">{{ctx.Locale.Tr "tool.days" 14}}</option>
+ <option{{if eq .CleanupRule.RemoveDays 30}} selected="selected"{{end}} value="30">{{ctx.Locale.Tr "tool.days" 30}}</option>
+ <option{{if eq .CleanupRule.RemoveDays 60}} selected="selected"{{end}} value="60">{{ctx.Locale.Tr "tool.days" 60}}</option>
+ <option{{if eq .CleanupRule.RemoveDays 90}} selected="selected"{{end}} value="90">{{ctx.Locale.Tr "tool.days" 90}}</option>
+ <option{{if eq .CleanupRule.RemoveDays 180}} selected="selected"{{end}} value="180">{{ctx.Locale.Tr "tool.days" 180}}</option>
+ </select>
+ </div>
+ <div class="field {{if .Err_RemovePattern}}error{{end}}">
+ <label>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.remove.pattern"}}:</label>
+ <input name="remove_pattern" type="text" value="{{.CleanupRule.RemovePattern}}">
+ </div>
+ <div class="field">
+ {{if .IsEditRule}}
+ <button class="ui primary button" name="action" value="save">{{ctx.Locale.Tr "save"}}</button>
+ <button class="ui red button" name="action" value="remove">{{ctx.Locale.Tr "remove"}}</button>
+ <a class="ui button" href="{{.Link}}/preview">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.preview"}}</a>
+ {{else}}
+ <button class="ui primary button" name="action" value="save">{{ctx.Locale.Tr "add"}}</button>
+ {{end}}
+ </div>
+ </form>
+</div>
diff --git a/templates/package/shared/cleanup_rules/list.tmpl b/templates/package/shared/cleanup_rules/list.tmpl
new file mode 100644
index 0000000..ba1683b
--- /dev/null
+++ b/templates/package/shared/cleanup_rules/list.tmpl
@@ -0,0 +1,56 @@
+<h4 class="ui top attached header">
+ {{ctx.Locale.Tr "packages.owner.settings.cleanuprules.title"}}
+ <div class="ui right">
+ <a class="ui primary tiny button" href="{{.Link}}/rules/add">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.add"}}</a>
+ </div>
+</h4>
+<div class="ui attached segment">
+ <div class="flex-list">
+ {{range .CleanupRules}}
+ <div class="flex-item">
+ <div class="flex-item-leading">
+ {{svg .Type.SVGName 32}}
+ </div>
+ <div class="flex-item-main">
+ <div class="flex-item-title">
+ <a class="item" href="{{$.Link}}/rules/{{.ID}}">{{.Type.Name}}</a>
+ </div>
+ <div class="flex-item-body">
+ <p>{{if .Enabled}}{{ctx.Locale.Tr "enabled"}}{{else}}{{ctx.Locale.Tr "disabled"}}{{end}}</p>
+ </div>
+ {{if .KeepCount}}
+ <div class="flex-item-body">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count"}}:</p> {{if eq .KeepCount 1}}{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.1"}}{{else}}{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.count.n" .KeepCount}}{{end}}
+ </div>
+ {{end}}
+ {{if .KeepPattern}}
+ <div class="flex-item-body">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.keep.pattern"}}:</p> {{StringUtils.EllipsisString .KeepPattern 100}}
+ </div>
+ {{end}}
+ {{if .RemoveDays}}
+ <div class="flex-item-body">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.remove.days"}}:</p> {{ctx.Locale.Tr "tool.days" .RemoveDays}}
+ </div>
+ {{end}}
+ {{if .RemovePattern}}
+ <div class="flex-item-body">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.remove.pattern"}}:</p> {{StringUtils.EllipsisString .RemovePattern 100}}
+ </div>
+ {{end}}
+ </div>
+ <div class="flex-item-trailing">
+ <div class="ui dropdown tiny basic button">
+ {{svg "octicon-kebab-horizontal"}}
+ <div class="menu">
+ <a class="item" href="{{$.Link}}/rules/{{.ID}}">{{ctx.Locale.Tr "edit"}}</a>
+ <a class="item" href="{{$.Link}}/rules/{{.ID}}/preview">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.preview"}}</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ {{else}}
+ <div class="item">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.none"}}</div>
+ {{end}}
+ </div>
+</div>
diff --git a/templates/package/shared/cleanup_rules/preview.tmpl b/templates/package/shared/cleanup_rules/preview.tmpl
new file mode 100644
index 0000000..0d9c4b0
--- /dev/null
+++ b/templates/package/shared/cleanup_rules/preview.tmpl
@@ -0,0 +1,34 @@
+<h4 class="ui top attached header">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.preview"}}</h4>
+<div class="ui attached segment">
+ <p>{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.preview.overview" (len .VersionsToRemove)}}</p>
+</div>
+<div class="ui attached table segment">
+ <table class="ui very basic striped table unstackable">
+ <thead>
+ <tr>
+ <th>{{ctx.Locale.Tr "admin.packages.type"}}</th>
+ <th>{{ctx.Locale.Tr "admin.packages.name"}}</th>
+ <th>{{ctx.Locale.Tr "admin.packages.version"}}</th>
+ <th>{{ctx.Locale.Tr "admin.packages.creator"}}</th>
+ <th>{{ctx.Locale.Tr "admin.packages.size"}}</th>
+ <th>{{ctx.Locale.Tr "admin.packages.published"}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{range .VersionsToRemove}}
+ <tr>
+ <td>{{.Package.Type.Name}}</td>
+ <td>{{.Package.Name}}</td>
+ <td><a href="{{.VersionWebLink}}">{{.Version.Version}}</a></td>
+ <td><a href="{{.Creator.HomeLink}}">{{.Creator.Name}}</a></td>
+ <td>{{ctx.Locale.TrSize .CalculateBlobSize}}</td>
+ <td>{{DateTime "short" .Version.CreatedUnix}}</td>
+ </tr>
+ {{else}}
+ <tr>
+ <td colspan="6">{{ctx.Locale.Tr "packages.owner.settings.cleanuprules.preview.none"}}</td>
+ </tr>
+ {{end}}
+ </tbody>
+ </table>
+</div>