diff --git a/lib/foreman_snapshot_management/engine.rb b/lib/foreman_snapshot_management/engine.rb index 3f1e77a..648cea6 100644 --- a/lib/foreman_snapshot_management/engine.rb +++ b/lib/foreman_snapshot_management/engine.rb @@ -63,7 +63,7 @@ class Engine < ::Rails::Engine context.add_pagelet :main_tabs, :name => N_('Snapshots'), :partial => 'hosts/snapshots_tab', - :onlyif => proc { |host| host&.compute_resource&.capable?(:snapshots) } + :onlyif => proc { |host| host&.uuid.present? && host&.compute_resource&.capable?(:snapshots) } end end end diff --git a/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js b/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js index deb6900..6980c85 100644 --- a/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js +++ b/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js @@ -18,7 +18,7 @@ const SnapshotManagementCard = ({ hostDetails, ...props }) => { hostDetails?.capabilities?.includes('snapshot_include_quiesce') || false, }; - if (hostDetails?.id && hostDetails?.permissions) + if (hostDetails?.uuid && hostDetails?.id && hostDetails?.permissions) { children.push( { capabilities={capabilities} /> ); - return ( - - {children} - - ); + return ( + + {children} + + ); + } + return null; }; export default SnapshotManagementCard; @@ -46,6 +48,7 @@ SnapshotManagementCard.propTypes = { hostDetails: PropTypes.shape({ name: PropTypes.string, id: PropTypes.number, + uuid: PropTypes.string, capabilities: PropTypes.array, permissions: PropTypes.shape({ create_snapshots: PropTypes.bool, diff --git a/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js b/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js index ab83287..23503fd 100644 --- a/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +++ b/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js @@ -5,6 +5,7 @@ import SnapshotManagementCard from '../SnapshotManagementCard'; const hostDetails = { id: 42, name: 'deep.thought', + uuid: '829aa26a-928f-11ee-b9d1-0242ac120002', permissions: { create_snapshots: true, edit_snapshots: false, diff --git a/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap b/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap index 88510d2..85b5eaa 100644 --- a/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +++ b/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap @@ -114,19 +114,4 @@ exports[`SnapshotManagementCard renders with VMWare capabilities 1`] = ` `; -exports[`SnapshotManagementCard renders without optional Props 1`] = ` - -`; +exports[`SnapshotManagementCard renders without optional Props 1`] = `""`;