Skip to content

Commit 8dce7b7

Browse files
jeremylenzclaude
andauthored
Redesign inventory upload UI with improved status tracking (#1130)
Update inventory upload dashboard to display task status using new generated_status and uploaded_status fields. Remove unused database tables and improve test coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 066fa63 commit 8dce7b7

File tree

27 files changed

+370
-239
lines changed

27 files changed

+370
-239
lines changed

.eslintrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,42 @@
1313
"skipWords": [
1414
"advisor",
1515
"ansible",
16+
"auditd",
1617
"camelcase",
1718
"cdn",
1819
"checkbox",
20+
"cpol",
1921
"csrf",
22+
"cryptopol",
2023
"cve",
2124
"cves",
22-
"dropdown",
25+
"db",
2326
"donut",
27+
"dropdown",
28+
"hardening",
29+
"hostid",
2430
"hostnames",
2531
"href",
2632
"iop",
2733
"ips",
2834
"ipv4",
29-
"dropdown",
3035
"jed",
3136
"katello",
3237
"knowledgebase",
38+
"krb5",
3339
"noopener",
3440
"noreferrer",
3541
"nowrap",
42+
"openssh",
3643
"pid",
3744
"redhat",
3845
"redux",
46+
"rebootable",
3947
"remediate",
4048
"remediations",
4149
"repo",
4250
"rhc",
51+
"rulename",
4352
"scalprum",
4453
"theforeman",
4554
"tooltip",

app/controllers/foreman_inventory_upload/accounts_controller.rb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@ def latest_task_for(org_id, job_class)
5252
.first
5353
end
5454

55-
def task_status_string(task)
56-
return nil unless task
57-
58-
if task.state == 'stopped'
59-
# Mimic old ProgressOutput format: "pid 12345 exit 0"
60-
exit_code = task.result == 'success' ? 0 : 1
61-
"pid #{Process.pid} exit #{exit_code}"
62-
else
63-
task.state
64-
end
65-
end
66-
6755
def sub_action_status(task, action_class_name)
6856
return nil unless task
6957

@@ -72,8 +60,7 @@ def sub_action_status(task, action_class_name)
7260

7361
# For GenerateHostReport: always show status if task completed (generation always runs)
7462
if action_class_name == 'GenerateHostReport'
75-
exit_code = task.result == 'success' ? 0 : 1
76-
return "pid #{Process.pid} exit #{exit_code}"
63+
return task.result
7764
end
7865

7966
# For UploadReportDirectJob: only show status if task had upload enabled
@@ -84,9 +71,8 @@ def sub_action_status(task, action_class_name)
8471
# Check if upload was enabled for this task
8572
return nil unless main_action.input[:upload]
8673

87-
# Show same status as overall task (upload runs as part of the task)
88-
exit_code = task.result == 'success' ? 0 : 1
89-
return "pid #{Process.pid} exit #{exit_code}"
74+
# Return the task result
75+
return task.result
9076
end
9177

9278
nil

app/models/task_output_line.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/models/task_output_status.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class DropTaskOutputTables < ActiveRecord::Migration[6.0]
2+
def up
3+
drop_table :task_output_lines
4+
drop_table :task_output_statuses
5+
end
6+
7+
def down
8+
create_table :task_output_lines do |t|
9+
t.string :label
10+
t.string :line
11+
t.timestamps
12+
13+
t.index :label
14+
end
15+
16+
create_table :task_output_statuses do |t|
17+
t.string :label
18+
t.string :status
19+
t.timestamps
20+
21+
t.index :label, unique: true
22+
end
23+
end
24+
end

lib/foreman_inventory_upload/async/progress_output.rb

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/foreman_inventory_upload/async/upload_report_direct_job.rb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ def self.output_label(label)
4242
"upload_for_#{label}"
4343
end
4444

45+
def resource_locks
46+
:link
47+
end
48+
4549
def plan(filename, organization_id)
50+
organization = Organization.find(organization_id)
51+
action_subject(organization)
52+
4653
plan_self(
4754
filename: filename,
4855
organization_id: organization_id
@@ -102,7 +109,10 @@ def upload_file(cer_path)
102109
def move_to_done_folder
103110
FileUtils.mkdir_p(ForemanInventoryUpload.done_folder)
104111
done_file = ForemanInventoryUpload.done_file_path(File.basename(filename))
105-
FileUtils.mv(filename, done_file)
112+
if File.exist?(done_file)
113+
logger.warn("Destination file #{done_file} already exists. Overwriting with new report.")
114+
end
115+
FileUtils.mv(filename, done_file, force: true)
106116
logger.debug("Moved #{filename} to #{done_file}")
107117
end
108118

@@ -119,9 +129,20 @@ def manifest_certificate
119129
end
120130

121131
def foreman_certificate
132+
cert_path = Setting[:ssl_certificate]
133+
key_path = Setting[:ssl_priv_key]
134+
135+
unless cert_path && File.readable?(cert_path)
136+
raise "SSL certificate file not found or not readable: #{cert_path}"
137+
end
138+
139+
unless key_path && File.readable?(key_path)
140+
raise "SSL private key file not found or not readable: #{key_path}"
141+
end
142+
122143
{
123-
cert: File.read(Setting[:ssl_certificate]),
124-
key: File.read(Setting[:ssl_priv_key]),
144+
cert: File.read(cert_path),
145+
key: File.read(key_path),
125146
}
126147
end
127148

@@ -134,6 +155,7 @@ def organization
134155
end
135156

136157
def content_disconnected?
158+
return false if ForemanRhCloud.with_iop_smart_proxy?
137159
!Setting[:subscription_connection_enabled]
138160
end
139161

test/controllers/accounts_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class AccountsControllerTest < ActionController::TestCase
55

66
include FolderIsolation
77

8-
test 'Returns statuses for each process type' do
8+
test 'Returns statuses for each organization' do
99
test_org = FactoryBot.create(:organization)
1010

1111
get :index, session: set_session_user

0 commit comments

Comments
 (0)