Skip to content

Commit

Permalink
Set different feedback URLs based on the solutionId
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Oct 29, 2024
1 parent 2e10933 commit 21f989e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -364,6 +365,7 @@ const isRecentlyAccessedDefinition = (
};

export const parseNavigationTree = (
id: SolutionId,
navigationTreeDef: NavigationTreeDefinition,
{ deepLinks, cloudLinks }: { deepLinks: Record<string, ChromeNavLink>; cloudLinks: CloudLinks }
): {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export interface NavigationTreeDefinition<
* with their corresponding "deepLink"...)
*/
export interface NavigationTreeDefinitionUI {
id: SolutionId;
body: Array<ChromeProjectNavigationNode | RecentlyAccessedDefinition>;
footer?: Array<ChromeProjectNavigationNode | RecentlyAccessedDefinition>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> = ({ solutionId }) => {
const { euiTheme } = useEuiTheme();
const [showCallOut, setShowCallOut] = useState(
sessionStorage.getItem(FEEDBACK_BTN_KEY) !== 'hidden'
Expand All @@ -26,7 +35,7 @@ export const FeedbackBtn: FC = () => {
};

const onClick = () => {
window.open(feedbackUrl, '_blank');
window.open(feedbackUrls[solutionId], '_blank');
onDismiss();
};

Expand Down
5 changes: 3 additions & 2 deletions packages/shared-ux/chrome/navigation/src/ui/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const NavigationComp: FC<Props> = ({ 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<Context>(
Expand Down Expand Up @@ -95,7 +96,7 @@ const NavigationComp: FC<Props> = ({ navigationTree$, dataTestSubj, panelContent
<EuiFlexItem>{renderNodes(navigationTree.body)}</EuiFlexItem>
{isFeedbackBtnVisible && (
<EuiFlexItem grow={false}>
<FeedbackBtn />
<FeedbackBtn solutionId={solutionId} />
</EuiFlexItem>
)}
</EuiFlexGroup>
Expand Down

0 comments on commit 21f989e

Please sign in to comment.