Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serverless] Fix truncation in breadcrumbs #171770

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ const getHeaderCss = ({ size }: EuiThemeComputed) => ({
top: 2px;
`,
},
leftHeaderSection: css`
// needed to enable breadcrumbs truncation
min-width: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex-shrink: 1;
`,
breadcrumbsSectionItem: css`
min-width: 0; // needed to enable breadcrumbs truncation
`,
redirectAppLinksContainer: css`
min-width: 0; // needed to enable breadcrumbs truncation
`,
});

type HeaderCss = ReturnType<typeof getHeaderCss>;
Expand Down Expand Up @@ -181,7 +192,7 @@ export const ProjectHeader = ({
<header data-test-subj="kibanaProjectHeader">
<div id="globalHeaderBars" data-test-subj="headerGlobalNav" className="header__bars">
<EuiHeader position="fixed" className="header__firstBar">
<EuiHeaderSection grow={false}>
<EuiHeaderSection grow={false} css={headerCss.leftHeaderSection}>
<Router history={application.history}>
<ProjectNavigation toggleSideNav={toggleSideNav}>{children}</ProjectNavigation>
</Router>
Expand All @@ -196,8 +207,11 @@ export const ProjectHeader = ({
/>
</EuiHeaderSectionItem>

<EuiHeaderSectionItem>
<RedirectAppLinks coreStart={{ application }}>
<EuiHeaderSectionItem css={headerCss.breadcrumbsSectionItem}>
<RedirectAppLinks
coreStart={{ application }}
css={headerCss.redirectAppLinksContainer}
>
<Breadcrumbs breadcrumbs$={observables.breadcrumbs$} />
</RedirectAppLinks>
</EuiHeaderSectionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
children,
navigateToUrl,
currentAppId,
...containerProps
}) => {
const containerRef = useRef<HTMLDivElement>(null);

Expand All @@ -50,6 +51,7 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
ref={containerRef}
css={redirectAppLinksStyles}
data-test-subj="kbnRedirectAppLink"
{...containerProps}
>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { FC } from 'react';
import type { RedirectAppLinksComponentProps } from '@kbn/shared-ux-link-redirect-app-types';

import { useServices } from './services';
import { RedirectAppLinks as Component } from './redirect_app_links.component';
Expand All @@ -22,6 +23,11 @@ import { RedirectAppLinks as Component } from './redirect_app_links.component';
* </RedirectAppLinks>
* ```
*/
export const RedirectAppLinks: FC<{}> = ({ children }) => (
<Component {...useServices()}>{children}</Component>
export const RedirectAppLinks: FC<Omit<RedirectAppLinksComponentProps, 'navigateToUrl'>> = ({
children,
...props
}) => (
<Component {...useServices()} {...props}>
{children}
</Component>
);
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ const isKibanaContract = (services: any): services is RedirectAppLinksKibanaDepe
* with which consumers can wrap their components or solutions.
*/
export const RedirectAppLinks: FC<RedirectAppLinksProps> = ({ children, ...props }) => {
const container = <RedirectAppLinksContainer>{children}</RedirectAppLinksContainer>;

if (isKibanaContract(props)) {
const { coreStart } = props;
const { coreStart, ...containerProps } = props;
const container = (
<RedirectAppLinksContainer {...containerProps}>{children}</RedirectAppLinksContainer>
);
return (
<RedirectAppLinksKibanaProvider {...{ coreStart }}>
{container}
</RedirectAppLinksKibanaProvider>
);
}

const { navigateToUrl, currentAppId } = props;
const { navigateToUrl, currentAppId, ...containerProps } = props;
const container = (
<RedirectAppLinksContainer {...containerProps}>{children}</RedirectAppLinksContainer>
);
return (
<RedirectAppLinksProvider {...{ currentAppId, navigateToUrl }}>
{container}
Expand Down
6 changes: 5 additions & 1 deletion packages/shared-ux/link/redirect_app/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export interface RedirectAppLinksKibanaDependencies {
}

/** Props for the `RedirectAppLinks` component. */
export type RedirectAppLinksProps = RedirectAppLinksServices | RedirectAppLinksKibanaDependencies;
export type RedirectAppLinksProps = (
| RedirectAppLinksServices
| RedirectAppLinksKibanaDependencies
) &
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;

/** Props for the `RedirectAppLinksComponent`. */
export interface RedirectAppLinksComponentProps
Expand Down
Loading