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 , IDragDropEvents , SelectionMode , 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 } from '@fluentui/react' ;
66import { useTheme } from '@fluentui/react/lib/Theme' ;
77import { TextField } from '@fluentui/react/lib/TextField' ;
88import { IPersonaProps } from '@fluentui/react/lib/Persona' ;
@@ -22,7 +22,7 @@ import { selectJobOwnerFilterSuggestions } from '../../store/jobs.slice';
2222import { manageMembershipIsEditingExistingJob } from '../../store/manageMembership.slice' ;
2323import { fetchDefaultSqlMembershipSourceAttributes } from '../../store/sqlMembershipSources.api' ;
2424import { fetchAttributeValues } from '../../store/sqlMembershipSources.api' ;
25- import { selectAttributes , selectSource , selectAttributeValues , selectFilterGroups , setFilterGroups } from '../../store/sqlMembershipSources.slice' ;
25+ import { selectAttributes , selectSource , selectAttributeValues } from '../../store/sqlMembershipSources.slice' ;
2626import { SqlMembershipAttribute , SqlMembershipAttributeValue } from '../../models' ;
2727import { IFilterPart } from '../../models/IFilterPart' ;
2828
@@ -60,12 +60,12 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
6060 const objectIdEmployeeIdMapping = useSelector ( selectObjectIdEmployeeIdMapping ) ;
6161 const ownerPickerSuggestions = useSelector ( selectJobOwnerFilterSuggestions ) ;
6262 const isEditingExistingJob = useSelector ( manageMembershipIsEditingExistingJob ) ;
63- const filterGroups = useSelector ( selectFilterGroups ) ;
6463 const [ isDragAndDropEnabled , setIsDragAndDropEnabled ] = useState ( false ) ;
6564 const [ isDisabled , setIsDisabled ] = useState ( true ) ;
6665 const [ includeOrg , setIncludeOrg ] = useState ( false ) ;
6766 const [ includeFilter , setIncludeFilter ] = useState ( false ) ;
68- const [ errorMessage , setErrorMessage ] = useState < string > ( '' ) ;
67+ const [ orgErrorMessage , setOrgErrorMessage ] = useState < string > ( '' ) ;
68+ const [ filterErrorMessage , setFilterErrorMessage ] = useState < string > ( '' ) ;
6969 const [ source , setSource ] = useState < HRSourcePartSource > ( props . source ) ;
7070 const [ children , setChildren ] = useState < ChildType [ ] > ( [ ] ) ;
7171 const excludeLeaderQuery = `EmployeeId <> ${ source . manager ?. id } `
@@ -77,14 +77,10 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
7777 const [ items , setItems ] = useState < IFilterPart [ ] > ( [ ] ) ;
7878 let options : IComboBoxOption [ ] = [ ] ;
7979 let valueOptions : IComboBoxOption [ ] = [ ] ;
80- const draggedItem = useRef < any | undefined > ( ) ;
81- const draggedIndex = useRef < number > ( - 1 ) ;
8280 const [ groups , setGroups ] = useState < Group [ ] > ( [ ] ) ;
8381 const [ selectedIndices , setSelectedIndices ] = useState < number [ ] > ( [ ] ) ;
8482 const [ groupingEnabled , setGroupingEnabled ] = useState ( false ) ;
8583 const [ filterTextEnabled , setFilterTextEnabled ] = useState ( false ) ;
86- const [ groupQuery , setGroupQuery ] = useState < string > ( ) ;
87- const [ forceUpdate , setForceUpdate ] = useState < number > ( 0 ) ;
8884
8985 useEffect ( ( ) => {
9086 if ( ! groupingEnabled ) {
@@ -123,7 +119,7 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
123119 } , [ items ] ) ;
124120
125121 useEffect ( ( ) => {
126- if ( ! includeOrg ) { setErrorMessage ( '' ) ; }
122+ if ( ! includeOrg ) { setOrgErrorMessage ( '' ) ; }
127123 } , [ includeOrg ] ) ;
128124
129125
@@ -420,16 +416,12 @@ function setItemsBasedOnGroups(groups: Group[]) {
420416
421417const getGroupLabels = ( groups : Group [ ] ) => {
422418 const str = stringifyGroups ( groups ) ;
423- setGroupQuery ( str ) ;
424- const groupQuery = str ;
425- const groupingEnabled = true ;
426419 const filter = str ;
427420 setSource ( prevSource => {
428421 const newSource = { ...prevSource , filter } ;
429422 onSourceChange ( newSource , partId ) ;
430423 return newSource ;
431424 } ) ;
432- dispatch ( setFilterGroups ( { partId, groupQuery, groupingEnabled} ) ) ;
433425}
434426
435427const checkType = ( value : string , type : string | undefined ) : string => {
@@ -520,7 +512,7 @@ const checkType = (value: string, type: string | undefined): string => {
520512
521513 useEffect ( ( ) => {
522514 if ( orgLeaderDetails . employeeId === 0 && orgLeaderDetails . maxDepth === 0 && includeOrg && partId === orgLeaderDetails . partId ) {
523- setErrorMessage ( hrSource ?. name && hrSource ?. name !== "" ?
515+ setOrgErrorMessage ( hrSource ?. name && hrSource ?. name !== "" ?
524516 orgLeaderDetails . text + strings . HROnboarding . customOrgLeaderMissingErrorMessage + hrSource ?. name + strings . HROnboarding . source :
525517 orgLeaderDetails . text + strings . HROnboarding . orgLeaderMissingErrorMessage ) ;
526518 }
@@ -534,7 +526,7 @@ const checkType = (value: string, type: string | undefined): string => {
534526
535527 const handleOrgLeaderInputChange = ( input : string ) : string => {
536528 setIncludeOrg ( true ) ;
537- setErrorMessage ( '' ) ;
529+ setOrgErrorMessage ( '' ) ;
538530 dispatch ( getJobOwnerFilterSuggestions ( { displayName : input , alias : input } ) )
539531 return input ;
540532 }
@@ -555,7 +547,7 @@ const checkType = (value: string, type: string | undefined): string => {
555547 const handleDepthChange = React . useCallback ( ( event : React . SyntheticEvent < HTMLElement > , newValue ?: string ) => {
556548 const nonNumericRegex = / [ ^ 0 - 9 ] / g;
557549 if ( newValue && nonNumericRegex . test ( newValue ) ) {
558- setErrorMessage ( strings . HROnboarding . invalidInputErrorMessage ) ;
550+ setOrgErrorMessage ( strings . HROnboarding . invalidInputErrorMessage ) ;
559551 return ;
560552 }
561553 const depth = newValue ?. trim ( ) !== '' ? Number ( newValue ) : undefined ;
@@ -582,7 +574,7 @@ const checkType = (value: string, type: string | undefined): string => {
582574 } ;
583575
584576 const addComponent = ( ) => {
585- setErrorMessage ( '' ) ;
577+ setFilterErrorMessage ( '' ) ;
586578 setSource ( props . source ) ;
587579 const regex = / (?< = A n d | O r ) / ;
588580 let segments = props . source . filter ?. split ( regex ) ;
@@ -599,7 +591,7 @@ const checkType = (value: string, type: string | undefined): string => {
599591 if ( result || children . length === 0 ) {
600592 setChildren ( prevChildren => [ ...prevChildren , { filter : '' } ] ) ;
601593 } else {
602- setErrorMessage ( strings . HROnboarding . missingAttributeErrorMessage ) ;
594+ setFilterErrorMessage ( strings . HROnboarding . missingAttributeErrorMessage ) ;
603595 }
604596 } ;
605597
@@ -766,12 +758,12 @@ const checkType = (value: string, type: string | undefined): string => {
766758 }
767759
768760 const handleIncludeLeaderChange = ( ev ?: React . FormEvent < HTMLElement | HTMLInputElement > , option ?: IChoiceGroupOption ) => {
769- setErrorMessage ( '' ) ;
761+ setOrgErrorMessage ( '' ) ;
770762 let filter : string ;
771763 if ( option ?. key === "No" ) {
772764 if ( ! source . manager ?. id )
773765 {
774- setErrorMessage ( hrSource ?. name && hrSource ?. name !== "" ?
766+ setOrgErrorMessage ( hrSource ?. name && hrSource ?. name !== "" ?
775767 orgLeaderDetails . text + strings . HROnboarding . customOrgLeaderMissingErrorMessage + hrSource ?. name + strings . HROnboarding . source :
776768 orgLeaderDetails . text + strings . HROnboarding . orgLeaderMissingErrorMessage ) ;
777769 return ;
@@ -1800,7 +1792,7 @@ const checkType = (value: string, type: string | undefined): string => {
18001792
18011793
18021794 < div className = { classNames . error } >
1803- { errorMessage }
1795+ { orgErrorMessage }
18041796 </ div >
18051797 < br />
18061798
@@ -1847,13 +1839,13 @@ const checkType = (value: string, type: string | undefined): string => {
18471839 < ActionButton
18481840 iconProps = { { iconName : 'GroupObject' } }
18491841 onClick = { onUnGroupClick }
1850- disabled = { ! ( selectedIndices . length > 0 && groups . length > 0 && ( groupingEnabled || ( filterGroups [ partId ] && filterGroups [ partId ] . groupingEnabled ) ) ) } >
1842+ disabled = { ! ( selectedIndices . length > 0 && groups . length > 0 && groupingEnabled ) } >
18511843 Ungroup
18521844 </ ActionButton >
18531845 < br />
18541846
18551847
1856- { ( groupingEnabled || ( filterGroups [ partId ] && filterGroups [ partId ] . groupingEnabled ) || groups != null ) ? (
1848+ { ( groupingEnabled || groups != null ) ? (
18571849 < div >
18581850 { groups . map ( ( group : Group , index : number ) => (
18591851 < div >
@@ -1872,24 +1864,21 @@ const checkType = (value: string, type: string | undefined): string => {
18721864 selection = { selection }
18731865 onRenderItemColumn = { ( item , index , column ) => onRenderItemColumn ( items , item , index , column ) }
18741866 layoutMode = { DetailsListLayoutMode . justified }
1875- ariaLabelForSelectionColumn = "Toggle selection"
1876- ariaLabelForSelectAllCheckbox = "Toggle selection for all items"
1877- checkButtonAriaLabel = "select row"
18781867 styles = { {
18791868 root : classNames . detailsList
18801869 } }
18811870 />
18821871 ) }
18831872
1884- { groups . length <= 0 && < ActionButton iconProps = { { iconName : "CirclePlus" } } onClick = { ( ) => addComponent ( ) } >
1873+ { ( groups . length <= 0 || ! groupingEnabled ) && < ActionButton iconProps = { { iconName : "CirclePlus" } } onClick = { ( ) => addComponent ( ) } >
18851874 { strings . HROnboarding . addAttribute }
18861875 </ ActionButton > }
18871876 </ div >
18881877 ) : null
18891878 }
18901879
18911880 < div className = { classNames . error } >
1892- { errorMessage }
1881+ { filterErrorMessage }
18931882 </ div >
18941883 </ div >
18951884 ) ;
0 commit comments