@@ -9,7 +9,7 @@ import {deletePolicy, newPolicy, uniquePolicyName, updatePolicy} from "../api/in
99import { isEmpty } from "../utils/Utils.js" ;
1010import ErrorIndicator from "../components/ErrorIndicator.jsx" ;
1111import SelectField from "../components/SelectField.jsx" ;
12- import { defaultAttributes , flatMapByValues } from "../utils/Policy.js" ;
12+ import { defaultAttributes , flatMapByValues , policyDesscription } from "../utils/Policy.js" ;
1313import TrashIcon from "@surfnet/sds/icons/functional-icons/bin.svg" ;
1414import ConfirmationDialog from "../components/ConfirmationDialog.jsx" ;
1515
@@ -61,6 +61,16 @@ export const PolicyForm = ({policy, setPolicy, isExistingPolicy, originalName, r
6161 const promise = isExistingPolicy ? updatePolicy : newPolicy ;
6262 //We need to destructure the attributes with multiple values, to single attribute / value pairs
6363 policy . data . attributes = flatMapByValues ( [ ...policy . data . attributes ] ) ;
64+ policy . data . description = policyDesscription (
65+ allowedAttributes ,
66+ policy ,
67+ I18n . t ( `appAccess.breakdown.${ policy . data . denyRule ? "when" : "if" } ` ) . toLowerCase ( ) ,
68+ I18n . t ( "forms.or" ) ,
69+ I18n . t ( `forms.${ policy . data . allAttributesMustMatch ? "and" : "or" } ` ) ,
70+ I18n . t ( `appAccess.breakdown.${ policy . data . denyRule ? "deny" : "allow" } DescriptionPrefix` , {
71+ idp : policy . data . identityProviderIds [ 0 ] . name , sp : policy . data . serviceProviderIds [ 0 ] . name
72+ } )
73+ ) ;
6474 promise ( policy )
6575 . then ( res => {
6676 setFlash ( I18n . t ( `appAccess.flash.${ isExistingPolicy ? "updated" : "created" } ` , { name : res . data . name } ) ) ;
@@ -154,18 +164,6 @@ export const PolicyForm = ({policy, setPolicy, isExistingPolicy, originalName, r
154164 < ErrorIndicator adjustMargin = { true }
155165 msg = { I18n . t ( "appAccess.duplicateName" , { name : policy . data . name } ) } /> }
156166
157- < InputField name = { I18n . t ( "appAccess.description" ) }
158- value = { policy . data . description }
159- required = { true }
160- multiline = { true }
161- error = { ! initial && isEmpty ( policy . data . description ) }
162- placeholder = { I18n . t ( "appAccess.placeholderDescription" ) }
163- onChange = { e => internalUpdatePolicy ( { description : e . target . value } ) }
164- />
165- { ( ! initial && isEmpty ( policy . data . description ) ) &&
166- < ErrorIndicator adjustMargin = { true }
167- msg = { I18n . t ( "forms.required" , { name : I18n . t ( "appAccess.description" ) } ) } /> }
168-
169167 < div className = "row" >
170168 < div className = "row-item" >
171169 < span className = "label standalone" > { I18n . t ( "appAccess.allowDeny" ) }
0 commit comments