1- import React , { useEffect } from ' react'
2- import { useDispatch , useSelector } from ' react-redux'
3- import { useNavigate } from ' react-router-dom'
4- import { CardBody , Card } from ' Components'
5- import ScopeForm from ' ./ScopeForm'
6- import { addScope } from ' Plugins/auth-server/redux/features/scopeSlice'
7- import { buildPayload } from ' Utils/PermChecker'
8- import GluuLoader from ' Routes/Apps/Gluu/GluuLoader'
9- import { getAttributes , getScripts } from ' Redux/features/initSlice'
10- import GluuAlert from ' Routes/Apps/Gluu/GluuAlert'
11- import { useTranslation } from ' react-i18next'
12- import applicationStyle from ' Routes/Apps/Gluu/styles/applicationstyle'
1+ import React , { useEffect } from " react" ;
2+ import { useDispatch , useSelector } from " react-redux" ;
3+ import { useNavigate } from " react-router-dom" ;
4+ import { CardBody , Card } from " Components" ;
5+ import ScopeForm from " ./ScopeForm" ;
6+ import { addScope } from " Plugins/auth-server/redux/features/scopeSlice" ;
7+ import { buildPayload } from " Utils/PermChecker" ;
8+ import GluuLoader from " Routes/Apps/Gluu/GluuLoader" ;
9+ import { getAttributes , getScripts } from " Redux/features/initSlice" ;
10+ import GluuAlert from " Routes/Apps/Gluu/GluuAlert" ;
11+ import { useTranslation } from " react-i18next" ;
12+ import applicationStyle from " Routes/Apps/Gluu/styles/applicationstyle" ;
1313
1414function ScopeAddPage ( ) {
15- const loading = useSelector ( ( state ) => state . scopeReducer . loading )
16- const scripts = useSelector ( ( state ) => state . initReducer . scripts )
17- const attributes = useSelector ( ( state ) => state . initReducer . attributes )
18- const saveOperationFlag = useSelector ( ( state ) => state . scopeReducer . saveOperationFlag )
19- const errorInSaveOperationFlag = useSelector ( ( state ) => state . scopeReducer . errorInSaveOperationFlag )
15+ const loading = useSelector ( ( state ) => state . scopeReducer . loading ) ;
16+ const scripts = useSelector ( ( state ) => state . initReducer . scripts ) ;
17+ const attributes = useSelector ( ( state ) => state . initReducer . attributes ) ;
18+ const saveOperationFlag = useSelector (
19+ ( state ) => state . scopeReducer . saveOperationFlag
20+ ) ;
21+ const errorInSaveOperationFlag = useSelector (
22+ ( state ) => state . scopeReducer . errorInSaveOperationFlag
23+ ) ;
2024
21- const dispatch = useDispatch ( )
25+ const dispatch = useDispatch ( ) ;
2226
23- const userAction = { }
24- const navigate = useNavigate ( )
25- const { t } = useTranslation ( )
27+ const userAction = { } ;
28+ const navigate = useNavigate ( ) ;
29+ const { t } = useTranslation ( ) ;
2630 useEffect ( ( ) => {
2731 if ( attributes . length === 0 ) {
28- buildPayload ( userAction , 'Fetch attributes' , { limit : 100 } )
29- dispatch ( getAttributes ( { options : userAction } ) )
32+ buildPayload ( userAction , "Fetch attributes" , { limit : 100 } ) ;
33+ console . log ( "userAction" , userAction ) ;
34+ dispatch ( getAttributes ( { options : userAction } ) ) ;
3035 }
3136 if ( scripts . length === 0 ) {
32- buildPayload ( userAction , ' Fetch custom scripts' , { } )
33- dispatch ( getScripts ( { action : userAction } ) )
37+ buildPayload ( userAction , " Fetch custom scripts" , { } ) ;
38+ dispatch ( getScripts ( { action : userAction } ) ) ;
3439 }
35- } , [ ] )
40+ } , [ ] ) ;
3641
3742 useEffect ( ( ) => {
3843 if ( saveOperationFlag && ! errorInSaveOperationFlag )
39- navigate ( ' /auth-server/scopes' )
40- } , [ saveOperationFlag ] )
44+ navigate ( " /auth-server/scopes" ) ;
45+ } , [ saveOperationFlag ] ) ;
4146
4247 function handleSubmit ( data ) {
4348 if ( data ) {
44- const postBody = { }
45- data = JSON . parse ( data )
46- const message = data . action_message
47- delete data . action_message
48- postBody [ ' scope' ] = data
49- buildPayload ( userAction , message , postBody )
50- dispatch ( addScope ( { action : userAction } ) )
49+ const postBody = { } ;
50+ data = JSON . parse ( data ) ;
51+ const message = data . action_message ;
52+ delete data . action_message ;
53+ postBody [ " scope" ] = data ;
54+ buildPayload ( userAction , message , postBody ) ;
55+ dispatch ( addScope ( { action : userAction } ) ) ;
5156 }
5257 }
5358
59+ const handleSearch = ( value ) => {
60+ const option = {
61+ pattern :value
62+ }
63+ dispatch ( getAttributes ( { options : option } ) ) ;
64+ } ;
65+
5466 const scope = {
5567 claims : [ ] ,
5668 dynamicScopeScripts : [ ] ,
@@ -60,13 +72,13 @@ function ScopeAddPage() {
6072 spontaneousClientScopes : [ ] ,
6173 showInConfigurationEndpoint : false ,
6274 } ,
63- }
75+ } ;
6476
6577 return (
6678 < GluuLoader blocking = { loading } >
6779 < GluuAlert
68- severity = { t ( ' titles.error' ) }
69- message = { t ( ' messages.error_in_saving' ) }
80+ severity = { t ( " titles.error" ) }
81+ message = { t ( " messages.error_in_saving" ) }
7082 show = { errorInSaveOperationFlag }
7183 />
7284 < Card className = "mb-3" style = { applicationStyle . mainCard } >
@@ -76,11 +88,12 @@ function ScopeAddPage() {
7688 scripts = { scripts }
7789 attributes = { attributes }
7890 handleSubmit = { handleSubmit }
91+ onSearch = { handleSearch }
7992 />
8093 </ CardBody >
8194 </ Card >
8295 </ GluuLoader >
83- )
96+ ) ;
8497}
8598
86- export default ScopeAddPage
99+ export default ScopeAddPage ;
0 commit comments