Files
artifactapi/ui/src/pages/Objects.css
T
unkinben f6b0afc5d6 feat(ui): direct-download links for downloadable local repo files (#106)
## Why

The local-repo object browser renders every file name as inert text, so there is no way to grab a file from the UI even though local rpm repos already serve their contents as real yum repos. Users have to hand-construct URLs. This adds one-click downloads, built as a modular per-repo-type capability so other types can be switched on later with a single map entry.

## Changes

- Adds a `downloadableTypes` capability map (`ui/src/components/downloads.ts`) keyed by `package_type`; each entry builds the direct-download URL for a file.
- Enables `rpm`, pointing at the yum files route `/api/v2/remotes/<repo>/files/<path>` (path-segment-encoded).
- Renders file names in the object browser as `<a href download>` links when the repo's type is downloadable, and as plain text otherwise.
- Fetches the repo's `package_type` on the Objects page as the modularity hook and threads it through the tree rows.

## Notes

Download links are same-origin unauthenticated GETs (the API serves local repos with no token on reads, matching how yum clients fetch), so a bare `href` carries no credentials. Adding a future type is one entry in `downloadableTypes`.

---------

Co-authored-by: Ben Vin <neotheo@gmail.com>
Reviewed-on: #106
Co-authored-by: Ben Vincent <ben@unkin.net>
Co-committed-by: Ben Vincent <ben@unkin.net>
2026-07-25 14:15:25 +10:00

105 lines
1.5 KiB
CSS

.objects-toolbar {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 16px;
flex-wrap: wrap;
}
.tree-controls {
display: flex;
gap: 6px;
margin-left: auto;
}
.tree-table .tree-label {
display: inline-flex;
align-items: center;
gap: 4px;
}
.tree-toggle {
display: inline-block;
width: 16px;
font-size: 0.85em;
color: var(--text-muted);
user-select: none;
flex-shrink: 0;
}
.tree-dir-name {
font-weight: 600;
color: var(--text-bright);
}
.tree-file-name {
font-size: 0.85em;
word-break: break-all;
}
.tree-file-link {
color: var(--accent, #4c9aff);
text-decoration: none;
}
.tree-file-link:hover {
text-decoration: underline;
}
.tree-dir {
cursor: pointer;
}
.tree-dir:hover {
background: var(--bg-elevated);
}
.tree-summary {
font-size: 0.8em;
color: var(--text-muted);
}
.num-cell {
font-family: var(--font-mono);
font-size: 0.85em;
}
.hash-cell {
font-size: 0.8em;
color: var(--text-muted);
}
.btn-evict {
background: transparent;
border: 1px solid var(--red);
color: var(--red);
padding: 3px 10px;
border-radius: 4px;
font-size: 0.8em;
cursor: pointer;
transition: all 0.15s;
}
.btn-evict:hover {
background: rgba(239, 68, 68, 0.15);
}
.btn-sm {
padding: 5px 12px;
font-size: 0.85em;
background: var(--bg-surface);
border: 1px solid var(--border);
color: var(--text);
border-radius: var(--radius);
cursor: pointer;
}
.btn-sm:hover:not(:disabled) {
background: var(--bg-elevated);
}
.btn-sm:disabled {
opacity: 0.4;
cursor: default;
}