Github user mcgilman commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2990#discussion_r217816900
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
 ---
    @@ -1045,29 +1041,38 @@
             var reportingTaskActionFormatter = function (row, cell, value, 
columnDef, dataContext) {
                 var markup = '';
     
    -            if (dataContext.permissions.canRead && 
dataContext.permissions.canWrite) {
    -                if (dataContext.component.state === 'RUNNING') {
    +            var canWrite = dataContext.permissions.canWrite;
    +            var canRead = dataContext.permissions.canRead;
    +            var canOperate = dataContext.operatePermissions.canWrite || 
canWrite;
    +            var isStopped = dataContext.status.runStatus === 'STOPPED';
    +
    +            if (dataContext.status.runStatus === 'RUNNING') {
    +                if (canOperate) {
                         markup += '<div title="Stop" class="pointer 
stop-reporting-task fa fa-stop"></div>';
    -                } else if (dataContext.component.state === 'STOPPED' || 
dataContext.component.state === 'DISABLED') {
    -                    markup += '<div title="Edit" class="pointer 
edit-reporting-task fa fa-pencil"></div>';
    +                }
     
    -                    // support starting when stopped and no validation 
errors
    -                    if (dataContext.component.state === 'STOPPED' && 
nfCommon.isEmpty(dataContext.component.validationErrors)) {
    -                        markup += '<div title="Start" class="pointer 
start-reporting-task fa fa-play"></div>';
    -                    }
    +            } else if (isStopped || dataContext.status.runStatus === 
'DISABLED') {
     
    -                    if (dataContext.component.multipleVersionsAvailable 
=== true) {
    -                        markup += '<div title="Change Version" 
class="pointer change-version-reporting-task fa fa-exchange"></div>';
    -                    }
    +                if (canRead && canWrite) {
    +                    markup += '<div title="Edit" class="pointer 
edit-reporting-task fa fa-pencil"></div>';
    +                }
     
    -                    if (nfCommon.canModifyController()) {
    -                        markup += '<div title="Remove" class="pointer 
delete-reporting-task fa fa-trash"></div>';
    -                    }
    +                // support starting when stopped and no validation errors
    +                if (canOperate && dataContext.status.runStatus === 
'STOPPED' && dataContext.status.validationStatus === 'VALID') {
    +                    markup += '<div title="Start" class="pointer 
start-reporting-task fa fa-play"></div>';
                     }
     
    -                if (dataContext.component.persistsState === true) {
    -                    markup += '<div title="View State" class="pointer 
view-state-reporting-task fa fa-tasks"></div>';
    +                if (canRead && canWrite && 
dataContext.component.multipleVersionsAvailable === true) {
    +                    markup += '<div title="Change Version" class="pointer 
change-version-reporting-task fa fa-exchange"></div>';
                     }
    +
    +                if (nfCommon.canModifyController()) {
    --- End diff --
    
    Ah, I see what's changed. I was a little confused. The issue is that 
component removal requires permissions to `WRITE` both the component in 
question and it's parent. With the changes introduced here, we are no longer 
including `canWrite` when determining the visibility of the delete icons.
    
    When I was reviewing, I was seeing the delete icon when I shouldn't have 
been. I only had read and operate permissions to the component but the UI was 
presenting the delete icon (because I still had write permissions to the 
parent). However, when I attempted to actually delete it NiFi correctly told me 
I wasn't allowed.


---

Reply via email to