Skip to content

Commit

Permalink
Hide snapshots in case UUID is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
goarsna committed Sep 18, 2023
1 parent c2d3795 commit cb0aa87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/foreman_snapshot_management/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<SnapshotManagement
key="SnapshotManagement"
Expand All @@ -30,14 +30,17 @@ const SnapshotManagementCard = ({ hostDetails, ...props }) => {
capabilities={capabilities}
/>
);
return (
<CardTemplate
overrideGridProps={{ xl2: 6, xl: 8, lg: 8, md: 12 }}
header={__('Snapshots')}
>
{children}
</CardTemplate>
);
return (
<CardTemplate
overrideGridProps={{ xl2: 6, xl: 8, lg: 8, md: 12 }}
header={__('Snapshots')}
>
{children}
</CardTemplate>
);
}

Check failure on line 41 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, develop)

Replace `⏎··else·⏎···` with `·else`

Check failure on line 41 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, 3.4-stable)

Replace `⏎··else·⏎···` with `·else`

Check failure on line 41 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, 3.3-stable)

Replace `⏎··else·⏎···` with `·else`
else
return null;

Check failure on line 43 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, develop)

Unnecessary 'else' after 'return'

Check failure on line 43 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, 3.4-stable)

Unnecessary 'else' after 'return'

Check failure on line 43 in webpack/components/SnapshotManagementCard/SnapshotManagementCard.js

View workflow job for this annotation

GitHub Actions / Test (12, 3.3-stable)

Unnecessary 'else' after 'return'
};

export default SnapshotManagementCard;
Expand All @@ -46,6 +49,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,
Expand Down

0 comments on commit cb0aa87

Please sign in to comment.