Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InfraUI] Infrastructure navigation changes #32892

Merged
merged 16 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions x-pack/plugins/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function infra(kibana: any) {
defaultMessage: 'Infrastructure',
}),
listed: false,
url: `/app/${APP_ID}#/home`,
url: `/app/${APP_ID}#/infrastructure`,
},
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
home: ['plugins/infra/register_feature'],
Expand All @@ -46,7 +46,7 @@ export function infra(kibana: any) {
title: i18n.translate('xpack.infra.linkInfrastructureTitle', {
defaultMessage: 'Infrastructure',
}),
url: `/app/${APP_ID}#/home`,
url: `/app/${APP_ID}#/infrastructure`,
},
{
description: i18n.translate('xpack.infra.linkLogsDescription', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ const SuggestionsPanel = styled(EuiPanel).attrs({
width: 100%;
margin-top: 2px;
overflow: hidden;
z-index: ${props => props.theme.eui.euiZLevel1};
`;
17 changes: 10 additions & 7 deletions x-pack/plugins/infra/public/components/document_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ const wrapWithSharedState = () => {
const TITLE_SUFFIX = ' - Kibana';

return class extends React.Component<DocumentTitleProps, DocumentTitleState> {
public readonly state = {
index: titles.push('') - 1,
};

public componentDidMount() {
this.pushTitle(this.getTitle(this.props.title));
this.updateDocumentTitle();
this.setState(
() => {
return { index: titles.push('') - 1 };
},
() => {
this.pushTitle(this.getTitle(this.props.title));
this.updateDocumentTitle();
}
);
}

public componentDidUpdate() {
Expand All @@ -53,7 +56,7 @@ const wrapWithSharedState = () => {
}

private removeTitle() {
titles.splice(this.state.index, 1);
titles.pop();
}

private updateDocumentTitle() {
Expand Down
40 changes: 40 additions & 0 deletions x-pack/plugins/infra/public/components/navigation/routed_tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 { EuiTab, EuiTabs } from '@elastic/eui';
import React from 'react';
import { Route } from 'react-router-dom';

interface TabConfiguration {
title: string;
path: string;
}

interface RoutedTabsProps {
tabs: TabConfiguration[];
}

export class RoutedTabs extends React.Component<RoutedTabsProps> {
public render() {
return <EuiTabs>{this.renderTabs()}</EuiTabs>;
}

private renderTabs() {
return this.props.tabs.map(tab => {
return (
<Route
key={`${tab.path}${tab.title}`}
path={tab.path}
children={({ match, history }) => (
<EuiTab onClick={() => history.push(tab.path)} isSelected={match !== null}>
Kerry350 marked this conversation as resolved.
Show resolved Hide resolved
{tab.title}
</EuiTab>
)}
/>
);
});
}
}
20 changes: 18 additions & 2 deletions x-pack/plugins/infra/public/components/nodes_overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';

import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { get, max, min } from 'lodash';
import React from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -132,7 +134,21 @@ export const NodesOverview = injectI18n(
return (
<MainContainer>
<ViewSwitcherContainer>
<ViewSwitcher view={view} onChange={this.handleViewChange} />
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<ViewSwitcher view={view} onChange={this.handleViewChange} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText color="subdued">
<p>
<FormattedMessage
id="xpack.infra.homePage.toolbar.showingLastOneMinuteDataText"
defaultMessage="Showing the last 1 minute of data from the time period"
/>
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</ViewSwitcherContainer>
{view === 'table' ? (
<TableContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiKeyPadMenu, EuiKeyPadMenuItemButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiButtonGroup } from '@elastic/eui';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React from 'react';
import {
InfraMetricInput,
Expand All @@ -15,55 +15,52 @@ import {
} from '../../graphql/types';

interface Props {
intl: InjectedIntl;
nodeType: InfraNodeType;
changeNodeType: (nodeType: InfraNodeType) => void;
changeGroupBy: (groupBy: InfraPathInput[]) => void;
changeMetric: (metric: InfraMetricInput) => void;
}

export class WaffleNodeTypeSwitcher extends React.PureComponent<Props> {
export class WaffleNodeTypeSwitcherClass extends React.PureComponent<Props> {
public render() {
const { intl } = this.props;

const nodeOptions = [
{
id: InfraNodeType.host,
label: intl.formatMessage({
id: 'xpack.infra.waffle.nodeTypeSwitcher.hostsLabel',
defaultMessage: 'Hosts',
}),
},
{
id: InfraNodeType.pod,
label: 'Kubernetes',
},
{
id: InfraNodeType.container,
label: 'Docker',
},
];

return (
<EuiKeyPadMenu>
<EuiKeyPadMenuItemButton
label={
<FormattedMessage
id="xpack.infra.waffle.nodeTypeSwitcher.hostsLabel"
defaultMessage="Hosts"
/>
}
onClick={this.handleClick(InfraNodeType.host)}
>
<img
src="../plugins/infra/images/hosts.svg"
role="presentation"
alt=""
className="euiIcon euiIcon--large"
/>
</EuiKeyPadMenuItemButton>
<EuiKeyPadMenuItemButton label="Kubernetes" onClick={this.handleClick(InfraNodeType.pod)}>
<img
src="../plugins/infra/images/k8.svg"
role="presentation"
alt=""
className="euiIcon euiIcon--large"
/>
</EuiKeyPadMenuItemButton>
<EuiKeyPadMenuItemButton label="Docker" onClick={this.handleClick(InfraNodeType.container)}>
<img
src="../plugins/infra/images/docker.svg"
role="presentation"
alt=""
className="euiIcon euiIcon--large"
/>
</EuiKeyPadMenuItemButton>
</EuiKeyPadMenu>
<EuiButtonGroup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the EUI docs recommend the small button size for groups, but how about setting buttonSize="m" on this one? To my eye the heights and spacing in

grafik

look a lot more harmonious than with the default size s

grafik

Copy link
Contributor Author

@Kerry350 Kerry350 Mar 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I agree. I have changed this, but there is a little bit of an issue with the EUI typings for this component.

Screenshot 2019-03-12 14 25 26

The <EuiButtonGroup /> component allows "m" for buttonSize. But, that component in it's tree renders a <EuiButton /> which only allows "s" and "l". There is a mismatch here; I can either leave the change in, we ignore the console warning for now, and I file a ticket against EUI. Or don't make the change so we don't have an error, file against EUI, change it once the EUI side is changed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I hadn't noticed that. I would say we should file an issue in EUI (or a PR, given the simplicity of the change) and leave it in for now.

legend="Node type selection"
color="primary"
options={nodeOptions}
idSelected={this.props.nodeType}
onChange={this.handleClick}
buttonSize="m"
/>
);
}

private handleClick = (nodeType: InfraNodeType) => () => {
this.props.changeNodeType(nodeType);
private handleClick = (nodeType: string) => {
Kerry350 marked this conversation as resolved.
Show resolved Hide resolved
this.props.changeNodeType(nodeType as InfraNodeType);
this.props.changeGroupBy([]);
this.props.changeMetric({ type: InfraMetricType.cpu });
};
}

export const WaffleNodeTypeSwitcher = injectI18n(WaffleNodeTypeSwitcherClass);
56 changes: 56 additions & 0 deletions x-pack/plugins/infra/public/pages/infrastructure/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React from 'react';
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
import { DocumentTitle } from '../../components/document_title';
import { HelpCenterContent } from '../../components/help_center_content';
import { RoutedTabs } from '../../components/navigation/routed_tabs';
import { ColumnarPage } from '../../components/page';
import { MetricsExplorerPage } from './metrics_explorer';
import { SnapshotPage } from './snapshot';

interface InfrastructurePageProps extends RouteComponentProps {
intl: InjectedIntl;
}

export const InfrastructurePage = injectI18n(({ match, intl }: InfrastructurePageProps) => (
<ColumnarPage>
<DocumentTitle
title={intl.formatMessage({
id: 'xpack.infra.homePage.documentTitle',
defaultMessage: 'Infrastructure',
})}
/>

<HelpCenterContent
feedbackLink="https://discuss.elastic.co/c/infrastructure"
feedbackLinkText={intl.formatMessage({
id: 'xpack.infra.infrastructure.infrastructureHelpContent.feedbackLinkText',
defaultMessage: 'Provide feedback for Infrastructure',
})}
/>

<RoutedTabs
tabs={[
{
title: 'Snapshot',
path: `${match.path}/snapshot`,
},
// {
// title: 'Metrics explorer',
// path: `${match.path}/metrics-explorer`,
// },
]}
/>

<Switch>
<Route path={`${match.path}/snapshot`} component={SnapshotPage} />
<Route path={`${match.path}/metrics-explorer`} component={MetricsExplorerPage} />
</Switch>
</ColumnarPage>
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React from 'react';
import { DocumentTitle } from '../../../components/document_title';

interface MetricsExplorerPageProps {
intl: InjectedIntl;
}

export const MetricsExplorerPage = injectI18n(({ intl }: MetricsExplorerPageProps) => (
<div>
<DocumentTitle
title={(previousTitle: string) =>
intl.formatMessage(
{
id: 'xpack.infra.infrastructureMetricsExplorerPage.documentTitle',
defaultMessage: '{previousTitle} | Metrics explorer',
},
{
previousTitle,
}
)
}
/>
Metrics Explorer
</div>
));
Loading