@salesforcedevs/docs-components 1.3.130 → 1.3.138
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.css +15 -0
- package/src/modules/doc/amfReference/amfReference.html +8 -0
- package/src/modules/doc/amfReference/amfReference.ts +43 -24
- package/src/modules/doc/amfReference/types.ts +2 -10
- package/src/modules/doc/contentLayout/contentLayout.html +1 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +65 -22
- package/src/modules/doc/phase/phase.css +5 -0
- package/src/modules/doc/phase/phase.html +11 -2
- package/src/modules/doc/phase/phase.ts +44 -8
- package/src/modules/doc/xmlContent/types.ts +3 -0
- package/src/modules/doc/xmlContent/xmlContent.css +6 -0
- package/src/modules/doc/xmlContent/xmlContent.html +8 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +37 -1
- package/src/modules/docUtils/utils/utils.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.138",
|
|
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": "
|
|
27
|
+
"gitHead": "23c5aa9a539b956d4d2c592d366663510af4f2ac"
|
|
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,6 +26,8 @@ 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;
|
|
@@ -39,6 +41,7 @@ export default class AmfReference extends LightningElement {
|
|
|
39
41
|
@api tocOptions?: string;
|
|
40
42
|
@track navigation = [];
|
|
41
43
|
@track versions: Array<ReferenceVersion> = [];
|
|
44
|
+
@track showVersionBanner = false;
|
|
42
45
|
|
|
43
46
|
// Update this to update what component gets rendered in the content block
|
|
44
47
|
@track
|
|
@@ -102,6 +105,12 @@ export default class AmfReference extends LightningElement {
|
|
|
102
105
|
this.versions = this.getVersions();
|
|
103
106
|
}
|
|
104
107
|
this.selectedVersion = selectedVersion;
|
|
108
|
+
if (
|
|
109
|
+
this.isSpecBasedReference(this._currentReferenceId) &&
|
|
110
|
+
this.oldVersionInfo
|
|
111
|
+
) {
|
|
112
|
+
this.showVersionBanner = true;
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
// This is to check if the url is hash based and redirect if needed
|
|
@@ -167,12 +176,10 @@ export default class AmfReference extends LightningElement {
|
|
|
167
176
|
constructor() {
|
|
168
177
|
super();
|
|
169
178
|
|
|
170
|
-
this._boundOnApiNavigationChanged =
|
|
171
|
-
this
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this
|
|
175
|
-
);
|
|
179
|
+
this._boundOnApiNavigationChanged =
|
|
180
|
+
this.onApiNavigationChanged.bind(this);
|
|
181
|
+
this._boundUpdateSelectedItemFromUrlQuery =
|
|
182
|
+
this.updateSelectedItemFromUrlQuery.bind(this);
|
|
176
183
|
}
|
|
177
184
|
|
|
178
185
|
connectedCallback(): void {
|
|
@@ -228,9 +235,8 @@ export default class AmfReference extends LightningElement {
|
|
|
228
235
|
const updatedReferenceId =
|
|
229
236
|
oldReferenceIdNewReferenceIdMap[referenceId];
|
|
230
237
|
const newReferenceId = updatedReferenceId || referenceId;
|
|
231
|
-
const referenceItemConfig =
|
|
232
|
-
newReferenceId
|
|
233
|
-
);
|
|
238
|
+
const referenceItemConfig =
|
|
239
|
+
this.getAmfConfigWithId(newReferenceId);
|
|
234
240
|
if (referenceItemConfig) {
|
|
235
241
|
hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
|
|
236
242
|
}
|
|
@@ -285,6 +291,17 @@ export default class AmfReference extends LightningElement {
|
|
|
285
291
|
return referenceId;
|
|
286
292
|
}
|
|
287
293
|
|
|
294
|
+
private get oldVersionInfo(): DocPhaseInfo | null {
|
|
295
|
+
let info = null;
|
|
296
|
+
if (this.versions.length > 1 && this.selectedVersion) {
|
|
297
|
+
const currentGAVersionRef = this.versions[0];
|
|
298
|
+
if (this.selectedVersion.id !== currentGAVersionRef.id) {
|
|
299
|
+
info = oldVersionDocInfo(currentGAVersionRef.link.href);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return info;
|
|
303
|
+
}
|
|
304
|
+
|
|
288
305
|
/**
|
|
289
306
|
* @returns versions to be shown in the dropdown
|
|
290
307
|
* For markdown based specs, Adds selected markdown topic url to same references
|
|
@@ -299,9 +316,8 @@ export default class AmfReference extends LightningElement {
|
|
|
299
316
|
for (let i = 0; i < allVersions.length; i++) {
|
|
300
317
|
const versionItem = allVersions[i];
|
|
301
318
|
const referenceLink = versionItem.link.href;
|
|
302
|
-
const referenceId =
|
|
303
|
-
referenceLink
|
|
304
|
-
);
|
|
319
|
+
const referenceId =
|
|
320
|
+
this.getReferenceIdFromUrl(referenceLink);
|
|
305
321
|
if (this._currentReferenceId === referenceId) {
|
|
306
322
|
// This is to navigate to respective topic in the changed version
|
|
307
323
|
versionItem.link.href = `${referenceLink}/${currentRefMeta}`;
|
|
@@ -1226,12 +1242,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1226
1242
|
}
|
|
1227
1243
|
if (!isRedirecting) {
|
|
1228
1244
|
const currentReferenceUrl = window.location.href;
|
|
1229
|
-
const referenceMeta =
|
|
1230
|
-
currentReferenceUrl
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
currentReferenceUrl
|
|
1234
|
-
);
|
|
1245
|
+
const referenceMeta =
|
|
1246
|
+
this.getMarkdownReferenceMeta(currentReferenceUrl);
|
|
1247
|
+
const selectedItemRefId =
|
|
1248
|
+
this.getReferenceIdFromUrl(currentReferenceUrl);
|
|
1235
1249
|
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1236
1250
|
selectedItemRefId,
|
|
1237
1251
|
referenceMeta
|
|
@@ -1241,6 +1255,9 @@ export default class AmfReference extends LightningElement {
|
|
|
1241
1255
|
}
|
|
1242
1256
|
|
|
1243
1257
|
this.versions = this.getVersions();
|
|
1258
|
+
if (this.oldVersionInfo) {
|
|
1259
|
+
this.showVersionBanner = true;
|
|
1260
|
+
}
|
|
1244
1261
|
this.updateDocPhase();
|
|
1245
1262
|
this.selectedSidebarValue = window.location.pathname;
|
|
1246
1263
|
}
|
|
@@ -1257,6 +1274,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1257
1274
|
);
|
|
1258
1275
|
}
|
|
1259
1276
|
|
|
1277
|
+
handleDismissVersionBanner() {
|
|
1278
|
+
this.showVersionBanner = false;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1260
1281
|
private updateNavTitleMetaTag(navTitle = ""): void {
|
|
1261
1282
|
// this is required to update the nav title meta tag.
|
|
1262
1283
|
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
@@ -1270,9 +1291,8 @@ export default class AmfReference extends LightningElement {
|
|
|
1270
1291
|
const name = event.detail.name;
|
|
1271
1292
|
if (name) {
|
|
1272
1293
|
const urlReferenceId = this.getReferenceIdFromUrl(name);
|
|
1273
|
-
const specBasedReference =
|
|
1274
|
-
urlReferenceId
|
|
1275
|
-
);
|
|
1294
|
+
const specBasedReference =
|
|
1295
|
+
this.isSpecBasedReference(urlReferenceId);
|
|
1276
1296
|
if (specBasedReference) {
|
|
1277
1297
|
const metaVal = this.getMetaFromUrl(name);
|
|
1278
1298
|
const currentSelectedMeta = this.selectedTopic
|
|
@@ -1322,9 +1342,8 @@ export default class AmfReference extends LightningElement {
|
|
|
1322
1342
|
const currentReferenceId = this.getReferenceIdFromUrl(currentUrl);
|
|
1323
1343
|
//No need to do anything if user is expanding currently selected reference
|
|
1324
1344
|
if (referenceId !== currentReferenceId) {
|
|
1325
|
-
const isSpecBasedReference =
|
|
1326
|
-
referenceId
|
|
1327
|
-
);
|
|
1345
|
+
const isSpecBasedReference =
|
|
1346
|
+
this.isSpecBasedReference(referenceId);
|
|
1328
1347
|
if (isSpecBasedReference) {
|
|
1329
1348
|
// Perform functionality same as item selection
|
|
1330
1349
|
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?:
|
|
68
|
+
docPhase?: DocPhaseInfo;
|
|
77
69
|
title: string;
|
|
78
70
|
href: string;
|
|
79
71
|
referenceType: ReferenceType;
|
|
@@ -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.
|
|
222
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
)
|
|
290
|
-
|
|
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
|
-
|
|
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(
|
|
@@ -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=
|
|
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={
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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 {
|
|
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
|