From b9c780c5a8a63f9c80bf6a8f680be04017a41f53 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 30 Jan 2020 19:34:08 +0100 Subject: [PATCH] ui snapshot tree: express formulas more concisely Use arrow functions to bring them in a more simple boolean expression style. Further, we can reuse the "isSnapshot" formula in the "canRollback" and "canRemove" ones. Signed-off-by: Thomas Lamprecht --- www/manager6/tree/SnapshotTree.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/www/manager6/tree/SnapshotTree.js b/www/manager6/tree/SnapshotTree.js index 8ab8bd34..25f487ab 100644 --- a/www/manager6/tree/SnapshotTree.js +++ b/www/manager6/tree/SnapshotTree.js @@ -18,26 +18,12 @@ Ext.define('PVE.guest.SnapshotTree', { load_delay: 3000, }, formulas: { - canSnapshot: function(get) { - return get('snapshotAllowed') && get('snapshotFeature'); - }, - canRollback: function(get) { - return get('rollbackAllowed') && - get('selected') && get('selected') !== 'current'; - }, - canRemove: function(get) { - return get('snapshotAllowed') && - get('selected') && get('selected') !== 'current'; - }, - isSnapshot: function(get) { - return get('selected') && get('selected') !== 'current'; - }, - buttonText: function(get) { - return get('snapshotAllowed') ? gettext('Edit') : gettext('View'); - }, - showMemory: function(get) { - return get('type') === 'qemu'; - }, + canSnapshot: (get) => get('snapshotAllowed') && get('snapshotFeature'), + canRollback: (get) => get('rollbackAllowed') && get('isSnapshot'), + canRemove: (get) => get('snapshotAllowed') && get('isSnapshot'), + isSnapshot: (get) => get('selected') && get('selected') !== 'current', + buttonText: (get) => gettext(get('snapshotAllowed') ? 'Edit' : 'View'), + showMemory: (get) => get('type') === 'qemu', }, }, -- 2.39.2