extension action handle access type
This commit is contained in:
@@ -14,7 +14,9 @@ class ContextualExtensionsMenu {
|
||||
$scope.renderData = {};
|
||||
|
||||
$scope.extensions = _.map(extensionManager.extensionsInContextOfItem($scope.item), function(ext){
|
||||
return _.cloneDeep(ext);
|
||||
// why are we cloning deep?
|
||||
// return _.cloneDeep(ext);
|
||||
return ext;
|
||||
});
|
||||
|
||||
for(let ext of $scope.extensions) {
|
||||
@@ -25,6 +27,10 @@ class ContextualExtensionsMenu {
|
||||
}
|
||||
|
||||
$scope.executeAction = function(action, extension) {
|
||||
if(!$scope.isActionEnabled(action, extension)) {
|
||||
alert("This action requires " + action.access_type + " access to this note. You can change this setting in the Extensions menu on the bottom of the app.");
|
||||
return;
|
||||
}
|
||||
if(action.verb == "nested") {
|
||||
action.showNestedActions = !action.showNestedActions;
|
||||
return;
|
||||
@@ -52,6 +58,18 @@ class ContextualExtensionsMenu {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.isActionEnabled = function(action, extension) {
|
||||
if(action.access_type) {
|
||||
var extEncryptedAccess = extensionManager.extensionUsesEncryptedData(extension);
|
||||
if(action.access_type == "decrypted" && extEncryptedAccess) {
|
||||
return false;
|
||||
} else if(action.access_type == "encrypted" && !extEncryptedAccess) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope.accessTypeForExtension = function(extension) {
|
||||
return extensionManager.extensionUsesEncryptedData(extension) ? "encrypted" : "decrypted";
|
||||
}
|
||||
|
||||
@@ -3,14 +3,18 @@
|
||||
.menu-section-header{"ng-click" => "extension.hide = !extension.hide"}
|
||||
.title {{extension.name}}
|
||||
.subtitle
|
||||
Can access your data
|
||||
Will submit your note
|
||||
%strong {{accessTypeForExtension(extension)}}
|
||||
.spinner.loading{"ng-if" => "extension.loading"}
|
||||
%ul{"ng-if" => "!extension.hide"}
|
||||
%li.menu-item{"ng-repeat" => "action in extension.actionsWithContextForItem(item)", "ng-click" => "executeAction(action, extension)"}
|
||||
%li.menu-item{"ng-repeat" => "action in extension.actionsWithContextForItem(item)", "ng-click" => "executeAction(action, extension)",
|
||||
"ng-class" => "{'faded' : !isActionEnabled(action, extension)}"}
|
||||
.menu-item-title {{action.label}}
|
||||
.menu-item-subtitle {{action.desc}}
|
||||
|
||||
.small.normal{"ng-if" => "!isActionEnabled(action, extension)"}
|
||||
Requires {{action.access_type}} access to this note.
|
||||
|
||||
%div{"ng-if" => "action.showNestedActions"}
|
||||
%ul.mt-10
|
||||
%li.menu-item.white-bg{"ng-repeat" => "subaction in action.subactions", "ng-click" => "executeAction(subaction, extension); $event.stopPropagation()", "style" => "margin-top: -1px;"}
|
||||
|
||||
Reference in New Issue
Block a user