@salesforcedevs/dx-components 1.2.2-avatar-button-7 → 1.2.2-avatar-button-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.2.2-avatar-button-7",
3
+ "version": "1.2.2-avatar-button-9",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -18,6 +18,7 @@
18
18
  "coveo-search-ui": "^2.10082.5",
19
19
  "debounce": "^1.2.0",
20
20
  "js-cookie": "^3.0.1",
21
+ "lodash.defaults": "^4.2.0",
21
22
  "lodash.get": "^4.4.2",
22
23
  "lodash.kebabcase": "^4.1.1",
23
24
  "microtip": "0.2.2",
@@ -27,6 +28,7 @@
27
28
  "@types/classnames": "^2.2.10",
28
29
  "@types/debounce": "^1.2.0",
29
30
  "@types/js-cookie": "^3.0.2",
31
+ "@types/lodash.defaults": "^4.2.7",
30
32
  "@types/lodash.get": "^4.4.6",
31
33
  "@types/lodash.kebabcase": "^4.1.7",
32
34
  "@types/vimeo__player": "^2.16.2"
@@ -1,6 +1,7 @@
1
1
  import { api, LightningElement } from "lwc";
2
- import Cookies from 'js-cookie';
2
+ import Cookies from "js-cookie";
3
3
  import { track } from "dxUtils/analytics";
4
+ import { defaults } from "lodash";
4
5
 
5
6
  // TODO: move to environment variable
6
7
  const TBID_BASE_URL = "https://dev1-trailblazer-identity.cs192.force.com";
@@ -36,7 +37,7 @@ export interface UserInfo {
36
37
  relationship?: string;
37
38
  role?: string;
38
39
  username?: string;
39
- readonly fullName: string;
40
+ fullName?: string;
40
41
  }
41
42
 
42
43
  interface EventSourceEvent extends Event {
@@ -63,14 +64,7 @@ const trackableUserInfo = new Set([
63
64
  export default class AvatarButton extends LightningElement {
64
65
  @api size: "small" | "medium" | "large" = "medium";
65
66
 
66
- private userInfo: UserInfo = {
67
- get fullName() {
68
- if (this.firstName && this.lastName) {
69
- return `${this.firstName} ${this.lastName}`;
70
- }
71
- return this.firstName || this.lastName || "";
72
- }
73
- };
67
+ private userInfo: UserInfo = {};
74
68
  private isLoading = false;
75
69
  private settingsUrl = TBID_SETTINGS_URL;
76
70
  private profileUrl = TBID_PROFILE_URL;
@@ -89,11 +83,12 @@ export default class AvatarButton extends LightningElement {
89
83
  }
90
84
 
91
85
  connectedCallback() {
92
- const isLoginSuccessRedirect = Cookies.get('tbidLoginSuccess') === 'true';
86
+ const isLoginSuccessRedirect =
87
+ Cookies.get("tbidLoginSuccess") === "true";
93
88
 
94
89
  if (isLoginSuccessRedirect) {
95
90
  this.isLoading = true;
96
- Cookies.remove('tbidLoginSuccess'); // cleanup
91
+ Cookies.remove("tbidLoginSuccess"); // cleanup
97
92
  }
98
93
 
99
94
  window.addEventListener("tbid-login", this.handleSsoLogin);
@@ -307,13 +302,17 @@ export default class AvatarButton extends LightningElement {
307
302
  return;
308
303
  }
309
304
 
310
- const nextUserInfo: Omit<UserInfo, 'fullName'> = {};
305
+ const nextUserInfo: UserInfo = {};
311
306
  nextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
312
307
  nextUserInfo.firstName = userInfo.given_name;
313
308
  nextUserInfo.lastName = userInfo.family_name;
314
309
  nextUserInfo.username = userInfo.preferred_username;
315
310
  nextUserInfo.id = userInfo.user_id;
316
311
  nextUserInfo.orgId = userInfo.organization_id;
312
+ nextUserInfo.fullName =
313
+ nextUserInfo.firstName && nextUserInfo.lastName
314
+ ? `${nextUserInfo.firstName} ${nextUserInfo.lastName}`
315
+ : nextUserInfo.firstName || nextUserInfo.lastName || "";
317
316
 
318
317
  if (userInfo.custom_attributes) {
319
318
  nextUserInfo.company = userInfo.custom_attributes.CompanyName;
@@ -323,10 +322,7 @@ export default class AvatarButton extends LightningElement {
323
322
  }
324
323
  // TODO: Consider displaying initials if no photo. Is there always a photo even if just a default one?
325
324
 
326
- this.userInfo = {
327
- ...this.userInfo,
328
- ...nextUserInfo,
329
- };
325
+ this.userInfo = defaults(nextUserInfo, this.userInfo);
330
326
  };
331
327
 
332
328
  private requestUserInfo = async () => {