@salesforcedevs/docs-components 1.27.22-banner3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.27.22-banner3",
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": "49710bbadab19e48d79fbdfd9dbffa27fbe393db"
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
- <div class="doc-notification-bar" part="container">
3
- <div class="icon-wrap" part="icon-wrap">
4
- <dx-icon symbol="info" part="icon" color="#747474"></dx-icon>
5
- </div>
6
- <div class="main" part="main">
7
- <div class="content" part="content">
8
- <p class="message dx-text-body-4" part="message">
9
- <template lwc:if={messageText}>{messageText}</template>
10
- <template lwc:if={hasMessageLink}>
11
- <a
12
- href={messageLinkUrl}
13
- target="_blank"
14
- rel="noopener noreferrer"
15
- part="message-link"
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
- {messageLinkText}
18
- </a>
42
+ {secondaryLabel}
43
+ </dx-button>
19
44
  </template>
20
- </p>
45
+ </div>
21
46
  </div>
22
- <div class="actions" part="actions">
23
- <template lwc:if={hasPrimaryButton}>
47
+ <template lwc:if={showCloseButton}>
48
+ <div class="close-wrap" part="close-wrap">
24
49
  <dx-button
25
- class="primary-btn"
26
- href={buttonHref}
27
- variant="primary"
28
- size="small"
29
- part="button"
30
- >
31
- {buttonLabel}
32
- </dx-button>
33
- </template>
34
- <template lwc:if={hasSecondaryAction}>
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
- <template lwc:if={showCloseButton}>
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
  );
@@ -25,7 +25,7 @@
25
25
  button-href={localeBannerEnUsHref}
26
26
  secondary-label="Not Now"
27
27
  show-close-button="true"
28
- ondismiss={handleLocaleBannerDismiss}
28
+ dismiss-storage-key={deliverable}
29
29
  ></doc-banner>
30
30
  <doc-phase
31
31
  slot="version-banner"
@@ -84,8 +84,6 @@ export default class DocXmlContent extends LightningElementWithState<{
84
84
  private latestVersion = false;
85
85
  private previewVersion = false;
86
86
 
87
- @track private localeBannerDismissed = false;
88
-
89
87
  private get enableFooter(): boolean {
90
88
  return !this.hideFooter;
91
89
  }
@@ -263,7 +261,7 @@ export default class DocXmlContent extends LightningElementWithState<{
263
261
  if (!normalizeBoolean(this.localeBannerEnabled)) {
264
262
  return false;
265
263
  }
266
- if (!this.pageReference?.deliverable || this.localeBannerDismissed) {
264
+ if (!this.pageReference?.deliverable) {
267
265
  return false;
268
266
  }
269
267
  if (!this.language || this.language.id === "en-us") {
@@ -366,16 +364,6 @@ export default class DocXmlContent extends LightningElementWithState<{
366
364
  this.showVersionBanner = false;
367
365
  }
368
366
 
369
- handleLocaleBannerDismiss() {
370
- if (this.pageReference?.deliverable) {
371
- window.localStorage.setItem(
372
- `dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`,
373
- "true"
374
- );
375
- }
376
- this.localeBannerDismissed = true;
377
- }
378
-
379
367
  handleSelect(event: CustomEvent<{ name: string }>): void {
380
368
  event.stopPropagation();
381
369
  const { name } = event.detail;
@@ -529,11 +517,6 @@ export default class DocXmlContent extends LightningElementWithState<{
529
517
  this.updateUrl(HistoryState.REPLACE_STATE);
530
518
  }
531
519
 
532
- this.localeBannerDismissed =
533
- window.localStorage.getItem(
534
- `dsc-doc-locale-banner-dismissed-${this.pageReference.deliverable}`
535
- ) === "true";
536
-
537
520
  if (this.oldVersionInfo) {
538
521
  this.showVersionBanner = true;
539
522
  } else {