@@ -60,7 +60,6 @@ import { red } from '@mui/material/colors/';
6060import Autocomplete from '@mui/material/Autocomplete' ;
6161import CheckBoxIcon from '@mui/icons-material/CheckBox' ;
6262import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank' ;
63- import Constraints from 'AppComponents/KeyManagers/Constraints' ;
6463
6564const StyledSpan = styled ( 'span' ) ( ( { theme } ) => ( { color : theme . palette . error . dark } ) ) ;
6665
@@ -247,9 +246,6 @@ function AddEditKeyManager(props) {
247246 const [ enableExchangeToken , setEnableExchangeToken ] = useState ( false ) ;
248247 const [ enableDirectToken , setEnableDirectToken ] = useState ( true ) ;
249248 const [ organizations , setOrganizations ] = useState ( [ ] ) ;
250- const [ constraintConfigurations , setConstraintConfigurations ] = useState ( [ ] ) ;
251- const [ constraints , setConstraints ] = useState ( { } ) ;
252- const [ constraintSectionExpanded , setConstraintSectionExpanded ] = useState ( false ) ;
253249
254250 const restApi = new API ( ) ;
255251 const handleRoleAddition = ( role ) => {
@@ -291,7 +287,6 @@ function AddEditKeyManager(props) {
291287 if ( settings . keyManagerConfiguration ) {
292288 settings . keyManagerConfiguration . map ( ( {
293289 type : key , defaultConsumerKeyClaim, defaultScopesClaim, configurations, authConfigurations,
294- configurationConstraints : constraintsConfigurations ,
295290 } ) => {
296291 if ( key === keyManagerType ) {
297292 if ( ! id ) {
@@ -307,11 +302,6 @@ function AddEditKeyManager(props) {
307302 ...( Array . isArray ( authConfigurations ) ? authConfigurations : [ ] ) ,
308303 ...configurations ,
309304 ] ) ;
310- setConstraintConfigurations ( constraintsConfigurations || [ ] ) ;
311- return true ;
312- } else if ( key === 'WSO2-IS' && keyManagerType === 'default' ) {
313- // since Application properties are same for default(resident key manager) and WSO2-IS Key managers
314- setConstraintConfigurations ( constraintsConfigurations || [ ] ) ;
315305 return true ;
316306 } else {
317307 return false ;
@@ -547,10 +537,6 @@ function AddEditKeyManager(props) {
547537
548538 const keymanager = {
549539 ...state ,
550- additionalProperties : {
551- ...state . additionalProperties ,
552- constraints : ! isEmpty ( constraints ) ? constraints : undefined ,
553- } ,
554540 tokenValidation : newTokenValidation ,
555541 allowedOrganizations : validOrgs ,
556542 tokenType,
@@ -612,60 +598,6 @@ function AddEditKeyManager(props) {
612598 }
613599 dispatch ( { field : 'additionalProperties' , value : clonedAdditionalProperties } ) ;
614600 } ;
615-
616- const getConstraintsData = ( ) => {
617- const savedConstraints = additionalProperties ?. constraints || { } ;
618- const constraintsData = { } ;
619- constraintConfigurations . forEach ( ( constraintConfig ) => {
620- const key = constraintConfig . name ;
621- const savedConstraint = savedConstraints [ key ] ;
622- if ( savedConstraint ?. type && savedConstraint ?. value ) {
623- constraintsData [ key ] = savedConstraint ;
624- } else if ( ! id && constraintConfig . default ) {
625- if ( isEmpty ( constraintConfig . default ) ) {
626- return ;
627- }
628- constraintsData [ key ] = {
629- type : constraintConfig . constraintType ,
630- value : constraintConfig . default ,
631- } ;
632- }
633- } ) ;
634- return { constraintsData } ;
635- } ;
636-
637- const handleConstraintUpdate = ( configName , value ) => {
638- setConstraints ( ( prev ) => {
639- const newConstraints = { ...prev } ;
640- if ( value === undefined || value === null ) {
641- delete newConstraints [ configName ] ;
642- } else {
643- const config = constraintConfigurations . find ( ( c ) => c . name === configName ) ;
644- if ( config ) {
645- newConstraints [ configName ] = { type : config . constraintType , value } ;
646- }
647- }
648- return newConstraints ;
649- } ) ;
650- } ;
651-
652- const handleConstraintsExpandClick = ( ) => {
653- setConstraintSectionExpanded ( ! constraintSectionExpanded ) ;
654- } ;
655-
656- useEffect ( ( ) => {
657- if ( ! isEmpty ( constraintConfigurations ) ) {
658- const { constraintsData } = getConstraintsData ( ) ;
659- if ( ! isEmpty ( constraintsData ) ) {
660- setConstraints ( constraintsData ) ;
661- }
662- // Auto-expand if any field is already constrained (value is not null)
663- if ( Object . values ( constraintsData ) . some ( ( c ) => c . value !== null ) ) {
664- setConstraintSectionExpanded ( true ) ;
665- }
666- }
667- } , [ constraintConfigurations , id ] ) ;
668-
669601 const setTokenValidations = ( value ) => {
670602 dispatch ( { field : 'tokenValidation' , value } ) ;
671603 } ;
@@ -2382,69 +2314,6 @@ function AddEditKeyManager(props) {
23822314 </ Typography >
23832315 ) }
23842316 </ Box >
2385- { ! isEmpty ( constraintConfigurations ) && (
2386- < >
2387- < Box display = 'flex' marginTop = { 3 } marginBottom = { 2 } >
2388- < Typography
2389- color = 'inherit'
2390- variant = 'subtitle2'
2391- component = 'a'
2392- onClick = { handleConstraintsExpandClick }
2393- style = { { cursor : 'pointer' } }
2394- id = 'KeyManagers.AddEditKeyManager.app.config.constraints.header'
2395- >
2396- < FormattedMessage
2397- id = 'KeyManagers.AddEditKeyManager.app.config.constraints'
2398- defaultMessage = 'Application Configuration Constraints'
2399- />
2400- </ Typography >
2401- < IconButton
2402- sx = { { marginLeft : 'auto' } }
2403- onClick = { handleConstraintsExpandClick }
2404- aria-expanded = { constraintSectionExpanded }
2405- aria-label = 'show more'
2406- size = 'large'
2407- >
2408- < StyledExpandMoreIcon
2409- className = {
2410- constraintSectionExpanded
2411- ? 'expandOpen' : 'expand'
2412- }
2413- />
2414- </ IconButton >
2415- </ Box >
2416- < Box >
2417- < Collapse
2418- in = { constraintSectionExpanded }
2419- timeout = 'auto'
2420- unmountOnExit
2421- >
2422- < Box pl = { 2 } >
2423- < Constraints
2424- items = { constraintConfigurations }
2425- constraintsData = { constraints }
2426- onChange = { handleConstraintUpdate }
2427- disabled = { false }
2428- />
2429- </ Box >
2430- </ Collapse >
2431- { ! constraintSectionExpanded && (
2432- < Typography
2433- color = 'inherit'
2434- variant = 'caption'
2435- component = 'div'
2436- style = { { paddingLeft : 16 } }
2437- id = 'KeyManagers.AddEditKeyManager.constraints.hidden.help.body'
2438- >
2439- < FormattedMessage
2440- id = 'KeyManagers.AddEditKeyManager.constraints.hidden.help'
2441- defaultMessage = 'Expand to configure constraints'
2442- />
2443- </ Typography >
2444- ) }
2445- </ Box >
2446- </ >
2447- ) }
24482317 </ Box >
24492318 </ Grid >
24502319 ) }
0 commit comments