Skip to content

Commit

Permalink
fix for fallback-details overriding person-query (#2786)
Browse files Browse the repository at this point in the history
Co-authored-by: Musale Martin <[email protected]>
  • Loading branch information
Mnickii and musale authored Oct 19, 2023
1 parent 4b85be1 commit d27ffa7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 4 additions & 8 deletions packages/mgt-components/src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,11 +1091,7 @@ export class MgtPerson extends MgtTemplatedComponent {

const graph = provider.graph.forComponent(this);

if (this.fallbackDetails) {
this.line2Property = 'email';
}

if (this.verticalLayout && this.view < ViewType.fourlines) {
if ((this.verticalLayout && this.view < ViewType.fourlines) || this.fallbackDetails) {
this.line2Property = 'email';
}

Expand All @@ -1109,8 +1105,7 @@ export class MgtPerson extends MgtTemplatedComponent {
];
personProps = personProps.filter(email => email !== 'email');

let details = this.personDetailsInternal || this.personDetails || this.fallbackDetails;

let details = this.personDetailsInternal || this.personDetails;
if (details) {
if (
!details.personImage &&
Expand Down Expand Up @@ -1168,6 +1163,8 @@ export class MgtPerson extends MgtTemplatedComponent {
}
}

details = details ? details : this.fallbackDetails;

// populate presence
const defaultPresence: Presence = {
activity: 'Offline',
Expand All @@ -1177,7 +1174,6 @@ export class MgtPerson extends MgtTemplatedComponent {

if (this.showPresence && !this.personPresence && !this._fetchedPresence) {
try {
details = this.personDetailsInternal || this.personDetails;
if (details) {
// setting userId to 'me' ensures only the presence.read permission is required
const userId = this.personQuery !== 'me' ? details?.id : null;
Expand Down
14 changes: 10 additions & 4 deletions stories/components/person/person.properties.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ export const setPersonDetails = () => html`

export const personFallbackDetails = () => html`
<div class="example">
<mgt-person person-query="mbowen" view="twoLines" fallback-details='{"displayName":"Megan Bowen"}'></mgt-person>
<mgt-person person-query="mbowen" view="twoLines" show-presence fallback-details='{"displayName":"Megan Bowen"}'></mgt-person>
</div>
<div class="example">
<mgt-person person-query="mbowen" view="twoLines"
<mgt-person person-query="mbowen" view="twoLines" show-presence
fallback-details='{"mail":"[email protected]"}'></mgt-person>
</div>
<div class="example">
<mgt-person person-query="mbowen" view="twoLines"
<mgt-person person-query="mbowen" view="twoLines" show-presence
fallback-details='{"mail":"[email protected]","displayName":"Megan Bowen"}'></mgt-person>
</div>
<!-- No Fallback details -->
<div class="example">
<mgt-person person-query="mbowen" view="twoLines"
<mgt-person person-query="mbowen" view="twoLines" show-presence
fallback-details='{}'></mgt-person>
</div>
<!-- Correct Person Query and Fallback Details -->
<div class="example">
<mgt-person person-query="bowen" view="twoLines" show-presence
fallback-details='{"mail":"[email protected]","displayName":"Someone"}'></mgt-person>
</div>
<style>
.example {
Expand Down

0 comments on commit d27ffa7

Please sign in to comment.