2
0

feat(repo): add move to vault action in file list
All checks were successful
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 3m6s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 4m57s
Build and Release / Lint (push) Successful in 5m14s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been skipped
Build and Release / Build Binary (linux/arm64) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped

Adds a "Move to Vault" action button for files in the repository file list. The button appears on hover next to the file age, and is only shown when the vault plugin is available and for regular files (not directories or submodules).
This commit is contained in:
2026-01-19 00:29:21 -05:00
parent d38d20bfaf
commit 70aee25079
3 changed files with 30 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ import (
"code.gitcaddy.com/server/v3/modules/htmlutil"
"code.gitcaddy.com/server/v3/modules/httplib"
"code.gitcaddy.com/server/v3/modules/log"
"code.gitcaddy.com/server/v3/modules/plugins"
repo_module "code.gitcaddy.com/server/v3/modules/repository"
"code.gitcaddy.com/server/v3/modules/setting"
"code.gitcaddy.com/server/v3/modules/svg"
@@ -143,6 +144,9 @@ func prepareToRenderDirectory(ctx *context.Context) {
return
}
// Check if vault plugin is available for Move to Vault action in file list
ctx.Data["CanMoveToVault"] = plugins.Get("vault") != nil
if ctx.Repo.TreePath != "" {
ctx.Data["HideRepoInfo"] = true
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+ctx.Repo.TreePath, ctx.Repo.RefFullName.ShortName())

View File

@@ -55,7 +55,14 @@
{{/* will be loaded again by LastCommitLoaderURL */}}
{{end}}
</div>
<div class="repo-file-cell age">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</div>
<div class="repo-file-cell age">
{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}
{{if and $.CanMoveToVault (not $entry.IsDir) (not $entry.IsSubModule)}}
<a class="repo-file-cell-action" href="{{$.RepoLink}}/_move-to-vault/{{PathEscapeSegments $.BranchName}}/{{if $.TreePath}}{{PathEscapeSegments $.TreePath}}/{{end}}{{PathEscapeSegments $entry.Name}}" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.move_to_vault"}}">
{{svg "octicon-shield-lock" 16}}
</a>
{{end}}
</div>
</div>
{{end}}
</div>

View File

@@ -88,7 +88,24 @@
}
#repo-files-table .repo-file-cell.age {
text-align: right;
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8px;
white-space: nowrap;
color: var(--color-text-light-1);
}
#repo-files-table .repo-file-cell-action {
display: none;
color: var(--color-text-light-2);
padding: 2px;
}
#repo-files-table .repo-file-cell-action:hover {
color: var(--color-primary);
}
#repo-files-table .repo-file-item:hover .repo-file-cell-action {
display: inline-flex;
}