@salesforcedevs/docs-components 0.55.6 → 0.55.9-docs-more-locales-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.55.6",
3
+ "version": "0.55.9-docs-more-locales-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": "1282a111935db22cc38409dd247f72cba86fa131"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -19,12 +19,6 @@ export enum HistoryState {
19
19
  REPLACE_STATE = "replaceState"
20
20
  }
21
21
 
22
- export type Labels = {
23
- language_english: string;
24
- language_japanese: string;
25
- toc_title: string;
26
- };
27
-
28
22
  export type TreeNode = {
29
23
  label: string;
30
24
  name: string;
@@ -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
- const LOCALE_TO_LABEL = {
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 labels: Labels;
18
+ private languages: Array<Language> = [];
23
19
 
24
- constructor(apiDomain: string, labels: Labels) {
20
+ constructor(apiDomain: string, languages: Array<Language>) {
25
21
  this.apiDomain = apiDomain;
26
- this.labels = labels;
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
- const labelKey = language.locale && LOCALE_TO_LABEL[language.locale];
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 { toJson } from "dxUtils/normalizers";
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,15 +28,25 @@ export default class DocXmlContent extends LightningElementWithState<{
27
28
  @api coveoPublicAccessToken!: string;
28
29
 
29
30
  @api
30
- get labels() {
31
- return this._labels;
31
+ get allLanguages(): Array<Language> {
32
+ return this._allLanguages;
32
33
  }
33
34
 
34
- set labels(value) {
35
- this._labels = toJson(value);
35
+ set allLanguages(value: string) {
36
+ if (value) {
37
+ this._allLanguages = JSON.parse(value);
38
+ }
39
+ }
40
+
41
+ @api
42
+ get enableCoveo() {
43
+ return this._enableCoveo;
44
+ }
45
+
46
+ set enableCoveo(value) {
47
+ this._enableCoveo = normalizeBoolean(value);
36
48
  }
37
49
 
38
- private _labels: Labels = null;
39
50
  private availableLanguages: Array<DocLanguage> = [];
40
51
  private availableVersions: Array<DocVersion> = [];
41
52
  private contentProvider: FetchContent;
@@ -51,6 +62,8 @@ export default class DocXmlContent extends LightningElementWithState<{
51
62
  private _pathName = "";
52
63
  private _pageHeader?: Header;
53
64
  private listenerAttached = false;
65
+ private _enableCoveo?: boolean = false;
66
+
54
67
  private searchSyncer = new SearchSyncer({
55
68
  callbacks: {
56
69
  onSearchChange: (nextSearchString: string): void => {
@@ -87,6 +100,7 @@ export default class DocXmlContent extends LightningElementWithState<{
87
100
  shouldStopPropagation: true,
88
101
  target: window
89
102
  });
103
+ private _allLanguages: Array<Language> = DEFAULT_LANGUAGES;
90
104
 
91
105
  @track private pageReference: PageReference = {};
92
106
 
@@ -109,8 +123,10 @@ export default class DocXmlContent extends LightningElementWithState<{
109
123
  window.location.href = "/docs";
110
124
  return;
111
125
  }
112
-
113
- this.contentProvider = new FetchContent(this.apiDomain, this._labels);
126
+ this.contentProvider = new FetchContent(
127
+ this.apiDomain,
128
+ this.allLanguages
129
+ );
114
130
  this.fetchDocument().then(() => (this.loaded = true));
115
131
  window.addEventListener("popstate", this.handlePopState);
116
132
 
@@ -184,12 +200,15 @@ export default class DocXmlContent extends LightningElementWithState<{
184
200
  // Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
185
201
  // TODO: we need a better fix for version number check
186
202
  return !(
187
- process.env.COVEO_ORGANIZATION_ID &&
188
- process.env.COVEO_PUBLIC_ACCESS_TOKEN &&
203
+ this.enableCoveo &&
204
+ this.coveoOrganizationId &&
205
+ this.coveoPublicAccessToken &&
189
206
  (!this.version?.releaseVersion ||
190
207
  (this.version?.releaseVersion &&
191
- parseInt(this.version.releaseVersion.replace("v", ""), 10) >
192
- 51))
208
+ parseInt(
209
+ this.version.releaseVersion.replace("v", ""),
210
+ 10
211
+ ) >= 53))
193
212
  );
194
213
  }
195
214
 
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.