@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.124-old-version-banner-4",
3
+ "version": "1.3.124-old-version-banner-6",
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,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 = `${this.pageReference.contentDocumentId
293
- }${this.normalizeHash(this.pageReference.hash)}`;
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
- ...version,
315
- link: {
316
- href: this.pageReferenceToString({
317
- ...this.pageReference,
318
- docId: version.url
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
- reference.contentDocumentId &&
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
- window.location.host +
724
- this.pageReferenceToString(copyPageReference)
734
+ "//" +
735
+ window.location.host +
736
+ this.pageReferenceToString(copyPageReference)
725
737
  );
726
738
  }
727
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
+ };