forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Update the Overview page (elastic#159609)
## Summary Resolves elastic#154294 and updates the UI of the Overview page - Updates panels layout - Stores expand/collapsed state of the panels in the local storage - Update empty states text and layout <img width="1341" alt="image" src="https://github.com/elastic/kibana/assets/5236598/8833fa2a-b574-44ee-bacb-e974186dd35f"> ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) (cherry picked from commit 6ac52fb)
- Loading branch information
Showing
18 changed files
with
441 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
x-pack/plugins/ml/public/application/components/collapsible_panel/collapsible_panel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
EuiBadge, | ||
EuiButtonIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSplitPanel, | ||
EuiText, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
import React, { type FC } from 'react'; | ||
import { css } from '@emotion/react/dist/emotion-react.cjs'; | ||
import { useCurrentThemeVars } from '../../contexts/kibana'; | ||
|
||
export interface CollapsiblePanelProps { | ||
isOpen: boolean; | ||
onToggle: (isOpen: boolean) => void; | ||
|
||
header: React.ReactElement; | ||
headerItems?: React.ReactElement[]; | ||
} | ||
|
||
export const CollapsiblePanel: FC<CollapsiblePanelProps> = ({ | ||
isOpen, | ||
onToggle, | ||
children, | ||
header, | ||
headerItems, | ||
}) => { | ||
const { euiTheme } = useCurrentThemeVars(); | ||
|
||
return ( | ||
<EuiSplitPanel.Outer | ||
grow | ||
hasShadow={false} | ||
css={{ | ||
border: `${euiTheme.euiBorderWidthThin} solid ${ | ||
isOpen ? euiTheme.euiBorderColor : 'transparent' | ||
}`, | ||
}} | ||
> | ||
<EuiSplitPanel.Inner color={isOpen ? 'plain' : 'subdued'}> | ||
<EuiFlexGroup justifyContent={'spaceBetween'} alignItems={'center'}> | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup gutterSize={'s'}> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonIcon | ||
color={'text'} | ||
iconType={isOpen ? 'arrowDown' : 'arrowRight'} | ||
onClick={() => { | ||
onToggle(!isOpen); | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="xxs"> | ||
<h2>{header}</h2> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
{headerItems ? ( | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup gutterSize={'l'} alignItems={'center'}> | ||
{headerItems.map((item, i) => { | ||
return ( | ||
<EuiFlexItem key={i} grow={false}> | ||
<div | ||
css={ | ||
i < headerItems?.length - 1 | ||
? css` | ||
border-right: ${euiTheme.euiBorderWidthThin} solid | ||
${euiTheme.euiBorderColor}; | ||
padding-right: ${euiTheme.euiPanelPaddingModifiers.paddingLarge}; | ||
` | ||
: null | ||
} | ||
> | ||
{item} | ||
</div> | ||
</EuiFlexItem> | ||
); | ||
})} | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
) : null} | ||
</EuiFlexGroup> | ||
</EuiSplitPanel.Inner> | ||
{isOpen ? ( | ||
<EuiSplitPanel.Inner | ||
css={{ borderTop: `${euiTheme.euiBorderWidthThin} solid ${euiTheme.euiBorderColor}` }} | ||
grow={false} | ||
> | ||
{children} | ||
</EuiSplitPanel.Inner> | ||
) : null} | ||
</EuiSplitPanel.Outer> | ||
); | ||
}; | ||
|
||
export interface StatEntry { | ||
label: string; | ||
value: number; | ||
'data-test-subj'?: string; | ||
} | ||
|
||
export interface OverviewStatsBarProps { | ||
inputStats: StatEntry[]; | ||
dataTestSub?: string; | ||
} | ||
|
||
export const OverviewStatsBar: FC<OverviewStatsBarProps> = ({ inputStats, dataTestSub }) => { | ||
return ( | ||
<EuiFlexGroup data-test-subj={dataTestSub} alignItems={'center'} gutterSize={'m'}> | ||
{inputStats.map(({ value, label, 'data-test-subj': dataTestSubjValue }) => { | ||
return ( | ||
<EuiFlexItem grow={false} key={label}> | ||
<EuiFlexGroup alignItems={'center'} gutterSize={'s'}> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size={'s'}>{label}:</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge data-test-subj={dataTestSubjValue}>{value}</EuiBadge> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
); | ||
})} | ||
</EuiFlexGroup> | ||
); | ||
}; |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/ml/public/application/components/collapsible_panel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { CollapsiblePanel } from './collapsible_panel'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.