A kódbázis kommentek nélkül marad
Kérésre: minden magyarázó komment kikerült a forrásfájlokból — 89 Ruby, 16 TypeScript, 14 Vue, plusz a CSS/JS/CJS. Nem soralapú kereséssel: a Ruby-t a Ripper tokenizálta, a JS/TS/CSS-t állapotgép járta végig, hogy az URL-ekben, reguláris kifejezésekben és heredocokban álló // és # jelek helyükön maradjanak. Három komment maradt, mert nélkülük nem indul a kód: az entrypoint.sh shebangja, a vite-env.d.ts hármas perjeles referenciája, és a sanitize teszt @vitest-environment direktívája (ez utóbbi a magyarázó része nélkül). Egy helyen kódot is kellett írni: a CommandBlock másolás-hibaágán a komment volt a catch egyetlen tartalma, és üres blokkot az eslint nem enged — a copied jelző visszaállítása került a helyére. A yaml, Dockerfile, Makefile, erb és markdown fájlokat nem érintettem. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,7 @@ ActiveAdmin.register WarpEngine::ApplicationToken, as: "Application Token" do
|
||||
scope :all, default: true
|
||||
scope("Active") { |scope| scope.where("expires_at IS NULL OR expires_at > ?", Time.current) }
|
||||
scope("Expired") { |scope| scope.where("expires_at <= ?", Time.current) }
|
||||
# Two kinds of token share this table: one publishes software, the other reads the
|
||||
# catalog from somebody's desktop client. They are told apart by scope, and an admin
|
||||
# looking for one is rarely looking for the other.
|
||||
|
||||
CATALOG_SCOPE_SQL = %(JSON_CONTAINS(COALESCE(scopes, '[]'), '"catalog"')).freeze
|
||||
scope("Publishing") { |scope| scope.where("NOT #{CATALOG_SCOPE_SQL}") }
|
||||
scope("Clients") { |scope| scope.where(CATALOG_SCOPE_SQL) }
|
||||
@@ -98,9 +96,6 @@ ActiveAdmin.register WarpEngine::ApplicationToken, as: "Application Token" do
|
||||
end
|
||||
|
||||
controller do
|
||||
# The plain token only exists right after creation; it travels via the
|
||||
# session to its one-time display (flash is unsuitable: the AA layout
|
||||
# renders every flash key as a message bar).
|
||||
def create
|
||||
create! do |success, _failure|
|
||||
success.html do
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
ActiveAdmin.register WarpEngine::DeviceGrant, as: "Device Sign-in" do
|
||||
# Read-only on purpose. A grant is created by a client and answered by a person on the
|
||||
# host's own page; an admin creating one by hand would be issuing somebody else a
|
||||
# credential, which is not a thing this page should make easy.
|
||||
actions :index, :show
|
||||
|
||||
menu parent: "🌀 WarpEngine", priority: 10, label: "📱 Device Sign-ins",
|
||||
@@ -45,8 +42,7 @@ ActiveAdmin.register WarpEngine::DeviceGrant, as: "Device Sign-in" do
|
||||
subject = g.subject
|
||||
subject.try(:email) || subject.try(:name) || "#{g.subject_type} ##{g.subject_id}"
|
||||
end
|
||||
# The device code itself is never shown: it is the client's live credential for as
|
||||
# long as the grant is pending, and this page is not where it should leak from.
|
||||
|
||||
row("Token") do |g|
|
||||
token = g.application_token
|
||||
next "—" if token.nil?
|
||||
|
||||
@@ -13,7 +13,6 @@ ActiveAdmin.register_page "Files" do
|
||||
entries = []
|
||||
end
|
||||
|
||||
# Picker mode: hide admin header/menu/footer
|
||||
if picker_mode
|
||||
text_node "<style>#header,#tabs,.footer,#title_bar,#utility_nav{display:none!important}#active_admin_content{margin:0;padding:0}#wrapper{margin:0}body{min-height:auto}</style>".html_safe
|
||||
end
|
||||
@@ -26,7 +25,6 @@ ActiveAdmin.register_page "Files" do
|
||||
end
|
||||
end
|
||||
|
||||
# Breadcrumbs
|
||||
div class: "fm-breadcrumbs" do
|
||||
parts = current_dir.split("/").reject(&:blank?)
|
||||
picker_params = picker_mode ? { picker: 1, field: picker_field } : {}
|
||||
@@ -39,7 +37,6 @@ ActiveAdmin.register_page "Files" do
|
||||
end
|
||||
end
|
||||
|
||||
# Action bar (also drop zone on standalone page)
|
||||
div class: "fm-actions fm-dropzone", id: "fm-page-dropzone" do
|
||||
form action: admin_files_upload_path, method: "post", enctype: "multipart/form-data", class: "fm-inline-form" do |_f|
|
||||
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
||||
@@ -56,9 +53,7 @@ ActiveAdmin.register_page "Files" do
|
||||
end
|
||||
end
|
||||
|
||||
# File listing
|
||||
table class: "fm-table" do
|
||||
# Pre-fetch download counts for files in current directory
|
||||
file_entries = entries.select { |e| e[:type] != :directory }
|
||||
dl_counts = if file_entries.any?
|
||||
WarpEngine::Download.where(file_path: file_entries.map { |e| e[:path] })
|
||||
@@ -68,7 +63,6 @@ ActiveAdmin.register_page "Files" do
|
||||
{}
|
||||
end
|
||||
|
||||
# File icon helper
|
||||
file_icon = ->(name) do
|
||||
ext = File.extname(name).downcase
|
||||
case ext
|
||||
@@ -100,7 +94,6 @@ ActiveAdmin.register_page "Files" do
|
||||
end
|
||||
|
||||
tbody do
|
||||
# Parent directory link
|
||||
if current_dir.present?
|
||||
parent = File.dirname(current_dir)
|
||||
parent = "" if parent == "."
|
||||
@@ -145,32 +138,26 @@ ActiveAdmin.register_page "Files" do
|
||||
td class: "fm-entry-actions" do
|
||||
entry_id = entry[:path].parameterize
|
||||
|
||||
# Download (files only)
|
||||
if entry[:type] != :directory
|
||||
a "⬇️", href: "/file/#{entry[:path]}", class: "fm-icon-btn", title: "Download", download: entry[:name]
|
||||
end
|
||||
|
||||
# Rename
|
||||
a "✏️", href: "#", class: "fm-icon-btn", title: "Rename",
|
||||
onclick: "var n=prompt('New name:','#{j entry[:name]}');if(n){var f=document.getElementById('rename-#{entry_id}');f.querySelector('[name=new_name]').value=n;f.submit();}return false;"
|
||||
|
||||
# Delete
|
||||
a "🗑️", href: "#", class: "fm-icon-btn fm-icon-danger", title: "Delete",
|
||||
onclick: "if(confirm('Delete \\'#{j entry[:name]}\\'?')){document.getElementById('delete-#{entry_id}').submit();}return false;"
|
||||
|
||||
# Stats (files only)
|
||||
if entry[:type] != :directory
|
||||
a "📊", href: admin_downloads_path(q: { file_path_cont: entry[:path] }), class: "fm-icon-btn", title: "Stats"
|
||||
end
|
||||
|
||||
# Picker mode: Select button
|
||||
if picker_mode
|
||||
abs_path = File.join(WarpEngine.config.file_container_path, entry[:path])
|
||||
a "Select", href: "#", class: "fm-btn fm-btn-select",
|
||||
onclick: "var inp=window.parent.document.getElementById('#{j picker_field}');if(inp){inp.value='#{j abs_path}';}var ov=window.parent.document.querySelector('.fm-modal-overlay');if(ov){ov.remove();window.parent.document.body.style.overflow='';}return false;"
|
||||
end
|
||||
|
||||
# Hidden rename form
|
||||
form action: admin_files_rename_path, method: "post", id: "rename-#{entry_id}", style: "display:none" do
|
||||
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
||||
input type: "hidden", name: "path", value: entry[:path]
|
||||
@@ -178,7 +165,6 @@ ActiveAdmin.register_page "Files" do
|
||||
input type: "hidden", name: "dir", value: current_dir
|
||||
end
|
||||
|
||||
# Hidden delete form
|
||||
form action: admin_files_delete_path, method: "post", id: "delete-#{entry_id}", style: "display:none" do
|
||||
input type: "hidden", name: "authenticity_token", value: form_authenticity_token
|
||||
input type: "hidden", name: "_method", value: "delete"
|
||||
@@ -197,7 +183,6 @@ ActiveAdmin.register_page "Files" do
|
||||
end
|
||||
end
|
||||
|
||||
# JSON API for AJAX file picker
|
||||
page_action :list, method: :get do
|
||||
service = WarpEngine::FileManagerService.new
|
||||
dir = params[:dir].to_s.presence || ""
|
||||
|
||||
@@ -3,8 +3,6 @@ ActiveAdmin.register WarpEngine::Image, as: "Image" do
|
||||
|
||||
menu parent: "🌀 WarpEngine", priority: 5, label: "🖼️ Images"
|
||||
|
||||
# SoftwareImage a natív használó; a hoston regisztrált image_owners
|
||||
# (WarpEngine.config) további használókat adhat hozzá (pl. TTG Member).
|
||||
used_ids = -> {
|
||||
WarpEngine::SoftwareImage.unscope(:order).distinct.pluck(:image_id) +
|
||||
WarpEngine.config.image_owners.flat_map { |o| o[:image_ids].call }
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
ActiveAdmin.register WarpEngine::Pipeline, as: "Pipeline" do
|
||||
actions :index, :show, :edit, :update
|
||||
|
||||
# Without this the edit form cannot save at all: ActiveAdmin hands unpermitted params to
|
||||
# the model and Rails raises ForbiddenAttributesError. The two fields here are the two
|
||||
# the form offers; everything else about a pipeline comes from the Woodpecker sync.
|
||||
permit_params :platform, :software_id
|
||||
|
||||
menu parent: "🌀 WarpEngine", priority: 10, label: "🚀 Pipelines"
|
||||
@@ -91,7 +88,7 @@ ActiveAdmin.register WarpEngine::Pipeline, as: "Pipeline" do
|
||||
column("Status") { |p| status_tag p["status"], class: p["status"] == "success" ? "yes" : "no" }
|
||||
column("Branch") { |p| p["branch"] }
|
||||
column("Message") { |p| p["message"]&.truncate(60) }
|
||||
# Woodpecker returns unix epoch seconds in "created"
|
||||
|
||||
column("Created") { |p| p["created"] ? Time.zone.at(p["created"]).strftime("%Y-%m-%d %H:%M") : "-" }
|
||||
end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user