From f50e6ab514ad9b1e4deb0113e4f50558c8ec49c3 Mon Sep 17 00:00:00 2001 From: Nickii Miaro Date: Wed, 20 Sep 2023 20:42:48 +0300 Subject: [PATCH] fix: add spaces to presence hover text in mgt-person (#2693) * fix: add spaces to presence hover text * use localized strings to map availability * add all supported presence states * use sentence-casing * map activity to presence rather than availability * remove iteration, use the nullish coalescing operator Co-authored-by: Gavin Barron * update lit imports, remove unused util function --------- Co-authored-by: Gavin Barron --- .../src/components/mgt-person/mgt-person.ts | 22 +++++++++++-- .../src/components/mgt-person/strings.ts | 31 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/packages/mgt-components/src/components/mgt-person/mgt-person.ts b/packages/mgt-components/src/components/mgt-person/mgt-person.ts index d149ce5a47..2dd243a9df 100644 --- a/packages/mgt-components/src/components/mgt-person/mgt-person.ts +++ b/packages/mgt-components/src/components/mgt-person/mgt-person.ts @@ -14,7 +14,7 @@ import { mgtHtml } from '@microsoft/mgt-element'; import { Contact, Presence } from '@microsoft/microsoft-graph-types'; -import { html, TemplateResult } from 'lit'; +import { html, TemplateResult, nothing } from 'lit'; import { property, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { findPeople, getEmailFromGraphEntity } from '../../graph/graph.people'; @@ -753,6 +753,7 @@ export class MgtPerson extends MgtTemplatedComponent { const { activity, availability } = presence; switch (availability) { case 'Available': + case 'AvailableIdle': switch (activity) { case 'OutOfOffice': presenceIcon = getSvg(SvgIcon.PresenceOofAvailable); @@ -765,6 +766,7 @@ export class MgtPerson extends MgtTemplatedComponent { } break; case 'Busy': + case 'BusyIdle': switch (activity) { case 'OutOfOffice': case 'OnACall': @@ -785,6 +787,9 @@ export class MgtPerson extends MgtTemplatedComponent { case 'OutOfOffice': presenceIcon = getSvg(SvgIcon.PresenceOofDnd); break; + case 'Presenting': + case 'Focusing': + case 'UrgentInterruptionsOnly': default: presenceIcon = getSvg(SvgIcon.PresenceDnd); break; @@ -796,6 +801,14 @@ export class MgtPerson extends MgtTemplatedComponent { case 'OutOfOffice': presenceIcon = getSvg(SvgIcon.PresenceOofAway); break; + case 'AwayLastSeenTime': + default: + presenceIcon = getSvg(SvgIcon.PresenceAway); + break; + } + break; + case 'BeRightBack': + switch (activity) { default: presenceIcon = getSvg(SvgIcon.PresenceAway); break; @@ -807,6 +820,7 @@ export class MgtPerson extends MgtTemplatedComponent { presenceIcon = getSvg(SvgIcon.PresenceOffline); break; case 'OutOfOffice': + case 'OffWork': presenceIcon = getSvg(SvgIcon.PresenceOofAway); break; default: @@ -825,11 +839,13 @@ export class MgtPerson extends MgtTemplatedComponent { oneline: this.isOneLine() }); + const formattedActivity = (this.strings[activity] as string) ?? nothing; + return html` ${presenceIcon} diff --git a/packages/mgt-components/src/components/mgt-person/strings.ts b/packages/mgt-components/src/components/mgt-person/strings.ts index 0b2909d272..1287297882 100644 --- a/packages/mgt-components/src/components/mgt-person/strings.ts +++ b/packages/mgt-components/src/components/mgt-person/strings.ts @@ -5,7 +5,38 @@ * ------------------------------------------------------------------------------------------- */ +const availabilityMap = { + Available: 'Available', + Away: 'Away', + Busy: 'Busy', + DoNotDisturb: 'Do not disturb', + Offline: 'Offline', + BeRightBack: 'Be right back', + PresenceUnknown: 'Presence unknown', + AvailableIdle: 'Available idle', + BusyIdle: 'Busy idle' +}; + +const activityMap = { + Available: 'Available', + Away: 'Away', + BeRightBack: 'Be right back', + Busy: 'Busy', + DoNotDisturb: 'Do not disturb', + InACall: 'In a call', + InAConferenceCall: 'In a conference call', + Inactive: 'Inactive', + InAMeeting: 'In a meeting', + Offline: 'Offline', + OffWork: 'Off work', + OutOfOffice: 'Out of office', + PresenceUnknown: 'Presence unknown', + Presenting: 'Presenting', + UrgentInterruptionsOnly: 'Urgent interruptions only' +}; + export const strings = { + ...activityMap, photoFor: 'Photo for', emailAddress: 'Email address', initials: 'Initials'