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

    https://github.com/apache/nifi/pull/1188#discussion_r87585264
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js
 ---
    @@ -470,6 +470,214 @@ nf.UsersTable = (function () {
         };
     
         /**
    +     * Initializes the user policies dialog.
    +     */
    +    var initUserPoliciesDialog = function () {
    +        $('#user-policies-dialog').modal({
    +            headerText: 'User Policies',
    +            buttons: [{
    +                buttonText: 'Close',
    +                color: {
    +                    base: '#728E9B',
    +                    hover: '#004849',
    +                    text: '#ffffff'
    +                },
    +                handler: {
    +                    click: function () {
    +                        //TODO: some work
    +
    +                        $('#user-policies-dialog').modal('hide');
    +                    }
    +                }
    +            }]
    +        });
    +    };
    +
    +    /**
    +     * Generates a human readable global policy strung.
    +     *
    +     * @param dataContext
    +     * @returns {string}
    +     */
    +    var globalResourceParser = function (dataContext) {
    +        return 'Global policy to ' +
    +            
nf.Common.getPolicyTypeListing(nf.Common.substringAfterFirst(dataContext.component.resource,
 '/')).text;
    +    };
    +
    +    /**
    +     * Generates a human readable component policy string.
    +     *
    +     * @param dataContext
    +     * @returns {string}
    +     */
    +    var componentResourceParser = function (dataContext) {
    +        var resource = dataContext.component.resource;
    +        var policyLabel = '';
    +
    +        //determine policy type
    +        if (resource.startsWith('/policies')) {
    +            resource = nf.Common.substringAfterFirst(resource, 
'/policies');
    +            policyLabel += 'Admin policy for ';
    +        } else if (resource.startsWith('/data-transfer')) {
    +            resource = nf.Common.substringAfterFirst(resource, 
'/data-transfer');
    +            policyLabel += 'Site to site policy for ';
    +        } else if (resource.startsWith('/data')) {
    +            resource = nf.Common.substringAfterFirst(resource, '/data');
    +            policyLabel += 'Data policy for ';
    +        } else {
    +            policyLabel += 'Component policy for ';
    +        }
    +
    +        if (resource.startsWith('/processors')) {
    +            policyLabel += 'processor ';
    +        } else if (resource.startsWith('/controller-services')) {
    +            policyLabel += 'controller services ';
    +        } else if (resource.startsWith('/funnels')) {
    +            policyLabel += 'funnel ';
    +        } else if (resource.startsWith('/input-ports')) {
    +            policyLabel += 'input port ';
    +        } else if (resource.startsWith('/labels')) {
    +            policyLabel += 'label ';
    +        } else if (resource.startsWith('/output-ports')) {
    +            policyLabel += 'output port ';
    +        } else if (resource.startsWith('/process-groups')) {
    +            policyLabel += 'process group ';
    +        } else if (resource.startsWith('/remote-process-groups')) {
    +            policyLabel += 'remote process group ';
    +        } else if (resource.startsWith('/reporting-tasks')) {
    +            policyLabel += 'reporting task ';
    +        } else if (resource.startsWith('/templates')) {
    +            policyLabel += 'template ';
    +        }
    +
    +        if (dataContext.component.componentReference.permissions.canRead 
=== true) {
    +            policyLabel += 
dataContext.component.componentReference.component.name;
    +        } else {
    +            policyLabel += '<span class="unset">' + 
dataContext.component.componentReference.id + '</span>'
    +        }
    +
    +        return policyLabel;
    +    };
    +
    +    /**
    +     * Initializes the user policies table.
    +     */
    +    var initUserPoliciesTable = function () {
    +
    +        // function for formatting the human readable name of the policy
    +        var policyDisplayNameFormatter = function (row, cell, value, 
columnDef, dataContext) {
    +            // if the user has permission to the policy
    +            if (dataContext.permissions.canRead === true) {
    +                // check if Global policy
    +                if 
(nf.Common.isUndefinedOrNull(dataContext.component.componentReference)) {
    +                    return globalResourceParser(dataContext);
    +                }
    +                // not a global policy... check if user has access to the 
component reference
    +                return componentResourceParser(dataContext);
    +            } else {
    +                return '<span class="unset">' + dataContext.id + '</span>';
    +            }
    +        };
    +
    +        // function for formatting the actions column
    +        var actionsFormatter = function (row, cell, value, columnDef, 
dataContext) {
    +            var markup = '';
    +
    +            if (dataContext.permissions.canRead === true) {
    +                if 
(nf.Common.isDefinedAndNotNull(dataContext.component.componentReference)) {
    +                    markup += '<div title="Go To" class="pointer 
go-to-user-policies fa fa-long-arrow-right" style="float: left;"></div>';
    +                }
    +            }
    +
    +            return markup;
    +        };
    +
    +        // function for formatting the action column
    +        var actionFormatter = function (row, cell, value, columnDef, 
dataContext) {
    +            var markup = '';
    +
    +            if (dataContext.permissions.canRead === true) {
    +                markup += dataContext.component.action;
    +            }
    +
    +            return markup;
    +        };
    +
    +        var userPoliciesColumns = [
    +            {id: 'policy', name: 'Policy', sortable: true, resizable: 
true, formatter: policyDisplayNameFormatter, width: 150},
    +            {id: 'action', name: 'Action', sortable: true, resizable: 
false, formatter: actionFormatter, width: 50}
    +        ];
    +
    +        // add the actions if we're in the shell
    +        if ((top !== window) && nf.Common.canAccessPolicies()) {
    --- End diff --
    
    Policies will have their own specific permissions. No need to check if the 
user can access all policies here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to