Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5916: Never display edit link to system items #705

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -152,8 +152,7 @@ case class ComplianceData(
val details = getDirectivesComplianceDetails(report.directives)

RuleComplianceLine (
rule.name
, rule.id
rule
, status
, severity
, details
Expand Down Expand Up @@ -186,10 +185,9 @@ case class ComplianceData(
val callback = AnonFunc("",ajaxCall)

DirectiveComplianceLine (
directive.name
, directive.id
directive
, techniqueName
, techniqueVersion : TechniqueVersion
, techniqueVersion
, Some(buildComplianceChart(directiveStatus))
, status
, severity
Expand All @@ -216,10 +214,9 @@ case class ComplianceData(
} yield {

DirectiveComplianceLine (
directive.name
, directive.id
directive
, techniqueName
, techniqueVersion : TechniqueVersion
, techniqueVersion
, None
, status
, severity
Expand Down Expand Up @@ -480,19 +477,19 @@ case class ComponentComplianceLine (
/*
* Javascript object containing all data to create a line in the DataTable
* { "directive" : Directive name [String]
* , "id" : Rule id [String]
* , "compliance" : compliance percent as String, not used in message popup [String]
* , "id" : Directive id [String]
* , "compliance" : compliance percent as String [String]
* , "techniqueName": Name of the technique the Directive is based upon [String]
* , "techniqueVersion" : Version of the technique the Directive is based upon [String]
* , "status" : Worst status of the Directive [String]
* , "statusClass" : Class to use on status cell [String]
* , "details" : Details of components contained in the Directive [Array of Directive values ]
* , "callback" : Function to when clicking on compliance percent, not used in message popup [ Function ]
* , "callback" : Function to when clicking on compliance percent [ Function ]
* , "isSystem" : Is it a system Directive? [Boolean]
* }
*/
case class DirectiveComplianceLine (
directive : String
, id : DirectiveId
directive : Directive
, techniqueName : String
, techniqueVersion : TechniqueVersion
, compliance : Option[String]
Expand All @@ -510,13 +507,14 @@ case class DirectiveComplianceLine (

val baseFields = {
JsObj (
( "directive" -> directive )
, ( "id" -> id.value )
( "directive" -> directive.name )
, ( "id" -> directive.id.value )
, ( "techniqueName" -> techniqueName )
, ( "techniqueVersion" -> techniqueVersion.toString )
, ( "status" -> status )
, ( "statusClass" -> statusClass )
, ( "details" -> details.json )
, ( "isSystem" -> directive.isSystem )
)
}

Expand Down Expand Up @@ -554,25 +552,26 @@ case class NodeComplianceLine (
* Javascript object containing all data to create a line in the DataTable
* { "rule" : Rule name [String]
* , "id" : Rule id [String]
* , "status" : Worst status of the Directive [String]
* , "status" : Worst status of the Rule [String]
* , "statusClass" : Class to use on status cell [String]
* , "details" : Details of components contained in the Directive [Array of Component values ]
* , "details" : Details of directives contained in the Rule [Array of Directives ]
* , "isSystem" : is it a system Rule? [Boolean]
* }
*/
case class RuleComplianceLine (
name : String
, id : RuleId
rule : Rule
, status : String
, statusClass : String
, details : JsTableData[DirectiveComplianceLine]
) extends JsTableLine {
val json = {
JsObj (
( "rule" -> name )
( "rule" -> rule.name )
, ( "status" -> status )
, ( "statusClass" -> statusClass )
, ( "id" -> id.value )
, ( "id" -> rule.id.value )
, ( "details" -> details.json )
, ( "isSystem" -> rule.isSystem )
)
}
}
Expand Up @@ -235,7 +235,7 @@ object DisplayDirectiveTree extends Loggable {
val tooltipId = Helpers.nextFuncName

val actions = {
if (addEditLink) {
if (addEditLink && ! directive.isSystem) {
<img src="/images/icPen.png" class="treeActions treeAction noRight" /> ++ Script(JsRaw(s"""
$$('#${htmlId} .treeActions').on("mouseup", function(e) {
var url = '${S.contextPath}/secure/configurationManager/directiveManagement#{"directiveId":"${directive.id.value}"}';
Expand Down
48 changes: 27 additions & 21 deletions rudder-web/src/main/webapp/javascript/rudder/rudder-datatable.js
Expand Up @@ -452,14 +452,15 @@ function createComponentTable (isTopLevel, addCompliance, contextPath) {
/*
* Javascript object containing all data to create a line in the DataTable
* { "directive" : Directive name [String]
* , "id" : Rule id [String]
* , "id" : Directive id [String]
* , "compliance" : compliance percent as String [String]
* , "techniqueName": Name of the technique the Directive is based upon [String]
* , "techniqueVersion" : Version of the technique the Directive is based upon [String]
* , "status" : Worst status of the Directive [String]
* , "statusClass" : Class to use on status cell [String]
* , "details" : Details of components contained in the Directive [Array of Directive values ]
* , "callback" : Function to when clicking on compliance percent [ Function ]
* , "isSystem" : Is it a system Directive? [Boolean]
* }
*/
function createDirectiveTable (isTopLevel, addCompliance, contextPath) {
Expand Down Expand Up @@ -500,17 +501,20 @@ function createDirectiveTable (isTopLevel, addCompliance, contextPath) {
toolTipContainer.addClass("tooltipContent");
toolTipContainer.attr("id",tooltipId);

var editLink = $("<a />");
editLink.attr("href",contextPath + '/secure/configurationManager/directiveManagement#{"directiveId":"'+oData.id+'"}')
var editIcon = $("<img />");
editIcon.attr("src",contextPath + "/images/icPen.png");
editLink.click(function(e) {e.stopPropagation();})
editLink.append(editIcon);
editLink.addClass("reportIcon");

$(nTd).append(tooltipIcon);
$(nTd).append(toolTipContainer);
$(nTd).append(editLink);

if (! oData.isSystem) {
var editLink = $("<a />");
editLink.attr("href",contextPath + '/secure/configurationManager/directiveManagement#{"directiveId":"'+oData.id+'"}')
var editIcon = $("<img />");
editIcon.attr("src",contextPath + "/images/icPen.png");
editLink.click(function(e) {e.stopPropagation();})
editLink.append(editIcon);
editLink.addClass("reportIcon");

$(nTd).append(editLink);
}
}
} , {
"sWidth": statusWidth
Expand Down Expand Up @@ -573,9 +577,10 @@ function createDirectiveTable (isTopLevel, addCompliance, contextPath) {
* Javascript object containing all data to create a line in the DataTable
* { "rule" : Rule name [String]
* , "id" : Rule id [String]
* , "status" : Worst status of the Directive [String]
* , "status" : Worst status of the Rule [String]
* , "statusClass" : Class to use on status cell [String]
* , "details" : Details of components contained in the Directive [Array of Component values ]
* , "details" : Details of directives contained in the Rule [Array of Directives ]
* , "isSystem" : is it a system Rule? [Boolean]
* }
*/
function createRuleComplianceTable (gridId, data, contextPath, refresh) {
Expand All @@ -586,16 +591,17 @@ function createRuleComplianceTable (gridId, data, contextPath, refresh) {
, "sTitle": "Rule"
, "fnCreatedCell" : function (nTd, sData, oData, iRow, iCol) {
$(nTd).addClass("listopen");

if (! oData.isSystem) {
var editLink = $("<a />");
editLink.attr("href",contextPath + '/secure/configurationManager/ruleManagement#{"ruleId":"'+oData.id+'"}')
var editIcon = $("<img />");
editIcon.attr("src",contextPath + "/images/icPen.png");
editLink.click(function(e) {e.stopPropagation();})
editLink.append(editIcon);
editLink.addClass("reportIcon");

$(nTd).append(editLink);
editLink.attr("href",contextPath + '/secure/configurationManager/ruleManagement#{"ruleId":"'+oData.id+'"}')
var editIcon = $("<img />");
editIcon.attr("src",contextPath + "/images/icPen.png");
editLink.click(function(e) {e.stopPropagation();})
editLink.append(editIcon);
editLink.addClass("reportIcon");

$(nTd).append(editLink);
}
}
} , {
"sWidth": "15%"
Expand Down