Skip to content

Commit

Permalink
Move the Metrics' actions to the kibana header
Browse files Browse the repository at this point in the history
  • Loading branch information
afgomez authored and Alejandro Fernández Gómez committed Dec 1, 2020
1 parent 1f13227 commit c5375ef
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions x-pack/plugins/infra/public/pages/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ import { SourceConfigurationFields } from '../../graphql/types';
import { AlertPrefillProvider } from '../../alerting/use_alert_prefill';
import { InfraMLCapabilitiesProvider } from '../../containers/ml/infra_ml_capabilities';
import { AnomalyDetectionFlyout } from './inventory_view/components/ml/anomaly_detection/anomoly_detection_flyout';
import { HeaderMenuPortal } from '../../../../observability/public';
import { HeaderActionMenuContext } from '../../utils/header_action_menu_provider';

const ADD_DATA_LABEL = i18n.translate('xpack.infra.metricsHeaderAddDataButtonLabel', {
defaultMessage: 'Add data',
});

export const InfrastructurePage = ({ match }: RouteComponentProps) => {
const uiCapabilities = useKibana().services.application?.capabilities;
const { setHeaderActionMenu } = useContext(HeaderActionMenuContext);

const kibana = useKibana();

Expand All @@ -72,6 +75,32 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
})}
/>

{setHeaderActionMenu && (
<HeaderMenuPortal setHeaderActionMenu={setHeaderActionMenu}>
<EuiFlexGroup alignItems="center" gutterSize="none">
<EuiFlexItem grow={false}>
<Route path={'/inventory'} component={AnomalyDetectionFlyout} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<Route path={'/explorer'} component={MetricsAlertDropdown} />
<Route path={'/inventory'} component={InventoryAlertDropdown} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={kibana.services?.application?.getUrlForApp(
'/home#/tutorial_directory/metrics'
)}
size="s"
color="primary"
iconType="plusInCircle"
>
{ADD_DATA_LABEL}
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</HeaderMenuPortal>
)}

<Header
breadcrumbs={[
{
Expand Down Expand Up @@ -121,30 +150,6 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
]}
/>
</EuiFlexItem>
<EuiFlexItem
grow={false}
style={{ flexDirection: 'row', alignItems: 'center' }}
>
<EuiFlexItem grow={false}>
<Route path={'/inventory'} component={AnomalyDetectionFlyout} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<Route path={'/explorer'} component={MetricsAlertDropdown} />
<Route path={'/inventory'} component={InventoryAlertDropdown} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={kibana.services?.application?.getUrlForApp(
'/home#/tutorial_directory/metrics'
)}
size="s"
color="primary"
iconType="plusInCircle"
>
{ADD_DATA_LABEL}
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexItem>
</EuiFlexGroup>
</AppNavigation>

Expand Down

0 comments on commit c5375ef

Please sign in to comment.