ui.acls.util.ftl Maven / Gradle / Ivy
<#-- @ftlvariable name="appUrl" type="com.infobip.kafkistry.webapp.url.AppUrl" -->
<#macro resource resource>
<#-- @ftlvariable name="resource" type="com.infobip.kafkistry.model.AclResource" -->
${resource.type}
${resource.name}<#if resource.namePattern.name() == "PREFIXED">*
#if>
#macro>
<#macro operation type>
<#-- @ftlvariable name="type" type="com.infobip.kafkistry.model.AclOperation.Type" -->
${type}
#macro>
<#macro policy policy>
<#-- @ftlvariable name="policy" type="com.infobip.kafkistry.model.AclOperation.Policy" -->
<#switch policy>
<#case "ALLOW">
ALLOW
<#break>
<#case "DENY">
DENY
<#break>
<#default>
${policy}
#switch>
#macro>
<#function operationBtnClass operation>
<#-- @ftlvariable name="operation" type="com.infobip.kafkistry.service.acl.AvailableAclOperation" -->
<#switch operation>
<#case "CREATE_MISSING_ACLS">
<#return "btn-outline-info">
<#case "DELETE_UNWANTED_ACLS">
<#return "btn-outline-danger">
<#case "EDIT_PRINCIPAL_ACLS">
<#return "btn-outline-primary">
<#case "IMPORT_PRINCIPAL">
<#return "btn-outline-primary">
<#default>
<#return "">
#switch>
#function>
<#macro availableOperation operation principal cluster rule>
<#-- @ftlvariable name="operation" type="com.infobip.kafkistry.service.acl.AvailableAclOperation" -->
<#-- @ftlvariable name="principal" type="java.lang.String" -->
<#-- @ftlvariable name="cluster" type="java.lang.String" -->
<#-- @ftlvariable name="rule" type="java.lang.String" OPTIONAL -->
<#assign url = "">
<#assign btnClass = operationBtnClass(operation)>
<#assign btnText = "---">
<#switch operation>
<#case "CREATE_MISSING_ACLS">
<#if rule != "">
<#assign btnText = "Create rule...">
<#assign url = appUrl.acls().showCreatePrincipalRules(principal, cluster, rule)>
<#else>
<#assign btnText = "Create rules...">
<#assign url = appUrl.acls().showCreatePrincipalRules(principal, cluster)>
#if>
<#break>
<#case "DELETE_UNWANTED_ACLS">
<#if rule != "">
<#assign btnText = "Delete rule...">
<#assign url = appUrl.acls().showDeletePrincipalRules(principal, cluster, rule)>
<#else>
<#assign btnText = "Delete rules...">
<#assign url = appUrl.acls().showDeletePrincipalRules(principal, cluster)>
#if>
<#break>
<#case "EDIT_PRINCIPAL_ACLS">
<#assign btnText = "Suggested edit...">
<#assign url = appUrl.acls().showSuggestedEditPrincipal(principal)>
<#break>
<#case "IMPORT_PRINCIPAL">
<#assign btnText = "Import principal ACLs...">
<#assign url = appUrl.acls().showImportPrincipal(principal)>
<#break>
#switch>
${btnText}
#macro>