@salesforcedevs/dw-components 1.2.14 → 1.2.17-canary.0
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/lwc.config.json +3 -1
- package/package.json +2 -3
- package/src/modules/dw/browseTrials/browseTrials.css +58 -0
- package/src/modules/dw/browseTrials/browseTrials.html +83 -0
- package/src/modules/dw/browseTrials/browseTrials.ts +104 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.css +119 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +150 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.ts +159 -0
- package/LICENSE +0 -12
package/lwc.config.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
],
|
|
6
6
|
"expose": [
|
|
7
7
|
"dw/blogsGrid",
|
|
8
|
+
"dw/browseTrials",
|
|
8
9
|
"dw/cardBlogPostProvider",
|
|
9
10
|
"dw/cardPodcastEpisodeProvider",
|
|
10
11
|
"dw/codeSamplesGrid",
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"dw/podcastsPromo",
|
|
20
21
|
"dw/rcgTable",
|
|
21
22
|
"dw/slackCta",
|
|
22
|
-
"dw/slackSuccess"
|
|
23
|
+
"dw/slackSuccess",
|
|
24
|
+
"dw/tbidLoginMenu"
|
|
23
25
|
]
|
|
24
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17-canary.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -21,6 +21,5 @@
|
|
|
21
21
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
22
22
|
"@types/lodash.orderby": "^4.6.7",
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7"
|
|
24
|
-
}
|
|
25
|
-
"gitHead": "1a4776017fd922a02ccb0f7bda28af97ebec720f"
|
|
24
|
+
}
|
|
26
25
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
--dw-browse-trials-padding-top: 0;
|
|
6
|
+
--dw-browse-trials-padding-bottom: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
11
|
+
font-family: var(--dx-g-font-display);
|
|
12
|
+
font-weight: var(--dx-g-font-weight-demi);
|
|
13
|
+
font-size: 32px;
|
|
14
|
+
letter-spacing: -0.4px;
|
|
15
|
+
line-height: 40px;
|
|
16
|
+
margin-bottom: var(--dx-g-spacing-md);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.panel-list-container {
|
|
20
|
+
padding: var(--dw-browse-trials-padding-top)
|
|
21
|
+
var(--dx-g-page-padding-horizontal)
|
|
22
|
+
var(--dw-browse-trials-padding-bottom)
|
|
23
|
+
var(--dx-g-page-padding-horizontal);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
dx-tab-panel-list {
|
|
27
|
+
--dx-c-tab-panel-list-horizontal-padding: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dx-card-trial {
|
|
31
|
+
width: 400px;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
min-width: 240px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.category-text-container {
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.category-subtitle {
|
|
41
|
+
color: var(--dx-g-font-sans);
|
|
42
|
+
margin-top: var(--dx-g-spacing-smd);
|
|
43
|
+
max-width: 560px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.button-toggle-container {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
gap: var(--dx-g-spacing-md);
|
|
50
|
+
margin-top: var(--dx-g-spacing-3xl);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.category-container {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
gap: 40px;
|
|
57
|
+
margin-top: var(--dx-g-spacing-4xl);
|
|
58
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="panel-list-container">
|
|
3
|
+
<h2 class="title">{title}</h2>
|
|
4
|
+
<dx-tab-panel-list tabs={tabLabels} onchange={handleTabChange}>
|
|
5
|
+
<template for:each={trials} for:item="trial">
|
|
6
|
+
<dx-tab-panel key={trial.label}>
|
|
7
|
+
<div
|
|
8
|
+
key={trial.label}
|
|
9
|
+
class="button-toggle-container"
|
|
10
|
+
if:false={trial.hideFilters}
|
|
11
|
+
>
|
|
12
|
+
<template
|
|
13
|
+
for:each={buttonToggleStates}
|
|
14
|
+
for:item="buttonToggleState"
|
|
15
|
+
>
|
|
16
|
+
<dx-button-toggle
|
|
17
|
+
label={buttonToggleState.label}
|
|
18
|
+
key={buttonToggleState.label}
|
|
19
|
+
value={buttonToggleState.value}
|
|
20
|
+
ontoggle={handleFilters}
|
|
21
|
+
></dx-button-toggle>
|
|
22
|
+
</template>
|
|
23
|
+
</div>
|
|
24
|
+
<template for:each={filteredCategories} for:item="category">
|
|
25
|
+
<div key={category.title} class="category-container">
|
|
26
|
+
<div
|
|
27
|
+
if:true={category.title}
|
|
28
|
+
class="category-text-container"
|
|
29
|
+
>
|
|
30
|
+
<h2 class="dx-text-heading-4 category-title">
|
|
31
|
+
{category.title}
|
|
32
|
+
</h2>
|
|
33
|
+
<p
|
|
34
|
+
if:true={category.subtitle}
|
|
35
|
+
class="category-subtitle"
|
|
36
|
+
>
|
|
37
|
+
{category.subtitle}
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
<template for:each={category.cards} for:item="card">
|
|
41
|
+
<template if:true={card.hasModal}>
|
|
42
|
+
<dx-card-trial
|
|
43
|
+
key={card.title}
|
|
44
|
+
badge-background-color={card.badgeBackgroundColor}
|
|
45
|
+
badge-symbol={card.badgeSymbol}
|
|
46
|
+
body={card.body}
|
|
47
|
+
details={card.details}
|
|
48
|
+
modal-title={card.modalTitle}
|
|
49
|
+
modal-details={card.modalDetails}
|
|
50
|
+
href={card.href}
|
|
51
|
+
label={card.label}
|
|
52
|
+
terms={card.terms}
|
|
53
|
+
title={card.title}
|
|
54
|
+
button-one-cta={card.buttonOneCta}
|
|
55
|
+
button-one-href={card.buttonOneHref}
|
|
56
|
+
button-one-icon={card.buttonOneIcon}
|
|
57
|
+
button-two-cta={card.buttonTwoCta}
|
|
58
|
+
hide-card-details="true"
|
|
59
|
+
></dx-card-trial>
|
|
60
|
+
</template>
|
|
61
|
+
<template if:false={card.hasModal}>
|
|
62
|
+
<dx-card-trial
|
|
63
|
+
key={card.title}
|
|
64
|
+
badge-background-color={card.badgeBackgroundColor}
|
|
65
|
+
badge-symbol={card.badgeSymbol}
|
|
66
|
+
body={card.body}
|
|
67
|
+
href={card.href}
|
|
68
|
+
label={card.label}
|
|
69
|
+
terms={card.terms}
|
|
70
|
+
title={card.title}
|
|
71
|
+
button-one-cta={card.buttonOneCta}
|
|
72
|
+
button-one-href={card.buttonOneHref}
|
|
73
|
+
button-one-icon={card.buttonOneIcon}
|
|
74
|
+
></dx-card-trial>
|
|
75
|
+
</template>
|
|
76
|
+
</template>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
79
|
+
</dx-tab-panel>
|
|
80
|
+
</template>
|
|
81
|
+
</dx-tab-panel-list>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import { toJson } from "dxUtils/normalizers";
|
|
3
|
+
|
|
4
|
+
export default class BrowseTrials extends LightningElement {
|
|
5
|
+
@api title = "Browse Trials";
|
|
6
|
+
|
|
7
|
+
@api
|
|
8
|
+
get trials() {
|
|
9
|
+
return this._trials;
|
|
10
|
+
}
|
|
11
|
+
set trials(
|
|
12
|
+
value: [{ label: string; hideFilters: boolean; buttonLabels: string[] }]
|
|
13
|
+
) {
|
|
14
|
+
this._trials = toJson(value);
|
|
15
|
+
this.tabLabels = this._trials.map((trial) => ({ label: trial.label }));
|
|
16
|
+
this.buttonLabels = this._trials.map((trial) =>
|
|
17
|
+
!trial.hideFilters ? trial.buttonLabels : []
|
|
18
|
+
);
|
|
19
|
+
this._filteredTitles = this._trials.map(() => []);
|
|
20
|
+
this._filteredCategories = this._trials.map(
|
|
21
|
+
(trial) => trial.categories
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get buttonToggleStates() {
|
|
26
|
+
return this.buttonLabels[this.activeTabIndex].map((label) => ({
|
|
27
|
+
label,
|
|
28
|
+
value: this.activeFilteredTitles.includes(label)
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get activeFilteredTitles() {
|
|
33
|
+
return this._filteredTitles[this.activeTabIndex];
|
|
34
|
+
}
|
|
35
|
+
set activeFilteredTitles(value: string[]) {
|
|
36
|
+
this._filteredTitles[this.activeTabIndex] = value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get activeCategories() {
|
|
40
|
+
return this._trials[this.activeTabIndex].categories;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get filteredCategories() {
|
|
44
|
+
return this._filteredCategories[this.activeTabIndex];
|
|
45
|
+
}
|
|
46
|
+
set filteredCategories(value: any) {
|
|
47
|
+
this._filteredCategories[this.activeTabIndex] = value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@track
|
|
51
|
+
private _filteredCategories!: Array<any>;
|
|
52
|
+
|
|
53
|
+
private activeTabIndex = 0;
|
|
54
|
+
private buttonLabels!: string[][];
|
|
55
|
+
private _filteredTitles!: string[][];
|
|
56
|
+
private tabLabels!: Array<{ label: string }>;
|
|
57
|
+
private _trials!: [
|
|
58
|
+
{
|
|
59
|
+
label: string;
|
|
60
|
+
hideFilters: boolean;
|
|
61
|
+
buttonLabels: string[];
|
|
62
|
+
categories: Array<{ title: string }>;
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
handleTabChange(e: CustomEvent) {
|
|
67
|
+
this.activeTabIndex = e.detail;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
filterCategories() {
|
|
71
|
+
this.filteredCategories = this.activeCategories.filter((category) =>
|
|
72
|
+
this.activeFilteredTitles.includes(category.title)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
addLabelToFilter(label: string) {
|
|
77
|
+
this.activeFilteredTitles.push(label);
|
|
78
|
+
this.filterCategories();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
removeLabelFromFilter(label: string) {
|
|
82
|
+
this.activeFilteredTitles = this.activeFilteredTitles.filter(
|
|
83
|
+
(filterTitle) => filterTitle !== label
|
|
84
|
+
);
|
|
85
|
+
this.filterCategories();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
resetFilters() {
|
|
89
|
+
this.activeFilteredTitles = [];
|
|
90
|
+
this.filteredCategories = this.activeCategories;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
handleFilters(e: CustomEvent) {
|
|
94
|
+
const { label, value } = e.detail;
|
|
95
|
+
|
|
96
|
+
if (value) {
|
|
97
|
+
this.addLabelToFilter(label);
|
|
98
|
+
} else if (this.activeFilteredTitles.length !== 1) {
|
|
99
|
+
this.removeLabelFromFilter(label);
|
|
100
|
+
} else {
|
|
101
|
+
this.resetFilters();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--dx-c-button-custom-color: var(--dx-g-blue-vibrant-50);
|
|
3
|
+
--dx-c-button-custom-background: transparent;
|
|
4
|
+
--dx-c-button-custom-border: 1px solid transparent;
|
|
5
|
+
--dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-50);
|
|
6
|
+
--dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
7
|
+
--dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
8
|
+
--dx-c-slot-empty-width: max-content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.avatar {
|
|
12
|
+
border-radius: 100%;
|
|
13
|
+
border: 2px solid #0d9dda;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.avatar.avatar-medium {
|
|
17
|
+
margin-bottom: 14px;
|
|
18
|
+
width: var(--dx-g-spacing-2xl);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.login-container {
|
|
22
|
+
padding: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.login-container.logged-in {
|
|
26
|
+
padding-top: 68px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.header-img {
|
|
30
|
+
left: 0;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0;
|
|
33
|
+
width: 100%;
|
|
34
|
+
z-index: -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.heading {
|
|
38
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
39
|
+
display: block;
|
|
40
|
+
font-family: var(--dx-g-font-display);
|
|
41
|
+
font-size: var(--dx-g-text-lg);
|
|
42
|
+
line-height: 28px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.sub-heading {
|
|
46
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
47
|
+
display: block;
|
|
48
|
+
font-family: var(--dx-g-font-sans);
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
line-height: 18px;
|
|
51
|
+
padding: 8px 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ul {
|
|
55
|
+
list-style: none;
|
|
56
|
+
margin: 0;
|
|
57
|
+
padding: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.login-list-item {
|
|
61
|
+
padding-bottom: 10px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.login-section ~ .login-section {
|
|
65
|
+
border-top: 1px solid var(--dx-g-gray-90);
|
|
66
|
+
margin-top: 12px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.login-section-title {
|
|
70
|
+
color: var(--dx-g-gray-30);
|
|
71
|
+
display: inline-block;
|
|
72
|
+
font-family: var(--dx-g-font-sans);
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
line-height: 20px;
|
|
75
|
+
padding: 20px 0 12px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.login-link {
|
|
79
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
80
|
+
display: inline-block;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.login-link-label {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
font-family: var(--dx-g-font-display);
|
|
86
|
+
font-size: 16px;
|
|
87
|
+
line-height: 24px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.login-link-img {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
height: 16px;
|
|
93
|
+
margin-left: 6px;
|
|
94
|
+
vertical-align: sub;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.login-link-icon {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
margin-left: 6px;
|
|
100
|
+
vertical-align: text-bottom;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.login-link-blurb {
|
|
104
|
+
font-family: var(--dx-g-font-sans);
|
|
105
|
+
font-size: 14px;
|
|
106
|
+
line-height: 20px;
|
|
107
|
+
padding-top: 4px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.heading-links {
|
|
111
|
+
color: var(--dx-g-gray-90);
|
|
112
|
+
font-family: var(--dx-g-font-sans);
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
line-height: 20px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
a.inline-link {
|
|
118
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
119
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dx-tbid-avatar-button
|
|
3
|
+
tbid-base-url={tbidBaseUrl}
|
|
4
|
+
tbid-api-base-url={tbidApiBaseUrl}
|
|
5
|
+
ontbiduserinfo={handleTbidUserInfo}
|
|
6
|
+
ontbidloginsuccess={handleTbidLoginSuccess}
|
|
7
|
+
ontbidlogoutsuccess={handleTbidLogoutSuccess}
|
|
8
|
+
>
|
|
9
|
+
<div slot="popover-content">
|
|
10
|
+
<div if:true={isLoggedIn}>
|
|
11
|
+
<div class="login-container logged-in">
|
|
12
|
+
<img
|
|
13
|
+
src="/assets/svg/login-widget-bg.png"
|
|
14
|
+
class="header-img"
|
|
15
|
+
/>
|
|
16
|
+
<img
|
|
17
|
+
src={userInfo.avatarImgSrc}
|
|
18
|
+
class="avatar avatar-medium"
|
|
19
|
+
/>
|
|
20
|
+
<span class="heading">{userInfo.fullName}</span>
|
|
21
|
+
<span class="sub-heading">{userInfo.username}</span>
|
|
22
|
+
<div class="heading-links">
|
|
23
|
+
<a
|
|
24
|
+
href="#"
|
|
25
|
+
onclick={handleComponentLogoutClick}
|
|
26
|
+
class="inline-link"
|
|
27
|
+
>
|
|
28
|
+
Logout
|
|
29
|
+
</a>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="login-section">
|
|
32
|
+
<span class="login-section-title">Trailblazer.me</span>
|
|
33
|
+
<ul>
|
|
34
|
+
<li class="login-list-item">
|
|
35
|
+
<a href={settingsUrl} class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
36
|
+
<span class="login-link-label">
|
|
37
|
+
Settings
|
|
38
|
+
</span>
|
|
39
|
+
<dx-icon
|
|
40
|
+
class="login-link-icon"
|
|
41
|
+
symbol="new_window"
|
|
42
|
+
size="xsmall"
|
|
43
|
+
></dx-icon>
|
|
44
|
+
</a>
|
|
45
|
+
</li>
|
|
46
|
+
<li class="login-list-item">
|
|
47
|
+
<a href={profileUrl} class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
48
|
+
<span class="login-link-label">
|
|
49
|
+
Profile
|
|
50
|
+
</span>
|
|
51
|
+
<dx-icon
|
|
52
|
+
class="login-link-icon"
|
|
53
|
+
symbol="new_window"
|
|
54
|
+
size="xsmall"
|
|
55
|
+
></dx-icon>
|
|
56
|
+
</a>
|
|
57
|
+
</li>
|
|
58
|
+
<li class="login-list-item">
|
|
59
|
+
<a href="https://trailhead.salesforce.com/trailblazer-community/groups/0F93A000000DJbJSAW" class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
60
|
+
<span class="login-link-label">
|
|
61
|
+
Developer Community
|
|
62
|
+
</span>
|
|
63
|
+
<dx-icon
|
|
64
|
+
class="login-link-icon"
|
|
65
|
+
symbol="new_window"
|
|
66
|
+
size="xsmall"
|
|
67
|
+
></dx-icon>
|
|
68
|
+
</a>
|
|
69
|
+
<div class="login-link-blurb">
|
|
70
|
+
Collaborate, network, build connections
|
|
71
|
+
and learn Salesforce development.
|
|
72
|
+
</div>
|
|
73
|
+
</li>
|
|
74
|
+
</ul>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div if:false={isLoggedIn}>
|
|
79
|
+
<div class="login-container">
|
|
80
|
+
<span class="heading">Login</span>
|
|
81
|
+
<div class="login-section">
|
|
82
|
+
<span class="login-section-title">Products</span>
|
|
83
|
+
<ul>
|
|
84
|
+
<li class="login-list-item">
|
|
85
|
+
<a href="https://www.salesforce.com" class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
86
|
+
<span class="login-link-label">
|
|
87
|
+
Salesforce
|
|
88
|
+
</span>
|
|
89
|
+
<img
|
|
90
|
+
class="login-link-img"
|
|
91
|
+
src="/assets/svg/salesforce-cloud.svg"
|
|
92
|
+
alt="Salesforce logo"
|
|
93
|
+
/>
|
|
94
|
+
<dx-icon
|
|
95
|
+
class="login-link-icon"
|
|
96
|
+
symbol="new_window"
|
|
97
|
+
size="xsmall"
|
|
98
|
+
></dx-icon>
|
|
99
|
+
</a>
|
|
100
|
+
</li>
|
|
101
|
+
<li class="login-list-item">
|
|
102
|
+
<a href={marketingCloudUrl} class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
103
|
+
<span class="login-link-label">
|
|
104
|
+
Marketing Cloud
|
|
105
|
+
</span>
|
|
106
|
+
<dx-icon
|
|
107
|
+
class="login-link-icon"
|
|
108
|
+
symbol="new_window"
|
|
109
|
+
size="xsmall"
|
|
110
|
+
></dx-icon>
|
|
111
|
+
</a>
|
|
112
|
+
</li>
|
|
113
|
+
</ul>
|
|
114
|
+
</div>
|
|
115
|
+
<div class="login-section">
|
|
116
|
+
<span class="login-section-title">
|
|
117
|
+
Salesforce Developers
|
|
118
|
+
</span>
|
|
119
|
+
<ul>
|
|
120
|
+
<li class="login-list-item">
|
|
121
|
+
<a href={loginUrl} class="login-link" onclick={handleComponentLoginClick}>
|
|
122
|
+
<span class="login-link-label">
|
|
123
|
+
Trailblazer.me
|
|
124
|
+
</span>
|
|
125
|
+
</a>
|
|
126
|
+
<div class="login-link-blurb">
|
|
127
|
+
Login into access a rich community of
|
|
128
|
+
Salesforce Developers, get ideas, and find
|
|
129
|
+
solutions.
|
|
130
|
+
</div>
|
|
131
|
+
</li>
|
|
132
|
+
<li class="login-list-item">
|
|
133
|
+
<a href="https://developer.salesforce.com/forums" class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
134
|
+
<span class="login-link-label">
|
|
135
|
+
Developer Forums
|
|
136
|
+
</span>
|
|
137
|
+
<dx-icon
|
|
138
|
+
class="login-link-icon"
|
|
139
|
+
symbol="new_window"
|
|
140
|
+
size="xsmall"
|
|
141
|
+
></dx-icon>
|
|
142
|
+
</a>
|
|
143
|
+
</li>
|
|
144
|
+
</ul>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</dx-tbid-avatar-button>
|
|
150
|
+
</template>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { LightningElement } from "lwc";
|
|
2
|
+
import { track } from "dxUtils/analytics";
|
|
3
|
+
import type TbidAvatarButton from "dx/tbidAvatarButton";
|
|
4
|
+
|
|
5
|
+
const DSC_BASE_URL = process.env.BASE_URL || "https://developer.salesforce.com";
|
|
6
|
+
|
|
7
|
+
interface UserInfo {
|
|
8
|
+
avatarImgSrc?: string;
|
|
9
|
+
company?: string;
|
|
10
|
+
firstName?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
lastName?: string;
|
|
13
|
+
orgId?: string;
|
|
14
|
+
relationship?: string;
|
|
15
|
+
role?: string;
|
|
16
|
+
username?: string;
|
|
17
|
+
fullName?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const trackableUserInfo = new Set([
|
|
21
|
+
"company",
|
|
22
|
+
"id",
|
|
23
|
+
"orgId",
|
|
24
|
+
"relationship",
|
|
25
|
+
"role"
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
// This component is DSC-specific, essentially just handling tracking and UI for the TBID login menu.
|
|
29
|
+
// TBID-login-related *functionality* is handled by the generic and hopefully-reusable dx/tbidAvatarButton,
|
|
30
|
+
// which this component uses.
|
|
31
|
+
export default class TbidLoginMenu extends LightningElement {
|
|
32
|
+
// URLs:
|
|
33
|
+
// TODO: change these urls when the environment is correct
|
|
34
|
+
private tbidBaseUrl = "https://dev1-trailblazer-identity.cs192.force.com";
|
|
35
|
+
private tbidApiBaseUrl =
|
|
36
|
+
"https://development.developer.salesforce.com/tbid";
|
|
37
|
+
private settingsUrl = `${this.tbidBaseUrl}/settings`;
|
|
38
|
+
private profileUrl = `${this.tbidBaseUrl}/id`;
|
|
39
|
+
private logoutUrl = `${this.tbidApiBaseUrl}/logout`;
|
|
40
|
+
private get marketingCloudUrl() {
|
|
41
|
+
return `${DSC_BASE_URL}/developer-centers/marketing-cloud`;
|
|
42
|
+
}
|
|
43
|
+
private get loginUrl() {
|
|
44
|
+
return `${this.tbidApiBaseUrl}/dologin?startURL=${encodeURIComponent(
|
|
45
|
+
window.location.href
|
|
46
|
+
)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private isLoggedIn = false;
|
|
50
|
+
private userInfo: UserInfo = {};
|
|
51
|
+
|
|
52
|
+
private handleComponentLogoutClick = (event: Event) => {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
this.trackLogoutClick();
|
|
55
|
+
(this.template.querySelector('dx-tbid-avatar-button') as unknown as TbidAvatarButton).logout();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
private handleComponentLoginClick = (event: Event) => {
|
|
59
|
+
this.trackLoginClick();
|
|
60
|
+
(this.template.querySelector('dx-tbid-avatar-button') as unknown as TbidAvatarButton).login(event);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
private handleTbidLoginSuccess = (event: CustomEvent) => {
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
this.isLoggedIn = true;
|
|
66
|
+
|
|
67
|
+
// Special tracking for this event only
|
|
68
|
+
track(document, "custEv_userLogin", {
|
|
69
|
+
authenticationMethod: "tbid",
|
|
70
|
+
id: {
|
|
71
|
+
tb: Object.entries(this.userInfo)
|
|
72
|
+
.filter(([key]) => trackableUserInfo.has(key))
|
|
73
|
+
.reduce(
|
|
74
|
+
(infoToTrack, [key, value]) => ({
|
|
75
|
+
...infoToTrack,
|
|
76
|
+
[key]: value
|
|
77
|
+
}),
|
|
78
|
+
{} as Record<string, string>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
private handleTbidLogoutSuccess = (event: CustomEvent) => {
|
|
85
|
+
event.stopPropagation();
|
|
86
|
+
this.isLoggedIn = false;
|
|
87
|
+
this.userInfo = {};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
private handleTbidUserInfo = (event: CustomEvent) => {
|
|
91
|
+
event.stopPropagation();
|
|
92
|
+
const { detail } = event;
|
|
93
|
+
if (detail && detail.userInfo) {
|
|
94
|
+
this.userInfo = detail.userInfo;
|
|
95
|
+
|
|
96
|
+
if (!this.isLoggedIn) {
|
|
97
|
+
// If we are not "logged in" but we receive userInfo, it means the user has a valid
|
|
98
|
+
// session cookie that was re-used without login, and we should update the UI to a
|
|
99
|
+
// logged in state.
|
|
100
|
+
this.isLoggedIn = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
private trackLoginClick = () => {
|
|
106
|
+
track(document, "custEv_userLogin", {
|
|
107
|
+
clickText: "Trailblazer.me",
|
|
108
|
+
clickUrl: this.loginUrl,
|
|
109
|
+
itemTitle: "TBID Login Link",
|
|
110
|
+
elementType: "link"
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
private trackLogoutClick = () => {
|
|
115
|
+
track(document, "custEv_userLogout", {
|
|
116
|
+
clickText: "Logout",
|
|
117
|
+
clickUrl: this.logoutUrl,
|
|
118
|
+
itemTitle: "TBID Logout Link",
|
|
119
|
+
elementType: "link"
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Shared utility for tracking link clicks.
|
|
124
|
+
private trackMenuClick = (
|
|
125
|
+
target: HTMLAnchorElement | null,
|
|
126
|
+
eventName: string,
|
|
127
|
+
navItemPrefix: string
|
|
128
|
+
) => {
|
|
129
|
+
const trackingPayload: any = {
|
|
130
|
+
nav_level: "utility",
|
|
131
|
+
nav_type: "global",
|
|
132
|
+
elementType: "link"
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if (target) {
|
|
136
|
+
trackingPayload.clickText = target.textContent?.trim() || "";
|
|
137
|
+
trackingPayload.clickUrl = target.href;
|
|
138
|
+
const [
|
|
139
|
+
firstWord,
|
|
140
|
+
...remainingText
|
|
141
|
+
] = trackingPayload.clickText.split(" ");
|
|
142
|
+
trackingPayload.nav_item = `${navItemPrefix}${firstWord.toLowerCase()}${remainingText.join()}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
track(target || document, eventName, trackingPayload);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// Track link clicks on the "logged out" version of the dropdown.
|
|
149
|
+
private trackLoginMenuClick = (event: Event) => {
|
|
150
|
+
const target = event.currentTarget as HTMLAnchorElement | null;
|
|
151
|
+
this.trackMenuClick(target, "custEv_userLogin", "login:salesforce:");
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Track link clicks on the "logged in" version of the dropdown.
|
|
155
|
+
private trackLoggedInMenuClick = (event: Event) => {
|
|
156
|
+
const target = event.currentTarget as HTMLAnchorElement | null;
|
|
157
|
+
this.trackMenuClick(target, "custEv_loginMenuClick", "login:tbid:");
|
|
158
|
+
};
|
|
159
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|