@salesforcedevs/docs-components 1.3.124-old-version-banner-7 → 1.3.126

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": "1.3.124-old-version-banner-7",
3
+ "version": "1.3.126",
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": "a2651830cfd3ed7af0373f7792acd852d903fe0b"
28
28
  }
@@ -4,21 +4,6 @@ doc-phase {
4
4
  );
5
5
  }
6
6
 
7
- /* We need to apply some borders when there are two doc phases */
8
- doc-phase:not(:only-child):first-child::part(container) {
9
- border-top: 1px solid #f9e3b6 !important;
10
- }
11
-
12
- doc-phase:nth-child(2)::part(container) {
13
- border-top: 1px solid #f9e3b6 !important;
14
- border-bottom: 1px solid #f9e3b6 !important;
15
- }
16
-
17
- /* We don't want second component to sticky as we need to handle different cases like position */
18
- doc-phase:nth-child(2) {
19
- position: static;
20
- }
21
-
22
7
  .api-documentation {
23
8
  margin-top: 48px;
24
9
  }
@@ -21,13 +21,6 @@
21
21
  if:true={docPhaseInfo}
22
22
  doc-phase-info={docPhaseInfo}
23
23
  ></doc-phase>
24
- <doc-phase
25
- slot="version-banner"
26
- if:true={oldVersionInfo}
27
- doc-phase-info={oldVersionInfo}
28
- dismissible="true"
29
- icon-name="warning"
30
- ></doc-phase>
31
24
  <div slot="sidebar-header" class="version-picker">
32
25
  <template if:true={isVersionEnabled}>
33
26
  <dx-dropdown
@@ -48,13 +48,6 @@ export default class AmfReference extends LightningElement {
48
48
  return !!this._referenceSetConfig?.versions?.length;
49
49
  }
50
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
-
58
51
  /**
59
52
  * Gives if the currently selected reference is spec based or not
60
53
  */
@@ -174,10 +167,12 @@ export default class AmfReference extends LightningElement {
174
167
  constructor() {
175
168
  super();
176
169
 
177
- this._boundOnApiNavigationChanged =
178
- this.onApiNavigationChanged.bind(this);
179
- this._boundUpdateSelectedItemFromUrlQuery =
180
- this.updateSelectedItemFromUrlQuery.bind(this);
170
+ this._boundOnApiNavigationChanged = this.onApiNavigationChanged.bind(
171
+ this
172
+ );
173
+ this._boundUpdateSelectedItemFromUrlQuery = this.updateSelectedItemFromUrlQuery.bind(
174
+ this
175
+ );
181
176
  }
182
177
 
183
178
  connectedCallback(): void {
@@ -233,8 +228,9 @@ export default class AmfReference extends LightningElement {
233
228
  const updatedReferenceId =
234
229
  oldReferenceIdNewReferenceIdMap[referenceId];
235
230
  const newReferenceId = updatedReferenceId || referenceId;
236
- const referenceItemConfig =
237
- this.getAmfConfigWithId(newReferenceId);
231
+ const referenceItemConfig = this.getAmfConfigWithId(
232
+ newReferenceId
233
+ );
238
234
  if (referenceItemConfig) {
239
235
  hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
240
236
  }
@@ -303,8 +299,9 @@ export default class AmfReference extends LightningElement {
303
299
  for (let i = 0; i < allVersions.length; i++) {
304
300
  const versionItem = allVersions[i];
305
301
  const referenceLink = versionItem.link.href;
306
- const referenceId =
307
- this.getReferenceIdFromUrl(referenceLink);
302
+ const referenceId = this.getReferenceIdFromUrl(
303
+ referenceLink
304
+ );
308
305
  if (this._currentReferenceId === referenceId) {
309
306
  // This is to navigate to respective topic in the changed version
310
307
  versionItem.link.href = `${referenceLink}/${currentRefMeta}`;
@@ -1229,10 +1226,12 @@ export default class AmfReference extends LightningElement {
1229
1226
  }
1230
1227
  if (!isRedirecting) {
1231
1228
  const currentReferenceUrl = window.location.href;
1232
- const referenceMeta =
1233
- this.getMarkdownReferenceMeta(currentReferenceUrl);
1234
- const selectedItemRefId =
1235
- this.getReferenceIdFromUrl(currentReferenceUrl);
1229
+ const referenceMeta = this.getMarkdownReferenceMeta(
1230
+ currentReferenceUrl
1231
+ );
1232
+ const selectedItemRefId = this.getReferenceIdFromUrl(
1233
+ currentReferenceUrl
1234
+ );
1236
1235
  const referenceDetails = this.getRefDetailsForGivenTopicMeta(
1237
1236
  selectedItemRefId,
1238
1237
  referenceMeta
@@ -1271,8 +1270,9 @@ export default class AmfReference extends LightningElement {
1271
1270
  const name = event.detail.name;
1272
1271
  if (name) {
1273
1272
  const urlReferenceId = this.getReferenceIdFromUrl(name);
1274
- const specBasedReference =
1275
- this.isSpecBasedReference(urlReferenceId);
1273
+ const specBasedReference = this.isSpecBasedReference(
1274
+ urlReferenceId
1275
+ );
1276
1276
  if (specBasedReference) {
1277
1277
  const metaVal = this.getMetaFromUrl(name);
1278
1278
  const currentSelectedMeta = this.selectedTopic
@@ -1322,8 +1322,9 @@ export default class AmfReference extends LightningElement {
1322
1322
  const currentReferenceId = this.getReferenceIdFromUrl(currentUrl);
1323
1323
  //No need to do anything if user is expanding currently selected reference
1324
1324
  if (referenceId !== currentReferenceId) {
1325
- const isSpecBasedReference =
1326
- this.isSpecBasedReference(referenceId);
1325
+ const isSpecBasedReference = this.isSpecBasedReference(
1326
+ referenceId
1327
+ );
1327
1328
  if (isSpecBasedReference) {
1328
1329
  // Perform functionality same as item selection
1329
1330
  this.onNavSelect(event);
@@ -1,4 +1,4 @@
1
- import { Json, DocPhaseInfo } from "typings/custom";
1
+ import { Json } from "typings/custom";
2
2
 
3
3
  export interface AmfTopicType {
4
4
  referenceId: string;
@@ -46,6 +46,14 @@ export interface AmfModelRecord {
46
46
  parsedModel: Json;
47
47
  }
48
48
 
49
+ export type DocPhase = "pilot" | "dev-preview" | "beta";
50
+
51
+ export type DocPhaseEntry = {
52
+ phase: DocPhase;
53
+ title: string;
54
+ body: string;
55
+ };
56
+
49
57
  export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
50
58
 
51
59
  /**
@@ -65,7 +73,7 @@ export interface ParsedMarkdownTopic {
65
73
  export interface AmfConfig {
66
74
  id: string;
67
75
  version?: string;
68
- docPhase?: DocPhaseInfo;
76
+ docPhase?: DocPhaseEntry;
69
77
  title: string;
70
78
  href: string;
71
79
  referenceType: ReferenceType;
@@ -28,7 +28,6 @@
28
28
  </template>
29
29
  <div class="content-body-doc-phase-container">
30
30
  <slot name="doc-phase"></slot>
31
- <slot name="version-banner"></slot>
32
31
  <div class="content-body-container">
33
32
  <div class="content-body">
34
33
  <doc-breadcrumbs
@@ -2,6 +2,7 @@
2
2
  <div class="container">
3
3
  <doc-phase
4
4
  if:true={docPhaseInfo}
5
+ max-width-size="large"
5
6
  doc-phase-info={docPhaseInfo}
6
7
  ></doc-phase>
7
8
 
@@ -23,6 +23,10 @@
23
23
  }
24
24
 
25
25
  .max-width-container {
26
+ max-width: var(--dx-g-doc-content-body-max-width);
27
+ }
28
+
29
+ .doc-phase-max-width-large .max-width-container {
26
30
  max-width: var(--dx-g-doc-content-max-width);
27
31
  }
28
32
 
@@ -64,11 +68,6 @@ dx-button {
64
68
  color: var(--dx-g-blue-vibrant-50);
65
69
  }
66
70
 
67
- .dismissible-icon {
68
- margin-left: auto;
69
- cursor: pointer;
70
- }
71
-
72
71
  /* Small Devices */
73
72
  @media screen and (max-width: 480px) {
74
73
  .doc-phase-container {
@@ -4,7 +4,7 @@
4
4
  <div class="doc-phase-title-container">
5
5
  <dx-icon
6
6
  class="doc-status-icon doc-phase-icon"
7
- symbol={iconName}
7
+ symbol="recipe"
8
8
  size="large"
9
9
  color="status-icon-color"
10
10
  ></dx-icon>
@@ -12,27 +12,18 @@
12
12
  {docPhaseTitle}
13
13
  </p>
14
14
  <dx-button
15
- if:false={dismissible}
16
15
  variant="inline"
17
- onclick={onShowHide}
16
+ onclick={onButtonClick}
18
17
  aria-label={hideBodyText}
19
18
  >
20
19
  {hideBodyText}
21
20
  </dx-button>
22
- <dx-icon
23
- if:true={dismissible}
24
- class="dismissible-icon"
25
- onclick={onDismiss}
26
- symbol="close"
27
- size="large"
28
- color="status-icon-color"
29
- ></dx-icon>
30
21
  </div>
31
22
  <!--
32
- NOTE: Here we are rendering mark up using lwc:dom & innerHTML
33
- option instead of slots because the html markup will come as a
34
- property to the component from a configuration
35
- -->
23
+ NOTE: Here we are rendering mark up using lwc:dom & innerHTML
24
+ option instead of slots because the html markup will come as a
25
+ property to the component from a configuration
26
+ -->
36
27
  <span lwc:dom="manual" class={bodyClassName}></span>
37
28
  </div>
38
29
  </div>
@@ -2,48 +2,27 @@ import { LightningElement, api } from "lwc";
2
2
  import cx from "classnames";
3
3
 
4
4
  import { DocPhaseInfo } from "typings/custom";
5
- import { toJson, normalizeBoolean } from "dxUtils/normalizers";
5
+ import { toJson } from "dxUtils/normalizers";
6
6
 
7
7
  export default class Phase extends LightningElement {
8
8
  _docPhaseInfo: DocPhaseInfo | null = null;
9
- _dismissible = false;
10
- _iconName = "recipe";
11
9
 
12
- @api
13
- get docPhaseInfo(): DocPhaseInfo | null {
14
- return this._docPhaseInfo;
15
- }
16
-
17
- set docPhaseInfo(value) {
18
- this._docPhaseInfo = toJson(value);
19
- }
10
+ isBodyHidden = false;
20
11
 
21
12
  @api
22
- get dismissible(): boolean {
23
- return this._dismissible;
24
- }
13
+ maxWidthSize: "small" | "large" = "small";
25
14
 
26
- set dismissible(value) {
27
- if (value) {
28
- this._dismissible = normalizeBoolean(value);
29
- }
15
+ get docPhaseTitle() {
16
+ return this.docPhaseInfo?.title;
30
17
  }
31
18
 
32
19
  @api
33
- get iconName(): string {
34
- return this._iconName;
35
- }
36
-
37
- set iconName(value) {
38
- if (value) {
39
- this._iconName = value;
40
- }
20
+ get docPhaseInfo(): DocPhaseInfo | null {
21
+ return this._docPhaseInfo;
41
22
  }
42
23
 
43
- isBodyHidden = false;
44
-
45
- get docPhaseTitle() {
46
- return this.docPhaseInfo?.title;
24
+ set docPhaseInfo(value) {
25
+ this._docPhaseInfo = toJson(value);
47
26
  }
48
27
 
49
28
  get hideBodyText() {
@@ -54,7 +33,8 @@ export default class Phase extends LightningElement {
54
33
  return cx(
55
34
  "doc-status-base",
56
35
  "doc-status-container",
57
- "doc-phase-container"
36
+ "doc-phase-container",
37
+ `doc-phase-max-width-${this.maxWidthSize}`
58
38
  );
59
39
  }
60
40
 
@@ -75,19 +55,7 @@ export default class Phase extends LightningElement {
75
55
  }
76
56
  }
77
57
 
78
- onShowHide() {
58
+ onButtonClick() {
79
59
  this.isBodyHidden = !this.isBodyHidden;
80
60
  }
81
-
82
- onDismiss() {
83
- this.dispatchEvent(
84
- new CustomEvent("dismissphase", {
85
- detail: {
86
- docPhaseInfo: this.docPhaseInfo
87
- },
88
- composed: true,
89
- bubbles: true
90
- })
91
- );
92
- }
93
61
  }
@@ -35,9 +35,6 @@ type DropdownOption = {
35
35
  export type DocVersion = DropdownOption & {
36
36
  releaseVersion: string;
37
37
  url: string;
38
- link?: {
39
- href: string;
40
- };
41
38
  };
42
39
 
43
40
  export type DocLanguage = DropdownOption & {
@@ -44,9 +44,3 @@ 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
- }
@@ -11,14 +11,6 @@
11
11
  onselect={handleSelect}
12
12
  use-old-sidebar={useOldSidebar}
13
13
  >
14
- <doc-phase
15
- slot="version-banner"
16
- if:true={showVersionBanner}
17
- doc-phase-info={oldVersionInfo}
18
- icon-name="warning"
19
- dismissible="true"
20
- ondismissphase={handleDismissVersionBanner}
21
- ></doc-phase>
22
14
  <div slot="sidebar-header" class="document-pickers">
23
15
  <dx-dropdown
24
16
  data-type="version"
@@ -14,8 +14,7 @@ import {
14
14
  } from "./types";
15
15
  import { SearchSyncer } from "docUtils/SearchSyncer";
16
16
  import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
17
- import { oldVersionDocInfo } from "docUtils/utils";
18
- import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
17
+ import { Breadcrumb, Language } from "typings/custom";
19
18
 
20
19
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
21
20
  const handleContentError = (error): void => console.log(error);
@@ -109,33 +108,6 @@ export default class DocXmlContent extends LightningElementWithState<{
109
108
  });
110
109
  private _allLanguages: Array<Language> = [];
111
110
 
112
- private get oldVersionInfo(): DocPhaseInfo | null {
113
- let info = null;
114
- if (!this.disableVersion) {
115
- const currentGAVersion = this.versionOptions.find(
116
- (version) => !version.url.includes(version.id)
117
- );
118
- if (currentGAVersion?.link?.href && this.version?.id) {
119
- const versionNo = currentGAVersion.id;
120
- /**
121
- * Need to show old version doc banner only if the version is less than the current ga version
122
- * We should not show it to the preview version whose version is more than ga
123
- **/
124
- try {
125
- if (parseFloat(this.version.id) < parseFloat(versionNo)) {
126
- info = oldVersionDocInfo(currentGAVersion.link.href);
127
- }
128
- } catch (exception) {
129
- /* Ideally this use case should not happen, but just added to not to break the page*/
130
- console.warn(exception);
131
- }
132
- }
133
- }
134
- return info;
135
- }
136
-
137
- @track showVersionBanner = false;
138
-
139
111
  @track private pageReference: PageReference = {};
140
112
  @track breadcrumbs: Array<Breadcrumb> = [];
141
113
 
@@ -342,10 +314,6 @@ export default class DocXmlContent extends LightningElementWithState<{
342
314
  private handlePopState = (event: PopStateEvent): void =>
343
315
  this.updatePageReference(this.getReferenceFromUrl(), event);
344
316
 
345
- handleDismissVersionBanner() {
346
- this.showVersionBanner = false;
347
- }
348
-
349
317
  handleSelect(event: CustomEvent<{ name: string }>): void {
350
318
  event.stopPropagation();
351
319
  const { name } = event.detail;
@@ -477,10 +445,6 @@ export default class DocXmlContent extends LightningElementWithState<{
477
445
  this.updateUrl(HistoryState.REPLACE_STATE);
478
446
  }
479
447
 
480
- if (this.oldVersionInfo) {
481
- this.showVersionBanner = true;
482
- }
483
-
484
448
  if (
485
449
  this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
486
450
  data.id
@@ -1,7 +0,0 @@
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
- };