-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Stack Monitoring] Migrate Index Views to React #113660
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/monitoring/public/application/pages/elasticsearch/index_advanced_page.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,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React, { useContext, useState, useCallback } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { GlobalStateContext } from '../../global_state_context'; | ||
import { ComponentProps } from '../../route_init'; | ||
import { SetupModeRenderer } from '../../setup_mode/setup_mode_renderer'; | ||
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context'; | ||
import { useCharts } from '../../hooks/use_charts'; | ||
import { ItemTemplate } from './item_template'; | ||
// @ts-ignore | ||
import { AdvancedIndex } from '../../../components/elasticsearch/index/advanced'; | ||
|
||
interface SetupModeProps { | ||
setupMode: any; | ||
flyoutComponent: any; | ||
bottomBarComponent: any; | ||
} | ||
|
||
export const ElasticsearchIndexAdvancedPage: React.FC<ComponentProps> = ({ clusters }) => { | ||
const globalState = useContext(GlobalStateContext); | ||
const { services } = useKibana<{ data: any }>(); | ||
const { index }: { index: string } = useParams(); | ||
const { zoomInfo, onBrush } = useCharts(); | ||
const clusterUuid = globalState.cluster_uuid; | ||
const [data, setData] = useState({} as any); | ||
|
||
const title = i18n.translate('xpack.monitoring.elasticsearch.index.advanced.title', { | ||
defaultMessage: 'Elasticsearch - Indices - {indexName} - Advanced', | ||
values: { | ||
indexName: index, | ||
}, | ||
}); | ||
|
||
const getPageData = useCallback(async () => { | ||
const bounds = services.data?.query.timefilter.timefilter.getBounds(); | ||
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch/indices/${index}`; | ||
const response = await services.http?.fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
timeRange: { | ||
min: bounds.min.toISOString(), | ||
max: bounds.max.toISOString(), | ||
}, | ||
is_advanced: true, | ||
}), | ||
}); | ||
setData(response); | ||
}, [clusterUuid, services.data?.query.timefilter.timefilter, services.http, index]); | ||
|
||
return ( | ||
<ItemTemplate title={title} getPageData={getPageData} id={index} pageType="indices"> | ||
<SetupModeRenderer | ||
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => ( | ||
<SetupModeContext.Provider value={{ setupModeSupported: true }}> | ||
{flyoutComponent} | ||
<AdvancedIndex | ||
setupMode={setupMode} | ||
alerts={{}} | ||
indexSummary={data.indexSummary} | ||
metrics={data.metrics} | ||
onBrush={onBrush} | ||
zoomInfo={zoomInfo} | ||
/> | ||
{bottomBarComponent} | ||
</SetupModeContext.Provider> | ||
)} | ||
/> | ||
</ItemTemplate> | ||
); | ||
}; |
106 changes: 106 additions & 0 deletions
106
x-pack/plugins/monitoring/public/application/pages/elasticsearch/index_page.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,106 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React, { useContext, useState, useCallback } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { GlobalStateContext } from '../../global_state_context'; | ||
// @ts-ignore | ||
import { IndexReact } from '../../../components/elasticsearch/index/index_react'; | ||
import { ComponentProps } from '../../route_init'; | ||
import { SetupModeRenderer } from '../../setup_mode/setup_mode_renderer'; | ||
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context'; | ||
import { useCharts } from '../../hooks/use_charts'; | ||
import { ItemTemplate } from './item_template'; | ||
// @ts-ignore | ||
import { indicesByNodes } from '../../../components/elasticsearch/shard_allocation/transformers/indices_by_nodes'; | ||
// @ts-ignore | ||
import { labels } from '../../../components/elasticsearch/shard_allocation/lib/labels'; | ||
|
||
interface SetupModeProps { | ||
setupMode: any; | ||
flyoutComponent: any; | ||
bottomBarComponent: any; | ||
} | ||
|
||
export const ElasticsearchIndexPage: React.FC<ComponentProps> = ({ clusters }) => { | ||
const globalState = useContext(GlobalStateContext); | ||
const { services } = useKibana<{ data: any }>(); | ||
const { index }: { index: string } = useParams(); | ||
const { zoomInfo, onBrush } = useCharts(); | ||
const clusterUuid = globalState.cluster_uuid; | ||
const [data, setData] = useState({} as any); | ||
const [indexLabel, setIndexLabel] = useState(labels.index as any); | ||
const [nodesByIndicesData, setNodesByIndicesData] = useState([]); | ||
|
||
const title = i18n.translate('xpack.monitoring.elasticsearch.index.overview.title', { | ||
defaultMessage: 'Elasticsearch - Indices - {indexName} - Overview', | ||
values: { | ||
indexName: index, | ||
}, | ||
}); | ||
|
||
const pageTitle = i18n.translate('xpack.monitoring.elasticsearch.index.overview.pageTitle', { | ||
defaultMessage: 'Index: {indexName}', | ||
values: { | ||
indexName: index, | ||
}, | ||
}); | ||
|
||
const getPageData = useCallback(async () => { | ||
const bounds = services.data?.query.timefilter.timefilter.getBounds(); | ||
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch/indices/${index}`; | ||
const response = await services.http?.fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
timeRange: { | ||
min: bounds.min.toISOString(), | ||
max: bounds.max.toISOString(), | ||
}, | ||
is_advanced: false, | ||
}), | ||
}); | ||
setData(response); | ||
const transformer = indicesByNodes(); | ||
setNodesByIndicesData(transformer(response.shards, response.nodes)); | ||
|
||
const shards = response.shards; | ||
if (shards.some((shard: any) => shard.state === 'UNASSIGNED')) { | ||
setIndexLabel(labels.indexWithUnassigned); | ||
} | ||
}, [clusterUuid, services.data?.query.timefilter.timefilter, services.http, index]); | ||
|
||
return ( | ||
<ItemTemplate | ||
title={title} | ||
pageTitle={pageTitle} | ||
getPageData={getPageData} | ||
id={index} | ||
pageType="indices" | ||
> | ||
<SetupModeRenderer | ||
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => ( | ||
<SetupModeContext.Provider value={{ setupModeSupported: true }}> | ||
{flyoutComponent} | ||
<IndexReact | ||
setupMode={setupMode} | ||
labels={indexLabel} | ||
alerts={{}} | ||
onBrush={onBrush} | ||
indexUuid={index} | ||
clusterUuid={clusterUuid} | ||
zoomInfo={zoomInfo} | ||
nodesByIndices={nodesByIndicesData} | ||
{...data} | ||
/> | ||
{bottomBarComponent} | ||
</SetupModeContext.Provider> | ||
)} | ||
/> | ||
</ItemTemplate> | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/monitoring/public/application/pages/elasticsearch/item_template.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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { PageTemplate } from '../page_template'; | ||
import { TabMenuItem, PageTemplateProps } from '../page_template'; | ||
|
||
interface ItemTemplateProps extends PageTemplateProps { | ||
id: string; | ||
pageType: string; | ||
} | ||
export const ItemTemplate: React.FC<ItemTemplateProps> = (props) => { | ||
const { pageType, id, ...rest } = props; | ||
const tabs: TabMenuItem[] = [ | ||
{ | ||
id: 'overview', | ||
label: i18n.translate('xpack.monitoring.esItemNavigation.overviewLinkText', { | ||
defaultMessage: 'Overview', | ||
}), | ||
route: `/elasticsearch/${pageType}/${id}`, | ||
}, | ||
{ | ||
id: 'advanced', | ||
label: i18n.translate('xpack.monitoring.esItemNavigation.advancedLinkText', { | ||
defaultMessage: 'Advanced', | ||
}), | ||
route: `/elasticsearch/${pageType}/${id}/advanced`, | ||
}, | ||
]; | ||
|
||
return <PageTemplate {...rest} tabs={tabs} product="elasticsearch" />; | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So weird that there's a setup mode here (that doesn't seem to do anything), but it's the same on angular so 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I was tempted to remove it. There's no action to take from what I could see.