Skip to content

Commit ca2b316

Browse files
committed
Onboarding using Place Membership source part
1 parent 8dab40e commit ca2b316

File tree

13 files changed

+90
-6
lines changed

13 files changed

+90
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import {
1818
} from './AdvancedViewSourcePart.types';
1919
import { useStrings } from "../../store/hooks";
2020
import GroupOwnershipSchema from '../../models/schemas/GroupOwnershipSchema.json';
21+
import PlaceMembershipSchema from '../../models/schemas/PlaceMembershipSchema.json';
2122
import { AppDispatch } from '../../store';
2223
import {
2324
setIsAdvancedQueryValid,
2425
updateSourcePart,
2526
} from '../../store/manageMembership.slice';
2627
import { ISourcePart } from '../../models/ISourcePart';
2728
import { GroupOwnershipSourcePart } from '../../models/GroupOwnershipSourcePart';
29+
import { PlaceMembershipSourcePart } from '../../models/PlaceMembershipSourcePart';
2830

2931
const getClassNames = classNamesFunction<
3032
IAdvancedViewSourcePartStyleProps,
@@ -48,7 +50,7 @@ export const AdvancedViewSourcePartBase: React.FunctionComponent<IAdvancedViewSo
4850
const dispatch = useDispatch<AppDispatch>();
4951
const [validationMessage, setValidationMessage] = useState<React.ReactNode | null>(null);
5052
const [localQuery, setLocalQuery] = useState<string | undefined>(JSON.stringify(part.query));
51-
const schema = GroupOwnershipSchema;
53+
const schema = part.query.type === 'GroupOwnership' ? GroupOwnershipSchema : PlaceMembershipSchema;
5254
const ajv = new Ajv();
5355

5456
useEffect(() => {
@@ -88,7 +90,7 @@ export const AdvancedViewSourcePartBase: React.FunctionComponent<IAdvancedViewSo
8890
if(isValid) {
8991
const updatedSourcePart: ISourcePart = {
9092
id: part.id,
91-
query: JSON.parse(localQuery?? '{}') as GroupOwnershipSourcePart
93+
query: JSON.parse(localQuery ?? '{}') as GroupOwnershipSourcePart | PlaceMembershipSourcePart
9294
};
9395
dispatch(updateSourcePart(updatedSourcePart));
9496
setValidationMessage(strings.ManageMembership.labels.validQuery);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
115115
}
116116
sourceTypeOptions.push( { key: SourcePartType.GroupMembership, text: strings.ManageMembership.labels.groupMembership });
117117
sourceTypeOptions.push( { key: SourcePartType.GroupOwnership, text: strings.ManageMembership.labels.groupOwnership });
118+
sourceTypeOptions.push( { key: SourcePartType.PlaceMembership, text: strings.ManageMembership.labels.placeMembership });
118119
return sourceTypeOptions;
119120
};
120121

@@ -214,6 +215,9 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
214215
{part.query.type === SourcePartType.GroupOwnership && (
215216
<AdvancedViewSourcePart key={SourcePartType.GroupOwnership} part={part} />
216217
)}
218+
{part.query.type === SourcePartType.PlaceMembership && (
219+
<AdvancedViewSourcePart key={SourcePartType.PlaceMembership} part={part} />
220+
)}
217221
<div className={classNames.error}>
218222
{errorMessage}
219223
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { SourcePartQuery } from "./SourcePartQuery";
5+
import { SourcePartType } from "./SourcePartType";
6+
7+
export type PlaceMembershipSourcePart = {
8+
type: SourcePartType.PlaceMembership;
9+
source: string;
10+
exclusionary?: boolean;
11+
};
12+
13+
export const IsPlaceMembershipSourcePartQuery = (query: SourcePartQuery): query is PlaceMembershipSourcePart => {
14+
return query.type === SourcePartType.PlaceMembership;
15+
}

UI/web-app/src/models/SourcePartQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
import { HRSourcePart } from "./HRSourcePart";
55
import { GroupOwnershipSourcePart } from "./GroupOwnershipSourcePart";
66
import { GroupMembershipSourcePart } from "./GroupMembershipSourcePart";
7+
import { PlaceMembershipSourcePart } from "./PlaceMembershipSourcePart";
78

8-
export type SourcePartQuery = HRSourcePart | GroupMembershipSourcePart | GroupOwnershipSourcePart;
9+
export type SourcePartQuery = HRSourcePart | GroupMembershipSourcePart | GroupOwnershipSourcePart | PlaceMembershipSourcePart;

UI/web-app/src/models/SourcePartType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
export enum SourcePartType {
55
HR = "SqlMembership",
66
GroupMembership = "GroupMembership",
7-
GroupOwnership = "GroupOwnership"
7+
GroupOwnership = "GroupOwnership",
8+
PlaceMembership = "PlaceMembership",
89
}

UI/web-app/src/models/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ export * from './DestinationPickerPersona';
2525
export * from './ISourcePart';
2626
export * from './HRSourcePart';
2727
export * from './GroupMembershipSourcePart';
28-
export * from './GroupOwnershipSourcePart';
28+
export * from './GroupOwnershipSourcePart';
29+
export * from './PlaceMembershipSourcePart';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"type": {
6+
"type": "string",
7+
"enum": ["PlaceMembership"]
8+
},
9+
"source": {
10+
"type": "string",
11+
"minLength": 1
12+
},
13+
"exclusionary": {
14+
"type": "boolean"
15+
}
16+
},
17+
"required": ["type", "source"],
18+
"additionalProperties": false
19+
}

UI/web-app/src/models/schemas/Query.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@
103103
},
104104
"required": ["type", "source"],
105105
"additionalProperties": false
106+
},
107+
{
108+
"type": "object",
109+
"properties": {
110+
"type": {
111+
"type": "string",
112+
"enum": ["PlaceMembership"]
113+
},
114+
"source": {
115+
"type": "string",
116+
"minLength": 1
117+
},
118+
"exclusionary": {
119+
"type": "boolean"
120+
}
121+
},
122+
"required": ["type", "source"],
123+
"additionalProperties": false
106124
}
107125
]
108126
}

UI/web-app/src/services/localization/IStrings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export type IStrings = {
321321
HR: string;
322322
groupMembership: string;
323323
groupOwnership: string;
324+
placeMembership: string;
324325
clickHere: string;
325326
requestor: string;
326327
}

UI/web-app/src/services/localization/i18n/locales/en/translations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ export const strings: IStrings = {
326326
HR: 'HR',
327327
groupMembership: 'Group Membership',
328328
groupOwnership: 'Group Ownership',
329+
placeMembership: 'Place Membership',
329330
clickHere: 'Click here',
330331
requestor: 'Requestor',
331332
}

0 commit comments

Comments
 (0)