@@ -13,13 +13,15 @@ import { useToast } from '@redpanda-data/ui';
1313import {
1414 convertRulesToCreateACLRequests ,
1515 handleResponses ,
16+ type PrincipalType ,
17+ PrincipalTypeRedpandaRole ,
1618 PrincipalTypeUser ,
1719 parsePrincipal ,
1820 type Rule ,
1921} from 'components/pages/acls/new-acl/acl.model' ;
2022import CreateACL from 'components/pages/acls/new-acl/create-acl' ;
2123import { useEffect } from 'react' ;
22- import { useNavigate } from 'react-router-dom' ;
24+ import { useNavigate , useSearchParams } from 'react-router-dom' ;
2325import { uiState } from 'state/ui-state' ;
2426
2527import { useCreateAcls } from '../../../../react-query/api/acl' ;
@@ -28,6 +30,20 @@ import PageContent from '../../../misc/page-content';
2830const AclCreatePage = ( ) => {
2931 const toast = useToast ( ) ;
3032 const navigate = useNavigate ( ) ;
33+ const [ searchParams ] = useSearchParams ( ) ;
34+
35+ const principalTypeParam = searchParams . get ( 'principalType' ) ?. toLowerCase ( ) ;
36+ const principalName = searchParams . get ( 'principalName' ) ;
37+
38+ const principalTypeMap : Record < string , PrincipalType > = {
39+ redpandarole : PrincipalTypeRedpandaRole ,
40+ user : PrincipalTypeUser ,
41+ } ;
42+
43+ const principalType = principalTypeParam ? principalTypeMap [ principalTypeParam ] : undefined ;
44+
45+ const sharedConfig =
46+ principalName && principalType ? { principal : `${ principalType } ${ principalName } ` , host : '*' } : undefined ;
3147
3248 useEffect ( ( ) => {
3349 uiState . pageBreadcrumbs = [
@@ -53,7 +69,8 @@ const AclCreatePage = () => {
5369 edit = { false }
5470 onCancel = { ( ) => navigate ( '/security/acls' ) }
5571 onSubmit = { createAclMutation }
56- principalType = { PrincipalTypeUser }
72+ principalType = { principalType }
73+ sharedConfig = { sharedConfig }
5774 />
5875 </ PageContent >
5976 ) ;
0 commit comments