Skip to content

Commit f50e6ab

Browse files
Mnickiigavinbarron
andauthored
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 <[email protected]> * update lit imports, remove unused util function --------- Co-authored-by: Gavin Barron <[email protected]>
1 parent ba381c8 commit f50e6ab

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

packages/mgt-components/src/components/mgt-person/mgt-person.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
mgtHtml
1515
} from '@microsoft/mgt-element';
1616
import { Contact, Presence } from '@microsoft/microsoft-graph-types';
17-
import { html, TemplateResult } from 'lit';
17+
import { html, TemplateResult, nothing } from 'lit';
1818
import { property, state } from 'lit/decorators.js';
1919
import { classMap } from 'lit/directives/class-map.js';
2020
import { findPeople, getEmailFromGraphEntity } from '../../graph/graph.people';
@@ -753,6 +753,7 @@ export class MgtPerson extends MgtTemplatedComponent {
753753
const { activity, availability } = presence;
754754
switch (availability) {
755755
case 'Available':
756+
case 'AvailableIdle':
756757
switch (activity) {
757758
case 'OutOfOffice':
758759
presenceIcon = getSvg(SvgIcon.PresenceOofAvailable);
@@ -765,6 +766,7 @@ export class MgtPerson extends MgtTemplatedComponent {
765766
}
766767
break;
767768
case 'Busy':
769+
case 'BusyIdle':
768770
switch (activity) {
769771
case 'OutOfOffice':
770772
case 'OnACall':
@@ -785,6 +787,9 @@ export class MgtPerson extends MgtTemplatedComponent {
785787
case 'OutOfOffice':
786788
presenceIcon = getSvg(SvgIcon.PresenceOofDnd);
787789
break;
790+
case 'Presenting':
791+
case 'Focusing':
792+
case 'UrgentInterruptionsOnly':
788793
default:
789794
presenceIcon = getSvg(SvgIcon.PresenceDnd);
790795
break;
@@ -796,6 +801,14 @@ export class MgtPerson extends MgtTemplatedComponent {
796801
case 'OutOfOffice':
797802
presenceIcon = getSvg(SvgIcon.PresenceOofAway);
798803
break;
804+
case 'AwayLastSeenTime':
805+
default:
806+
presenceIcon = getSvg(SvgIcon.PresenceAway);
807+
break;
808+
}
809+
break;
810+
case 'BeRightBack':
811+
switch (activity) {
799812
default:
800813
presenceIcon = getSvg(SvgIcon.PresenceAway);
801814
break;
@@ -807,6 +820,7 @@ export class MgtPerson extends MgtTemplatedComponent {
807820
presenceIcon = getSvg(SvgIcon.PresenceOffline);
808821
break;
809822
case 'OutOfOffice':
823+
case 'OffWork':
810824
presenceIcon = getSvg(SvgIcon.PresenceOofAway);
811825
break;
812826
default:
@@ -825,11 +839,13 @@ export class MgtPerson extends MgtTemplatedComponent {
825839
oneline: this.isOneLine()
826840
});
827841

842+
const formattedActivity = (this.strings[activity] as string) ?? nothing;
843+
828844
return html`
829845
<span
830846
class="${presenceWrapperClasses}"
831-
title="${availability}"
832-
aria-label="${availability}"
847+
title="${formattedActivity}"
848+
aria-label="${formattedActivity}"
833849
role="img">
834850
${presenceIcon}
835851
</span>

packages/mgt-components/src/components/mgt-person/strings.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,38 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8+
const availabilityMap = {
9+
Available: 'Available',
10+
Away: 'Away',
11+
Busy: 'Busy',
12+
DoNotDisturb: 'Do not disturb',
13+
Offline: 'Offline',
14+
BeRightBack: 'Be right back',
15+
PresenceUnknown: 'Presence unknown',
16+
AvailableIdle: 'Available idle',
17+
BusyIdle: 'Busy idle'
18+
};
19+
20+
const activityMap = {
21+
Available: 'Available',
22+
Away: 'Away',
23+
BeRightBack: 'Be right back',
24+
Busy: 'Busy',
25+
DoNotDisturb: 'Do not disturb',
26+
InACall: 'In a call',
27+
InAConferenceCall: 'In a conference call',
28+
Inactive: 'Inactive',
29+
InAMeeting: 'In a meeting',
30+
Offline: 'Offline',
31+
OffWork: 'Off work',
32+
OutOfOffice: 'Out of office',
33+
PresenceUnknown: 'Presence unknown',
34+
Presenting: 'Presenting',
35+
UrgentInterruptionsOnly: 'Urgent interruptions only'
36+
};
37+
838
export const strings = {
39+
...activityMap,
940
photoFor: 'Photo for',
1041
emailAddress: 'Email address',
1142
initials: 'Initials'

0 commit comments

Comments
 (0)