Skip to content

Commit 05137c8

Browse files
lipalath-msdanielluo-msft
authored andcommitted
display SqlMembershipSource
1 parent 53fe1cc commit 05137c8

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

UI/web-app/src/components/SourcePart/SourcePart.base.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { GroupQuerySource } from '../GroupQuerySource';
2424
import { SourcePartType } from '../../models/SourcePartType';
2525
import { SourcePartQuery } from '../../models/SourcePartQuery';
2626
import { AdvancedViewSourcePart } from '../AdvancedViewSourcePart';
27+
import { selectSource } from '../../store/sqlMembershipSources.slice';
28+
import { SqlMembershipSource } from '../../models';
2729

2830
const getClassNames = classNamesFunction<SourcePartStyleProps, SourcePartStyles>();
2931

@@ -46,17 +48,13 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
4648
{ key: 'No', text: strings.no },
4749
];
4850

49-
const sourceTypeOptions: IDropdownOption[] = [
50-
{ key: SourcePartType.HR, text: strings.ManageMembership.labels.HR },
51-
{ key: SourcePartType.GroupMembership, text: strings.ManageMembership.labels.groupMembership },
52-
{ key: SourcePartType.GroupOwnership, text: strings.ManageMembership.labels.groupOwnership }
53-
];
5451

5552
const dispatch = useDispatch<AppDispatch>();
5653
const [isExclusionary, setIsExclusionary] = useState(query.exclusionary);
5754
const [errorMessage, setErrorMessage] = useState<string>('');
5855
const isEditingExistingJob = useSelector(manageMembershipIsEditingExistingJob);
5956
const [expanded, setExpanded] = useState(isEditingExistingJob);
57+
const hrSource = useSelector(selectSource);
6058

6159
const handleSourceTypeChanged = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption | undefined): void => {
6260
if (!item) return;
@@ -105,6 +103,21 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
105103
setErrorMessage('');
106104
}, [query, expanded]);
107105

106+
const getOptions = (hrSource?: SqlMembershipSource): IDropdownOption[] => {
107+
let sourceTypeOptions: IDropdownOption[] = [];
108+
if (hrSource) {
109+
sourceTypeOptions.push({
110+
key: SourcePartType.HR,
111+
text: hrSource.customLabel || hrSource.name,
112+
});
113+
} else {
114+
sourceTypeOptions.push( { key: SourcePartType.HR, text: strings.ManageMembership.labels.HR });
115+
}
116+
sourceTypeOptions.push( { key: SourcePartType.GroupMembership, text: strings.ManageMembership.labels.groupMembership });
117+
sourceTypeOptions.push( { key: SourcePartType.GroupOwnership, text: strings.ManageMembership.labels.groupOwnership });
118+
return sourceTypeOptions;
119+
};
120+
108121
useEffect(() => {
109122
setIsExclusionary(part.query.exclusionary ?? false);
110123
if (part.query.type === SourcePartType.HR) {
@@ -166,7 +179,7 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
166179
<div className={classNames.controls}>
167180
<Dropdown
168181
styles={{ title: classNames.dropdownTitle }}
169-
options={sourceTypeOptions}
182+
options={getOptions(hrSource)}
170183
label="Source Type"
171184
required={true}
172185
selectedKey={part.query.type}

0 commit comments

Comments
 (0)