Phase 5: ship the catalog ActiveAdmin resources from the engine
- the 7 catalog admin files (softwares, releases, external_links, platform_links, images, files page, downloads) move to the engine's app/admin; the host ActiveAdmin instance loads them via ActiveAdmin.application.load_paths (single admin, URLs unchanged) - engine initializers: Zeitwerk ignore for app/admin (production eager load) and load_paths + watchable_dirs registration, guarded by defined?(ActiveAdmin) so the admin-less dummy app boots - images admin reads image owners from WarpEngine.config.image_owners; the host registers the Member owner in config/initializers/warp_engine.rb; the interim ImageUsage registry is gone - fix: SoftwareImage.distinct.pluck clashed with its order(:position) default scope on MySQL (unscope(:order)) — introduced in phase 0, caught by the first authenticated /admin/images smoke test - files page: download links use the public /file/ URL instead of the raw container path; the picker's stored path comes from config Verified: both suites green, zeitwerk:check (production) clean, JSON baselines intact, authenticated admin smoke test on every page incl. the 3-level nested software form and Files picker mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
ActiveAdmin.register WarpEngine::Release, as: "Release" do
|
||||
actions :index, :show
|
||||
|
||||
menu false
|
||||
|
||||
belongs_to :software, optional: true
|
||||
|
||||
index do
|
||||
selectable_column
|
||||
id_column
|
||||
column(:software) { |r| link_to r.software.title, admin_software_path(r.software) }
|
||||
column :version
|
||||
column(:assets) { |r| r.release_assets.map(&:kind).sort.join(", ") }
|
||||
column :created_at
|
||||
actions only: [ :show ]
|
||||
end
|
||||
|
||||
filter :version
|
||||
|
||||
show do
|
||||
attributes_table do
|
||||
row :id
|
||||
row(:software) { |r| link_to r.software.title, admin_software_path(r.software) }
|
||||
row :version
|
||||
row :created_at
|
||||
row :updated_at
|
||||
end
|
||||
|
||||
panel "Assets" do
|
||||
if resource.release_assets.any?
|
||||
table_for resource.release_assets.order(:kind) do
|
||||
column :kind
|
||||
column(:path) { |a| span a.path, style: "font-family:monospace;font-size:12px;" }
|
||||
end
|
||||
else
|
||||
para "No assets for this release.", style: "color:#999;font-style:italic;"
|
||||
end
|
||||
end
|
||||
|
||||
panel "Downloads by File" do
|
||||
file_stats = WarpEngine::Download.where(release_id: resource.id)
|
||||
.group(:file_path)
|
||||
.select("file_path, COUNT(*) as dl_count, MAX(created_at) as last_dl")
|
||||
.order("dl_count DESC")
|
||||
|
||||
if file_stats.any?
|
||||
div style: "margin-bottom:8px;" do
|
||||
strong "Total downloads: "
|
||||
b file_stats.sum(&:dl_count).to_s
|
||||
end
|
||||
|
||||
table_for file_stats do
|
||||
column("File") { |row| span row.file_path, style: "font-family:monospace;font-size:12px;" }
|
||||
column("Downloads") { |row| row.dl_count }
|
||||
column("Last download") { |row| row.last_dl&.strftime("%Y-%m-%d %H:%M") }
|
||||
end
|
||||
else
|
||||
para "No downloads for this release.", style: "color:#999;font-style:italic;"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user