@@ -3,14 +3,26 @@ import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query";
33import {
44 Button ,
55 ChakraBox as Box ,
6+ ChakraDeleteIcon as DeleteIcon ,
7+ ChakraFlex as Flex ,
68 ChakraStack as Stack ,
79 useChakraToast as useToast ,
810} from "fidesui" ;
9- import { Form , Formik , FormikHelpers , useFormikContext } from "formik" ;
11+ import {
12+ FieldArray ,
13+ Form ,
14+ Formik ,
15+ FormikHelpers ,
16+ useFormikContext ,
17+ } from "formik" ;
1018import { useMemo } from "react" ;
1119import * as Yup from "yup" ;
1220
13- import { CustomSwitch , CustomTextInput } from "~/features/common/form/inputs" ;
21+ import {
22+ CustomSwitch ,
23+ CustomTextInput ,
24+ Label ,
25+ } from "~/features/common/form/inputs" ;
1426import { getErrorMessage , isErrorResult } from "~/features/common/helpers" ;
1527import { errorToastParams , successToastParams } from "~/features/common/toast" ;
1628import {
@@ -68,7 +80,7 @@ const SSOProviderFormValidationSchema = Yup.object().shape({
6880
6981const CustomProviderExtraFields = ( ) => {
7082 const {
71- values : { verify_email : verifyEmail } ,
83+ values : { verify_email : verifyEmail , scopes = [ ] } ,
7284 } = useFormikContext < SSOProviderFormValues > ( ) ;
7385
7486 return (
@@ -97,14 +109,6 @@ const CustomProviderExtraFields = () => {
97109 variant = "stacked"
98110 isRequired
99111 />
100- < ControlledSelect
101- id = "scopes"
102- name = "scopes"
103- label = "Scopes"
104- tooltip = "Scopes requested during authorization callback, defaults to 'openid email'"
105- placeholder = "openid email"
106- mode = "tags"
107- />
108112 < CustomTextInput
109113 id = "email_field"
110114 name = "email_field"
@@ -130,6 +134,43 @@ const CustomProviderExtraFields = () => {
130134 placeholder = "verified_email"
131135 />
132136 ) }
137+ < FieldArray
138+ name = "scopes"
139+ render = { ( arrayHelpers ) => (
140+ < Flex flexDir = "column" >
141+ < Label size = "small" > Scopes</ Label >
142+ { scopes ?. map ( ( _ : string , index : number ) => (
143+ // eslint-disable-next-line react/no-array-index-key
144+ < Flex flexDir = "row" key = { index } my = "3" >
145+ < CustomTextInput
146+ name = { `scopes[${ index } ]` }
147+ variant = "stacked"
148+ placeholder = "openid"
149+ />
150+ < Button
151+ aria-label = "delete-scope"
152+ icon = { < DeleteIcon /> }
153+ className = "z-[2] ml-4"
154+ onClick = { ( ) => {
155+ arrayHelpers . remove ( index ) ;
156+ } }
157+ />
158+ </ Flex >
159+ ) ) }
160+ < Flex justifyContent = "center" >
161+ < Button
162+ aria-label = "add-scope"
163+ className = "w-full"
164+ onClick = { ( ) => {
165+ arrayHelpers . push ( "" ) ;
166+ } }
167+ >
168+ Add scope
169+ </ Button >
170+ </ Flex >
171+ </ Flex >
172+ ) }
173+ />
133174 </ >
134175 ) ;
135176} ;
0 commit comments