Skip to content

Commit

Permalink
fix: add Group entity type to IDynamicPerson and entityType property
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnickii committed Aug 29, 2023
1 parent 10b25f9 commit 074e5a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ export class MgtPersonCard extends MgtTemplatedComponent {
*/
protected renderPersonSubtitle(person?: IDynamicPerson): TemplateResult {
person = person || this.internalPersonDetails;
if (!person.department) {
if (!(person as Person).department) {
return;
}
return html`
<div class="department">${person.department}</div>
<div class="department">${(person as Person).department}</div>
`;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/mgt-components/src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
customElementHelper,
mgtHtml
} from '@microsoft/mgt-element';
import { Contact, Presence } from '@microsoft/microsoft-graph-types';
import { Contact, Presence, Person } from '@microsoft/microsoft-graph-types';
import { html, TemplateResult } from 'lit';
import { property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
Expand Down Expand Up @@ -1195,11 +1195,11 @@ export class MgtPerson extends MgtTemplatedComponent {
}

let initials = '';
if (person.givenName) {
initials += person.givenName[0].toUpperCase();
if ((person as Person).givenName) {
initials += (person as Person).givenName[0].toUpperCase();
}
if (person.surname) {
initials += person.surname[0].toUpperCase();
if ((person as Person).surname) {
initials += (person as Person).surname[0].toUpperCase();
}

if (!initials && person.displayName) {
Expand Down
14 changes: 13 additions & 1 deletion packages/mgt-components/src/graph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';
* In addition, this custom type also defines the optional `personImage` property,
* which is used to pass the image around to other components as part of the person object.
*/
export type IDynamicPerson = (MicrosoftGraph.User | MicrosoftGraph.Person | MicrosoftGraph.Contact) & {
export type IDynamicPerson = (
| MicrosoftGraph.User
| MicrosoftGraph.Person
| MicrosoftGraph.Contact
| MicrosoftGraph.Group
) & {
/**
* personDetails.personImage is a toolkit injected property to pass image between components
* an optimization to avoid fetching the image when unnecessary.
*
* @type {string}
*/
personImage?: string;
/**
* personDetails.entityType is a toolkit injected property to pass the type of each entity
* in the array.
*
* @type {string}
*/
entityType?: 'user' | 'person' | 'group';
};

/**
Expand Down

0 comments on commit 074e5a9

Please sign in to comment.