@salesforcedevs/docs-components 1.3.124-old-version-banner-4 → 1.3.124-old-version-banner-6
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 +1 -1
- package/src/modules/doc/amfReference/amfReference.html +1 -1
- package/src/modules/doc/amfReference/types.ts +2 -10
- package/src/modules/doc/phase/phase.css +1 -0
- package/src/modules/doc/xmlContent/types.ts +2 -2
- package/src/modules/doc/xmlContent/xmlContent.html +3 -2
- package/src/modules/doc/xmlContent/xmlContent.ts +51 -39
- package/src/modules/docUtils/utils/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
>
|
|
14
14
|
<doc-phase
|
|
15
15
|
slot="version-banner"
|
|
16
|
-
if:true={
|
|
16
|
+
if:true={showVersionBanner}
|
|
17
17
|
doc-phase-info={oldVersionInfo}
|
|
18
|
+
icon-name="warning"
|
|
18
19
|
dismissible="true"
|
|
19
|
-
|
|
20
|
+
ondismissphase={handleDismissVersionBanner}
|
|
20
21
|
></doc-phase>
|
|
21
22
|
<div slot="sidebar-header" class="document-pickers">
|
|
22
23
|
<dx-dropdown
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./types";
|
|
15
15
|
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
16
16
|
import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
|
|
17
|
-
import { oldVersionDocInfo } from "docUtils/utils"
|
|
17
|
+
import { oldVersionDocInfo } from "docUtils/utils";
|
|
18
18
|
import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
|
|
19
19
|
|
|
20
20
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
@@ -35,30 +35,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
35
35
|
@api coveoPublicAccessToken!: string;
|
|
36
36
|
@api coveoSearchHub!: string;
|
|
37
37
|
|
|
38
|
-
@api
|
|
39
|
-
get oldVersionInfo(): DocPhaseInfo | null {
|
|
40
|
-
let info = null;
|
|
41
|
-
if (!this.disableVersion) {
|
|
42
|
-
const currentGAVersion = this.versionOptions.find((version) => version.url.includes(version.id));
|
|
43
|
-
if (currentGAVersion?.link?.href && this.version?.id) {
|
|
44
|
-
const versionNo = currentGAVersion.id;
|
|
45
|
-
/**
|
|
46
|
-
* Need to show old version doc banner only if the version is less than the current ga version
|
|
47
|
-
* We should not show it to the preview version whose version is more than ga
|
|
48
|
-
**/
|
|
49
|
-
try {
|
|
50
|
-
if (parseFloat(this.version.id) < parseFloat(versionNo)) {
|
|
51
|
-
info = oldVersionDocInfo(currentGAVersion.link.href)
|
|
52
|
-
}
|
|
53
|
-
} catch (exception) {
|
|
54
|
-
/* Ideally this use case should not happen, but just added to not to break the page*/
|
|
55
|
-
console.warn(exception);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return info;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
38
|
@api
|
|
63
39
|
get allLanguages(): Array<Language> {
|
|
64
40
|
return this._allLanguages;
|
|
@@ -133,6 +109,33 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
133
109
|
});
|
|
134
110
|
private _allLanguages: Array<Language> = [];
|
|
135
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
|
+
|
|
136
139
|
@track private pageReference: PageReference = {};
|
|
137
140
|
@track breadcrumbs: Array<Breadcrumb> = [];
|
|
138
141
|
|
|
@@ -289,8 +292,9 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
289
292
|
|
|
290
293
|
private get sidebarValue(): string {
|
|
291
294
|
if (this.pageReference?.contentDocumentId) {
|
|
292
|
-
const hashedUri = `${
|
|
293
|
-
|
|
295
|
+
const hashedUri = `${
|
|
296
|
+
this.pageReference.contentDocumentId
|
|
297
|
+
}${this.normalizeHash(this.pageReference.hash)}`;
|
|
294
298
|
if (hashedUri in this.tocMap) {
|
|
295
299
|
return hashedUri;
|
|
296
300
|
}
|
|
@@ -311,14 +315,14 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
311
315
|
return this.disableVersion
|
|
312
316
|
? this.availableVersions
|
|
313
317
|
: this.availableVersions.map((version) => ({
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
...version,
|
|
319
|
+
link: {
|
|
320
|
+
href: this.pageReferenceToString({
|
|
321
|
+
...this.pageReference,
|
|
322
|
+
docId: version.url
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
}));
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
private get breadcrumbPixelPerCharacter() {
|
|
@@ -338,6 +342,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
338
342
|
private handlePopState = (event: PopStateEvent): void =>
|
|
339
343
|
this.updatePageReference(this.getReferenceFromUrl(), event);
|
|
340
344
|
|
|
345
|
+
handleDismissVersionBanner() {
|
|
346
|
+
this.showVersionBanner = false;
|
|
347
|
+
}
|
|
348
|
+
|
|
341
349
|
handleSelect(event: CustomEvent<{ name: string }>): void {
|
|
342
350
|
event.stopPropagation();
|
|
343
351
|
const { name } = event.detail;
|
|
@@ -428,7 +436,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
428
436
|
isSamePage(reference: PageReference): boolean {
|
|
429
437
|
return (
|
|
430
438
|
this.pageReference.contentDocumentId ===
|
|
431
|
-
|
|
439
|
+
reference.contentDocumentId &&
|
|
432
440
|
this.pageReference.docId === reference.docId &&
|
|
433
441
|
this.pageReference.page === reference.page &&
|
|
434
442
|
this.pageReference.deliverable === reference.deliverable
|
|
@@ -469,6 +477,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
469
477
|
this.updateUrl(HistoryState.REPLACE_STATE);
|
|
470
478
|
}
|
|
471
479
|
|
|
480
|
+
if (this.oldVersionInfo) {
|
|
481
|
+
this.showVersionBanner = true;
|
|
482
|
+
}
|
|
483
|
+
|
|
472
484
|
if (
|
|
473
485
|
this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
|
|
474
486
|
data.id
|
|
@@ -719,9 +731,9 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
719
731
|
metadescription.setAttribute(
|
|
720
732
|
"href",
|
|
721
733
|
window.location.protocol +
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
734
|
+
"//" +
|
|
735
|
+
window.location.host +
|
|
736
|
+
this.pageReferenceToString(copyPageReference)
|
|
725
737
|
);
|
|
726
738
|
}
|
|
727
739
|
}
|