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

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
+ "version": "1.3.124-old-version-banner-3",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -14,7 +14,7 @@ doc-phase:nth-child(2)::part(container) {
14
14
  border-bottom: 1px solid #f9e3b6 !important;
15
15
  }
16
16
 
17
- /* We don't want second component to sticky as we need to handle different cases like position*/
17
+ /* We don't want second component to sticky as we need to handle different cases like position */
18
18
  doc-phase:nth-child(2) {
19
19
  position: static;
20
20
  }
@@ -44,16 +44,17 @@ export default class AmfReference extends LightningElement {
44
44
  @track
45
45
  protected topicModel!: TopicModel;
46
46
 
47
- @api oldVersionInfo = {
48
- title: "Newer Version Available",
49
- body: `This content describes an older version of this product. <a style="font-weight: bold;" href="https://developer.salesforce.com/">
50
- View Latest</a>`,
51
- }
52
-
53
47
  get isVersionEnabled(): boolean {
54
48
  return !!this._referenceSetConfig?.versions?.length;
55
49
  }
56
50
 
51
+ /*TODO: Get the info based on logic*/
52
+ @api oldVersionInfo = {
53
+ title: "Newer Version Available",
54
+ body: `This content describes an older version of this product. <a style="font-weight: bold;" href="https://developer.salesforce.com/">
55
+ View Latest</a>`
56
+ };
57
+
57
58
  /**
58
59
  * Gives if the currently selected reference is spec based or not
59
60
  */
@@ -173,12 +174,10 @@ export default class AmfReference extends LightningElement {
173
174
  constructor() {
174
175
  super();
175
176
 
176
- this._boundOnApiNavigationChanged = this.onApiNavigationChanged.bind(
177
- this
178
- );
179
- this._boundUpdateSelectedItemFromUrlQuery = this.updateSelectedItemFromUrlQuery.bind(
180
- this
181
- );
177
+ this._boundOnApiNavigationChanged =
178
+ this.onApiNavigationChanged.bind(this);
179
+ this._boundUpdateSelectedItemFromUrlQuery =
180
+ this.updateSelectedItemFromUrlQuery.bind(this);
182
181
  }
183
182
 
184
183
  connectedCallback(): void {
@@ -234,9 +233,8 @@ export default class AmfReference extends LightningElement {
234
233
  const updatedReferenceId =
235
234
  oldReferenceIdNewReferenceIdMap[referenceId];
236
235
  const newReferenceId = updatedReferenceId || referenceId;
237
- const referenceItemConfig = this.getAmfConfigWithId(
238
- newReferenceId
239
- );
236
+ const referenceItemConfig =
237
+ this.getAmfConfigWithId(newReferenceId);
240
238
  if (referenceItemConfig) {
241
239
  hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
242
240
  }
@@ -305,9 +303,8 @@ export default class AmfReference extends LightningElement {
305
303
  for (let i = 0; i < allVersions.length; i++) {
306
304
  const versionItem = allVersions[i];
307
305
  const referenceLink = versionItem.link.href;
308
- const referenceId = this.getReferenceIdFromUrl(
309
- referenceLink
310
- );
306
+ const referenceId =
307
+ this.getReferenceIdFromUrl(referenceLink);
311
308
  if (this._currentReferenceId === referenceId) {
312
309
  // This is to navigate to respective topic in the changed version
313
310
  versionItem.link.href = `${referenceLink}/${currentRefMeta}`;
@@ -1232,12 +1229,10 @@ export default class AmfReference extends LightningElement {
1232
1229
  }
1233
1230
  if (!isRedirecting) {
1234
1231
  const currentReferenceUrl = window.location.href;
1235
- const referenceMeta = this.getMarkdownReferenceMeta(
1236
- currentReferenceUrl
1237
- );
1238
- const selectedItemRefId = this.getReferenceIdFromUrl(
1239
- currentReferenceUrl
1240
- );
1232
+ const referenceMeta =
1233
+ this.getMarkdownReferenceMeta(currentReferenceUrl);
1234
+ const selectedItemRefId =
1235
+ this.getReferenceIdFromUrl(currentReferenceUrl);
1241
1236
  const referenceDetails = this.getRefDetailsForGivenTopicMeta(
1242
1237
  selectedItemRefId,
1243
1238
  referenceMeta
@@ -1276,9 +1271,8 @@ export default class AmfReference extends LightningElement {
1276
1271
  const name = event.detail.name;
1277
1272
  if (name) {
1278
1273
  const urlReferenceId = this.getReferenceIdFromUrl(name);
1279
- const specBasedReference = this.isSpecBasedReference(
1280
- urlReferenceId
1281
- );
1274
+ const specBasedReference =
1275
+ this.isSpecBasedReference(urlReferenceId);
1282
1276
  if (specBasedReference) {
1283
1277
  const metaVal = this.getMetaFromUrl(name);
1284
1278
  const currentSelectedMeta = this.selectedTopic
@@ -1328,9 +1322,8 @@ export default class AmfReference extends LightningElement {
1328
1322
  const currentReferenceId = this.getReferenceIdFromUrl(currentUrl);
1329
1323
  //No need to do anything if user is expanding currently selected reference
1330
1324
  if (referenceId !== currentReferenceId) {
1331
- const isSpecBasedReference = this.isSpecBasedReference(
1332
- referenceId
1333
- );
1325
+ const isSpecBasedReference =
1326
+ this.isSpecBasedReference(referenceId);
1334
1327
  if (isSpecBasedReference) {
1335
1328
  // Perform functionality same as item selection
1336
1329
  this.onNavSelect(event);
@@ -20,9 +20,9 @@
20
20
  {hideBodyText}
21
21
  </dx-button>
22
22
  <dx-icon
23
+ if:true={dismissible}
23
24
  class="dismissible-icon"
24
25
  onclick={onDismiss}
25
- if:true={dismissible}
26
26
  symbol="close"
27
27
  size="large"
28
28
  color="status-icon-color"
@@ -7,7 +7,7 @@ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
7
7
  export default class Phase extends LightningElement {
8
8
  _docPhaseInfo: DocPhaseInfo | null = null;
9
9
  _dismissible = false;
10
- _iconName = 'recipe';
10
+ _iconName = "recipe";
11
11
 
12
12
  @api
13
13
  get docPhaseInfo(): DocPhaseInfo | null {
@@ -67,9 +67,8 @@ export default class Phase extends LightningElement {
67
67
  }
68
68
 
69
69
  renderedCallback() {
70
- const phaseBodyContainer = this.template.querySelector(
71
- ".doc-phase-body"
72
- );
70
+ const phaseBodyContainer =
71
+ this.template.querySelector(".doc-phase-body");
73
72
  if (phaseBodyContainer && this.docPhaseInfo) {
74
73
  // eslint-disable-next-line @lwc/lwc/no-inner-html
75
74
  phaseBodyContainer.innerHTML = this.docPhaseInfo.body;
@@ -79,16 +78,16 @@ export default class Phase extends LightningElement {
79
78
  onShowHide() {
80
79
  this.isBodyHidden = !this.isBodyHidden;
81
80
  }
82
-
83
- onDismiss(){
81
+
82
+ onDismiss() {
84
83
  this.dispatchEvent(
85
- new CustomEvent("dismissbanner", {
86
- detail: {
84
+ new CustomEvent("dismissphase", {
85
+ detail: {
87
86
  docPhaseInfo: this.docPhaseInfo
88
87
  },
89
88
  composed: true,
90
89
  bubbles: true
91
90
  })
92
- );
91
+ );
93
92
  }
94
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
+ }
@@ -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);
@@ -34,10 +35,23 @@ export default class DocXmlContent extends LightningElementWithState<{
34
35
  @api coveoPublicAccessToken!: string;
35
36
  @api coveoSearchHub!: string;
36
37
 
37
- @api oldVersionInfo = {
38
- title: "Newer Version Available",
39
- body: `This content describes an older version of this product. <a style="font-weight: bold;" href="https://developer.salesforce.com/">
40
- View Latest</a>`,
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;
41
55
  }
42
56
 
43
57
  @api
@@ -270,9 +284,8 @@ export default class DocXmlContent extends LightningElementWithState<{
270
284
 
271
285
  private get sidebarValue(): string {
272
286
  if (this.pageReference?.contentDocumentId) {
273
- const hashedUri = `${
274
- this.pageReference.contentDocumentId
275
- }${this.normalizeHash(this.pageReference.hash)}`;
287
+ const hashedUri = `${this.pageReference.contentDocumentId
288
+ }${this.normalizeHash(this.pageReference.hash)}`;
276
289
  if (hashedUri in this.tocMap) {
277
290
  return hashedUri;
278
291
  }
@@ -293,14 +306,14 @@ export default class DocXmlContent extends LightningElementWithState<{
293
306
  return this.disableVersion
294
307
  ? this.availableVersions
295
308
  : this.availableVersions.map((version) => ({
296
- ...version,
297
- link: {
298
- href: this.pageReferenceToString({
299
- ...this.pageReference,
300
- docId: version.url
301
- })
302
- }
303
- }));
309
+ ...version,
310
+ link: {
311
+ href: this.pageReferenceToString({
312
+ ...this.pageReference,
313
+ docId: version.url
314
+ })
315
+ }
316
+ }));
304
317
  }
305
318
 
306
319
  private get breadcrumbPixelPerCharacter() {
@@ -410,7 +423,7 @@ export default class DocXmlContent extends LightningElementWithState<{
410
423
  isSamePage(reference: PageReference): boolean {
411
424
  return (
412
425
  this.pageReference.contentDocumentId ===
413
- reference.contentDocumentId &&
426
+ reference.contentDocumentId &&
414
427
  this.pageReference.docId === reference.docId &&
415
428
  this.pageReference.page === reference.page &&
416
429
  this.pageReference.deliverable === reference.deliverable
@@ -701,9 +714,9 @@ export default class DocXmlContent extends LightningElementWithState<{
701
714
  metadescription.setAttribute(
702
715
  "href",
703
716
  window.location.protocol +
704
- "//" +
705
- window.location.host +
706
- this.pageReferenceToString(copyPageReference)
717
+ "//" +
718
+ window.location.host +
719
+ this.pageReferenceToString(copyPageReference)
707
720
  );
708
721
  }
709
722
  }
@@ -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
+ }