Skip to content

Commit

Permalink
Merge pull request #88 from ATIX-AG/Hide_snapshots_in_case_no_VM_asso…
Browse files Browse the repository at this point in the history
…ciated

Hide snapshots in case no vm associated
  • Loading branch information
m-bucher authored Dec 5, 2023
2 parents 6f28c97 + 4f8cf69 commit b1eb3b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 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,16 @@ 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>
);
}
return null;
};

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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,4 @@ exports[`SnapshotManagementCard renders with VMWare capabilities 1`] = `
</CardTemplate>
`;

exports[`SnapshotManagementCard renders without optional Props 1`] = `
<CardTemplate
expandable={false}
header="Snapshots"
masonryLayout={false}
overrideDropdownProps={Object {}}
overrideGridProps={
Object {
"lg": 8,
"md": 12,
"xl": 8,
"xl2": 6,
}
}
/>
`;
exports[`SnapshotManagementCard renders without optional Props 1`] = `""`;

0 comments on commit b1eb3b9

Please sign in to comment.