-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds engage community user add
. Closes #6293
#6388
base: main
Are you sure you want to change the base?
Adds engage community user add
. Closes #6293
#6388
Conversation
fb971cd
to
b4b41b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MathijsVerbeeck, got some comments for you. ⚡
`--userNames [userNames]` | ||
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both. | ||
|
||
`--entraGroupId [entraGroupId]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say place this one right below communityDisplayName, as it's an optionset
async getCommunityIdByEntraGroupId(entraGroupId: string): Promise<string> { | ||
const communities = await odata.getAllItems<Community>('https://graph.microsoft.com/v1.0/employeeExperience/communities?$select=id,groupId'); | ||
|
||
const filtereCommunities = communities.filter(c => c.groupId === entraGroupId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use find()
instead of filter()
(and fix the typo in the const name)
const filtereCommunities = communities.filter(c => c.groupId === entraGroupId); | |
const filteredCommunities = communities.find(c => c.groupId === entraGroupId); |
* @returns The ID of the Viva Engage group. | ||
*/ | ||
async getEntraGroupIdByCommunityDisplayName(displayName: string): Promise<string> { | ||
const communityId = await this.getCommunityIdByDisplayName(displayName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're doing in two requests what can be done in one. Or so it seems.
Also, I dont think there's real value in a helper method that only retrieves the entra group Id for a community. Let's rewrite getCommunityIdByDisplayName
to getCommunityByDisplayName
and use that to get the group and its Id.
* @param displayName Community display name. | ||
* @returns The ID of the Viva Engage community. | ||
*/ | ||
async getCommunityIdByDisplayName(displayName: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more logical to just have a function that returns the community. So let's rename this one to getCommunityByDisplayName
.
Of course it's important to only $select
what we need. What you could do is add an optional selectProperties: string[]
parameter on this function, so that it's possible to optimize the request (if necessary).
In this case we'd be able to call the function as follows: getCommunityByDisplayName("Some community", ["id"])
.
In the case of retrieving the entra group id, we could run getCommunityByDisplayName("Some community", ["groupId"])
.
* @param entraGroupId The ID of the Microsoft Entra group. | ||
* @returns The ID of the Viva Engage community. | ||
*/ | ||
async getCommunityIdByEntraGroupId(entraGroupId: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's return the entire community object by default, and let's allow to select specific properties using a selectProperties string[] parameter.
* @param communityId The ID of the Viva Engage community. | ||
* @returns The ID of the Viva Engage group. | ||
*/ | ||
async getEntraGroupIdByCommunityId(communityId: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets ditch this method in favor of reusing getCommunityByDisplayName('communityName', ['groupId'])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't drop this method since we use communityId
to locate the correct community. Instead, I suggest aligning it with the other methods by making it more dynamic, like getCommunityById(communityId: string, selectProperties: string[])
, and returning the community object. This will make it more future-proof for other scenarios. Thoughts?
Hi @MathijsVerbeeck, do you have the time to conclude the work on these two viva PR's soon? I'm in the presupposition they need to be included in v10. So I'd hope to merge them sometime soon. |
@MathijsVerbeeck, since you're using the same util, I’ve already applied the changes @martinlingstuyl recommended. You can check it out here: #6371. |
Whats the status here @MathijsVerbeeck? It's marked PR-major. But we'll need to do some work yet to include it. |
I am removing the pr-major label from this PR as we agreed to proceed with this change the 'standard' way and the removal of the |
Closes #6293