Skip to content

Commit 1329707

Browse files
authored
Grid layout fixes (#80305) (#80326)
* fixes to make grid layout a bit more solid. * Changed the spacing a bit more. * Updated snapshot.
1 parent fe94245 commit 1329707

File tree

3 files changed

+90
-28
lines changed

3 files changed

+90
-28
lines changed

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/trusted_apps_grid/__snapshots__/index.test.tsx.snap

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

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/trusted_apps_grid/index.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Provider } from 'react-redux';
88
import { ThemeProvider } from 'styled-components';
99
import { storiesOf } from '@storybook/react';
1010
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
11+
import { EuiHorizontalRule } from '@elastic/eui';
1112

1213
import { KibanaContextProvider } from '../../../../../../../../../../src/plugins/kibana_react/public';
1314

@@ -27,7 +28,11 @@ const renderGrid = (store: ReturnType<typeof createGlobalNoMiddlewareStore>) =>
2728
<Provider store={store}>
2829
<KibanaContextProvider services={{ uiSettings: { get: () => 'MMM D, YYYY @ HH:mm:ss.SSS' } }}>
2930
<ThemeProvider theme={() => ({ eui: euiLightVars, darkMode: false })}>
31+
<EuiHorizontalRule margin="none" />
32+
3033
<TrustedAppsGrid />
34+
35+
<EuiHorizontalRule margin="none" />
3136
</ThemeProvider>
3237
</KibanaContextProvider>
3338
</Provider>

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/trusted_apps_grid/index.tsx

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React, { memo, useCallback, useEffect } from 'react';
7+
import React, { FC, memo, useCallback, useEffect } from 'react';
88
import {
99
EuiTablePagination,
1010
EuiFlexGroup,
1111
EuiFlexItem,
1212
EuiProgress,
1313
EuiIcon,
1414
EuiText,
15+
EuiSpacer,
1516
} from '@elastic/eui';
1617

1718
import { Pagination } from '../../../state';
@@ -64,6 +65,14 @@ const PaginationBar = ({ pagination, onChange }: PaginationBarProps) => {
6465
);
6566
};
6667

68+
const GridMessage: FC = ({ children }) => (
69+
<div className="euiTextAlign--center">
70+
<EuiSpacer size="m" />
71+
{children}
72+
<EuiSpacer size="m" />
73+
</div>
74+
);
75+
6776
export const TrustedAppsGrid = memo(() => {
6877
const pagination = useTrustedAppsSelector(getListPagination);
6978
const listItems = useTrustedAppsSelector(getListItems);
@@ -80,35 +89,41 @@ export const TrustedAppsGrid = memo(() => {
8089
}));
8190

8291
return (
83-
<EuiFlexGroup direction="column">
92+
<EuiFlexGroup direction="column" gutterSize="none">
8493
{isLoading && (
8594
<EuiFlexItem grow={false}>
8695
<EuiProgress size="xs" color="primary" />
8796
</EuiFlexItem>
8897
)}
8998
<EuiFlexItem>
9099
{error && (
91-
<div className="euiTextAlign--center">
100+
<GridMessage>
92101
<EuiIcon type="minusInCircle" color="danger" /> {error}
93-
</div>
102+
</GridMessage>
103+
)}
104+
{!error && listItems.length === 0 && (
105+
<GridMessage>
106+
<EuiText size="s">{NO_RESULTS_MESSAGE}</EuiText>
107+
</GridMessage>
94108
)}
95-
{!error && (
96-
<EuiFlexGroup direction="column">
97-
{listItems.map((item) => (
98-
<EuiFlexItem grow={false} key={item.id}>
99-
<TrustedAppCard trustedApp={item} onDelete={handleTrustedAppDelete} />
100-
</EuiFlexItem>
101-
))}
102-
{listItems.length === 0 && (
103-
<EuiText size="s" className="euiTextAlign--center">
104-
{NO_RESULTS_MESSAGE}
105-
</EuiText>
106-
)}
107-
</EuiFlexGroup>
109+
{!error && listItems.length > 0 && (
110+
<>
111+
<EuiSpacer size="l" />
112+
113+
<EuiFlexGroup direction="column">
114+
{listItems.map((item) => (
115+
<EuiFlexItem grow={false} key={item.id}>
116+
<TrustedAppCard trustedApp={item} onDelete={handleTrustedAppDelete} />
117+
</EuiFlexItem>
118+
))}
119+
</EuiFlexGroup>
120+
</>
108121
)}
109122
</EuiFlexItem>
110123
{!error && pagination.totalItemCount > 0 && (
111124
<EuiFlexItem grow={false}>
125+
<EuiSpacer size="l" />
126+
112127
<PaginationBar pagination={pagination} onChange={handlePaginationChange} />
113128
</EuiFlexItem>
114129
)}

0 commit comments

Comments
 (0)