rfellows commented on a change in pull request #3606: [WIP] Nifi 6282
URL: https://github.com/apache/nifi/pull/3606#discussion_r309422588
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-parameter-contexts.js
 ##########
 @@ -0,0 +1,2092 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* global define, module, require, exports */
+
+(function (root, factory) {
+    if (typeof define === 'function' && define.amd) {
+        define(['jquery',
+                'Slick',
+                'd3',
+                'nf.Client',
+                'nf.Dialog',
+                'nf.Storage',
+                'nf.Common',
+                'nf.CanvasUtils',
+                'nf.ng.Bridge',
+                'nf.ErrorHandler',
+                'nf.FilteredDialogCommon',
+                'nf.Shell',
+                'nf.ComponentState',
+                'nf.ComponentVersion',
+                'nf.PolicyManagement',
+                'nf.Processor',
+                'nf.ProcessGroup',
+                'nf.ProcessGroupConfiguration'],
+            function ($, Slick, d3, nfClient, nfDialog, nfStorage, nfCommon, 
nfCanvasUtils, nfNgBridge, nfErrorHandler, nfFilteredDialogCommon, nfShell, 
nfComponentState, nfComponentVersion, nfPolicyManagement, nfProcessor, 
nfProcessGroup, nfProcessGroupConfiguration) {
+                return (nf.ParameterContexts = factory($, Slick, d3, nfClient, 
nfDialog, nfStorage, nfCommon, nfCanvasUtils, nfNgBridge, nfErrorHandler, 
nfFilteredDialogCommon, nfShell, nfComponentState, nfComponentVersion, 
nfPolicyManagement, nfProcessor, nfProcessGroup, nfProcessGroupConfiguration));
+            });
+    } else if (typeof exports === 'object' && typeof module === 'object') {
+        module.exports = (nf.ParameterContexts =
+            factory(require('jquery'),
+                require('Slick'),
+                require('d3'),
+                require('nf.Client'),
+                require('nf.Dialog'),
+                require('nf.Storage'),
+                require('nf.Common'),
+                require('nf.CanvasUtils'),
+                require('nf.ng.Bridge'),
+                require('nf.ErrorHandler'),
+                require('nf.FilteredDialogCommon'),
+                require('nf.Shell'),
+                require('nf.ComponentState'),
+                require('nf.ComponentVersion'),
+                require('nf.PolicyManagement'),
+                require('nf.Processor'),
+                require('nf.ProcessGroup'),
+                require('nf.ProcessGroupConfiguration')));
+    } else {
+        nf.ParameterContexts = factory(root.$,
+            root.Slick,
+            root.d3,
+            root.nf.Client,
+            root.nf.Dialog,
+            root.nf.Storage,
+            root.nf.Common,
+            root.nf.CanvasUtils,
+            root.nf.ng.Bridge,
+            root.nf.ErrorHandler,
+            root.nf.FilteredDialogCommon,
+            root.nf.Shell,
+            root.nf.ComponentState,
+            root.nf.ComponentVersion,
+            root.nf.PolicyManagement,
+            root.nf.Processor,
+            root.nf.ProcessGroup,
+            root.nf.ProcessGroupConfiguration);
+    }
+}(this, function ($, Slick, d3, nfClient, nfDialog, nfStorage, nfCommon, 
nfCanvasUtils, nfNgBridge, nfErrorHandler, nfFilteredDialogCommon, nfShell, 
nfComponentState, nfComponentVersion, nfPolicyManagement, nfProcessor, 
nfProcessGroup, nfProcessGroupConfiguration) {
+    'use strict';
+
+    var config = {
+        urls: {
+            parameterContexts: '../nifi-api/parameter-contexts'
+        }
+    };
+
+    var parameterContextsGridOptions = {
+        forceFitColumns: true,
+        enableTextSelectionOnCells: true,
+        enableCellNavigation: true,
+        enableColumnReorder: false,
+        autoEdit: false,
+        multiSelect: false,
+        rowHeight: 24
+    };
+
+    var parametersGridOptions = {
+        forceFitColumns: true,
+        enableTextSelectionOnCells: true,
+        enableCellNavigation: true,
+        enableColumnReorder: false,
+        editable: false,
+        enableAddRow: false,
+        autoEdit: false,
+        multiSelect: false,
+        rowHeight: 24
+    };
+
+    /**
+     * Formatter for the name column.
+     *
+     * @param {type} row
+     * @param {type} cell
+     * @param {type} value
+     * @param {type} columnDef
+     * @param {type} dataContext
+     * @returns {String}
+     */
+    var nameFormatter = function (row, cell, value, columnDef, dataContext) {
+        if (!dataContext.permissions.canRead) {
+            return '<span class="blank">' + 
nfCommon.escapeHtml(dataContext.id) + '</span>';
+        }
+
+        return nfCommon.escapeHtml(dataContext.component.name);
+    };
+
+    /**
+     * Sorts the specified data using the specified sort details.
+     *
+     * @param {object} sortDetails
+     * @param {object} data
+     */
+    var sort = function (sortDetails, data) {
+        // defines a function for sorting
+        var comparer = function (a, b) {
+            if (a.permissions.canRead && b.permissions.canRead) {
+                var aString = 
nfCommon.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? 
a.component[sortDetails.columnId] : '';
 
 Review comment:
   These kinds of ternaries are good candidates to be replaced with lodash 
calls.
   Example: 
   ```
   // use _.get to try to access the piece of the object you want, but provide 
a default value it it is not there
   var aString = _.get(a, 'component[' +  sortDetails.columnId + ']', '');
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to