-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Add Managed label to data streams and a view switch for the table #83049
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
Changes from 3 commits
b669bca
7190c28
2661b2e
77a02c4
2c781af
1048166
33469e4
0c7efef
ea4c669
230efd5
69f4146
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * 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 { DataStream } from '../../../common'; | ||
|
|
||
| export const isManagedByIngestManager = (dataStream: DataStream): boolean => { | ||
| return Boolean(dataStream._meta?.managed && dataStream._meta?.managed_by === 'ingest-manager'); | ||
| }; | ||
|
|
||
| export const filterDataStreams = (dataStreams: DataStream[], managed: boolean): DataStream[] => { | ||
| return dataStreams.filter((dataStream: DataStream) => | ||
| managed ? isManagedByIngestManager(dataStream) : !isManagedByIngestManager(dataStream) | ||
|
||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ import { documentationService } from '../../../services/documentation'; | |
| import { Section } from '../home'; | ||
| import { DataStreamTable } from './data_stream_table'; | ||
| import { DataStreamDetailPanel } from './data_stream_detail_panel'; | ||
| import { filterDataStreams } from '../../../lib/data_streams'; | ||
|
|
||
| interface MatchParams { | ||
| dataStreamName?: string; | ||
|
|
@@ -52,6 +53,7 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
| } = useAppContext(); | ||
|
|
||
| const [isIncludeStatsChecked, setIsIncludeStatsChecked] = useState(false); | ||
| const [isIncludeManagedChecked, setIsIncludeManagedChecked] = useState(true); | ||
| const { error, isLoading, data: dataStreams, resendRequest: reload } = useLoadDataStreams({ | ||
| includeStats: isIncludeStatsChecked, | ||
| }); | ||
|
|
@@ -147,11 +149,13 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
| /> | ||
| ); | ||
| } else if (Array.isArray(dataStreams) && dataStreams.length > 0) { | ||
| const filteredDataStreams = isIncludeManagedChecked | ||
| ? dataStreams | ||
| : filterDataStreams(dataStreams, isIncludeManagedChecked); | ||
| content = ( | ||
| <> | ||
| <EuiFlexGroup alignItems="center" justifyContent="spaceBetween"> | ||
| <EuiFlexItem> | ||
| {/* TODO: Add a switch for toggling on data streams created by Ingest Manager */} | ||
| <EuiText color="subdued"> | ||
| <FormattedMessage | ||
| id="xpack.idxMgmt.dataStreamList.dataStreamsDescription" | ||
|
|
@@ -202,6 +206,16 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiSwitch | ||
| label={i18n.translate('xpack.idxMgmt.dataStreamListControls.viewManagedSwitchLabel', { | ||
| defaultMessage: 'View managed', | ||
|
||
| })} | ||
| checked={isIncludeManagedChecked} | ||
| onChange={(e) => setIsIncludeManagedChecked(e.target.checked)} | ||
| data-test-subj="viewManagedSwitch" | ||
| /> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
|
|
||
| <EuiSpacer size="l" /> | ||
|
|
@@ -212,7 +226,7 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
| ? `name="${attemptToURIDecode(dataStreamName)}"` | ||
| : '' | ||
| } | ||
| dataStreams={dataStreams} | ||
| dataStreams={filteredDataStreams} | ||
| reload={reload} | ||
| history={history as ScopedHistory} | ||
| includeStats={isIncludeStatsChecked} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,10 @@ | |
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import React, { useState, Fragment } from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { EuiInMemoryTable, EuiBasicTableColumn, EuiButton, EuiLink } from '@elastic/eui'; | ||
| import { EuiInMemoryTable, EuiBasicTableColumn, EuiButton, EuiLink, EuiBadge } from '@elastic/eui'; | ||
| import { ScopedHistory } from 'kibana/public'; | ||
|
|
||
| import { DataStream } from '../../../../../../common/types'; | ||
|
|
@@ -16,6 +16,7 @@ import { getDataStreamDetailsLink, getIndexListUri } from '../../../../services/ | |
| import { DataHealth } from '../../../../components'; | ||
| import { DeleteDataStreamConfirmationModal } from '../delete_data_stream_confirmation_modal'; | ||
| import { humanizeTimeStamp } from '../humanize_time_stamp'; | ||
| import { isManagedByIngestManager } from '../../../../lib/data_streams'; | ||
|
|
||
| interface Props { | ||
| dataStreams?: DataStream[]; | ||
|
|
@@ -44,14 +45,27 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({ | |
| }), | ||
| truncateText: true, | ||
| sortable: true, | ||
| render: (name: DataStream['name']) => { | ||
| render: (name: DataStream['name'], dataStream: DataStream) => { | ||
| return ( | ||
| <EuiLink | ||
| data-test-subj="nameLink" | ||
| {...reactRouterNavigate(history, getDataStreamDetailsLink(name))} | ||
| > | ||
| {name} | ||
| </EuiLink> | ||
| <Fragment> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (nit) you can use shorthand |
||
| <EuiLink | ||
| data-test-subj="nameLink" | ||
| {...reactRouterNavigate(history, getDataStreamDetailsLink(name))} | ||
| > | ||
| {name} | ||
| </EuiLink> | ||
| {isManagedByIngestManager(dataStream) ? ( | ||
| <Fragment> | ||
| | ||
| <EuiBadge color="hollow"> | ||
|
||
| <FormattedMessage | ||
| id="xpack.idxMgmt.dataStreamList.table.managedDataStreamBadge" | ||
| defaultMessage="Managed" | ||
| /> | ||
| </EuiBadge> | ||
| </Fragment> | ||
| ) : null} | ||
| </Fragment> | ||
| ); | ||
| }, | ||
| }); | ||
|
|
@@ -121,7 +135,7 @@ export const DataStreamTable: React.FunctionComponent<Props> = ({ | |
| name: i18n.translate('xpack.idxMgmt.dataStreamList.table.actionDeleteText', { | ||
| defaultMessage: 'Delete', | ||
| }), | ||
| description: i18n.translate('xpack.idxMgmt.dataStreamList.table.actionDeleteDecription', { | ||
| description: i18n.translate('xpack.idxMgmt.dataStreamList.table.actionDeleteDescription', { | ||
| defaultMessage: 'Delete this data stream', | ||
| }), | ||
| icon: 'trash', | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.