11import React , { type JSX } from 'react' ;
22
3- import { Col , descriptors , Heading , Text } from '@/customizables' ;
3+ import { Badge , Col , descriptors , Flex , Heading , Table , Tbody , Td , Text , Th , Thead , Tr } from '@/customizables' ;
44import { ClipboardInput } from '@/elements/ClipboardInput' ;
55import { useCardState } from '@/elements/contexts' ;
66import { Form } from '@/elements/Form' ;
@@ -12,7 +12,6 @@ import { useConfigureSSO } from '../../../ConfigureSSOContext';
1212import { Step } from '../../../elements/Step' ;
1313import { useWizard , Wizard } from '../../../elements/Wizard' ;
1414import { InnerStepCounter } from '../../../elements/Wizard/InnerStepCounter' ;
15- import { AttributeMappingTable , type AttributeMappingTableConfig } from './shared/AttributeMappingTable' ;
1615import {
1716 applySamlSubmitError ,
1817 buildSamlConfigurationPayload ,
@@ -474,49 +473,89 @@ const SamlGoogleServiceProviderStep = (): JSX.Element => {
474473 ) ;
475474} ;
476475
477- const GOOGLE_ATTRIBUTE_MAPPING : AttributeMappingTableConfig = {
478- columns : {
479- first : localizationKeys (
480- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.columns.googleAttribute' ,
481- ) ,
482- second : localizationKeys (
483- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.columns.appAttribute' ,
484- ) ,
485- } ,
486- rows : [
487- {
488- id : 'email' ,
489- isRequired : true ,
490- first : localizationKeys (
491- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.email.googleAttribute' ,
492- ) ,
493- second : localizationKeys (
494- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.email.appAttribute' ,
495- ) ,
496- } ,
497- {
498- id : 'firstName' ,
499- isRequired : false ,
500- first : localizationKeys (
501- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.firstName.googleAttribute' ,
502- ) ,
503- second : localizationKeys (
504- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.firstName.appAttribute' ,
505- ) ,
506- } ,
507- {
508- id : 'lastName' ,
509- isRequired : false ,
510- first : localizationKeys (
511- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.lastName.googleAttribute' ,
512- ) ,
513- second : localizationKeys (
514- 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.lastName.appAttribute' ,
515- ) ,
516- } ,
517- ] ,
476+ type GoogleAttributeRow = {
477+ id : 'email' | 'firstName' | 'lastName' ;
478+ isRequired : boolean ;
518479} ;
519480
481+ const GOOGLE_ATTRIBUTE_ROWS : ReadonlyArray < GoogleAttributeRow > = [
482+ { id : 'email' , isRequired : true } ,
483+ { id : 'firstName' , isRequired : false } ,
484+ { id : 'lastName' , isRequired : false } ,
485+ ] ;
486+
487+ const GoogleAttributeMappingTable = ( ) : JSX . Element => (
488+ < Table
489+ elementDescriptor = { descriptors . configureSSOAttributeMappingTable }
490+ sx = { theme => ( {
491+ 'tr > th:first-of-type' : { paddingInlineStart : theme . space . $4 } ,
492+ } ) }
493+ >
494+ < Thead >
495+ < Tr >
496+ < Th >
497+ < Text
498+ sx = { theme => ( { fontSize : theme . fontSizes . $xs } ) }
499+ localizationKey = { localizationKeys (
500+ 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.columns.googleAttribute' ,
501+ ) }
502+ />
503+ </ Th >
504+ < Th >
505+ < Text
506+ sx = { theme => ( { fontSize : theme . fontSizes . $xs } ) }
507+ localizationKey = { localizationKeys (
508+ 'configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.columns.appAttribute' ,
509+ ) }
510+ />
511+ </ Th >
512+ </ Tr >
513+ </ Thead >
514+ < Tbody >
515+ { GOOGLE_ATTRIBUTE_ROWS . map ( row => (
516+ < Tr key = { row . id } >
517+ < Td >
518+ < Flex
519+ as = 'span'
520+ align = 'center'
521+ sx = { theme => ( { gap : theme . space . $2 } ) }
522+ >
523+ < Text
524+ as = 'span'
525+ colorScheme = 'secondary'
526+ localizationKey = { localizationKeys (
527+ `configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.${ row . id } .googleAttribute` ,
528+ ) }
529+ />
530+ < Badge
531+ elementDescriptor = { descriptors . configureSSOAttributeMappingBadge }
532+ elementId = { descriptors . configureSSOAttributeMappingBadge . setId (
533+ row . isRequired ? 'required' : 'optional' ,
534+ ) }
535+ colorScheme = { row . isRequired ? 'warning' : 'primary' }
536+ localizationKey = { localizationKeys (
537+ row . isRequired
538+ ? 'configureSSO.configureStep.attributeMappingTable.badges.required'
539+ : 'configureSSO.configureStep.attributeMappingTable.badges.optional' ,
540+ ) }
541+ />
542+ </ Flex >
543+ </ Td >
544+ < Td >
545+ < Text
546+ as = 'span'
547+ sx = { { fontFamily : 'monospace' } }
548+ localizationKey = { localizationKeys (
549+ `configureSSO.configureStep.samlGoogle.attributeMappingStep.attributeMappingTable.rows.${ row . id } .appAttribute` ,
550+ ) }
551+ />
552+ </ Td >
553+ </ Tr >
554+ ) ) }
555+ </ Tbody >
556+ </ Table >
557+ ) ;
558+
520559const SamlGoogleAttributeMappingStep = ( ) : JSX . Element => {
521560 const { goNext, goPrev, isFirstStep, isLastStep } = useWizard ( ) ;
522561
@@ -554,7 +593,7 @@ const SamlGoogleAttributeMappingStep = (): JSX.Element => {
554593 />
555594 </ Col >
556595
557- < AttributeMappingTable config = { GOOGLE_ATTRIBUTE_MAPPING } />
596+ < GoogleAttributeMappingTable />
558597 </ Step . Section >
559598 </ Step . Body >
560599
0 commit comments