Skip to content

Commit e1c2cb7

Browse files
Include no snapshot message
1 parent 422b891 commit e1c2cb7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

app/javascript/components/vm-snapshot-tree-select/index.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './styles.css';
44
import SnapshotTree from './snapshot-tree';
55

66
const VMSnapshotTreeSelect = ({
7-
tree, snapshot, size, time,
7+
tree, snapshot, size, time, name,
88
}) => {
99
const [currentSnapshot, setCurrentSnapshot] = useState({ ...snapshot, size, time });
1010

@@ -52,7 +52,13 @@ const VMSnapshotTreeSelect = ({
5252
<div className="snapshot-tree-title">
5353
{__('Available Snapshots')}
5454
</div>
55-
<SnapshotTree nodes={tree.tree_nodes} setCurrentSnapshot={setCurrentSnapshot} />
55+
{tree.nodes && tree.nodes.length > 1
56+
? <SnapshotTree nodes={tree.tree_nodes} setCurrentSnapshot={setCurrentSnapshot} />
57+
: (
58+
<div className="no-snapshots-message">
59+
{sprintf(__('%s has no snapshots'), name)}
60+
</div>
61+
)}
5662
</div>
5763
);
5864
};
@@ -62,12 +68,14 @@ VMSnapshotTreeSelect.propTypes = {
6268
snapshot: PropTypes.objectOf(PropTypes.any),
6369
size: PropTypes.string,
6470
time: PropTypes.string,
71+
name: PropTypes.string,
6572
};
6673

6774
VMSnapshotTreeSelect.defaultProps = {
6875
snapshot: {},
6976
size: '',
7077
time: '',
78+
name: '',
7179
};
7280

7381
export default VMSnapshotTreeSelect;

app/javascript/components/vm-snapshot-tree-select/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
padding-top: 40px;
2323
}
2424

25+
.no-snapshots-message {
26+
padding-left: 20px;
27+
}
28+
2529
.checkbox {
2630
font-size: 16px;
2731
user-select: none;

app/views/vm_common/_snapshots_desc.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
- total_bytes = _("%{number} bytes") % {:number => number_with_delimiter(snapshot[:total_size], :delimiter => ",", :separator => ".")}
1313
- size = "%{formatted_number} (%{total})" % {:formatted_number => formatted_bytes, :total => total_bytes}
1414

15-
= react('VmSnapshotTreeSelect', {tree: @snapshot_tree, snapshot: snapshot, size: size, time: time})
15+
= react('VmSnapshotTreeSelect', {tree: @snapshot_tree, snapshot: snapshot, size: size, time: time, name: @record.name})

0 commit comments

Comments
 (0)