]> git.proxmox.com Git - pve-manager.git/commitdiff
ui snapshot tree: express formulas more concisely
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Jan 2020 18:34:08 +0000 (19:34 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Jan 2020 18:34:35 +0000 (19:34 +0100)
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 <t.lamprecht@proxmox.com>
www/manager6/tree/SnapshotTree.js

index 8ab8bd34475ee7c7ed8a28b9bfe80b7aab89803d..25f487abc51c9e568abaf7678788f65dca20106f 100644 (file)
@@ -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',
        },
     },