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 14, 2023
1 parent c2d3795 commit 1b236ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 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&.compute_resource&.capable?(:snapshots) && host&.uuid }
end
end
end
Expand Down
41 changes: 22 additions & 19 deletions webpack/components/SnapshotManagementCard/SnapshotManagementCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@ const SnapshotManagementCard = ({ hostDetails, ...props }) => {
hostDetails?.capabilities?.includes('snapshot_include_quiesce') || false,
};

if (hostDetails?.id && hostDetails?.permissions)
children.push(
<SnapshotManagement
key="SnapshotManagement"
host={{ id: hostDetails.id, name: hostDetails.name }}
canCreate={hostDetails.permissions.create_snapshots}
canUpdate={hostDetails.permissions.edit_snapshots}
canRevert={hostDetails.permissions.revert_snapshots}
canDelete={hostDetails.permissions.destroy_snapshots}
capabilities={capabilities}
/>
if (hostDetails?.uuid) {
if (hostDetails?.id && hostDetails?.permissions)
children.push(
<SnapshotManagement
key="SnapshotManagement"
host={{ id: hostDetails.id, name: hostDetails.name }}
canCreate={hostDetails.permissions.create_snapshots}
canUpdate={hostDetails.permissions.edit_snapshots}
canRevert={hostDetails.permissions.revert_snapshots}
canDelete={hostDetails.permissions.destroy_snapshots}
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>
);
}
};

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

0 comments on commit 1b236ff

Please sign in to comment.