Skip to content

Commit

Permalink
Fixes #34930 - ACS audit and UI fixes (#10126)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed May 26, 2022
1 parent 46276c9 commit 1e399f1
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/lib/actions/katello/alternate_content_source/refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def plan(acs)
end

def finalize
acs = ::Katello::AlternateContentSource.find_by(id: input[:acs_id])
acs.update(last_refreshed: ::DateTime.now)
::Katello::AlternateContentSource.find_by(id: input[:acs_id])&.audit_refresh
end

def humanized_name
Expand Down
6 changes: 6 additions & 0 deletions app/models/katello/alternate_content_source.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Katello
class AlternateContentSource < Katello::Model
audited
include Ext::LabelFromName
include Encryptable
include ::ScopedSearchExtensions
Expand All @@ -11,6 +12,7 @@ class AlternateContentSource < Katello::Model
# TODO: simplified, rhui
ACS_TYPES = %w(custom).freeze
CONTENT_TYPES = [::Katello::Repository::YUM_TYPE, ::Katello::Repository::FILE_TYPE].freeze
AUDIT_REFRESH_ACTION = 'refresh'.freeze

encrypts :upstream_password

Expand Down Expand Up @@ -67,5 +69,9 @@ def latest_dynflow_refresh_task
@latest_dynflow_refresh_task ||= ForemanTasks::Task::DynflowTask.where(:label => Actions::Katello::AlternateContentSource::Refresh.name).
for_resource(self).order(:started_at).last
end

def audit_refresh
write_audit(action: AUDIT_REFRESH_ACTION, comment: _('Successfully refreshed.'), audited_changes: {})
end
end
end
1 change: 1 addition & 0 deletions app/models/katello/smart_proxy_alternate_content_source.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Katello
class SmartProxyAlternateContentSource < Katello::Model
audited
# Do not use active record callbacks in this join model. Direct INSERTs and DELETEs are done
self.table_name = :katello_smart_proxy_alternate_content_sources
belongs_to :smart_proxy, :inverse_of => :smart_proxy_alternate_content_sources, :class_name => 'SmartProxy'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveLastRefreshedFromKatelloAlternateContentSources < ActiveRecord::Migration[6.0]
def change
remove_column :katello_alternate_content_sources, :last_refreshed, :datetime
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ACSCreateWizard = ({ show, setIsOpen }) => {
id: 4,
name: __('URL and paths'),
component: <AcsUrlPaths />,
enableNext: url !== '' && subpaths !== '',
enableNext: url !== '',
},
{
id: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ const ACSCreateFinish = () => {
name,
description,
base_url: url,
subpaths: subpaths.split(','),
smart_proxy_names: smartProxies,
content_type: contentType,
alternate_content_source_type: acsType,
verify_ssl: verifySSL,
ssl_ca_cert_id: caCert,
};
if (subpaths !== '') {
params = { subpaths: subpaths.split(','), ...params };
}
if (authentication === 'content_credentials') {
params = { ssl_client_cert_id: sslCert, ssl_client_key_id: sslKey, ...params };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ACSReview = () => {
</TextListItem>
<TextListItem component={TextListItemVariants.dt}>{__('Smart proxies')}</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
{smartProxies}
{smartProxies.join(',')}
</TextListItem>
<TextListItem component={TextListItemVariants.dt}>{__('Base URL')}</TextListItem>
<TextListItem component={TextListItemVariants.dd}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const AcsUrlPaths = () => {
label={__('Subpaths')}
type="string"
fieldId="acs_subpaths"
isRequired
>
<TextArea
placeholder="test/repo1/, test/repo2/,"
Expand Down

0 comments on commit 1e399f1

Please sign in to comment.