@salesforcedevs/docs-components 1.29.0-alpha1 → 1.29.0-docspec-alpha

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.
Files changed (25) hide show
  1. package/lwc.config.json +3 -1
  2. package/package.json +3 -3
  3. package/src/modules/doc/amfReference/amfReference.ts +52 -10
  4. package/src/modules/doc/amfReference/types.ts +5 -0
  5. package/src/modules/doc/banner/banner.css +88 -0
  6. package/src/modules/doc/banner/banner.html +47 -0
  7. package/src/modules/doc/banner/banner.ts +73 -0
  8. package/src/modules/doc/contentLayout/contentLayout.html +1 -1
  9. package/src/modules/doc/contentLayout/contentLayout.ts +42 -0
  10. package/src/modules/doc/header/header.html +0 -1
  11. package/src/modules/doc/localeBanner/localeBanner.css +3 -0
  12. package/src/modules/doc/localeBanner/localeBanner.html +9 -0
  13. package/src/modules/doc/localeBanner/localeBanner.ts +195 -0
  14. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +5 -2
  15. package/src/modules/doc/redocReference/redocReference.ts +183 -121
  16. package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.css +19 -0
  17. package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.html +26 -0
  18. package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.ts +85 -0
  19. package/src/modules/doc/xmlContent/xmlContent.html +1 -1
  20. package/src/modules/doc/xmlContent/xmlContent.ts +28 -1
  21. package/src/modules/doc/apiPlayground/apiPlayground.css +0 -186
  22. package/src/modules/doc/apiPlayground/apiPlayground.html +0 -136
  23. package/src/modules/doc/apiPlayground/apiPlayground.ts +0 -240
  24. package/src/modules/docUtils/apiRequestExecutor/apiRequestExecutor.ts +0 -96
  25. package/src/modules/docUtils/openApiParser/openApiParser.ts +0 -187
@@ -41,7 +41,7 @@
41
41
  ></path>
42
42
  </g>
43
43
  </svg>
44
- {readingTime} minute read
44
+ {readingTimeLabel}
45
45
  </div>
46
46
  <slot onslotchange={onSlotChange}></slot>
47
47
  <doc-sprig-survey
@@ -57,7 +57,10 @@
57
57
  </div>
58
58
  </div>
59
59
  <div lwc:if={showFooter} class="footer-container">
60
- <dx-footer variant="no-signup" mfe-config-origin={effectiveFooterOrigin}></dx-footer>
60
+ <dx-footer
61
+ variant="no-signup"
62
+ mfe-config-origin={effectiveFooterOrigin}
63
+ ></dx-footer>
61
64
  </div>
62
65
  </div>
63
66
  </div>
@@ -2,12 +2,11 @@
2
2
  import { createElement, LightningElement, api } from "lwc";
3
3
  import DocPhase from "doc/phase";
4
4
  import DxFooter from "dx/footer";
5
+ import DxIcon from "dx/icon";
5
6
  import SprigSurvey from "doc/sprigSurvey";
6
- import ApiPlayground from "doc/apiPlayground";
7
7
  import { throttle } from "throttle-debounce";
8
8
  import { pollUntil } from "dxUtils/async";
9
- import { parseOpenApiSpec } from "docUtils/openApiParser";
10
- import type { OperationDefinition } from "docUtils/openApiParser";
9
+ import { normalizeBoolean } from "dxUtils/normalizers";
11
10
 
12
11
  declare global {
13
12
  interface Window {
@@ -17,11 +16,19 @@ declare global {
17
16
 
18
17
  declare const Sprig: (eventType: string, eventName: string) => void;
19
18
 
19
+ type ReferenceTopic = {
20
+ link?: { href?: string };
21
+ children?: ReferenceTopic[];
22
+ };
23
+
20
24
  type ReferenceItem = {
21
25
  source: string;
22
26
  href: string;
27
+ title?: string;
23
28
  isSelected?: boolean;
24
29
  docPhase?: string | null;
30
+ referenceType?: string;
31
+ topic?: ReferenceTopic;
25
32
  };
26
33
 
27
34
  type ReferenceConfig = {
@@ -31,6 +38,7 @@ type ReferenceConfig = {
31
38
  const SCROLL_THROTTLE_DELAY = 50;
32
39
  const ELEMENT_TIMEOUT = 10000;
33
40
  const ELEMENT_CHECK_INTERVAL = 100;
41
+ const REFERENCES_SEGMENT = "/references/";
34
42
 
35
43
  export default class RedocReference extends LightningElement {
36
44
  private _referenceConfig: ReferenceConfig = { refList: [] };
@@ -41,11 +49,13 @@ export default class RedocReference extends LightningElement {
41
49
  private docPhaseWrapperElement: Element | null = null;
42
50
  private lastSidebarTop = 0;
43
51
 
44
- showError = false;
52
+ /**
53
+ * History length captured at mount (pre-Redoc), used by `onBackClick` to
54
+ * distinguish in-tab navigation (> 1) from a fresh entry (=== 1).
55
+ */
56
+ private initialHistoryLength = 0;
45
57
 
46
- private parsedOperations: OperationDefinition[] = [];
47
- private openApiSpec: any = null;
48
- private playgroundInstances: Map<string, HTMLElement> = new Map();
58
+ showError = false;
49
59
 
50
60
  @api
51
61
  get referenceConfig(): ReferenceConfig {
@@ -78,6 +88,100 @@ export default class RedocReference extends LightningElement {
78
88
  /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer. */
79
89
  @api origin: string | null = null;
80
90
 
91
+ /**
92
+ * Project title (same value passed to `<doc-header>` as `subtitle`). Used
93
+ * inside the Redoc-rendered UI to label the parent project.
94
+ */
95
+ @api projectTitle: string | null = "All Reference";
96
+
97
+ /**
98
+ * Href to navigate to when the back link is clicked AND there is no
99
+ * usable referrer (e.g. the user opened the page directly in a fresh
100
+ * tab).
101
+ */
102
+ @api headerHref: string | null = null;
103
+
104
+ @api
105
+ get docContentType(): boolean {
106
+ return this._docContentType;
107
+ }
108
+ set docContentType(value: boolean | string) {
109
+ this._docContentType = normalizeBoolean(value);
110
+ }
111
+ private _docContentType = false;
112
+
113
+ get specTitle(): string | null {
114
+ return this.getSelectedReference()?.title ?? null;
115
+ }
116
+
117
+ /**
118
+ * Whether to show the project header. Shown for multi-spec reference
119
+ * sets, and for any docs-content spec topic so it always has a back
120
+ * link.
121
+ */
122
+ get showRedocHeader(): boolean {
123
+ const refCount = this._referenceConfig?.refList?.length ?? 0;
124
+ const isMultiSpecSet = refCount > 1;
125
+ return (
126
+ (isMultiSpecSet || this._docContentType) &&
127
+ !!(this.projectTitle || this.specTitle)
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Navigates back to reference doc.
133
+ */
134
+ private onBackClick = (event: Event): void => {
135
+ event.preventDefault();
136
+ const referrerHref = this.getSameOriginReferrerHref();
137
+ if (referrerHref) {
138
+ window.location.href = referrerHref;
139
+ return;
140
+ }
141
+ if (this._docContentType && this.headerHref) {
142
+ window.location.href = this.headerHref;
143
+ return;
144
+ }
145
+ const fallbackHref = this.getReferencesRootHref();
146
+ if (fallbackHref) {
147
+ window.location.href = fallbackHref;
148
+ }
149
+ };
150
+
151
+ /**
152
+ * Returns the referrer URL when the page was reached via in-tab navigation
153
+ * from a same-origin page; otherwise `null`. Both `initialHistoryLength`
154
+ * and `document.referrer` are checked since neither signal is reliable on
155
+ * its own.
156
+ */
157
+ private getSameOriginReferrerHref(): string | null {
158
+ if (this.initialHistoryLength <= 1 || !document.referrer) {
159
+ return null;
160
+ }
161
+ try {
162
+ const referrerUrl = new URL(document.referrer);
163
+ if (referrerUrl.origin !== window.location.origin) {
164
+ return null;
165
+ }
166
+ return referrerUrl.href;
167
+ } catch {
168
+ return null;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Derives the project's `.../references` root from the current URL by
174
+ * trimming any trailing reference id (and deeper segments). Returns null
175
+ * when the URL doesn't contain a `/references` segment.
176
+ */
177
+ private getReferencesRootHref(): string | null {
178
+ const { pathname } = window.location;
179
+ const idx = pathname.lastIndexOf(REFERENCES_SEGMENT);
180
+ return idx === -1
181
+ ? null
182
+ : pathname.slice(0, idx + REFERENCES_SEGMENT.length);
183
+ }
184
+
81
185
  /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
82
186
  get effectiveFooterOrigin(): string {
83
187
  return (
@@ -86,6 +190,10 @@ export default class RedocReference extends LightningElement {
86
190
  }
87
191
 
88
192
  connectedCallback(): void {
193
+ // Snapshot history length before Redoc pushes its own hash entries,
194
+ // so it reflects real in-tab navigation rather than Redoc's churn.
195
+ this.initialHistoryLength = window.history.length;
196
+
89
197
  window.addEventListener("scroll", this.handleScrollAndResize);
90
198
  window.addEventListener("resize", this.handleScrollAndResize);
91
199
  }
@@ -106,7 +214,6 @@ export default class RedocReference extends LightningElement {
106
214
  // Clean up cached DOM element references to prevent memory leaks
107
215
  this.docHeaderElement = null;
108
216
  this.docPhaseWrapperElement = null;
109
- this.playgroundInstances.clear();
110
217
  }
111
218
 
112
219
  // Displays error UI and logs error message for debugging
@@ -220,7 +327,8 @@ export default class RedocReference extends LightningElement {
220
327
  const currentUrl = window.location;
221
328
  const existingParams = currentUrl.search + currentUrl.hash;
222
329
 
223
- window.history.pushState(
330
+ // Use replaceState to avoid creating a new history entry when the user visits /references without any reference ID
331
+ window.history.replaceState(
224
332
  {},
225
333
  "",
226
334
  `${parentReferencePath}${existingParams}`
@@ -254,8 +362,6 @@ export default class RedocReference extends LightningElement {
254
362
  return;
255
363
  }
256
364
 
257
- this.fetchAndParseSpec(specUrl);
258
-
259
365
  window.Redoc.init(
260
366
  specUrl,
261
367
  {
@@ -313,10 +419,12 @@ export default class RedocReference extends LightningElement {
313
419
 
314
420
  this.appendFooterItems(apiContentDiv);
315
421
 
422
+ // Inject the multi-spec project header into Redoc's left menu only.
423
+ this.insertProjectHeaderInMenu(redocContainer);
424
+
316
425
  // Wait for footer to be rendered before updating styles
317
426
  requestAnimationFrame(() => {
318
427
  this.updateRedocThirdColumnStyle(redocContainer);
319
- this.injectTryItButtons();
320
428
 
321
429
  // Fix initial hash scroll after doc phase insertion
322
430
  this.handleInitialHashScrollFix();
@@ -326,6 +434,65 @@ export default class RedocReference extends LightningElement {
326
434
  }
327
435
  }
328
436
 
437
+ /**
438
+ * Inserts the project header into Redoc for multi-spec reference sets.
439
+ */
440
+ private insertProjectHeaderInMenu(redocContainer: HTMLElement): void {
441
+ if (!this.showRedocHeader) {
442
+ return;
443
+ }
444
+
445
+ // Select the LNB and content area of Redoc and insert the requried header.
446
+ redocContainer
447
+ .querySelectorAll<HTMLElement>(".menu-content, .api-content")
448
+ .forEach((target) => {
449
+ target.insertBefore(
450
+ this.buildProjectHeaderDom(),
451
+ target.firstChild
452
+ );
453
+ });
454
+ }
455
+
456
+ /**
457
+ * Builds a fresh project-title/spec-title header DOM node.
458
+ */
459
+ private buildProjectHeaderDom(): HTMLElement {
460
+ const wrapper = document.createElement("div");
461
+ wrapper.className = "redoc-project-header";
462
+
463
+ if (this.projectTitle) {
464
+ const backLink = document.createElement("a");
465
+ backLink.className = "redoc-project-back";
466
+ backLink.href = "#";
467
+ backLink.addEventListener("click", this.onBackClick);
468
+
469
+ const icon = createElement("dx-icon", { is: DxIcon });
470
+ Object.assign(icon, {
471
+ sprite: "utility",
472
+ symbol: "back",
473
+ size: "medium"
474
+ });
475
+ icon.classList.add("redoc-project-back-arrow");
476
+
477
+ const label = document.createElement("span");
478
+ label.className = "redoc-project-title";
479
+ label.textContent = this.projectTitle;
480
+
481
+ backLink.appendChild(icon);
482
+ backLink.appendChild(label);
483
+ wrapper.appendChild(backLink);
484
+ }
485
+
486
+ if (this.specTitle) {
487
+ const specEl = document.createElement("h2");
488
+ specEl.className = "redoc-spec-title dx-text-display-7";
489
+ specEl.textContent = this.specTitle;
490
+ wrapper.appendChild(specEl);
491
+ }
492
+
493
+ return wrapper;
494
+ }
495
+
329
496
  // Waits for Redoc's API content element to be rendered
330
497
  private async waitForApiContent(
331
498
  container: HTMLElement
@@ -359,7 +526,10 @@ export default class RedocReference extends LightningElement {
359
526
  // Appends footer component to container
360
527
  private insertFooter(container: HTMLElement): void {
361
528
  const footerElement = createElement("dx-footer", { is: DxFooter });
362
- Object.assign(footerElement, { variant: "no-signup", mfeConfigOrigin: this.effectiveFooterOrigin });
529
+ Object.assign(footerElement, {
530
+ variant: "no-signup",
531
+ mfeConfigOrigin: this.effectiveFooterOrigin
532
+ });
363
533
  container.appendChild(footerElement);
364
534
  }
365
535
 
@@ -421,114 +591,6 @@ export default class RedocReference extends LightningElement {
421
591
  );
422
592
  }
423
593
 
424
- // Fetches and parses the OpenAPI spec for Try It playground
425
- private async fetchAndParseSpec(specUrl: string): Promise<void> {
426
- try {
427
- const response = await fetch(specUrl);
428
- if (!response.ok) {
429
- return;
430
- }
431
- this.openApiSpec = await response.json();
432
- this.parsedOperations = parseOpenApiSpec(this.openApiSpec);
433
- } catch {
434
- // Non-fatal: playground simply won't be available
435
- }
436
- }
437
-
438
- // Injects "Try It" toggle buttons into Redoc operation sections
439
- private injectTryItButtons(): void {
440
- if (this.parsedOperations.length === 0) {
441
- return;
442
- }
443
-
444
- const redocContainer = this.getRedocContainer();
445
- if (!redocContainer) {
446
- return;
447
- }
448
-
449
- for (const operation of this.parsedOperations) {
450
- const sectionId = `operation/${operation.operationId}`;
451
- const section = redocContainer.querySelector(
452
- `[data-section-id="${sectionId}"]`
453
- );
454
- if (!section) {
455
- continue;
456
- }
457
-
458
- // Skip if button already injected
459
- if (section.querySelector(".try-it-toggle")) {
460
- continue;
461
- }
462
-
463
- const button = document.createElement("button");
464
- button.className = "try-it-toggle";
465
- button.textContent = "Try It";
466
- button.setAttribute("type", "button");
467
- button.setAttribute("aria-expanded", "false");
468
- button.style.cssText =
469
- "display:inline-flex;align-items:center;gap:4px;padding:4px 12px;" +
470
- "border:1px solid #0070d2;border-radius:4px;background:#fff;color:#0070d2;" +
471
- "font-size:12px;font-weight:600;cursor:pointer;margin-left:12px;vertical-align:middle;";
472
- button.addEventListener("click", () => {
473
- this.togglePlayground(operation, section as HTMLElement);
474
- });
475
-
476
- // Insert button after the first heading or at the start
477
- const heading = section.querySelector("h1, h2, h3");
478
- if (heading?.parentElement) {
479
- heading.parentElement.insertBefore(
480
- button,
481
- heading.nextSibling
482
- );
483
- } else {
484
- section.insertBefore(button, section.firstChild);
485
- }
486
- }
487
- }
488
-
489
- // Toggles the playground panel for an operation section
490
- private togglePlayground(
491
- operation: OperationDefinition,
492
- section: HTMLElement
493
- ): void {
494
- const operationId = operation.operationId;
495
- const existingWrapper = this.playgroundInstances.get(operationId);
496
-
497
- if (existingWrapper) {
498
- const isHidden = existingWrapper.style.display === "none";
499
- existingWrapper.style.display = isHidden ? "block" : "none";
500
-
501
- const button = section.querySelector(".try-it-toggle");
502
- if (button) {
503
- button.setAttribute(
504
- "aria-expanded",
505
- isHidden ? "true" : "false"
506
- );
507
- }
508
- return;
509
- }
510
-
511
- const wrapper = document.createElement("div");
512
- wrapper.className = "try-it-playground-wrapper";
513
-
514
- const playgroundElement = createElement("doc-api-playground", {
515
- is: ApiPlayground
516
- });
517
- Object.assign(playgroundElement, {
518
- operation,
519
- spec: this.openApiSpec
520
- });
521
-
522
- wrapper.appendChild(playgroundElement);
523
- section.appendChild(wrapper);
524
- this.playgroundInstances.set(operationId, wrapper);
525
-
526
- const button = section.querySelector(".try-it-toggle");
527
- if (button) {
528
- button.setAttribute("aria-expanded", "true");
529
- }
530
- }
531
-
532
594
  // Fixes initial hash scroll positioning after doc phase insertion
533
595
  private handleInitialHashScrollFix(): void {
534
596
  const hash = window.location.hash;
@@ -0,0 +1,19 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .content-type-docs doc-phase {
6
+ --doc-c-phase-top: calc(
7
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
8
+ var(--dx-g-spacing-xl)
9
+ );
10
+ }
11
+
12
+ @media screen and (max-width: 768px) {
13
+ .content-type-docs doc-phase {
14
+ --doc-c-phase-top: calc(
15
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
16
+ 40px
17
+ );
18
+ }
19
+ }
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <doc-content-layout
3
+ class="content-type content-type-markdown content-type-docs"
4
+ breadcrumbs={breadcrumbs}
5
+ share-title={shareTitle}
6
+ share-twitter-via={twitterVia}
7
+ sidebar-header={sidebarHeader}
8
+ sidebar-value={sidebarValue}
9
+ sidebar-content={sidebarContent}
10
+ toc-title={tocTitle}
11
+ toc-options={tocOptions}
12
+ toc-aria-level={tocAriaLevel}
13
+ enable-slot-change="true"
14
+ languages={languages}
15
+ language={language}
16
+ show-footer={enableFooter}
17
+ origin={origin}
18
+ >
19
+ <doc-phase
20
+ slot="doc-phase"
21
+ lwc:if={docPhaseInfo}
22
+ doc-phase-info={docPhaseInfo}
23
+ ></doc-phase>
24
+ <slot></slot>
25
+ </doc-content-layout>
26
+ </template>
@@ -0,0 +1,85 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { toJson } from "dxUtils/normalizers";
3
+ import type { OptionWithLink, TreeNode } from "typings/custom";
4
+
5
+ /**
6
+ * Per-topic type emitted by the docs content-type parser
7
+ * (see @salesforcedevs/sfdocs-doc-framework: `TopicTypeEnum`). Only `spec`
8
+ * is meaningful inside this component; everything else renders as a plain
9
+ * markdown-style tile.
10
+ */
11
+ const TOPIC_TYPE_SPEC = "spec";
12
+
13
+ /**
14
+ * Translates per-topic `topicType` into the generic `showForwardArrow` flag
15
+ * that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
16
+ */
17
+ function decorateTopicsWithForwardArrow(
18
+ topics: Array<TreeNode & { topicType?: string }> | undefined
19
+ ): TreeNode[] | undefined {
20
+ return topics?.map((topic) => {
21
+ const { topicType, ...decorated } = topic;
22
+ if (topicType === TOPIC_TYPE_SPEC) {
23
+ decorated.showForwardArrow = true;
24
+ }
25
+ if (decorated.children) {
26
+ decorated.children = decorateTopicsWithForwardArrow(
27
+ decorated.children
28
+ );
29
+ }
30
+ return decorated;
31
+ });
32
+ }
33
+
34
+ /**
35
+ * Wrapper around `doc-content-layout` for the "docs" content type emitted by
36
+ * the `DocsContentTypeParser`.
37
+ */
38
+ export default class UnifiedContentLayout extends LightningElement {
39
+ @api breadcrumbs: string | null = null;
40
+ @api sidebarHeader?: string;
41
+ @api sidebarValue?: string;
42
+ @api tocTitle?: string;
43
+ @api tocOptions?: string;
44
+ @api tocAriaLevel?: string;
45
+ @api languages?: OptionWithLink[];
46
+ @api language?: string;
47
+
48
+ /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). */
49
+ @api origin: string | null = null;
50
+
51
+ /** Article name from breadcrumbs, used as share title (e.g. for social share). */
52
+ @api shareTitle: string | null = null;
53
+
54
+ /** Optional Twitter "via" handle (e.g. SalesforceDevs) for social share. */
55
+ @api twitterVia: string | null = null;
56
+
57
+ @api hideFooter = false;
58
+
59
+ private _docPhaseInfo: string | null = null;
60
+ private _sidebarContent: unknown = null;
61
+
62
+ @api
63
+ get docPhaseInfo(): string | null {
64
+ return this._docPhaseInfo;
65
+ }
66
+
67
+ set docPhaseInfo(value: string | null) {
68
+ this._docPhaseInfo = value || null;
69
+ }
70
+
71
+ @api
72
+ get sidebarContent(): unknown {
73
+ return this._sidebarContent;
74
+ }
75
+
76
+ set sidebarContent(value: string) {
77
+ this._sidebarContent = decorateTopicsWithForwardArrow(
78
+ toJson(value)?.topics
79
+ );
80
+ }
81
+
82
+ private get enableFooter(): boolean {
83
+ return !this.hideFooter;
84
+ }
85
+ }
@@ -53,7 +53,7 @@
53
53
  </doc-content-layout>
54
54
  <div lwc:if={display404}>
55
55
  <dx-error
56
- image="https://a.sfdcstatic.com/developer-website/prod/images/404.svg"
56
+ image="https://developer.salesforce.com/ns-assets/404.svg"
57
57
  code="404"
58
58
  header="Beep boop. That did not compute."
59
59
  subtitle="The document you're looking for doesn't seem to exist."
@@ -322,8 +322,10 @@ export default class DocXmlContent extends LightningElementWithState<{
322
322
  };
323
323
  }
324
324
 
325
- private handlePopState = (event: PopStateEvent): void =>
325
+ private handlePopState = (event: PopStateEvent): void => {
326
326
  this.updatePageReference(this.getReferenceFromUrl(), event);
327
+ this.handleLocaleReload();
328
+ };
327
329
 
328
330
  handleDismissVersionBanner() {
329
331
  this.showVersionBanner = false;
@@ -598,6 +600,31 @@ export default class DocXmlContent extends LightningElementWithState<{
598
600
  "docs",
599
601
  this.pageReferenceToString(this.pageReference)
600
602
  );
603
+ this.handleLocaleReload();
604
+ }
605
+
606
+ /* This method reloads the page as locale banner context is not available in developer-website. */
607
+ private handleLocaleReload(): void {
608
+ const targetLocale = this.language?.id;
609
+ if (!targetLocale) {
610
+ return;
611
+ }
612
+
613
+ const currentPath = window.location.pathname;
614
+ const localePattern = /atlas\.[a-z]{2}-[a-z]{2}\./;
615
+
616
+ if (localePattern.test(currentPath)) {
617
+ const newPath = currentPath.replace(
618
+ localePattern,
619
+ `atlas.${targetLocale}.`
620
+ );
621
+ const newUrl =
622
+ window.location.origin +
623
+ newPath +
624
+ window.location.search +
625
+ window.location.hash;
626
+ window.location.href = newUrl;
627
+ }
601
628
  }
602
629
 
603
630
  private updateHighlighting(searchParam: string): void {