From 21f989ee61d0c446fd3a3f55da87b8e4514e08c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 29 Oct 2024 11:09:39 +0000 Subject: [PATCH] Set different feedback URLs based on the solutionId --- .../project_navigation_service.ts | 2 +- .../src/project_navigation/utils.ts | 4 +++- .../core-chrome-browser/src/project_navigation.ts | 1 + .../navigation/src/ui/components/feedback_btn.tsx | 15 ++++++++++++--- .../chrome/navigation/src/ui/navigation.tsx | 5 +++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts index 62b771d6a9d05..7960d9f710c90 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts @@ -221,7 +221,7 @@ export class ProjectNavigationService { .pipe( takeUntil(this.stop$), map(([def, deepLinksMap, cloudLinks]) => { - return parseNavigationTree(def, { + return parseNavigationTree(id, def, { deepLinks: deepLinksMap, cloudLinks, }); diff --git a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/utils.ts b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/utils.ts index 9a45290c95389..bdf3929c464dc 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/utils.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/utils.ts @@ -22,6 +22,7 @@ import type { CloudLinkId, CloudLinks, ItemDefinition, + SolutionId, } from '@kbn/core-chrome-browser/src'; import type { Location } from 'history'; import type { MouseEventHandler } from 'react'; @@ -364,6 +365,7 @@ const isRecentlyAccessedDefinition = ( }; export const parseNavigationTree = ( + id: SolutionId, navigationTreeDef: NavigationTreeDefinition, { deepLinks, cloudLinks }: { deepLinks: Record; cloudLinks: CloudLinks } ): { @@ -376,7 +378,7 @@ export const parseNavigationTree = ( const navigationTree: ChromeProjectNavigationNode[] = []; // Contains UI layout information (body, footer) and render "special" blocks like recently accessed. - const navigationTreeUI: NavigationTreeDefinitionUI = { body: [] }; + const navigationTreeUI: NavigationTreeDefinitionUI = { id, body: [] }; const initNodeAndChildren = ( node: GroupDefinition | ItemDefinition | NodeDefinition, diff --git a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts index 7e9a6e5acba56..f4a5af26c4176 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -416,6 +416,7 @@ export interface NavigationTreeDefinition< * with their corresponding "deepLink"...) */ export interface NavigationTreeDefinitionUI { + id: SolutionId; body: Array; footer?: Array; } diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/feedback_btn.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/feedback_btn.tsx index 3cc2fca2d8f81..182838d88b5d6 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/feedback_btn.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/feedback_btn.tsx @@ -10,11 +10,20 @@ import { EuiButton, EuiCallOut, useEuiTheme, EuiText, EuiSpacer } from '@elastic/eui'; import React, { FC, useState } from 'react'; import { i18n } from '@kbn/i18n'; +import type { SolutionId } from '@kbn/core-chrome-browser'; -const feedbackUrl = 'https://ela.st/nav-feedback'; +const feedbackUrls: { [id in SolutionId]: string } = { + es: 'https://ela.st/search-nav-feedback', + oblt: 'https://ela.st/o11y-nav-feedback', + security: 'https://ela.st/security-nav-feedback', +}; const FEEDBACK_BTN_KEY = 'core.chrome.sideNav.feedbackBtn'; -export const FeedbackBtn: FC = () => { +interface Props { + solutionId: SolutionId; +} + +export const FeedbackBtn: FC = ({ solutionId }) => { const { euiTheme } = useEuiTheme(); const [showCallOut, setShowCallOut] = useState( sessionStorage.getItem(FEEDBACK_BTN_KEY) !== 'hidden' @@ -26,7 +35,7 @@ export const FeedbackBtn: FC = () => { }; const onClick = () => { - window.open(feedbackUrl, '_blank'); + window.open(feedbackUrls[solutionId], '_blank'); onDismiss(); }; diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.tsx index 688ee1e709e15..80365bd16133f 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.tsx @@ -52,7 +52,8 @@ const NavigationComp: FC = ({ navigationTree$, dataTestSubj, panelContent useNavigationService(); const activeNodes = useObservable(activeNodes$, []); - const navigationTree = useObservable(navigationTree$, { body: [] }); + const navigationTree = useObservable(navigationTree$, { id: 'es', body: [] }); + const { id: solutionId } = navigationTree; const isFeedbackBtnVisible = useObservable(isFeedbackBtnVisible$, false); const contextValue = useMemo( @@ -95,7 +96,7 @@ const NavigationComp: FC = ({ navigationTree$, dataTestSubj, panelContent {renderNodes(navigationTree.body)} {isFeedbackBtnVisible && ( - + )}