@salesforcedevs/docs-components 1.27.22-banner2 → 1.27.22-banner4
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 +2 -2
- package/src/modules/doc/amfReference/amfReference.html +12 -0
- package/src/modules/doc/amfReference/amfReference.ts +14 -0
- package/src/modules/doc/banner/banner.html +55 -53
- package/src/modules/doc/banner/banner.ts +43 -1
- package/src/modules/doc/xmlContent/xmlContent.html +1 -1
- package/src/modules/doc/xmlContent/xmlContent.ts +17 -27
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.27.22-
|
|
3
|
+
"version": "1.27.22-banner4",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "32fcf61be8c3868caa09ab6e8e9b353d1f54a287"
|
|
29
29
|
}
|
|
@@ -25,6 +25,18 @@
|
|
|
25
25
|
lwc:if={docPhaseInfo}
|
|
26
26
|
doc-phase-info={docPhaseInfo}
|
|
27
27
|
></doc-phase>
|
|
28
|
+
<doc-banner
|
|
29
|
+
slot="locale-banner"
|
|
30
|
+
lwc:if={showLocaleBanner}
|
|
31
|
+
message-text="This text was translated using Salesforce's machine translation system. More details can be found "
|
|
32
|
+
message-link-url="https://help.salesforce.com/s/articleView?id=sf.machine_translation.htm"
|
|
33
|
+
message-link-text="here"
|
|
34
|
+
button-label="Switch to English"
|
|
35
|
+
button-href={localeBannerEnUsHref}
|
|
36
|
+
secondary-label="Not Now"
|
|
37
|
+
show-close-button="true"
|
|
38
|
+
dismiss-storage-key={deliverable}
|
|
39
|
+
></doc-banner>
|
|
28
40
|
<doc-phase
|
|
29
41
|
slot="version-banner"
|
|
30
42
|
lwc:if={showVersionBanner}
|
|
@@ -51,6 +51,8 @@ export default class AmfReference extends LightningElement {
|
|
|
51
51
|
@api language!: string;
|
|
52
52
|
@api hideFooter = false;
|
|
53
53
|
|
|
54
|
+
@api deliverable = "";
|
|
55
|
+
|
|
54
56
|
/** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer-mfe. */
|
|
55
57
|
@api origin: string | null = null;
|
|
56
58
|
@track navigation = [] as NavigationItem[];
|
|
@@ -72,6 +74,18 @@ export default class AmfReference extends LightningElement {
|
|
|
72
74
|
return this.isSpecBasedReference(this._currentReferenceId);
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
get showLocaleBanner(): boolean {
|
|
78
|
+
if (!this.deliverable || this.language === "en-us") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return this.languages?.some((l) => l.id === "en-us") ?? false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get localeBannerEnUsHref(): string {
|
|
85
|
+
const enUs = this.languages?.find((l) => l.id === "en-us");
|
|
86
|
+
return enUs?.link?.href ?? "";
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
@api
|
|
76
90
|
get referenceSetConfig(): ReferenceSetConfig {
|
|
77
91
|
return this._referenceSetConfig;
|
|
@@ -1,60 +1,62 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<div class="
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<div class="
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<template lwc:if={showBanner}>
|
|
3
|
+
<div class="doc-notification-bar" part="container">
|
|
4
|
+
<div class="icon-wrap" part="icon-wrap">
|
|
5
|
+
<dx-icon symbol="info" part="icon" color="#747474"></dx-icon>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="main" part="main">
|
|
8
|
+
<div class="content" part="content">
|
|
9
|
+
<p class="message dx-text-body-4" part="message">
|
|
10
|
+
<template lwc:if={messageText}>{messageText}</template>
|
|
11
|
+
<template lwc:if={hasMessageLink}>
|
|
12
|
+
<a
|
|
13
|
+
href={messageLinkUrl}
|
|
14
|
+
target="_blank"
|
|
15
|
+
rel="noopener noreferrer"
|
|
16
|
+
part="message-link"
|
|
17
|
+
>
|
|
18
|
+
{messageLinkText}
|
|
19
|
+
</a>
|
|
20
|
+
</template>
|
|
21
|
+
</p>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="actions" part="actions">
|
|
24
|
+
<template lwc:if={hasPrimaryButton}>
|
|
25
|
+
<dx-button
|
|
26
|
+
class="primary-btn"
|
|
27
|
+
href={buttonHref}
|
|
28
|
+
variant="primary"
|
|
29
|
+
size="small"
|
|
30
|
+
part="button"
|
|
31
|
+
>
|
|
32
|
+
{buttonLabel}
|
|
33
|
+
</dx-button>
|
|
34
|
+
</template>
|
|
35
|
+
<template lwc:if={hasSecondaryAction}>
|
|
36
|
+
<dx-button
|
|
37
|
+
class="secondary-btn"
|
|
38
|
+
variant="inline"
|
|
39
|
+
onclick={handleSecondaryClick}
|
|
40
|
+
part="secondary"
|
|
16
41
|
>
|
|
17
|
-
{
|
|
18
|
-
</
|
|
42
|
+
{secondaryLabel}
|
|
43
|
+
</dx-button>
|
|
19
44
|
</template>
|
|
20
|
-
</
|
|
45
|
+
</div>
|
|
21
46
|
</div>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
47
|
+
<template lwc:if={showCloseButton}>
|
|
48
|
+
<div class="close-wrap" part="close-wrap">
|
|
24
49
|
<dx-button
|
|
25
|
-
class="
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
</
|
|
34
|
-
|
|
35
|
-
<dx-button
|
|
36
|
-
class="secondary-btn"
|
|
37
|
-
variant="inline"
|
|
38
|
-
onclick={handleSecondaryClick}
|
|
39
|
-
part="secondary"
|
|
40
|
-
>
|
|
41
|
-
{secondaryLabel}
|
|
42
|
-
</dx-button>
|
|
43
|
-
</template>
|
|
44
|
-
</div>
|
|
50
|
+
class="close-btn"
|
|
51
|
+
variant="icon-only"
|
|
52
|
+
icon-symbol="close"
|
|
53
|
+
icon-color="#747474"
|
|
54
|
+
aria-label="Close"
|
|
55
|
+
onclick={handleCloseClick}
|
|
56
|
+
part="close"
|
|
57
|
+
></dx-button>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
45
60
|
</div>
|
|
46
|
-
|
|
47
|
-
<div class="close-wrap" part="close-wrap">
|
|
48
|
-
<dx-button
|
|
49
|
-
class="close-btn"
|
|
50
|
-
variant="icon-only"
|
|
51
|
-
icon-symbol="close"
|
|
52
|
-
icon-color="#747474"
|
|
53
|
-
aria-label="Close"
|
|
54
|
-
onclick={handleCloseClick}
|
|
55
|
-
part="close"
|
|
56
|
-
></dx-button>
|
|
57
|
-
</div>
|
|
58
|
-
</template>
|
|
59
|
-
</div>
|
|
61
|
+
</template>
|
|
60
62
|
</template>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { LightningElement, api } from "lwc";
|
|
1
|
+
import { LightningElement, api, track } from "lwc";
|
|
2
2
|
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
3
3
|
|
|
4
|
+
const LOCALE_BANNER_STORAGE_PREFIX = "dsc-doc-locale-banner-dismissed-";
|
|
5
|
+
|
|
4
6
|
export default class Banner extends LightningElement {
|
|
5
7
|
@api messageText = "";
|
|
6
8
|
|
|
@@ -14,6 +16,8 @@ export default class Banner extends LightningElement {
|
|
|
14
16
|
|
|
15
17
|
@api secondaryLabel = "";
|
|
16
18
|
|
|
19
|
+
@api dismissStorageKey = "";
|
|
20
|
+
|
|
17
21
|
_showCloseButton = false;
|
|
18
22
|
|
|
19
23
|
@api
|
|
@@ -24,6 +28,28 @@ export default class Banner extends LightningElement {
|
|
|
24
28
|
this._showCloseButton = normalizeBoolean(value);
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
@track private _dismissed = false;
|
|
32
|
+
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
if (
|
|
35
|
+
this.dismissStorageKey &&
|
|
36
|
+
typeof window !== "undefined" &&
|
|
37
|
+
window.localStorage
|
|
38
|
+
) {
|
|
39
|
+
this._dismissed =
|
|
40
|
+
window.localStorage.getItem(
|
|
41
|
+
`${LOCALE_BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`
|
|
42
|
+
) === "true";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get showBanner(): boolean {
|
|
47
|
+
if (!this.dismissStorageKey) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return !this._dismissed;
|
|
51
|
+
}
|
|
52
|
+
|
|
27
53
|
get hasMessageLink(): boolean {
|
|
28
54
|
return !!this.messageLinkUrl;
|
|
29
55
|
}
|
|
@@ -36,13 +62,29 @@ export default class Banner extends LightningElement {
|
|
|
36
62
|
return !!this.secondaryLabel;
|
|
37
63
|
}
|
|
38
64
|
|
|
65
|
+
persistDismissAndHide() {
|
|
66
|
+
if (
|
|
67
|
+
this.dismissStorageKey &&
|
|
68
|
+
typeof window !== "undefined" &&
|
|
69
|
+
window.localStorage
|
|
70
|
+
) {
|
|
71
|
+
window.localStorage.setItem(
|
|
72
|
+
`${LOCALE_BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`,
|
|
73
|
+
"true"
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
this._dismissed = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
39
79
|
handleSecondaryClick() {
|
|
80
|
+
this.persistDismissAndHide();
|
|
40
81
|
this.dispatchEvent(
|
|
41
82
|
new CustomEvent("dismiss", { bubbles: true, composed: true })
|
|
42
83
|
);
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
handleCloseClick() {
|
|
87
|
+
this.persistDismissAndHide();
|
|
46
88
|
this.dispatchEvent(
|
|
47
89
|
new CustomEvent("dismiss", { bubbles: true, composed: true })
|
|
48
90
|
);
|
|
@@ -17,6 +17,7 @@ import { LightningElementWithState } from "dxBaseElements/lightningElementWithSt
|
|
|
17
17
|
import { oldVersionDocInfo } from "docUtils/utils";
|
|
18
18
|
import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
|
|
19
19
|
import { track as trackGTM } from "dxUtils/analytics";
|
|
20
|
+
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
20
21
|
import DOMPurify from "dompurify";
|
|
21
22
|
|
|
22
23
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
@@ -48,6 +49,11 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
48
49
|
/** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer-mfe. */
|
|
49
50
|
@api origin: string | null = null;
|
|
50
51
|
|
|
52
|
+
/** Optional base URL for the canonical link (e.g. https://developer.salesforce.com). When set, used instead of window.location for the canonical href. */
|
|
53
|
+
@api baseUrl: string | null = null;
|
|
54
|
+
|
|
55
|
+
@api localeBannerEnabled = false;
|
|
56
|
+
|
|
51
57
|
@api
|
|
52
58
|
get allLanguages(): Array<Language> {
|
|
53
59
|
return this._allLanguages;
|
|
@@ -78,8 +84,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
78
84
|
private latestVersion = false;
|
|
79
85
|
private previewVersion = false;
|
|
80
86
|
|
|
81
|
-
@track private localeBannerDismissed = false;
|
|
82
|
-
|
|
83
87
|
private get enableFooter(): boolean {
|
|
84
88
|
return !this.hideFooter;
|
|
85
89
|
}
|
|
@@ -254,7 +258,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
private get showLocaleBanner(): boolean {
|
|
257
|
-
if (!this.
|
|
261
|
+
if (!normalizeBoolean(this.localeBannerEnabled)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (!this.pageReference?.deliverable) {
|
|
258
265
|
return false;
|
|
259
266
|
}
|
|
260
267
|
if (!this.language || this.language.id === "en-us") {
|
|
@@ -357,16 +364,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
357
364
|
this.showVersionBanner = false;
|
|
358
365
|
}
|
|
359
366
|
|
|
360
|
-
handleLocaleBannerDismiss() {
|
|
361
|
-
if (this.pageReference?.deliverable) {
|
|
362
|
-
window.localStorage.setItem(
|
|
363
|
-
`dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`,
|
|
364
|
-
"true"
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
this.localeBannerDismissed = true;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
367
|
handleSelect(event: CustomEvent<{ name: string }>): void {
|
|
371
368
|
event.stopPropagation();
|
|
372
369
|
const { name } = event.detail;
|
|
@@ -520,11 +517,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
520
517
|
this.updateUrl(HistoryState.REPLACE_STATE);
|
|
521
518
|
}
|
|
522
519
|
|
|
523
|
-
this.localeBannerDismissed =
|
|
524
|
-
window.localStorage.getItem(
|
|
525
|
-
`dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`
|
|
526
|
-
) === "true";
|
|
527
|
-
|
|
528
520
|
if (this.oldVersionInfo) {
|
|
529
521
|
this.showVersionBanner = true;
|
|
530
522
|
} else {
|
|
@@ -812,21 +804,19 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
812
804
|
}
|
|
813
805
|
|
|
814
806
|
if (this.pageReference) {
|
|
815
|
-
const
|
|
807
|
+
const canonicalLink = document.querySelector(
|
|
816
808
|
'link[rel="canonical"]'
|
|
817
809
|
);
|
|
818
|
-
if (
|
|
810
|
+
if (canonicalLink) {
|
|
819
811
|
const copyPageReference = { ...this.pageReference };
|
|
820
812
|
copyPageReference.docId = copyPageReference.docId
|
|
821
813
|
? this.dropVersionFromDocId(copyPageReference.docId)
|
|
822
814
|
: copyPageReference.docId;
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
this.pageReferenceToString(copyPageReference)
|
|
829
|
-
);
|
|
815
|
+
const path = this.pageReferenceToString(copyPageReference);
|
|
816
|
+
const origin = this.baseUrl
|
|
817
|
+
? this.baseUrl.replace(/\/$/, "")
|
|
818
|
+
: `${window.location.protocol}//${window.location.host}`;
|
|
819
|
+
canonicalLink.setAttribute("href", `${origin}${path}`);
|
|
830
820
|
}
|
|
831
821
|
}
|
|
832
822
|
|