@salesforcedevs/docs-components 1.3.130 → 1.3.138-coveo-alpha

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.3.130",
3
+ "version": "1.3.138-coveo-alpha",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "cd52db111aee7bb881d15862490c5c07463acb3b"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -4,6 +4,21 @@ doc-phase {
4
4
  );
5
5
  }
6
6
 
7
+ /* We need to apply some borders when there are two doc phases */
8
+ doc-phase:not(:only-of-type)::part(container) {
9
+ border-top: 1px solid var(--dx-g-yellow-vibrant-90);
10
+ }
11
+
12
+ doc-phase:nth-child(2)::part(container) {
13
+ border-top: 1px solid var(--dx-g-yellow-vibrant-90);
14
+ border-bottom: 1px solid var(--dx-g-yellow-vibrant-90);
15
+ }
16
+
17
+ /* We don't want second component to sticky as we need to handle different cases like position */
18
+ doc-phase:nth-child(2) {
19
+ position: static;
20
+ }
21
+
7
22
  .api-documentation {
8
23
  margin-top: 48px;
9
24
  }
@@ -21,6 +21,14 @@
21
21
  if:true={docPhaseInfo}
22
22
  doc-phase-info={docPhaseInfo}
23
23
  ></doc-phase>
24
+ <doc-phase
25
+ slot="version-banner"
26
+ if:true={showVersionBanner}
27
+ doc-phase-info={oldVersionInfo}
28
+ icon-name="warning"
29
+ dismissible="true"
30
+ ondismissphase={handleDismissVersionBanner}
31
+ ></doc-phase>
24
32
  <div slot="sidebar-header" class="version-picker">
25
33
  <template if:true={isVersionEnabled}>
26
34
  <dx-dropdown
@@ -26,19 +26,21 @@ import {
26
26
  oldReferenceIdNewReferenceIdMap
27
27
  } from "./constants";
28
28
  import { restoreScroll } from "dx/scrollManager";
29
+ import { DocPhaseInfo } from "typings/custom";
30
+ import { oldVersionDocInfo } from "docUtils/utils";
29
31
 
30
32
  export default class AmfReference extends LightningElement {
31
33
  @api breadcrumbs?: string | null | undefined = null;
32
34
  @api sidebarHeader!: string;
33
35
  @api coveoOrganizationId!: string;
34
36
  @api coveoPublicAccessToken!: string;
35
- @api coveoAdvancedQueryConfig!: string;
36
37
  @api coveoSearchHub!: string;
37
38
  @api useOldSidebar?: boolean = false;
38
39
  @api tocTitle?: string;
39
40
  @api tocOptions?: string;
40
41
  @track navigation = [];
41
42
  @track versions: Array<ReferenceVersion> = [];
43
+ @track showVersionBanner = false;
42
44
 
43
45
  // Update this to update what component gets rendered in the content block
44
46
  @track
@@ -102,6 +104,12 @@ export default class AmfReference extends LightningElement {
102
104
  this.versions = this.getVersions();
103
105
  }
104
106
  this.selectedVersion = selectedVersion;
107
+ if (
108
+ this.isSpecBasedReference(this._currentReferenceId) &&
109
+ this.oldVersionInfo
110
+ ) {
111
+ this.showVersionBanner = true;
112
+ }
105
113
  }
106
114
 
107
115
  // This is to check if the url is hash based and redirect if needed
@@ -113,6 +121,21 @@ export default class AmfReference extends LightningElement {
113
121
  }
114
122
  }
115
123
 
124
+ private get coveoAdvancedQueryConfig(config: string): string {
125
+ try {
126
+ const coveoAgConfig = JSON.parse(config);
127
+ if(this.showVersionBanner) {
128
+ coveoAgConfig.version = this.getSelectedVersion();
129
+ } else {
130
+ coveoAgConfig.version = "latest";
131
+ }
132
+
133
+ return JSON.stringify(coveoAgConfig);
134
+ } catch (error) {
135
+ console.log(`Error during version implementation.`)
136
+ }
137
+ }
138
+
116
139
  @api
117
140
  get docPhaseInfo() {
118
141
  return this.selectedReferenceDocPhase;
@@ -167,12 +190,10 @@ export default class AmfReference extends LightningElement {
167
190
  constructor() {
168
191
  super();
169
192
 
170
- this._boundOnApiNavigationChanged = this.onApiNavigationChanged.bind(
171
- this
172
- );
173
- this._boundUpdateSelectedItemFromUrlQuery = this.updateSelectedItemFromUrlQuery.bind(
174
- this
175
- );
193
+ this._boundOnApiNavigationChanged =
194
+ this.onApiNavigationChanged.bind(this);
195
+ this._boundUpdateSelectedItemFromUrlQuery =
196
+ this.updateSelectedItemFromUrlQuery.bind(this);
176
197
  }
177
198
 
178
199
  connectedCallback(): void {
@@ -228,9 +249,8 @@ export default class AmfReference extends LightningElement {
228
249
  const updatedReferenceId =
229
250
  oldReferenceIdNewReferenceIdMap[referenceId];
230
251
  const newReferenceId = updatedReferenceId || referenceId;
231
- const referenceItemConfig = this.getAmfConfigWithId(
232
- newReferenceId
233
- );
252
+ const referenceItemConfig =
253
+ this.getAmfConfigWithId(newReferenceId);
234
254
  if (referenceItemConfig) {
235
255
  hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
236
256
  }
@@ -285,6 +305,17 @@ export default class AmfReference extends LightningElement {
285
305
  return referenceId;
286
306
  }
287
307
 
308
+ private get oldVersionInfo(): DocPhaseInfo | null {
309
+ let info = null;
310
+ if (this.versions.length > 1 && this.selectedVersion) {
311
+ const currentGAVersionRef = this.versions[0];
312
+ if (this.selectedVersion.id !== currentGAVersionRef.id) {
313
+ info = oldVersionDocInfo(currentGAVersionRef.link.href);
314
+ }
315
+ }
316
+ return info;
317
+ }
318
+
288
319
  /**
289
320
  * @returns versions to be shown in the dropdown
290
321
  * For markdown based specs, Adds selected markdown topic url to same references
@@ -299,9 +330,8 @@ export default class AmfReference extends LightningElement {
299
330
  for (let i = 0; i < allVersions.length; i++) {
300
331
  const versionItem = allVersions[i];
301
332
  const referenceLink = versionItem.link.href;
302
- const referenceId = this.getReferenceIdFromUrl(
303
- referenceLink
304
- );
333
+ const referenceId =
334
+ this.getReferenceIdFromUrl(referenceLink);
305
335
  if (this._currentReferenceId === referenceId) {
306
336
  // This is to navigate to respective topic in the changed version
307
337
  versionItem.link.href = `${referenceLink}/${currentRefMeta}`;
@@ -1226,12 +1256,10 @@ export default class AmfReference extends LightningElement {
1226
1256
  }
1227
1257
  if (!isRedirecting) {
1228
1258
  const currentReferenceUrl = window.location.href;
1229
- const referenceMeta = this.getMarkdownReferenceMeta(
1230
- currentReferenceUrl
1231
- );
1232
- const selectedItemRefId = this.getReferenceIdFromUrl(
1233
- currentReferenceUrl
1234
- );
1259
+ const referenceMeta =
1260
+ this.getMarkdownReferenceMeta(currentReferenceUrl);
1261
+ const selectedItemRefId =
1262
+ this.getReferenceIdFromUrl(currentReferenceUrl);
1235
1263
  const referenceDetails = this.getRefDetailsForGivenTopicMeta(
1236
1264
  selectedItemRefId,
1237
1265
  referenceMeta
@@ -1241,6 +1269,9 @@ export default class AmfReference extends LightningElement {
1241
1269
  }
1242
1270
 
1243
1271
  this.versions = this.getVersions();
1272
+ if (this.oldVersionInfo) {
1273
+ this.showVersionBanner = true;
1274
+ }
1244
1275
  this.updateDocPhase();
1245
1276
  this.selectedSidebarValue = window.location.pathname;
1246
1277
  }
@@ -1257,6 +1288,10 @@ export default class AmfReference extends LightningElement {
1257
1288
  );
1258
1289
  }
1259
1290
 
1291
+ handleDismissVersionBanner() {
1292
+ this.showVersionBanner = false;
1293
+ }
1294
+
1260
1295
  private updateNavTitleMetaTag(navTitle = ""): void {
1261
1296
  // this is required to update the nav title meta tag.
1262
1297
  // eslint-disable-next-line @lwc/lwc/no-document-query
@@ -1270,9 +1305,8 @@ export default class AmfReference extends LightningElement {
1270
1305
  const name = event.detail.name;
1271
1306
  if (name) {
1272
1307
  const urlReferenceId = this.getReferenceIdFromUrl(name);
1273
- const specBasedReference = this.isSpecBasedReference(
1274
- urlReferenceId
1275
- );
1308
+ const specBasedReference =
1309
+ this.isSpecBasedReference(urlReferenceId);
1276
1310
  if (specBasedReference) {
1277
1311
  const metaVal = this.getMetaFromUrl(name);
1278
1312
  const currentSelectedMeta = this.selectedTopic
@@ -1322,9 +1356,8 @@ export default class AmfReference extends LightningElement {
1322
1356
  const currentReferenceId = this.getReferenceIdFromUrl(currentUrl);
1323
1357
  //No need to do anything if user is expanding currently selected reference
1324
1358
  if (referenceId !== currentReferenceId) {
1325
- const isSpecBasedReference = this.isSpecBasedReference(
1326
- referenceId
1327
- );
1359
+ const isSpecBasedReference =
1360
+ this.isSpecBasedReference(referenceId);
1328
1361
  if (isSpecBasedReference) {
1329
1362
  // Perform functionality same as item selection
1330
1363
  this.onNavSelect(event);
@@ -1,4 +1,4 @@
1
- import { Json } from "typings/custom";
1
+ import { Json, DocPhaseInfo } from "typings/custom";
2
2
 
3
3
  export interface AmfTopicType {
4
4
  referenceId: string;
@@ -46,14 +46,6 @@ export interface AmfModelRecord {
46
46
  parsedModel: Json;
47
47
  }
48
48
 
49
- export type DocPhase = "pilot" | "dev-preview" | "beta";
50
-
51
- export type DocPhaseEntry = {
52
- phase: DocPhase;
53
- title: string;
54
- body: string;
55
- };
56
-
57
49
  export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
58
50
 
59
51
  /**
@@ -73,7 +65,7 @@ export interface ParsedMarkdownTopic {
73
65
  export interface AmfConfig {
74
66
  id: string;
75
67
  version?: string;
76
- docPhase?: DocPhaseEntry;
68
+ docPhase?: DocPhaseInfo;
77
69
  title: string;
78
70
  href: string;
79
71
  referenceType: ReferenceType;
@@ -28,6 +28,7 @@
28
28
  </template>
29
29
  <div class="content-body-doc-phase-container">
30
30
  <slot name="doc-phase"></slot>
31
+ <slot name="version-banner"></slot>
31
32
  <div class="content-body-container">
32
33
  <div class="content-body">
33
34
  <doc-breadcrumbs
@@ -92,9 +92,6 @@ export default class ContentLayout extends LightningElement {
92
92
 
93
93
  private searchSyncer = new SearchSyncer({
94
94
  callbacks: {
95
- onUrlChange: (nextSearchString: string): void => {
96
- this.updateHighlightsAndSearch(nextSearchString);
97
- },
98
95
  onSearchChange: (nextSearchString: string): void => {
99
96
  this.dispatchHighlightChange(
100
97
  new URLSearchParams(nextSearchString).get("q") || ""
@@ -217,13 +214,16 @@ export default class ContentLayout extends LightningElement {
217
214
 
218
215
  // sync with the browser to account for any reflows that may have happened
219
216
  requestAnimationFrame(() => {
217
+ // ternary is a temporary fix for the global nav height reporting incorrectly on some browsers
220
218
  const globalNavHeight =
221
- globalNavEl.offsetHeight + contextNavEl.offsetHeight;
222
- const docHeaderHeight = docHeaderEl.offsetHeight;
219
+ (globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
220
+ contextNavEl.getBoundingClientRect().height;
221
+ const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
223
222
  sidebarEl.style.setProperty(
224
223
  "--dx-c-content-sidebar-sticky-top",
225
224
  `${globalNavHeight + docHeaderHeight}px`
226
225
  );
226
+
227
227
  docHeaderEl.style.setProperty(
228
228
  "--dx-g-global-header-height",
229
229
  `${globalNavHeight}px`
@@ -237,7 +237,7 @@ export default class ContentLayout extends LightningElement {
237
237
  window.innerWidth < 769
238
238
  ? globalNavHeight +
239
239
  docHeaderHeight +
240
- sidebarEl.offsetHeight
240
+ sidebarEl.getBoundingClientRect().height
241
241
  : globalNavHeight + docHeaderHeight
242
242
  }px`
243
243
  );
@@ -250,7 +250,7 @@ export default class ContentLayout extends LightningElement {
250
250
  docHeadingEl.style.scrollMarginTop = `${
251
251
  globalNavHeight +
252
252
  docHeaderHeight +
253
- docPhaseEl.offsetHeight
253
+ docPhaseEl.getBoundingClientRect().height
254
254
  }px`;
255
255
  });
256
256
 
@@ -262,7 +262,7 @@ export default class ContentLayout extends LightningElement {
262
262
  rightNavBarEl.style.top = `${
263
263
  globalNavHeight +
264
264
  docHeaderHeight +
265
- docPhaseEl.offsetHeight
265
+ docPhaseEl.getBoundingClientRect().height
266
266
  }px`;
267
267
  }
268
268
  }
@@ -280,15 +280,25 @@ export default class ContentLayout extends LightningElement {
280
280
  return;
281
281
  }
282
282
  this.disconnectObserver();
283
- this.observer = new IntersectionObserver((entries) => {
284
- entries.forEach(
285
- (entry) =>
286
- (this.anchoredElements[
287
- entry.target.getAttribute("id")
288
- ].intersect = entry.isIntersecting)
289
- );
290
- this.calculateActualSection();
291
- });
283
+
284
+ const globalNavOffset = `-${getComputedStyle(
285
+ document.documentElement
286
+ ).getPropertyValue("--dx-g-doc-header-main-nav-height")}`;
287
+
288
+ this.observer = new IntersectionObserver(
289
+ (entries) => {
290
+ entries.forEach(
291
+ (entry) =>
292
+ (this.anchoredElements[
293
+ entry.target.getAttribute("id")
294
+ ].intersect = entry.isIntersecting)
295
+ );
296
+ this.calculateActualSection();
297
+ },
298
+ {
299
+ rootMargin: globalNavOffset.trim()
300
+ }
301
+ );
292
302
 
293
303
  // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
294
304
  const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
@@ -307,10 +317,6 @@ export default class ContentLayout extends LightningElement {
307
317
  }
308
318
  };
309
319
 
310
- onSidebarClick() {
311
- this.resetScrollThreshold();
312
- }
313
-
314
320
  onSlotChange(event: Event): void {
315
321
  const slotElements = (
316
322
  event.target as HTMLSlotElement
@@ -366,15 +372,52 @@ export default class ContentLayout extends LightningElement {
366
372
  let { hash } = window.location;
367
373
  if (hash) {
368
374
  hash = hash.substr(1);
375
+
376
+ const docHeaderEl = document.querySelector(
377
+ ".sticky-doc-header"
378
+ ) as HTMLElement;
379
+ const globalNavEl = document.querySelector(
380
+ "hgf-c360nav"
381
+ ) as HTMLElement;
382
+ const contextNavEl = document.querySelector(
383
+ "hgf-c360contextnav"
384
+ ) as HTMLElement;
385
+
386
+ const headerHeight =
387
+ docHeaderEl.offsetHeight +
388
+ globalNavEl.offsetHeight +
389
+ contextNavEl.offsetHeight;
390
+
391
+ const docPhaseEl = this.template
392
+ .querySelector("[name=doc-phase]")!
393
+ .assignedElements()[0] as HTMLSlotElement;
394
+
395
+ const offset = docPhaseEl
396
+ ? headerHeight + docPhaseEl.offsetHeight
397
+ : headerHeight;
398
+
369
399
  for (const headingElement of headingElements) {
370
400
  if (headingElement.getAttribute("id") === hash) {
371
- headingElement.scrollIntoView({ behavior: "auto" });
401
+ this.scrollIntoViewWithOffset(headingElement, offset);
372
402
  break;
373
403
  }
374
404
  }
375
405
  }
376
406
  }
377
407
 
408
+ private scrollIntoViewWithOffset(
409
+ headingElement: HTMLElement,
410
+ offset: number
411
+ ) {
412
+ window.scrollTo({
413
+ behavior: "auto",
414
+ top:
415
+ headingElement.getBoundingClientRect().top -
416
+ document.body.getBoundingClientRect().top -
417
+ offset
418
+ });
419
+ }
420
+
378
421
  private calculateActualSection(): void {
379
422
  const currentScrollPosition = document.documentElement.scrollTop;
380
423
  const id = Object.keys(this.anchoredElements).find(
@@ -62,6 +62,11 @@ dx-button {
62
62
  color: var(--dx-g-blue-vibrant-50);
63
63
  }
64
64
 
65
+ .dismissible-icon {
66
+ margin-left: auto;
67
+ cursor: pointer;
68
+ }
69
+
65
70
  /* Small Devices */
66
71
  @media screen and (max-width: 480px) {
67
72
  .doc-phase-container {
@@ -3,7 +3,7 @@
3
3
  <div class="doc-phase-title-container">
4
4
  <dx-icon
5
5
  class="doc-status-icon doc-phase-icon"
6
- symbol="recipe"
6
+ symbol={iconName}
7
7
  size="large"
8
8
  color="status-icon-color"
9
9
  ></dx-icon>
@@ -11,12 +11,21 @@
11
11
  {docPhaseTitle}
12
12
  </p>
13
13
  <dx-button
14
+ if:false={dismissible}
14
15
  variant="inline"
15
- onclick={onButtonClick}
16
+ onclick={onShowHide}
16
17
  aria-label={hideBodyText}
17
18
  >
18
19
  {hideBodyText}
19
20
  </dx-button>
21
+ <dx-icon
22
+ class="dismissible-icon"
23
+ onclick={onDismiss}
24
+ if:true={dismissible}
25
+ symbol="close"
26
+ size="large"
27
+ color="status-icon-color"
28
+ ></dx-icon>
20
29
  </div>
21
30
  <!--
22
31
  NOTE: Here we are rendering mark up using lwc:dom & innerHTML
@@ -2,16 +2,12 @@ import { LightningElement, api } from "lwc";
2
2
  import cx from "classnames";
3
3
 
4
4
  import { DocPhaseInfo } from "typings/custom";
5
- import { toJson } from "dxUtils/normalizers";
5
+ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
6
 
7
7
  export default class Phase extends LightningElement {
8
8
  _docPhaseInfo: DocPhaseInfo | null = null;
9
-
10
- isBodyHidden = false;
11
-
12
- get docPhaseTitle() {
13
- return this.docPhaseInfo?.title;
14
- }
9
+ _dismissible = false;
10
+ _iconName = "recipe";
15
11
 
16
12
  @api
17
13
  get docPhaseInfo(): DocPhaseInfo | null {
@@ -22,6 +18,34 @@ export default class Phase extends LightningElement {
22
18
  this._docPhaseInfo = toJson(value);
23
19
  }
24
20
 
21
+ @api
22
+ get dismissible(): boolean {
23
+ return this._dismissible;
24
+ }
25
+
26
+ set dismissible(value) {
27
+ if (value) {
28
+ this._dismissible = normalizeBoolean(value);
29
+ }
30
+ }
31
+
32
+ @api
33
+ get iconName(): string {
34
+ return this._iconName;
35
+ }
36
+
37
+ set iconName(value) {
38
+ if (value) {
39
+ this._iconName = value;
40
+ }
41
+ }
42
+
43
+ isBodyHidden = false;
44
+
45
+ get docPhaseTitle() {
46
+ return this.docPhaseInfo?.title;
47
+ }
48
+
25
49
  get hideBodyText() {
26
50
  return this.isBodyHidden ? "Show" : "Hide";
27
51
  }
@@ -51,7 +75,19 @@ export default class Phase extends LightningElement {
51
75
  }
52
76
  }
53
77
 
54
- onButtonClick() {
78
+ onShowHide() {
55
79
  this.isBodyHidden = !this.isBodyHidden;
56
80
  }
81
+
82
+ onDismiss() {
83
+ this.dispatchEvent(
84
+ new CustomEvent("dismissphase", {
85
+ detail: {
86
+ docPhaseInfo: this.docPhaseInfo
87
+ },
88
+ composed: true,
89
+ bubbles: true
90
+ })
91
+ );
92
+ }
57
93
  }
@@ -35,6 +35,9 @@ type DropdownOption = {
35
35
  export type DocVersion = DropdownOption & {
36
36
  releaseVersion: string;
37
37
  url: string;
38
+ link?: {
39
+ href: string;
40
+ };
38
41
  };
39
42
 
40
43
  export type DocLanguage = DropdownOption & {
@@ -44,3 +44,9 @@ dx-dropdown > dx-button:hover {
44
44
  margin-left: auto;
45
45
  margin-right: var(--dx-g-spacing-sm);
46
46
  }
47
+
48
+ doc-phase {
49
+ --doc-c-phase-top: calc(
50
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
51
+ );
52
+ }
@@ -11,6 +11,14 @@
11
11
  onselect={handleSelect}
12
12
  use-old-sidebar={useOldSidebar}
13
13
  >
14
+ <doc-phase
15
+ slot="version-banner"
16
+ if:true={showVersionBanner}
17
+ doc-phase-info={oldVersionInfo}
18
+ icon-name="warning"
19
+ dismissible="true"
20
+ ondismissphase={handleDismissVersionBanner}
21
+ ></doc-phase>
14
22
  <div slot="sidebar-header" class="document-pickers">
15
23
  <dx-dropdown
16
24
  data-type="version"
@@ -14,7 +14,8 @@ import {
14
14
  } from "./types";
15
15
  import { SearchSyncer } from "docUtils/SearchSyncer";
16
16
  import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
17
- import { Breadcrumb, Language } from "typings/custom";
17
+ import { oldVersionDocInfo } from "docUtils/utils";
18
+ import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
18
19
 
19
20
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
20
21
  const handleContentError = (error): void => console.log(error);
@@ -108,6 +109,33 @@ export default class DocXmlContent extends LightningElementWithState<{
108
109
  });
109
110
  private _allLanguages: Array<Language> = [];
110
111
 
112
+ private get oldVersionInfo(): DocPhaseInfo | null {
113
+ let info = null;
114
+ if (!this.disableVersion) {
115
+ const currentGAVersion = this.versionOptions.find(
116
+ (version) => !version.url.includes(version.id)
117
+ );
118
+ if (currentGAVersion?.link?.href && this.version?.id) {
119
+ const versionNo = currentGAVersion.id;
120
+ /**
121
+ * Need to show old version doc banner only if the version is less than the current ga version
122
+ * We should not show it to the preview version whose version is more than ga
123
+ **/
124
+ try {
125
+ if (parseFloat(this.version.id) < parseFloat(versionNo)) {
126
+ info = oldVersionDocInfo(currentGAVersion.link.href);
127
+ }
128
+ } catch (exception) {
129
+ /* Ideally this use case should not happen, but just added to not to break the page*/
130
+ console.warn(exception);
131
+ }
132
+ }
133
+ }
134
+ return info;
135
+ }
136
+
137
+ @track showVersionBanner = false;
138
+
111
139
  @track private pageReference: PageReference = {};
112
140
  @track breadcrumbs: Array<Breadcrumb> = [];
113
141
 
@@ -293,6 +321,10 @@ export default class DocXmlContent extends LightningElementWithState<{
293
321
  private handlePopState = (event: PopStateEvent): void =>
294
322
  this.updatePageReference(this.getReferenceFromUrl(), event);
295
323
 
324
+ handleDismissVersionBanner() {
325
+ this.showVersionBanner = false;
326
+ }
327
+
296
328
  handleSelect(event: CustomEvent<{ name: string }>): void {
297
329
  event.stopPropagation();
298
330
  const { name } = event.detail;
@@ -424,6 +456,10 @@ export default class DocXmlContent extends LightningElementWithState<{
424
456
  this.updateUrl(HistoryState.REPLACE_STATE);
425
457
  }
426
458
 
459
+ if (this.oldVersionInfo) {
460
+ this.showVersionBanner = true;
461
+ }
462
+
427
463
  if (
428
464
  this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
429
465
  data.id
@@ -0,0 +1,7 @@
1
+ export const oldVersionDocInfo = (latestVersionLink: string) => {
2
+ return {
3
+ title: "Newer Version Available",
4
+ body: `This content describes an older version of this product.
5
+ <a style="font-weight: bold;" href="${latestVersionLink}">View Latest</a>`
6
+ };
7
+ };
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.