@salesforcedevs/docs-components 1.3.124-old-version-banner-3 → 1.3.124-old-version-banner-5

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.124-old-version-banner-3",
3
+ "version": "1.3.124-old-version-banner-5",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -26,7 +26,7 @@
26
26
  if:true={oldVersionInfo}
27
27
  doc-phase-info={oldVersionInfo}
28
28
  dismissible="true"
29
- icon="warning"
29
+ icon-name="warning"
30
30
  ></doc-phase>
31
31
  <div slot="sidebar-header" class="version-picker">
32
32
  <template if:true={isVersionEnabled}>
@@ -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;
@@ -66,6 +66,7 @@ dx-button {
66
66
 
67
67
  .dismissible-icon {
68
68
  margin-left: auto;
69
+ cursor: pointer;
69
70
  }
70
71
 
71
72
  /* Small Devices */
@@ -36,8 +36,8 @@ export type DocVersion = DropdownOption & {
36
36
  releaseVersion: string;
37
37
  url: string;
38
38
  link?: {
39
- href: string
40
- }
39
+ href: string;
40
+ };
41
41
  };
42
42
 
43
43
  export type DocLanguage = DropdownOption & {
@@ -13,10 +13,11 @@
13
13
  >
14
14
  <doc-phase
15
15
  slot="version-banner"
16
- if:true={oldVersionInfo}
16
+ if:true={showVersionBanner}
17
17
  doc-phase-info={oldVersionInfo}
18
+ icon-name="warning"
18
19
  dismissible="true"
19
- icon="warning"
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,25 +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) {
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
- if (parseFloat(this.version.id) < parseFloat(versionNo)) {
50
- info = oldVersionDocInfo(currentGAVersion.link.href)
51
- }
52
- }
53
- }
54
- return info;
55
- }
56
-
57
38
  @api
58
39
  get allLanguages(): Array<Language> {
59
40
  return this._allLanguages;
@@ -128,6 +109,33 @@ export default class DocXmlContent extends LightningElementWithState<{
128
109
  });
129
110
  private _allLanguages: Array<Language> = [];
130
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
+
131
139
  @track private pageReference: PageReference = {};
132
140
  @track breadcrumbs: Array<Breadcrumb> = [];
133
141
 
@@ -284,8 +292,9 @@ export default class DocXmlContent extends LightningElementWithState<{
284
292
 
285
293
  private get sidebarValue(): string {
286
294
  if (this.pageReference?.contentDocumentId) {
287
- const hashedUri = `${this.pageReference.contentDocumentId
288
- }${this.normalizeHash(this.pageReference.hash)}`;
295
+ const hashedUri = `${
296
+ this.pageReference.contentDocumentId
297
+ }${this.normalizeHash(this.pageReference.hash)}`;
289
298
  if (hashedUri in this.tocMap) {
290
299
  return hashedUri;
291
300
  }
@@ -306,14 +315,14 @@ export default class DocXmlContent extends LightningElementWithState<{
306
315
  return this.disableVersion
307
316
  ? this.availableVersions
308
317
  : this.availableVersions.map((version) => ({
309
- ...version,
310
- link: {
311
- href: this.pageReferenceToString({
312
- ...this.pageReference,
313
- docId: version.url
314
- })
315
- }
316
- }));
318
+ ...version,
319
+ link: {
320
+ href: this.pageReferenceToString({
321
+ ...this.pageReference,
322
+ docId: version.url
323
+ })
324
+ }
325
+ }));
317
326
  }
318
327
 
319
328
  private get breadcrumbPixelPerCharacter() {
@@ -333,6 +342,10 @@ export default class DocXmlContent extends LightningElementWithState<{
333
342
  private handlePopState = (event: PopStateEvent): void =>
334
343
  this.updatePageReference(this.getReferenceFromUrl(), event);
335
344
 
345
+ handleDismissVersionBanner() {
346
+ this.showVersionBanner = false;
347
+ }
348
+
336
349
  handleSelect(event: CustomEvent<{ name: string }>): void {
337
350
  event.stopPropagation();
338
351
  const { name } = event.detail;
@@ -423,7 +436,7 @@ export default class DocXmlContent extends LightningElementWithState<{
423
436
  isSamePage(reference: PageReference): boolean {
424
437
  return (
425
438
  this.pageReference.contentDocumentId ===
426
- reference.contentDocumentId &&
439
+ reference.contentDocumentId &&
427
440
  this.pageReference.docId === reference.docId &&
428
441
  this.pageReference.page === reference.page &&
429
442
  this.pageReference.deliverable === reference.deliverable
@@ -464,6 +477,10 @@ export default class DocXmlContent extends LightningElementWithState<{
464
477
  this.updateUrl(HistoryState.REPLACE_STATE);
465
478
  }
466
479
 
480
+ if (this.oldVersionInfo) {
481
+ this.showVersionBanner = true;
482
+ }
483
+
467
484
  if (
468
485
  this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
469
486
  data.id
@@ -714,9 +731,9 @@ export default class DocXmlContent extends LightningElementWithState<{
714
731
  metadescription.setAttribute(
715
732
  "href",
716
733
  window.location.protocol +
717
- "//" +
718
- window.location.host +
719
- this.pageReferenceToString(copyPageReference)
734
+ "//" +
735
+ window.location.host +
736
+ this.pageReferenceToString(copyPageReference)
720
737
  );
721
738
  }
722
739
  }
@@ -4,4 +4,4 @@ export const oldVersionDocInfo = (latestVersionLink: string) => {
4
4
  body: `This content describes an older version of this product.
5
5
  <a style="font-weight: bold;" href="${latestVersionLink}">View Latest</a>`
6
6
  };
7
- }
7
+ };