Skip to content

Commit 244ef02

Browse files
authored
[Shared UX] Fix redirect app links fill vertical space (#141656)
1 parent bf3ee9e commit 244ef02

File tree

10 files changed

+46
-32
lines changed

10 files changed

+46
-32
lines changed

packages/shared-ux/card/no_data/impl/src/__snapshots__/no_data_card.test.tsx.snap

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/shared-ux/link/redirect_app/impl/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ RUNTIME_DEPS = [
5353
"@npm//react",
5454
"@npm//rxjs",
5555
"//packages/kbn-shared-ux-utility",
56+
"@npm//@emotion/react",
57+
"@npm//@emotion/css",
5658
]
5759

5860
# In this array place dependencies necessary to build the types, which will include the
@@ -74,6 +76,8 @@ TYPES_DEPS = [
7476
"//packages/kbn-ambient-ui-types",
7577
"//packages/shared-ux/link/redirect_app/types",
7678
"//packages/kbn-shared-ux-utility:npm_module_types",
79+
"@npm//@emotion/css",
80+
"@npm//@emotion/react",
7781
]
7882

7983
jsts_transpiler(

packages/shared-ux/link/redirect_app/impl/src/redirect_app_links.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React, { FC, useRef, MouseEventHandler, useCallback } from 'react';
1111
import type { RedirectAppLinksComponentProps } from '@kbn/shared-ux-link-redirect-app-types';
1212

1313
import { navigateToUrlClickHandler } from './click_handler';
14+
import { redirectAppLinksStyles } from './redirect_app_links.styles';
1415

1516
/**
1617
* Utility component that will intercept click events on children anchor (`<a>`) elements to call
@@ -28,7 +29,6 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
2829
children,
2930
navigateToUrl,
3031
currentAppId,
31-
className,
3232
}) => {
3333
const containerRef = useRef<HTMLDivElement>(null);
3434

@@ -45,7 +45,7 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
4545

4646
return (
4747
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
48-
<div ref={containerRef} onClick={handleClick} className={className}>
48+
<div onClick={handleClick} ref={containerRef} css={redirectAppLinksStyles}>
4949
{children}
5050
</div>
5151
);

packages/shared-ux/link/redirect_app/impl/src/redirect_app_links.container.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import { RedirectAppLinks as Component } from './redirect_app_links.component';
2222
* </RedirectAppLinks>
2323
* ```
2424
*/
25-
export const RedirectAppLinks: FC<{ className?: string }> = ({ className, children }) => (
26-
<Component {...useServices()} className={className}>
27-
{children}
28-
</Component>
25+
export const RedirectAppLinks: FC<{}> = ({ children }) => (
26+
<Component {...useServices()}>{children}</Component>
2927
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { css } from '@emotion/react';
10+
11+
export const redirectAppLinksStyles = css({
12+
display: 'flex',
13+
flex: '1',
14+
});

packages/shared-ux/link/redirect_app/impl/src/redirect_app_links.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ const isKibanaContract = (services: any): services is RedirectAppLinksKibanaDepe
2424
* `RedirectAppLinksKibanaProvider` based on the services provided, creating a single component
2525
* with which consumers can wrap their components or solutions.
2626
*/
27-
export const RedirectAppLinks: FC<RedirectAppLinksProps> = ({ children, className, ...props }) => {
28-
const container = (
29-
<RedirectAppLinksContainer className={className}>{children}</RedirectAppLinksContainer>
30-
);
27+
export const RedirectAppLinks: FC<RedirectAppLinksProps> = ({ children, ...props }) => {
28+
const container = <RedirectAppLinksContainer>{children}</RedirectAppLinksContainer>;
3129

3230
if (isKibanaContract(props)) {
3331
const { coreStart } = props;

packages/shared-ux/link/redirect_app/impl/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"jest",
99
"node",
1010
"react",
11-
"@kbn/ambient-ui-types"
11+
"@kbn/ambient-ui-types",
12+
"@emotion/react/types/css-prop"
1213
]
1314
},
1415
"include": [

packages/shared-ux/link/redirect_app/types/index.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export interface RedirectAppLinksKibanaDependencies {
3232
}
3333

3434
/** Props for the `RedirectAppLinks` component. */
35-
export type RedirectAppLinksProps = { className?: string } & (
36-
| RedirectAppLinksServices
37-
| RedirectAppLinksKibanaDependencies
38-
);
35+
export type RedirectAppLinksProps = RedirectAppLinksServices | RedirectAppLinksKibanaDependencies;
3936

4037
/** Props for the `RedirectAppLinksComponent`. */
4138
export interface RedirectAppLinksComponentProps

x-pack/plugins/profiling/public/app.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { Storage } from '@kbn/kibana-utils-plugin/public';
1414
import { RouteRenderer, RouterProvider } from '@kbn/typed-react-router-config';
1515

1616
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
17-
import { css } from '@emotion/react';
1817
import { ProfilingDependenciesContextProvider } from './components/contexts/profiling_dependencies/profiling_dependencies_context';
1918
import { RedirectWithDefaultDateRange } from './components/redirect_with_default_date_range';
2019
import { profilingRouter } from './routing';
@@ -33,11 +32,6 @@ interface Props {
3332
history: AppMountParameters['history'];
3433
}
3534

36-
const redirectAppLinksCss = css`
37-
display: flex;
38-
flex-grow: 1;
39-
`;
40-
4135
const storage = new Storage(localStorage);
4236

4337
function App({
@@ -69,11 +63,7 @@ function App({
6963
<KibanaThemeProvider theme$={theme$}>
7064
<KibanaContextProvider services={{ ...coreStart, ...pluginsStart, storage }}>
7165
<i18nCore.Context>
72-
<RedirectAppLinks
73-
coreStart={coreStart}
74-
currentAppId="profiling"
75-
css={redirectAppLinksCss}
76-
>
66+
<RedirectAppLinks coreStart={coreStart} currentAppId="profiling">
7767
<RouterProvider router={profilingRouter as any} history={history}>
7868
<TimeRangeContextProvider>
7969
<ProfilingDependenciesContextProvider value={profilingDependencies}>

x-pack/plugins/security/public/nav_control/nav_control_service.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ describe('SecurityNavControlService', () => {
7575

7676
expect(target).toMatchInlineSnapshot(`
7777
<div>
78-
<div>
78+
<div
79+
css="You have tried to stringify object returned from \`css\` function. It isn't supposed to be used directly (e.g. as value of the \`className\` prop), but rather handed to emotion so it can handle it (e.g. as value of \`css\` prop)."
80+
>
7981
<div
8082
class="euiPopover emotion-euiPopover"
8183
id="headerUserMenu"

0 commit comments

Comments
 (0)