Skip to content

Commit

Permalink
Fix breadcrumbs for react ES pages so far (#113087)
Browse files Browse the repository at this point in the history
  • Loading branch information
matschaffer authored and kibanamachine committed Sep 28, 2021
1 parent d20ecc8 commit 0c32d59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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 React, { useContext, useState, useCallback, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { find } from 'lodash';
import { ElasticsearchTemplate } from './elasticsearch_template';
Expand All @@ -16,6 +16,7 @@ import { ComponentProps } from '../../route_init';
import { SetupModeRenderer } from '../../setup_mode/setup_mode_renderer';
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context';
import { useTable } from '../../hooks/use_table';
import { BreadcrumbContainer } from '../../hooks/use_breadcrumbs';

interface SetupModeProps {
setupMode: any;
Expand All @@ -27,13 +28,14 @@ export const ElasticsearchNodesPage: React.FC<ComponentProps> = ({ clusters }) =
const globalState = useContext(GlobalStateContext);
const { showCgroupMetricsElasticsearch } = useContext(ExternalConfigContext);
const { services } = useKibana<{ data: any }>();
const { generate: generateBreadcrumbs } = useContext(BreadcrumbContainer.Context);
const { getPaginationRouteOptions, updateTotalItemCount, getPaginationTableProps } =
useTable('elasticsearch.nodes');
const clusterUuid = globalState.cluster_uuid;
const ccs = globalState.ccs;
const cluster = find(clusters, {
cluster_uuid: clusterUuid,
});
}) as any;
const [data, setData] = useState({} as any);

const title = i18n.translate('xpack.monitoring.elasticsearch.nodes.routeTitle', {
Expand All @@ -44,6 +46,14 @@ export const ElasticsearchNodesPage: React.FC<ComponentProps> = ({ clusters }) =
defaultMessage: 'Elasticsearch nodes',
});

useEffect(() => {
if (cluster) {
generateBreadcrumbs(cluster.cluster_name, {
inElasticsearch: true,
});
}
}, [cluster, generateBreadcrumbs]);

const getPageData = useCallback(async () => {
const bounds = services.data?.query.timefilter.timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch/nodes`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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 React, { useContext, useState, useCallback, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { find } from 'lodash';
import { ElasticsearchTemplate } from './elasticsearch_template';
Expand All @@ -13,16 +13,18 @@ import { GlobalStateContext } from '../../global_state_context';
import { ElasticsearchOverview } from '../../../components/elasticsearch';
import { ComponentProps } from '../../route_init';
import { useCharts } from '../../hooks/use_charts';
import { BreadcrumbContainer } from '../../hooks/use_breadcrumbs';

export const ElasticsearchOverviewPage: React.FC<ComponentProps> = ({ clusters }) => {
const globalState = useContext(GlobalStateContext);
const { zoomInfo, onBrush } = useCharts();
const { services } = useKibana<{ data: any }>();
const { generate: generateBreadcrumbs } = useContext(BreadcrumbContainer.Context);
const clusterUuid = globalState.cluster_uuid;
const ccs = globalState.ccs;
const cluster = find(clusters, {
cluster_uuid: clusterUuid,
});
}) as any;
const [data, setData] = useState(null);
const [showShardActivityHistory, setShowShardActivityHistory] = useState(false);
const toggleShardActivityHistory = () => {
Expand All @@ -42,6 +44,14 @@ export const ElasticsearchOverviewPage: React.FC<ComponentProps> = ({ clusters }
defaultMessage: 'Elasticsearch overview',
});

useEffect(() => {
if (cluster) {
generateBreadcrumbs(cluster.cluster_name, {
inElasticsearch: true,
});
}
}, [cluster, generateBreadcrumbs]);

const getPageData = useCallback(async () => {
const bounds = services.data?.query.timefilter.timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch`;
Expand Down

0 comments on commit 0c32d59

Please sign in to comment.