name: "exte[nable]",
description: "Enable an extension",
action: function (addon) { addon.userDisabled = false; },
- filter: function ({ item }) item.userDisabled,
+ filter: function (addon) addon.userDisabled,
perm: "enable"
},
disable: {
name: "extd[isable]",
description: "Disable an extension",
action: function (addon) { addon.userDisabled = true; },
- filter: function ({ item }) !item.userDisabled,
+ filter: function (addon) !addon.userDisabled,
perm: "disable"
},
options: {
else
this.dactyl.open(addon.optionsURL, { from: "extoptions" });
},
- filter: function ({ item }) item.isActive && item.optionsURL
+ filter: function (addon) addon.isActive && addon.optionsURL
},
rehash: {
name: "extr[ehash]",
});
},
get filter() {
- return function ({ item }) !item.userDisabled &&
- !(item.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE))
+ return function (addon) !addon.userDisabled &&
+ !(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE))
},
perm: "disable"
},
let action = actions[cmd];
if ("perm" in action && !(this.permissions & AddonManager["PERM_CAN_" + action.perm.toUpperCase()]))
return false;
- if ("filter" in action && !action.filter({ item: this }))
+ if ("filter" in action && !action.filter(this))
return false;
return true;
},
}, {
}, {
commands: function (dactyl, modules, window) {
- const { CommandOption, commands, completion } = modules;
+ const { CommandOption, commands, completion, io } = modules;
commands.add(["addo[ns]", "ao"],
"List installed extensions",
// TODO: handle extension dependencies
values(actions).forEach(function (command) {
let perm = command.perm && AddonManager["PERM_CAN_" + command.perm.toUpperCase()];
- function ok(addon) !perm || addon.permissions & perm;
+ function ok(addon) (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon));
commands.add(Array.concat(command.name),
command.description,
dactyl.assert(list.some(ok), _("error.invalidOperation"));
list = list.filter(ok);
}
+ dactyl.assert(list.every(ok));
if (command.actions)
command.actions(list, this.modules);
else
completer: function (context, args) {
completion.addon(context, args["-types"]);
context.filters.push(function ({ item }) ok(item));
- if (command.filter)
- context.filters.push(command.filter);
},
literal: 0,
options: [