Skip to content

Commit

Permalink
[Stack monitoring] Remove getAngularInjector and duplicated angular c…
Browse files Browse the repository at this point in the history
…omponents (#115593)

* remove getAngularInjector and old angular components

* Remove suffix from CcrShardReact component

* Remove suffix from ElasticsearchOverviewReact component

* Remove suffix from indexReact component

* Remove suffix from NodeReact component

* Remove suffix from ShardActivityReact

* Remove suffix from ShardAllocationReact component and its childs

* Fix import

* fix translations

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/monitoring/public/components/elasticsearch/node/node.js
  • Loading branch information
estermv committed Oct 20, 2021
1 parent 18a137c commit 6c3750d
Show file tree
Hide file tree
Showing 39 changed files with 136 additions and 1,319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PageTemplate } from '../page_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../contexts/global_state_context';
// @ts-ignore
import { CcrShardReact } from '../../../components/elasticsearch/ccr_shard';
import { CcrShard } from '../../../components/elasticsearch/ccr_shard';
import { ComponentProps } from '../../route_init';
import { SetupModeRenderer, SetupModeProps } from '../../../components/renderers/setup_mode';
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context';
Expand Down Expand Up @@ -113,7 +113,7 @@ export const ElasticsearchCcrShardPage: React.FC<ComponentProps> = ({ clusters }
render={({ flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<CcrShardReact {...data} alerts={alerts} />
<CcrShard {...data} alerts={alerts} />
{bottomBarComponent}
</SetupModeContext.Provider>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { find } from 'lodash';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../contexts/global_state_context';
// @ts-ignore
import { IndexReact } from '../../../components/elasticsearch/index/index_react';
import { Index } from '../../../components/elasticsearch/index/index';
import { ComponentProps } from '../../route_init';
import { SetupModeRenderer, SetupModeProps } from '../../../components/renderers/setup_mode';
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context';
Expand Down Expand Up @@ -118,7 +118,7 @@ export const ElasticsearchIndexPage: React.FC<ComponentProps> = ({ clusters }) =
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<IndexReact
<Index
setupMode={setupMode}
labels={indexLabel}
alerts={alerts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
import { ItemTemplate } from './item_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../contexts/global_state_context';
import { NodeReact } from '../../../components/elasticsearch';
import { Node } from '../../../components/elasticsearch';
import { ComponentProps } from '../../route_init';
import { SetupModeRenderer, SetupModeProps } from '../../../components/renderers/setup_mode';
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context';
Expand Down Expand Up @@ -143,7 +143,7 @@ export const ElasticsearchNodePage: React.FC<ComponentProps> = ({ clusters }) =>
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<NodeReact
<Node
alerts={alerts}
labels={labels.node}
nodeId={node}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ElasticsearchTemplate } from './elasticsearch_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../contexts/global_state_context';
// @ts-ignore
import { ElasticsearchOverviewReact } from '../../../components/elasticsearch';
import { ElasticsearchOverview } from '../../../components/elasticsearch';
import { ComponentProps } from '../../route_init';
import { useCharts } from '../../hooks/use_charts';
import { BreadcrumbContainer } from '../../hooks/use_breadcrumbs';
Expand Down Expand Up @@ -79,7 +79,7 @@ export const ElasticsearchOverviewPage: React.FC<ComponentProps> = ({ clusters }
const shardActivityData = shardActivity && filterShardActivityData(shardActivity); // no filter on data = null

return (
<ElasticsearchOverviewReact
<ElasticsearchOverview
clusterStatus={clusterStatus}
metrics={metrics}
logs={logs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ import { merge } from 'lodash';
import { CHART_LINE_COLOR, CHART_TEXT_COLOR } from '../../../common/constants';

export async function getChartOptions(axisOptions) {
let timezone;
try {
const $injector = Legacy.shims.getAngularInjector();
timezone = $injector.get('config').get('dateFormat:tz');
} catch (error) {
if (error.message === 'Angular has been removed.') {
timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
} else {
throw error;
}
}
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');

const opts = {
legend: {
show: false,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import React, { Fragment, PureComponent } from 'react';
import { Legacy } from '../../../legacy_shims';
import React, { Fragment } from 'react';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import {
EuiPage,
EuiPageBody,
Expand All @@ -28,9 +28,11 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { AlertsCallout } from '../../../alerts/callout';

export class CcrShard extends PureComponent {
renderCharts() {
const { metrics } = this.props;
export function CcrShard(props) {
const { services } = useKibana();
const timezone = services.uiSettings?.get('dateFormat:tz');
const { metrics, stat, timestamp, oldestStat, formattedLeader, alerts } = props;
const renderCharts = () => {
const seriesToShow = [metrics.ccr_sync_lag_ops, metrics.ccr_sync_lag_time];

const charts = seriesToShow.map((data, index) => (
Expand All @@ -42,10 +44,9 @@ export class CcrShard extends PureComponent {
));

return <Fragment>{charts}</Fragment>;
}
};

renderErrors() {
const { stat } = this.props;
const renderErrors = () => {
if (stat.read_exceptions && stat.read_exceptions.length > 0) {
return (
<Fragment>
Expand Down Expand Up @@ -91,13 +92,9 @@ export class CcrShard extends PureComponent {
);
}
return null;
}

renderLatestStat() {
const { stat, timestamp } = this.props;
const injector = Legacy.shims.getAngularInjector();
const timezone = injector.get('config').get('dateFormat:tz');
};

const renderLatestStat = () => {
return (
<EuiAccordion
id="ccrLatestStat"
Expand All @@ -122,31 +119,27 @@ export class CcrShard extends PureComponent {
</Fragment>
</EuiAccordion>
);
}

render() {
const { stat, oldestStat, formattedLeader, alerts } = this.props;
};

return (
<EuiPage>
<EuiPageBody>
<EuiPanel>
<Status
stat={stat}
formattedLeader={formattedLeader}
oldestStat={oldestStat}
alerts={alerts}
/>
</EuiPanel>
<EuiSpacer size="m" />
<AlertsCallout alerts={alerts} />
<EuiSpacer size="m" />
{this.renderErrors()}
<EuiFlexGroup wrap>{this.renderCharts()}</EuiFlexGroup>
<EuiHorizontalRule />
{this.renderLatestStat()}
</EuiPageBody>
</EuiPage>
);
}
return (
<EuiPage>
<EuiPageBody>
<EuiPanel>
<Status
stat={stat}
formattedLeader={formattedLeader}
oldestStat={oldestStat}
alerts={alerts}
/>
</EuiPanel>
<EuiSpacer size="m" />
<AlertsCallout alerts={alerts} />
<EuiSpacer size="m" />
{renderErrors()}
<EuiFlexGroup wrap>{renderCharts()}</EuiFlexGroup>
<EuiHorizontalRule />
{renderLatestStat()}
</EuiPageBody>
</EuiPage>
);
}
Loading

0 comments on commit 6c3750d

Please sign in to comment.