@salesforcedevs/docs-components 1.3.138-coveo-alpha → 1.3.138-coveo-alpha2

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.138-coveo-alpha",
3
+ "version": "1.3.138-coveo-alpha2",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -6,6 +6,7 @@
6
6
  coveo-public-access-token={coveoPublicAccessToken}
7
7
  coveo-search-hub={coveoSearchHub}
8
8
  coveo-advanced-query-config={coveoAdvancedQueryConfig}
9
+ version={versionForCoveo}
9
10
  breadcrumbs={breadcrumbs}
10
11
  sidebar-header={sidebarHeader}
11
12
  sidebar-value={selectedSidebarValue}
@@ -34,6 +34,7 @@ export default class AmfReference extends LightningElement {
34
34
  @api sidebarHeader!: string;
35
35
  @api coveoOrganizationId!: string;
36
36
  @api coveoPublicAccessToken!: string;
37
+ @api coveoAdvancedQueryConfig!: string;
37
38
  @api coveoSearchHub!: string;
38
39
  @api useOldSidebar?: boolean = false;
39
40
  @api tocTitle?: string;
@@ -110,6 +111,7 @@ export default class AmfReference extends LightningElement {
110
111
  ) {
111
112
  this.showVersionBanner = true;
112
113
  }
114
+ this.setReferenceVersionForCoveo();
113
115
  }
114
116
 
115
117
  // This is to check if the url is hash based and redirect if needed
@@ -121,19 +123,17 @@ export default class AmfReference extends LightningElement {
121
123
  }
122
124
  }
123
125
 
124
- private get coveoAdvancedQueryConfig(config: string): string {
125
- try {
126
- const coveoAgConfig = JSON.parse(config);
127
- if(this.showVersionBanner) {
128
- coveoAgConfig.version = this.getSelectedVersion();
129
- } else {
130
- coveoAgConfig.version = "latest";
126
+ private setReferenceVersionForCoveo(): void {
127
+ let version = "latest";
128
+ const allVersions = this.getVersions();
129
+ if (allVersions.length > 1 && this.selectedVersion) {
130
+ const currentGAVersionRef = allVersions[0];
131
+ if (this.selectedVersion.id !== currentGAVersionRef.id) {
132
+ version = this.selectedVersion.id;
131
133
  }
132
-
133
- return JSON.stringify(coveoAgConfig);
134
- } catch (error) {
135
- console.log(`Error during version implementation.`)
136
134
  }
135
+ console.log("AMFReferences: " + version);
136
+ this.versionForCoveo = version;
137
137
  }
138
138
 
139
139
  @api
@@ -171,6 +171,7 @@ export default class AmfReference extends LightningElement {
171
171
  protected selectedSidebarValue = undefined;
172
172
 
173
173
  protected selectedVersion: ReferenceVersion | null = null;
174
+ protected versionForCoveo: string = "latest";
174
175
 
175
176
  private hasRendered = false;
176
177
 
@@ -53,7 +53,7 @@ export default class BreadcrumbItem extends LightningElement {
53
53
  private onLinkClick(event: Event): void {
54
54
  track(event.target!, "custEv_breadcrumbClick", {
55
55
  click_text: this.label,
56
- click_url: this.href,
56
+ click_url: `${window.location.origin}${this.href}`,
57
57
  element_type: "link",
58
58
  nav_type: "breadcrumb",
59
59
  nav_level: this.level ? this.level + 1 : 1,
@@ -62,7 +62,7 @@ export default class BreadcrumbItem extends LightningElement {
62
62
 
63
63
  track(event.target!, "custEv_linkClick", {
64
64
  click_text: this.label,
65
- click_url: this.href,
65
+ click_url: `${window.location.origin}${this.href}`,
66
66
  element_title: this.label,
67
67
  element_type: "link",
68
68
  content_category: "cta"
@@ -33,8 +33,19 @@ export default class ContentLayout extends LightningElement {
33
33
  @api coveoOrganizationId!: string;
34
34
  @api coveoPublicAccessToken!: string;
35
35
  @api coveoSearchHub!: string;
36
- @api coveoAdvancedQueryConfig!: string;
36
+
37
37
  @api useOldSidebar?: boolean = false;
38
+ @api
39
+ get version(): string {
40
+ return this._newVersion;
41
+ }
42
+
43
+ set version(val) {
44
+ if (val) {
45
+ this._newVersion = val;
46
+ }
47
+ console.log("Content Layout: " + this._newVersion);
48
+ }
38
49
 
39
50
  @api
40
51
  get breadcrumbs() {
@@ -70,13 +81,32 @@ export default class ContentLayout extends LightningElement {
70
81
  this.template.querySelector("dx-sidebar")?.setInputValue(searchTerm);
71
82
  }
72
83
 
84
+ @api
85
+ set coveoAdvancedQueryConfig(config) {
86
+ const coveoConfig = toJson(config);
87
+ if (this._newVersion !== "latest") {
88
+ coveoConfig.version = this._newVersion;
89
+ }
90
+ this._coveoAdvancedQueryConfig = coveoConfig;
91
+ }
92
+
93
+ get coveoAdvancedQueryConfig() {
94
+ console.log(
95
+ "AQ Content Layout: " +
96
+ JSON.stringify(this._coveoAdvancedQueryConfig)
97
+ );
98
+ return this._coveoAdvancedQueryConfig;
99
+ }
100
+
73
101
  @track
74
102
  private _sidebarContent: unknown;
75
103
 
76
104
  private _breadcrumbs = null;
105
+ protected _newVersion: string = "latest";
77
106
 
78
107
  @track
79
108
  private _tocOptions: Array<unknown>;
109
+ private _coveoAdvancedQueryConfig!: string;
80
110
 
81
111
  private tocOptionIdsSet = new Set();
82
112
  private anchoredElements: AnchorMap = {};
@@ -40,8 +40,8 @@ header:not(.has-brand) > .header_l2 {
40
40
  }
41
41
 
42
42
  .header_lang-dropdown {
43
- --button-primary-color: var(--dx-g-blue-vibrant-50);
44
- --button-primary-color-hover: var(--dx-g-blue-vibrant-40);
43
+ --button-primary-color: var(--dx-g-blue-vibrant-40);
44
+ --button-primary-color-hover: var(--dx-g-blue-vibrant-30);
45
45
  }
46
46
 
47
47
  .header_lang-dropdown > dx-button {
@@ -133,6 +133,7 @@ export default class Header extends HeaderBase {
133
133
  private onLangChange(event: CustomEvent<string>): void {
134
134
  const { detail } = event;
135
135
  this._language = detail;
136
+
136
137
  this.dispatchEvent(new CustomEvent("langchange", { detail }));
137
138
  }
138
139
 
@@ -16,6 +16,7 @@ import { SearchSyncer } from "docUtils/SearchSyncer";
16
16
  import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
17
17
  import { oldVersionDocInfo } from "docUtils/utils";
18
18
  import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
19
+ import { track as trackGTM } from "dxUtils/analytics";
19
20
 
20
21
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
21
22
  const handleContentError = (error): void => console.log(error);
@@ -364,6 +365,17 @@ export default class DocXmlContent extends LightningElementWithState<{
364
365
  ({ id }) => id === event.detail
365
366
  );
366
367
  this.pageReference.docId = this.language.url;
368
+
369
+ trackGTM(event.target!, "custEv_ctaLinkClick", {
370
+ click_text: event.detail,
371
+ element_title: "language selector",
372
+ click_url: `${window.location.origin}${this.pageReferenceToString(
373
+ this.pageReference
374
+ )}`,
375
+ element_type: "link",
376
+ content_category: "cta"
377
+ });
378
+
367
379
  this.updateUrl();
368
380
  this.fetchDocument();
369
381
  };