@salesforcedevs/docs-components 0.56.0 → 0.56.1
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": "0.56.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/lodash.orderby": "^4.6.7",
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "49fdd771cee3f6d50a27cd505ca2a612f1887493"
|
|
28
28
|
}
|
|
@@ -8,22 +8,18 @@ import {
|
|
|
8
8
|
DocumentData,
|
|
9
9
|
DocLanguage,
|
|
10
10
|
DocVersion,
|
|
11
|
-
Labels,
|
|
12
11
|
TreeNode
|
|
13
12
|
} from "./types";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"en-us": "language_english",
|
|
17
|
-
"ja-jp": "language_japanese"
|
|
18
|
-
};
|
|
13
|
+
import { Language } from "typings/custom";
|
|
14
|
+
import { getLanguageDisplayTextById } from "dxUtils/language";
|
|
19
15
|
|
|
20
16
|
export class FetchContent {
|
|
21
17
|
private apiDomain: string;
|
|
22
|
-
private
|
|
18
|
+
private languages: Array<Language> = [];
|
|
23
19
|
|
|
24
|
-
constructor(apiDomain: string,
|
|
20
|
+
constructor(apiDomain: string, languages: Array<Language>) {
|
|
25
21
|
this.apiDomain = apiDomain;
|
|
26
|
-
this.
|
|
22
|
+
this.languages = languages;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
async fetchDocumentData(docId: string): Promise<DocumentData | null> {
|
|
@@ -148,11 +144,10 @@ export class FetchContent {
|
|
|
148
144
|
}
|
|
149
145
|
|
|
150
146
|
private normalizeLanguage(language: ApiDocLanguage): DocLanguage {
|
|
151
|
-
|
|
147
|
+
|
|
152
148
|
return (
|
|
153
149
|
language && {
|
|
154
|
-
label:
|
|
155
|
-
(labelKey && this.labels && this.labels[labelKey]) ||
|
|
150
|
+
label: getLanguageDisplayTextById(this.languages, language.locale) ||
|
|
156
151
|
language.label,
|
|
157
152
|
id: language.locale,
|
|
158
153
|
code: language.code,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { api, track } from "lwc";
|
|
2
|
-
import { normalizeBoolean
|
|
2
|
+
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
3
3
|
import { FetchContent } from "./utils";
|
|
4
4
|
import {
|
|
5
5
|
CoveoAdvancedQueryXMLConfig,
|
|
6
6
|
DocLanguage,
|
|
7
7
|
DocVersion,
|
|
8
|
-
Labels,
|
|
9
8
|
TreeNode,
|
|
10
9
|
Header,
|
|
11
10
|
HistoryState,
|
|
@@ -13,6 +12,8 @@ import {
|
|
|
13
12
|
} from "./types";
|
|
14
13
|
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
15
14
|
import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
|
|
15
|
+
import { Language } from "typings/custom";
|
|
16
|
+
import { DEFAULT_LANGUAGES } from "dxUtils/constants";
|
|
16
17
|
|
|
17
18
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
18
19
|
const handleContentError = (error): void => console.log(error);
|
|
@@ -27,12 +28,14 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
27
28
|
@api coveoPublicAccessToken!: string;
|
|
28
29
|
|
|
29
30
|
@api
|
|
30
|
-
get
|
|
31
|
-
return this.
|
|
31
|
+
get allLanguages(): Array<Language> {
|
|
32
|
+
return this._allLanguages;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
set
|
|
35
|
-
|
|
35
|
+
set allLanguages(value: string) {
|
|
36
|
+
if (value) {
|
|
37
|
+
this._allLanguages = JSON.parse(value);
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
@api
|
|
@@ -44,7 +47,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
44
47
|
this._enableCoveo = normalizeBoolean(value);
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
private _labels: Labels = null;
|
|
48
50
|
private availableLanguages: Array<DocLanguage> = [];
|
|
49
51
|
private availableVersions: Array<DocVersion> = [];
|
|
50
52
|
private contentProvider: FetchContent;
|
|
@@ -98,6 +100,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
98
100
|
shouldStopPropagation: true,
|
|
99
101
|
target: window
|
|
100
102
|
});
|
|
103
|
+
private _allLanguages: Array<Language> = DEFAULT_LANGUAGES;
|
|
101
104
|
|
|
102
105
|
@track private pageReference: PageReference = {};
|
|
103
106
|
|
|
@@ -120,8 +123,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
120
123
|
window.location.href = "/docs";
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
this.contentProvider = new FetchContent(
|
|
127
|
+
this.apiDomain,
|
|
128
|
+
this.allLanguages
|
|
129
|
+
);
|
|
125
130
|
this.fetchDocument().then(() => (this.loaded = true));
|
|
126
131
|
window.addEventListener("popstate", this.handlePopState);
|
|
127
132
|
|