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

[Ingest] Data streams list page #64134

Merged
merged 8 commits into from
Apr 23, 2020
Merged
8 changes: 7 additions & 1 deletion x-pack/plugins/ingest_manager/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
// Base API paths
export const API_ROOT = `/api/ingest_manager`;
export const EPM_API_ROOT = `${API_ROOT}/epm`;
export const DATA_STREAM_API_ROOT = `${API_ROOT}/data_streams`;
export const DATASOURCE_API_ROOT = `${API_ROOT}/datasources`;
export const AGENT_CONFIG_API_ROOT = `${API_ROOT}/agent_configs`;
export const EPM_API_ROOT = `${API_ROOT}/epm`;
export const FLEET_API_ROOT = `${API_ROOT}/fleet`;

// EPM API routes
Expand All @@ -23,6 +24,11 @@ export const EPM_API_ROUTES = {
CATEGORIES_PATTERN: `${EPM_API_ROOT}/categories`,
};

// Data stream API routes
export const DATA_STREAM_API_ROUTES = {
LIST_PATTERN: `${DATA_STREAM_API_ROOT}`,
};

// Datasource API routes
export const DATASOURCE_API_ROUTES = {
LIST_PATTERN: `${DATASOURCE_API_ROOT}`,
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/ingest_manager/common/services/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
EPM_API_ROUTES,
DATASOURCE_API_ROUTES,
AGENT_CONFIG_API_ROUTES,
DATA_STREAM_API_ROUTES,
FLEET_SETUP_API_ROUTES,
AGENT_API_ROUTES,
ENROLLMENT_API_KEY_ROUTES,
Expand Down Expand Up @@ -88,6 +89,12 @@ export const agentConfigRouteService = {
},
};

export const dataStreamRouteService = {
getListPath: () => {
return DATA_STREAM_API_ROUTES.LIST_PATTERN;
},
};

export const fleetSetupRouteService = {
getFleetSetupPath: () => FLEET_SETUP_API_ROUTES.INFO_PATTERN,
postFleetSetupPath: () => FLEET_SETUP_API_ROUTES.CREATE_PATTERN,
Expand Down
15 changes: 15 additions & 0 deletions x-pack/plugins/ingest_manager/common/types/models/data_stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 interface DataStream {
index: string;
dataset: string;
namespace: string;
type: string;
package: string;
last_activity: string;
size_in_bytes: number;
}
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/common/types/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export * from './agent';
export * from './agent_config';
export * from './datasource';
export * from './data_stream';
export * from './output';
export * from './epm';
export * from './enrollment_api_key';
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { DataStream } from '../models';

export const GetFleetSetupRequestSchema = {};

export const CreateFleetSetupRequestSchema = {};

export interface CreateFleetSetupResponse {
isInitialized: boolean;
export interface GetDataStreamsResponse {
data_streams: DataStream[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface GetFleetSetupRequest {}

export interface CreateFleetSetupRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you talk about these changes? It's not clear to me why we're also making changes to the Fleet setup behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No behavioral changes, just cleaning up typings: e0e62b1

GetFleetSetupRequest, CreateFleetSetupRequest, and CreateFleetSetupResponse were duplicated in server/types/rest_spec/fleet_setup.ts, so I removed that file and kept this one in /common (to match with our existing structure).

GetFleetSetupRequest is empty so I removed it. CreateFleetSetupRequest is invalid as we no longer require username/password as part of the setup endpoint request, so it's also empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Thanks for the additional info. I wasn't aware of the duplication or that we don't require user/pass any longer for setup.

I feel like setting validate: false is a step backwards (platform/security encourage them for a reason). I'd prefer to keep that but it's nothing to hold up this change.

body: {
fleet_enroll_username: string;
fleet_enroll_password: string;
};
}

export interface CreateFleetSetupResponse {
isInitialized: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
export * from './common';
export * from './datasource';
export * from './data_stream';
export * from './agent';
export * from './agent_config';
export * from './fleet_setup';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const EPM_LIST_INSTALLED_PACKAGES_PATH = `${EPM_PATH}/installed`;
export const EPM_DETAIL_VIEW_PATH = `${EPM_PATH}/detail/:pkgkey/:panel?`;
export const AGENT_CONFIG_PATH = '/configs';
export const AGENT_CONFIG_DETAILS_PATH = `${AGENT_CONFIG_PATH}/`;
export const DATA_STREAM_PATH = '/data-streams';
export const FLEET_PATH = '/fleet';
export const FLEET_AGENTS_PATH = `${FLEET_PATH}/agents`;
export const FLEET_AGENT_DETAIL_PATH = `${FLEET_AGENTS_PATH}/`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { useRequest } from './use_request';
import { dataStreamRouteService } from '../../services';
import { GetDataStreamsResponse } from '../../types';

export const useGetDataStreams = () => {
return useRequest<GetDataStreamsResponse>({
path: dataStreamRouteService.getListPath(),
method: 'get',
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export { setHttpClient, sendRequest, useRequest } from './use_request';
export * from './agent_config';
export * from './datasource';
export * from './data_stream';
export * from './agents';
export * from './enrollment_api_keys';
export * from './epm';
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
IngestManagerConfigType,
IngestManagerStartDeps,
} from '../../plugin';
import { EPM_PATH, FLEET_PATH, AGENT_CONFIG_PATH } from './constants';
import { EPM_PATH, FLEET_PATH, AGENT_CONFIG_PATH, DATA_STREAM_PATH } from './constants';
import { DefaultLayout, WithoutHeaderLayout } from './layouts';
import { Loading, Error } from './components';
import { IngestManagerOverview, EPMApp, AgentConfigApp, FleetApp } from './sections';
import { IngestManagerOverview, EPMApp, AgentConfigApp, FleetApp, DataStreamApp } from './sections';
import { CoreContext, DepsContext, ConfigContext, setHttpClient, useConfig } from './hooks';
import { PackageInstallProvider } from './sections/epm/hooks';
import { sendSetup } from './hooks/use_request/setup';
Expand Down Expand Up @@ -98,6 +98,11 @@ const IngestManagerRoutes = ({ ...rest }) => {
<AgentConfigApp />
</DefaultLayout>
</Route>
<Route path={DATA_STREAM_PATH}>
<DefaultLayout section="data_stream">
<DataStreamApp />
</DefaultLayout>
</Route>
<ProtectedRoute path={FLEET_PATH} isAllowed={fleet.enabled}>
<DefaultLayout section="fleet">
<FleetApp />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { Section } from '../sections';
import { AlphaMessaging } from '../components';
import { useLink, useConfig } from '../hooks';
import { EPM_PATH, FLEET_PATH, AGENT_CONFIG_PATH } from '../constants';
import { EPM_PATH, FLEET_PATH, AGENT_CONFIG_PATH, DATA_STREAM_PATH } from '../constants';

interface Props {
section?: Section;
Expand Down Expand Up @@ -76,6 +76,12 @@ export const DefaultLayout: React.FunctionComponent<Props> = ({ section, childre
defaultMessage="Fleet"
/>
</EuiTab>
<EuiTab isSelected={section === 'data_stream'} href={useLink(DATA_STREAM_PATH)}>
<FormattedMessage
id="xpack.ingestManager.appNavigation.dataStreamsLinkText"
defaultMessage="Data streams"
/>
</EuiTab>
</EuiTabs>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export const AgentConfigListPage: React.FunctionComponent<{}> = () => {
defaultMessage: 'Name',
}),
width: '20%',
// FIXME: use version once available - see: https://github.com/elastic/kibana/issues/56750
render: (name: string, agentConfig: AgentConfig) => (
<EuiFlexGroup gutterSize="s" alignItems="baseline" style={{ minWidth: 0 }}>
<EuiFlexItem grow={false} style={NO_WRAP_TRUNCATE_STYLE}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 React from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import { DataStreamListPage } from './list_page';

export const DataStreamApp: React.FunctionComponent = () => {
return (
<Router>
<Switch>
<Route path="/data-streams">
<DataStreamListPage />
</Route>
</Switch>
</Router>
);
};
Loading