22// Licensed under the MIT license.
33
44import React , { useEffect , useRef , useState } from 'react' ;
5- import { classNamesFunction , Stack , type IProcessedStyleSet , IStackTokens , Label , IconButton , TooltipHost , ChoiceGroup , IChoiceGroupOption , SpinButton , NormalPeoplePicker , DirectionalHint , IDropdownOption , ActionButton , DetailsList , DetailsListLayoutMode , Dropdown , Selection , IColumn , ComboBox , IComboBoxOption , IComboBox , IDropdownStyles } from '@fluentui/react' ;
5+ import { classNamesFunction , Stack , type IProcessedStyleSet , IStackTokens , Label , IconButton , TooltipHost , ChoiceGroup , IChoiceGroupOption , SpinButton , NormalPeoplePicker , DirectionalHint , IDropdownOption , ActionButton , DetailsList , DetailsListLayoutMode , Dropdown , Selection , IColumn , ComboBox , IComboBoxOption , IComboBox , IDropdownStyles , Separator } from '@fluentui/react' ;
66import { useTheme } from '@fluentui/react/lib/Theme' ;
77import { TextField } from '@fluentui/react/lib/TextField' ;
88import { IPersonaProps } from '@fluentui/react/lib/Persona' ;
@@ -75,6 +75,7 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
7575 const [ selectedIndices , setSelectedIndices ] = useState < number [ ] > ( [ ] ) ;
7676 const [ groupingEnabled , setGroupingEnabled ] = useState ( false ) ;
7777 const [ filterTextEnabled , setFilterTextEnabled ] = useState ( false ) ;
78+ const [ expanded , setExpanded ] = useState ( true ) ;
7879
7980 useEffect ( ( ) => {
8081 if ( ! groupingEnabled ) {
@@ -170,6 +171,10 @@ function setItemsBasedOnGroups(groups: Group[]) {
170171 setItems ( items ) ;
171172}
172173
174+ const toggleExpand = ( ) => {
175+ setExpanded ( ! expanded ) ;
176+ } ;
177+
173178const getGroupLabels = ( groups : Group [ ] ) => {
174179 const str = stringifyGroups ( groups ) ;
175180 const filter = str ;
@@ -572,6 +577,7 @@ const checkType = (value: string, type: string | undefined): string => {
572577 const handleIncludeFilterChange = ( ev ?: React . FormEvent < HTMLElement | HTMLInputElement > , option ?: IChoiceGroupOption ) => {
573578 if ( option ?. key === "No" ) {
574579 setIncludeFilter ( false ) ;
580+ setExpanded ( false ) ;
575581 setFilteredOptions ( { } ) ;
576582 setFilteredValueOptions ( { } ) ;
577583 const filter = "" ;
@@ -586,6 +592,7 @@ const checkType = (value: string, type: string | undefined): string => {
586592 addComponent ( ) ;
587593 }
588594 setIncludeFilter ( true ) ;
595+ setExpanded ( true ) ;
589596 dispatch ( fetchDefaultSqlMembershipSourceAttributes ( ) ) ;
590597 setSource ( prevSource => {
591598 const newSource = { ...prevSource } ;
@@ -1664,6 +1671,21 @@ const checkType = (value: string, type: string | undefined): string => {
16641671 } }
16651672 />
16661673
1674+ { ( includeFilter || source . filter ) &&
1675+ < div className = { classNames . cardHeader } >
1676+ < div className = { classNames . cardTitle } >
1677+ Attributes
1678+ </ div >
1679+ < IconButton
1680+ iconProps = { { iconName : expanded ? 'ChevronUp' : 'ChevronDown' } }
1681+ styles = { { root : classNames . expandButton } }
1682+ onClick = { toggleExpand }
1683+ title = { strings . ManageMembership . labels . expandCollapse }
1684+ />
1685+ </ div > }
1686+
1687+ { ( includeFilter || source . filter ) && < Separator styles = { { root : classNames . separator } } /> }
1688+
16671689 { ( source . filter && ( filterTextEnabled || ! attributes ) ) ?
16681690 (
16691691 < > < div className = { classNames . labelContainer } >
@@ -1682,7 +1704,7 @@ const checkType = (value: string, type: string | undefined): string => {
16821704 validateOnLoad = { false }
16831705 validateOnFocusOut = { false }
16841706 > </ TextField > </ >
1685- ) : attributes && attributes . length > 0 && ( includeFilter || source . filter ) ?
1707+ ) : attributes && attributes . length > 0 && expanded && ( includeFilter || source . filter ) ?
16861708 (
16871709 < div >
16881710 < ActionButton
@@ -1700,7 +1722,7 @@ const checkType = (value: string, type: string | undefined): string => {
17001722 < br />
17011723
17021724
1703- { ( groupingEnabled ) ? (
1725+ { ( groupingEnabled && expanded ) ? (
17041726
17051727 < div >
17061728 { groups . map ( ( group : Group , index : number ) => (
0 commit comments