-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] DF Analytics: Collapsable sections on results pages (#76641)
- Fixes cell color coding based on influence score for outlier detection results page data grid. (Part of #77046) - Introduces expandable sections (<ExpandableSection />). In contrast to plain accordions, the main idea of this component is that it should also provide some sort of useful summary when collapsed instead of just being an expandable title. For example, the "Analysis" section is collapsed by default, but still offers information like analysis type, source and destination index. This concept should allow us to keep the analytics results pages usable with more content (additional results, evaluations, visualizations) being added over time. - The "Analysis" section is a reuse of the expandable row from the analytics jobs list. Some design adjustments have been made to make it usable in both places.
- Loading branch information
Showing
15 changed files
with
390 additions
and
115 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
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
3 changes: 3 additions & 0 deletions
3
...alytics/pages/analytics_exploration/components/expandable_section/expandable_section.scss
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,3 @@ | ||
.mlExpandableSection { | ||
padding: 0 $euiSizeS $euiSizeS $euiSizeS; | ||
} |
94 changes: 94 additions & 0 deletions
94
...nalytics/pages/analytics_exploration/components/expandable_section/expandable_section.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,94 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import './expandable_section.scss'; | ||
|
||
import React, { useState, FC, ReactNode } from 'react'; | ||
|
||
import { | ||
EuiBadge, | ||
EuiButtonEmpty, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLoadingContent, | ||
EuiPanel, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
|
||
interface HeaderItem { | ||
// id is used as the React key and to construct a data-test-subj | ||
id: string; | ||
label?: ReactNode; | ||
value: ReactNode; | ||
} | ||
|
||
const isHeaderItems = (arg: any): arg is HeaderItem[] => { | ||
return Array.isArray(arg); | ||
}; | ||
|
||
export interface ExpandableSectionProps { | ||
content: ReactNode; | ||
headerItems?: HeaderItem[] | 'loading'; | ||
isExpanded?: boolean; | ||
dataTestId: string; | ||
title: ReactNode; | ||
} | ||
|
||
export const ExpandableSection: FC<ExpandableSectionProps> = ({ | ||
headerItems, | ||
// For now we don't have a need for complete external control | ||
// and just want to pass in a default value. If we wanted | ||
// full external control we'd also need to add a onToggleExpanded() | ||
// callback. | ||
isExpanded: isExpandedDefault = true, | ||
content, | ||
dataTestId, | ||
title, | ||
}) => { | ||
const [isExpanded, setIsExpanded] = useState(isExpandedDefault); | ||
const toggleExpanded = () => { | ||
setIsExpanded(!isExpanded); | ||
}; | ||
|
||
return ( | ||
<EuiPanel paddingSize="none" data-test-subj={`mlDFExpandableSection-${dataTestId}`}> | ||
<div className="mlExpandableSection"> | ||
<EuiButtonEmpty | ||
onClick={toggleExpanded} | ||
iconType={isExpanded ? 'arrowUp' : 'arrowDown'} | ||
size="l" | ||
iconSide="right" | ||
flush="left" | ||
> | ||
{title} | ||
</EuiButtonEmpty> | ||
{headerItems === 'loading' && <EuiLoadingContent lines={1} />} | ||
{isHeaderItems(headerItems) && ( | ||
<EuiFlexGroup> | ||
{headerItems.map(({ label, value, id }) => ( | ||
<EuiFlexItem | ||
grow={false} | ||
key={id} | ||
data-test-subj={`mlDFExpandableSectionItem-${dataTestId}-${id}`} | ||
> | ||
{label !== undefined && value !== undefined && ( | ||
<> | ||
<EuiText size="xs" color="subdued"> | ||
<p>{label}</p> | ||
</EuiText> | ||
<EuiBadge>{value}</EuiBadge> | ||
</> | ||
)} | ||
{label === undefined && value} | ||
</EuiFlexItem> | ||
))} | ||
</EuiFlexGroup> | ||
)} | ||
</div> | ||
{isExpanded && content} | ||
</EuiPanel> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
...n/data_frame_analytics/pages/analytics_exploration/components/expandable_section/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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { ExpandableSection, ExpandableSectionProps } from './expandable_section'; |
Oops, something went wrong.