@salesforcedevs/docs-components 0.55.3-docs-locales2 → 0.55.4

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/LICENSE ADDED
@@ -0,0 +1,12 @@
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.55.3-docs-locales2",
3
+ "version": "0.55.4",
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": "4629fdd9ca18a13480044ad43515b91945d16aad"
27
+ "gitHead": "445324f9e54fc1169769990ac3e5315f133a1ca0"
28
28
  }
@@ -21,6 +21,12 @@ export enum HistoryState {
21
21
  REPLACE_STATE = "replaceState"
22
22
  }
23
23
 
24
+ export type Labels = {
25
+ language_english: string;
26
+ language_japanese: string;
27
+ toc_title: string;
28
+ };
29
+
24
30
  export type TreeNode = {
25
31
  label: string;
26
32
  name: string;
@@ -8,18 +8,22 @@ import {
8
8
  DocumentData,
9
9
  DocLanguage,
10
10
  DocVersion,
11
+ Labels,
11
12
  TreeNode
12
13
  } from "./types";
13
- import { Language } from "typings/custom";
14
- import { getLanguageDisplayTextById } from "dxUtils/language";
14
+
15
+ const LOCALE_TO_LABEL = {
16
+ "en-us": "language_english",
17
+ "ja-jp": "language_japanese"
18
+ };
15
19
 
16
20
  export class FetchContent {
17
21
  private apiDomain: string;
18
- private languages: Array<Language> = [];
22
+ private labels: Labels;
19
23
 
20
- constructor(apiDomain: string, languages: Array<Language>) {
24
+ constructor(apiDomain: string, labels: Labels) {
21
25
  this.apiDomain = apiDomain;
22
- this.languages = languages;
26
+ this.labels = labels;
23
27
  }
24
28
 
25
29
  async fetchDocumentData(docId: string): Promise<DocumentData | null> {
@@ -144,10 +148,11 @@ export class FetchContent {
144
148
  }
145
149
 
146
150
  private normalizeLanguage(language: ApiDocLanguage): DocLanguage {
147
-
151
+ const labelKey = language.locale && LOCALE_TO_LABEL[language.locale];
148
152
  return (
149
153
  language && {
150
- label: getLanguageDisplayTextById(this.languages, language.locale) ||
154
+ label:
155
+ (labelKey && this.labels && this.labels[labelKey]) ||
151
156
  language.label,
152
157
  id: language.locale,
153
158
  code: language.code,
@@ -9,7 +9,7 @@
9
9
  sidebar-content={sidebarContent}
10
10
  sidebar-value={sidebarValue}
11
11
  onselect={handleSelect}
12
- use-old-sidebar
12
+ use-old-sidebar={useOldSidebar}
13
13
  >
14
14
  <div slot="sidebar-header" class="document-pickers">
15
15
  <dx-dropdown
@@ -1,9 +1,11 @@
1
1
  import { api, track } from "lwc";
2
+ import { toJson } from "dxUtils/normalizers";
2
3
  import { FetchContent } from "./utils";
3
4
  import {
4
5
  CoveoAdvancedQueryXMLConfig,
5
6
  DocLanguage,
6
7
  DocVersion,
8
+ Labels,
7
9
  TreeNode,
8
10
  Header,
9
11
  HistoryState,
@@ -11,8 +13,6 @@ import {
11
13
  } from "./types";
12
14
  import { SearchSyncer } from "docUtils/SearchSyncer";
13
15
  import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
14
- import { Language } from "typings/custom";
15
- import { DEFAULT_LANGUAGES } from "dxUtils/constants";
16
16
 
17
17
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
18
18
  const handleContentError = (error): void => console.log(error);
@@ -27,16 +27,15 @@ export default class DocXmlContent extends LightningElementWithState<{
27
27
  @api coveoPublicAccessToken!: string;
28
28
 
29
29
  @api
30
- get allLanguages(): Array<Language> {
31
- return this._allLanguages;
30
+ get labels() {
31
+ return this._labels;
32
32
  }
33
33
 
34
- set allLanguages(value: string) {
35
- if (value) {
36
- this._allLanguages = JSON.parse(value);
37
- }
34
+ set labels(value) {
35
+ this._labels = toJson(value);
38
36
  }
39
37
 
38
+ private _labels: Labels = null;
40
39
  private availableLanguages: Array<DocLanguage> = [];
41
40
  private availableVersions: Array<DocVersion> = [];
42
41
  private contentProvider: FetchContent;
@@ -88,7 +87,6 @@ export default class DocXmlContent extends LightningElementWithState<{
88
87
  shouldStopPropagation: true,
89
88
  target: window
90
89
  });
91
- private _allLanguages: Array<Language> = DEFAULT_LANGUAGES;
92
90
 
93
91
  @track private pageReference: PageReference = {};
94
92
 
@@ -111,10 +109,8 @@ export default class DocXmlContent extends LightningElementWithState<{
111
109
  window.location.href = "/docs";
112
110
  return;
113
111
  }
114
- this.contentProvider = new FetchContent(
115
- this.apiDomain,
116
- this.allLanguages
117
- );
112
+
113
+ this.contentProvider = new FetchContent(this.apiDomain, this._labels);
118
114
  this.fetchDocument().then(() => (this.loaded = true));
119
115
  window.addEventListener("popstate", this.handlePopState);
120
116
 
@@ -184,6 +180,16 @@ export default class DocXmlContent extends LightningElementWithState<{
184
180
  return this.pageReference.deliverable;
185
181
  }
186
182
 
183
+ private get useOldSidebar(): boolean {
184
+ // Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
185
+ // TODO: we need a better fix for version number check.
186
+ return !(
187
+ process.env.COVEO_ORGANIZATION_ID &&
188
+ process.env.COVEO_PUBLIC_ACCESS_TOKEN &&
189
+ parseInt(this.version.releaseVersion.replace("v", ""), 10) > 51
190
+ );
191
+ }
192
+
187
193
  private get coveoAdvancedQueryConfig(): CoveoAdvancedQueryXMLConfig {
188
194
  return {
189
195
  // Temporary fix for empty results on apexref page