mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:07:58 +01:00
Show error for disallowed extension delete/enable/disable.
This commit is contained in:
@@ -1553,21 +1553,26 @@ const Dactyl = Module("dactyl", {
|
|||||||
{
|
{
|
||||||
name: "extde[lete]",
|
name: "extde[lete]",
|
||||||
description: "Uninstall an extension",
|
description: "Uninstall an extension",
|
||||||
action: callResult("uninstall")
|
action: callResult("uninstall"),
|
||||||
|
perm: "uninstall"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "exte[nable]",
|
name: "exte[nable]",
|
||||||
description: "Enable an extension",
|
description: "Enable an extension",
|
||||||
action: function (addon) addon.userDisabled = false,
|
action: function (addon) addon.userDisabled = false,
|
||||||
filter: function ({ item }) item.userDisabled
|
filter: function ({ item }) item.userDisabled,
|
||||||
|
perm: "enable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "extd[isable]",
|
name: "extd[isable]",
|
||||||
description: "Disable an extension",
|
description: "Disable an extension",
|
||||||
action: function (addon) addon.userDisabled = true,
|
action: function (addon) addon.userDisabled = true,
|
||||||
filter: function ({ item }) !item.userDisabled
|
filter: function ({ item }) !item.userDisabled,
|
||||||
|
perm: "disable"
|
||||||
}
|
}
|
||||||
].forEach(function (command) {
|
].forEach(function (command) {
|
||||||
|
let perm = AddonManager["PERM_CAN_" + command.perm.toUpperCase()];
|
||||||
|
function ok(addon) !perm || addon.permissions & perm;
|
||||||
commands.add([command.name],
|
commands.add([command.name],
|
||||||
command.description,
|
command.description,
|
||||||
function (args) {
|
function (args) {
|
||||||
@@ -1580,6 +1585,8 @@ const Dactyl = Module("dactyl", {
|
|||||||
AddonManager.getAddonsByTypes(["extension"], function (list) {
|
AddonManager.getAddonsByTypes(["extension"], function (list) {
|
||||||
if (!args.bang)
|
if (!args.bang)
|
||||||
list = list.filter(function (extension) extension.name == name);
|
list = list.filter(function (extension) extension.name == name);
|
||||||
|
if (!args.bang && !list.every(ok))
|
||||||
|
return dactyl.echoerr("Permission denied");
|
||||||
list.forEach(command.action);
|
list.forEach(command.action);
|
||||||
});
|
});
|
||||||
}, {
|
}, {
|
||||||
@@ -1587,6 +1594,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
completion.extension(context);
|
completion.extension(context);
|
||||||
|
context.filters.push(function ({ item }) ok(item));
|
||||||
if (command.filter)
|
if (command.filter)
|
||||||
context.filters.push(command.filter);
|
context.filters.push(command.filter);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user