[monitoring] fixup types (#114342)
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
badc77828e
commit
9667edf808
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { useState, useCallback } from 'react';
|
||||
import { EuiTableSortingType } from '@elastic/eui';
|
||||
import { euiTableStorageGetter, euiTableStorageSetter } from '../../components/table';
|
||||
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
|
@ -23,12 +24,7 @@ interface Page {
|
|||
index: number;
|
||||
}
|
||||
|
||||
interface Sorting {
|
||||
sort: {
|
||||
field: string;
|
||||
direction: string;
|
||||
};
|
||||
}
|
||||
type Sorting = EuiTableSortingType<string>;
|
||||
|
||||
const PAGE_SIZE_OPTIONS = [5, 10, 20, 50];
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const SetupModeRenderer: FunctionComponent<Props>;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const SetupModeRenderer: FunctionComponent<Record<any, any>>;
|
||||
export interface SetupModeProps {
|
||||
setupMode: any;
|
||||
flyoutComponent: any;
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { StatusIcon } from '../../components/status_icon';
|
||||
import { StatusIcon, STATUS_ICON_TYPES } from '../../components/status_icon';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function ApmStatusIcon({ status, availability = true }) {
|
||||
const type = (() => {
|
||||
if (!availability) {
|
||||
return StatusIcon.TYPES.GRAY;
|
||||
return STATUS_ICON_TYPES.GRAY;
|
||||
}
|
||||
|
||||
const statusKey = status.toUpperCase();
|
||||
return StatusIcon.TYPES[statusKey] || StatusIcon.TYPES.YELLOW;
|
||||
return STATUS_ICON_TYPES[statusKey] || STATUS_ICON_TYPES.YELLOW;
|
||||
})();
|
||||
|
||||
return (
|
||||
|
|
|
@ -5,4 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const Overview: FunctionComponent<Props>;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const Overview: FunctionComponent<OverviewProps>;
|
||||
|
||||
export interface OverviewProps {
|
||||
cluster: unknown;
|
||||
setupMode: unknown;
|
||||
showLicenseExpiration: boolean;
|
||||
alerts: unknown;
|
||||
}
|
||||
|
|
|
@ -5,4 +5,11 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const ClusterStatus: FunctionComponent<Props>;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const ClusterStatus: FunctionComponent<ClusterStatusProps>;
|
||||
|
||||
export interface ClusterStatusProps {
|
||||
stats: unknown;
|
||||
alerts?: unknown;
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const ElasticsearchOverview: FunctionComponent<Props>;
|
||||
export const ElasticsearchNodes: FunctionComponent<Props>;
|
||||
export const ElasticsearchIndices: FunctionComponent<Props>;
|
||||
export const ElasticsearchMLJobs: FunctionComponent<Props>;
|
||||
export const NodeReact: FunctionComponent<Props>;
|
20
x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.d.ts
vendored
Normal file
20
x-pack/plugins/monitoring/public/components/elasticsearch/indices/indices.d.ts
vendored
Normal file
|
@ -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
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const ElasticsearchIndices: FunctionComponent<ElasticsearchIndicesProps>;
|
||||
export interface ElasticsearchIndicesProps {
|
||||
clusterStatus: unknown;
|
||||
indices: unknown;
|
||||
sorting: unknown;
|
||||
pagination: unknown;
|
||||
onTableChange: unknown;
|
||||
toggleShowSystemIndices: unknown;
|
||||
showSystemIndices: unknown;
|
||||
alerts: unknown;
|
||||
}
|
|
@ -7,22 +7,22 @@
|
|||
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { StatusIcon } from '../../status_icon';
|
||||
import { StatusIcon, STATUS_ICON_TYPES } from '../../status_icon';
|
||||
|
||||
export function MachineLearningJobStatusIcon({ status }: { status: string }) {
|
||||
const type = (() => {
|
||||
const statusKey = status.toUpperCase();
|
||||
|
||||
if (statusKey === 'OPENED') {
|
||||
return StatusIcon.TYPES.GREEN;
|
||||
return STATUS_ICON_TYPES.GREEN;
|
||||
} else if (statusKey === 'CLOSED') {
|
||||
return StatusIcon.TYPES.GRAY;
|
||||
return STATUS_ICON_TYPES.GRAY;
|
||||
} else if (statusKey === 'FAILED') {
|
||||
return StatusIcon.TYPES.RED;
|
||||
return STATUS_ICON_TYPES.RED;
|
||||
}
|
||||
|
||||
// basically a "changing" state like OPENING or CLOSING
|
||||
return StatusIcon.TYPES.YELLOW;
|
||||
return STATUS_ICON_TYPES.YELLOW;
|
||||
})();
|
||||
|
||||
return (
|
||||
|
|
|
@ -31,7 +31,7 @@ import { ClusterStatus } from '../cluster_status';
|
|||
interface Props {
|
||||
clusterStatus: boolean;
|
||||
jobs: MLJobs;
|
||||
onTableChange: () => void;
|
||||
onTableChange: (props: any) => void;
|
||||
sorting: EuiTableSortingType<string>;
|
||||
pagination: Pagination;
|
||||
}
|
||||
|
|
20
x-pack/plugins/monitoring/public/components/elasticsearch/node/node.d.ts
vendored
Normal file
20
x-pack/plugins/monitoring/public/components/elasticsearch/node/node.d.ts
vendored
Normal file
|
@ -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
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const Node: FunctionComponent<NodeProps>;
|
||||
export interface NodeProps {
|
||||
nodeSummary: unknown;
|
||||
metrics: unknown;
|
||||
logs: unknown;
|
||||
alerts: unknown;
|
||||
nodeId: unknown;
|
||||
clusterUuid: unknown;
|
||||
scope: unknown;
|
||||
[key: string]: any;
|
||||
}
|
19
x-pack/plugins/monitoring/public/components/elasticsearch/node/node_react.d.ts
vendored
Normal file
19
x-pack/plugins/monitoring/public/components/elasticsearch/node/node_react.d.ts
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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 { FunctionComponent } from 'react';
|
||||
|
||||
export const NodeReact: FunctionComponent<NodeReactProps>;
|
||||
export interface NodeReactProps {
|
||||
nodeSummary: unknown;
|
||||
metrics: unknown;
|
||||
logs: unknown;
|
||||
alerts: unknown;
|
||||
nodeId: unknown;
|
||||
clusterUuid: unknown;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -5,4 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const StatusIcon: FunctionComponent<Props>;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const NodeStatusIcon: FunctionComponent<NodeStatusIconProps>;
|
||||
export interface NodeStatusIconProps {
|
||||
isOnline: boolean;
|
||||
status: string;
|
||||
}
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { StatusIcon } from '../../status_icon';
|
||||
import { StatusIcon, STATUS_ICON_TYPES } from '../../status_icon';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function NodeStatusIcon({ isOnline, status }) {
|
||||
const type = isOnline ? StatusIcon.TYPES.GREEN : StatusIcon.TYPES.GRAY;
|
||||
const type = isOnline ? STATUS_ICON_TYPES.GREEN : STATUS_ICON_TYPES.GRAY;
|
||||
|
||||
return (
|
||||
<StatusIcon
|
||||
|
|
15
x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.d.ts
vendored
Normal file
15
x-pack/plugins/monitoring/public/components/elasticsearch/nodes/nodes.d.ts
vendored
Normal file
|
@ -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
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const ElasticsearchNodes: FunctionComponent<ElasticsearchNodesProps>;
|
||||
export interface ElasticsearchNodesProps {
|
||||
clusterStatus: unknown;
|
||||
showCgroupMetricsElasticsearch: unknown;
|
||||
[key: string]: any;
|
||||
}
|
18
x-pack/plugins/monitoring/public/components/elasticsearch/overview/overview.d.ts
vendored
Normal file
18
x-pack/plugins/monitoring/public/components/elasticsearch/overview/overview.d.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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 { FunctionComponent } from 'react';
|
||||
|
||||
export const ElasticsearchOverview: FunctionComponent<ElasticsearchOverviewProps>;
|
||||
export interface ElasticsearchOverviewProps {
|
||||
clusterStatus: unknown;
|
||||
metrics: unknown;
|
||||
logs: unknown;
|
||||
cluster: unknown;
|
||||
shardActivity: unknown;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -5,4 +5,4 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const nodesByIndices: () => (shards, nodes) => any;
|
||||
export const nodesByIndices: () => (shards: any, nodes: any) => any;
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { StatusIcon } from '../status_icon';
|
||||
import { StatusIcon, STATUS_ICON_TYPES } from '../status_icon';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function ElasticsearchStatusIcon({ status }) {
|
||||
const type = (() => {
|
||||
const statusKey = status.toUpperCase();
|
||||
return StatusIcon.TYPES[statusKey] || StatusIcon.TYPES.GRAY;
|
||||
return STATUS_ICON_TYPES[statusKey] || STATUS_ICON_TYPES.GRAY;
|
||||
})();
|
||||
|
||||
return (
|
||||
|
|
|
@ -25,8 +25,7 @@ import { capitalize, get } from 'lodash';
|
|||
import { ClusterStatus } from '../cluster_status';
|
||||
// @ts-ignore
|
||||
import { EuiMonitoringTable } from '../../table';
|
||||
// @ts-ignore
|
||||
import { StatusIcon } from '../../status_icon';
|
||||
import { STATUS_ICON_TYPES } from '../../status_icon';
|
||||
// @ts-ignore
|
||||
import { formatMetric, formatNumber } from '../../../lib/format_number';
|
||||
import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link';
|
||||
|
@ -205,7 +204,7 @@ export const KibanaInstances: React.FC<Props> = (props: Props) => {
|
|||
_instances.push({
|
||||
kibana: {
|
||||
...(instance as any).instance.kibana,
|
||||
status: StatusIcon.TYPES.GRAY,
|
||||
status: STATUS_ICON_TYPES.GRAY,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { StatusIcon } from '../status_icon';
|
||||
import { StatusIcon, STATUS_ICON_TYPES } from '../status_icon';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function KibanaStatusIcon({ status, availability = true }) {
|
||||
const type = (() => {
|
||||
if (!availability) {
|
||||
return StatusIcon.TYPES.GRAY;
|
||||
return STATUS_ICON_TYPES.GRAY;
|
||||
}
|
||||
|
||||
const statusKey = status.toUpperCase();
|
||||
return StatusIcon.TYPES[statusKey] || StatusIcon.TYPES.YELLOW;
|
||||
return STATUS_ICON_TYPES[statusKey] || STATUS_ICON_TYPES.YELLOW;
|
||||
})();
|
||||
|
||||
return (
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { Fragment } from 'react';
|
||||
import React, { Fragment, FunctionComponent } from 'react';
|
||||
import {
|
||||
EuiPage,
|
||||
EuiPageBody,
|
||||
|
@ -27,7 +27,10 @@ import {
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { Legacy } from '../../legacy_shims';
|
||||
|
||||
export const AddLicense = ({ uploadPath }) => {
|
||||
interface AddLicenseProps {
|
||||
uploadPath?: string;
|
||||
}
|
||||
const AddLicense: FunctionComponent<AddLicenseProps> = ({ uploadPath }) => {
|
||||
return (
|
||||
<EuiCard
|
||||
title={
|
||||
|
@ -54,7 +57,14 @@ export const AddLicense = ({ uploadPath }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export class LicenseStatus extends React.PureComponent {
|
||||
export interface LicenseStatusProps {
|
||||
isExpired: boolean;
|
||||
status: string;
|
||||
type: string;
|
||||
expiryDate: string | Date;
|
||||
}
|
||||
|
||||
class LicenseStatus extends React.PureComponent<LicenseStatusProps> {
|
||||
render() {
|
||||
const { isExpired, status, type, expiryDate } = this.props;
|
||||
const typeTitleCase = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase();
|
||||
|
@ -133,7 +143,15 @@ export class LicenseStatus extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
const LicenseUpdateInfoForPrimary = ({ isPrimaryCluster, uploadLicensePath }) => {
|
||||
export interface LicenseUpdateInfoProps {
|
||||
isPrimaryCluster: boolean;
|
||||
uploadLicensePath?: string;
|
||||
}
|
||||
|
||||
const LicenseUpdateInfoForPrimary: FunctionComponent<LicenseUpdateInfoProps> = ({
|
||||
isPrimaryCluster,
|
||||
uploadLicensePath,
|
||||
}) => {
|
||||
if (!isPrimaryCluster) {
|
||||
return null;
|
||||
}
|
||||
|
@ -142,7 +160,9 @@ const LicenseUpdateInfoForPrimary = ({ isPrimaryCluster, uploadLicensePath }) =>
|
|||
return <AddLicense uploadPath={uploadLicensePath} />;
|
||||
};
|
||||
|
||||
const LicenseUpdateInfoForRemote = ({ isPrimaryCluster }) => {
|
||||
const LicenseUpdateInfoForRemote: FunctionComponent<LicenseUpdateInfoProps> = ({
|
||||
isPrimaryCluster,
|
||||
}) => {
|
||||
if (isPrimaryCluster) {
|
||||
return null;
|
||||
}
|
||||
|
@ -168,7 +188,8 @@ const LicenseUpdateInfoForRemote = ({ isPrimaryCluster }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export function License(props) {
|
||||
export interface LicenseProps extends LicenseStatusProps, LicenseUpdateInfoProps {}
|
||||
export const License: FunctionComponent<LicenseProps> = (props) => {
|
||||
const { status, type, isExpired, expiryDate } = props;
|
||||
const licenseManagement = `${Legacy.shims.getBasePath()}/app/management/stack/license_management`;
|
||||
return (
|
||||
|
@ -199,4 +220,4 @@ export function License(props) {
|
|||
</EuiPageBody>
|
||||
</EuiPage>
|
||||
);
|
||||
}
|
||||
};
|
|
@ -5,5 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const PageLoading: FunctionComponent<Props>;
|
||||
export const License: FunctionComponent<Props>;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const NoData: FunctionComponent<Record<any, any>>;
|
|
@ -48,17 +48,21 @@ function PageLoadingUI() {
|
|||
);
|
||||
}
|
||||
|
||||
function PageLoadingTracking({ pageViewTitle }) {
|
||||
const PageLoadingTracking: React.FunctionComponent<{ pageViewTitle: string }> = ({
|
||||
pageViewTitle,
|
||||
}) => {
|
||||
const path = pageViewTitle.toLowerCase().replace(/-/g, '').replace(/\s+/g, '_');
|
||||
useTrackPageview({ app: 'stack_monitoring', path });
|
||||
useTrackPageview({ app: 'stack_monitoring', path, delay: 15000 });
|
||||
return <PageLoadingUI />;
|
||||
}
|
||||
};
|
||||
|
||||
export function PageLoading({ pageViewTitle }) {
|
||||
export const PageLoading: React.FunctionComponent<{ pageViewTitle?: string }> = ({
|
||||
pageViewTitle,
|
||||
}) => {
|
||||
if (pageViewTitle) {
|
||||
return <PageLoadingTracking pageViewTitle={pageViewTitle} />;
|
||||
}
|
||||
|
||||
return <PageLoadingUI />;
|
||||
}
|
||||
};
|
|
@ -34,7 +34,7 @@ const SERVER_IDENTIFIER_PLURAL = i18n.translate('xpack.monitoring.setupMode.serv
|
|||
defaultMessage: `servers`,
|
||||
});
|
||||
|
||||
export function formatProductName(productName) {
|
||||
export function formatProductName(productName: string) {
|
||||
if (productName === APM_SYSTEM_ID) {
|
||||
return productName.toUpperCase();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ export function formatProductName(productName) {
|
|||
|
||||
const PRODUCTS_THAT_USE_NODES = [LOGSTASH_SYSTEM_ID, ELASTICSEARCH_SYSTEM_ID];
|
||||
const PRODUCTS_THAT_USE_INSTANCES = [KIBANA_SYSTEM_ID, BEATS_SYSTEM_ID];
|
||||
export function getIdentifier(productName, usePlural = false) {
|
||||
export function getIdentifier(productName: string, usePlural = false) {
|
||||
if (PRODUCTS_THAT_USE_INSTANCES.includes(productName)) {
|
||||
return usePlural ? INSTANCE_IDENTIFIER_PLURAL : INSTANCE_IDENTIFIER_SINGULAR;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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 { EuiIcon } from '@elastic/eui';
|
||||
|
||||
export function StatusIcon({ type, label }) {
|
||||
const typeToIconMap = {
|
||||
[StatusIcon.TYPES.RED]: 'danger',
|
||||
[StatusIcon.TYPES.YELLOW]: 'warning',
|
||||
[StatusIcon.TYPES.GREEN]: 'success',
|
||||
[StatusIcon.TYPES.GRAY]: 'subdued',
|
||||
};
|
||||
const icon = typeToIconMap[type];
|
||||
|
||||
return <EuiIcon alt={label} size="l" data-test-subj="statusIcon" type="dot" color={icon} />;
|
||||
}
|
||||
|
||||
StatusIcon.TYPES = {
|
||||
RED: 'RED',
|
||||
YELLOW: 'YELLOW',
|
||||
GREEN: 'GREEN',
|
||||
GRAY: 'GRAY',
|
||||
};
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* 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 { EuiIcon } from '@elastic/eui';
|
||||
|
||||
export const STATUS_ICON_TYPES = {
|
||||
RED: 'RED' as const,
|
||||
YELLOW: 'YELLOW' as const,
|
||||
GREEN: 'GREEN' as const,
|
||||
GRAY: 'GRAY' as const,
|
||||
};
|
||||
|
||||
const typeToIconMap = {
|
||||
[STATUS_ICON_TYPES.RED]: 'danger',
|
||||
[STATUS_ICON_TYPES.YELLOW]: 'warning',
|
||||
[STATUS_ICON_TYPES.GREEN]: 'success',
|
||||
[STATUS_ICON_TYPES.GRAY]: 'subdued',
|
||||
};
|
||||
|
||||
export interface StatusIconProps {
|
||||
type: keyof typeof STATUS_ICON_TYPES;
|
||||
label: string;
|
||||
}
|
||||
export const StatusIcon: React.FunctionComponent<StatusIconProps> = ({ type, label }) => {
|
||||
const icon = typeToIconMap[type];
|
||||
|
||||
return (
|
||||
<EuiIcon
|
||||
// @ts-ignore
|
||||
alt={label}
|
||||
size="l"
|
||||
data-test-subj="statusIcon"
|
||||
type="dot"
|
||||
color={icon}
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -9,7 +9,7 @@ import React, { Fragment } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { isEmpty, capitalize } from 'lodash';
|
||||
import { EuiFlexGroup, EuiFlexItem, EuiStat } from '@elastic/eui';
|
||||
import { StatusIcon } from '../status_icon/index.js';
|
||||
import { StatusIcon } from '../status_icon';
|
||||
import { AlertsStatus } from '../../alerts/status';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { Fragment } from 'react';
|
||||
import React, { Fragment, FunctionComponent } from 'react';
|
||||
import { EuiInMemoryTable, EuiButton, EuiSpacer, EuiSearchBar } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getIdentifier } from '../setup_mode/formatting';
|
||||
import { isSetupModeFeatureEnabled } from '../../lib/setup_mode';
|
||||
import { SetupModeFeature } from '../../../common/enums';
|
||||
|
||||
export function EuiMonitoringTable({
|
||||
export const EuiMonitoringTable: FunctionComponent<Record<any, any>> = ({
|
||||
rows: items,
|
||||
search = {},
|
||||
columns: _columns,
|
||||
setupMode,
|
||||
productName,
|
||||
...props
|
||||
}) {
|
||||
}) => {
|
||||
const [hasItems, setHasItem] = React.useState(items.length > 0);
|
||||
|
||||
if (search.box && !search.box['data-test-subj']) {
|
||||
|
@ -32,15 +32,17 @@ export function EuiMonitoringTable({
|
|||
|
||||
if (search) {
|
||||
const oldOnChange = search.onChange;
|
||||
search.onChange = (arg) => {
|
||||
search.onChange = (arg: any) => {
|
||||
const filteredItems = EuiSearchBar.Query.execute(arg.query, items, props.executeQueryOptions);
|
||||
setHasItem(filteredItems.length > 0);
|
||||
oldOnChange && oldOnChange(arg);
|
||||
if (oldOnChange) {
|
||||
oldOnChange(arg);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
const columns = _columns.map((column) => {
|
||||
const columns = _columns.map((column: any) => {
|
||||
if (!('sortable' in column)) {
|
||||
column.sortable = true;
|
||||
}
|
||||
|
@ -78,4 +80,4 @@ export function EuiMonitoringTable({
|
|||
{footerContent}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
|
@ -5,8 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const getClusterFromClusters: (
|
||||
clusters: any,
|
||||
globalState: State,
|
||||
unsetGlobalState: boolean
|
||||
) => any;
|
||||
import { FunctionComponent } from 'react';
|
||||
|
||||
export const EuiMonitoringSSPTable: FunctionComponent<Record<any, any>>;
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const euiTableStorageGetter: (string) => any;
|
||||
export const euiTableStorageSetter: (string) => any;
|
||||
export const EuiMonitoringTable: FunctionComponent<Props>;
|
|
@ -8,9 +8,22 @@
|
|||
import { set } from '@elastic/safer-lodash-set';
|
||||
import { get } from 'lodash';
|
||||
import { STORAGE_KEY } from '../../../common/constants';
|
||||
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
export const tableStorageGetter = (keyPrefix) => {
|
||||
return (storage) => {
|
||||
interface TableValues {
|
||||
filterText: any;
|
||||
pageIndex: any;
|
||||
sortKey: any;
|
||||
sortOrder: any;
|
||||
}
|
||||
|
||||
interface EuiTableValues {
|
||||
sort: any;
|
||||
page: any;
|
||||
}
|
||||
|
||||
export const tableStorageGetter = (keyPrefix: string) => {
|
||||
return (storage: Storage): TableValues => {
|
||||
const localStorageData = storage.get(STORAGE_KEY) || {};
|
||||
const filterText = get(localStorageData, [keyPrefix, 'filterText']);
|
||||
const pageIndex = get(localStorageData, [keyPrefix, 'pageIndex']);
|
||||
|
@ -21,8 +34,8 @@ export const tableStorageGetter = (keyPrefix) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const tableStorageSetter = (keyPrefix) => {
|
||||
return (storage, { filterText, pageIndex, sortKey, sortOrder }) => {
|
||||
export const tableStorageSetter = (keyPrefix: string) => {
|
||||
return (storage: Storage, { filterText, pageIndex, sortKey, sortOrder }: TableValues) => {
|
||||
const localStorageData = storage.get(STORAGE_KEY) || {};
|
||||
|
||||
set(localStorageData, [keyPrefix, 'filterText'], filterText || undefined); // don`t store empty data
|
||||
|
@ -36,8 +49,8 @@ export const tableStorageSetter = (keyPrefix) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const euiTableStorageGetter = (keyPrefix) => {
|
||||
return (storage) => {
|
||||
export const euiTableStorageGetter = (keyPrefix: string) => {
|
||||
return (storage: Storage): EuiTableValues => {
|
||||
const localStorageData = storage.get(STORAGE_KEY) || {};
|
||||
const sort = get(localStorageData, [keyPrefix, 'sort']);
|
||||
const page = get(localStorageData, [keyPrefix, 'page']);
|
||||
|
@ -46,8 +59,8 @@ export const euiTableStorageGetter = (keyPrefix) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const euiTableStorageSetter = (keyPrefix) => {
|
||||
return (storage, { sort, page }) => {
|
||||
export const euiTableStorageSetter = (keyPrefix: string) => {
|
||||
return (storage: Storage, { sort, page }: EuiTableValues) => {
|
||||
const localStorageData = storage.get(STORAGE_KEY) || {};
|
||||
|
||||
set(localStorageData, [keyPrefix, 'sort'], sort || undefined); // don`t store empty data
|
|
@ -6,15 +6,20 @@
|
|||
*/
|
||||
|
||||
import { find, first } from 'lodash';
|
||||
import { State } from '../application/global_state_context';
|
||||
|
||||
export function getClusterFromClusters(clusters, globalState, unsetGlobalState = false) {
|
||||
export function getClusterFromClusters(
|
||||
clusters: any,
|
||||
globalState: State,
|
||||
unsetGlobalState = false
|
||||
) {
|
||||
const cluster = (() => {
|
||||
const existingCurrent = find(clusters, { cluster_uuid: globalState.cluster_uuid });
|
||||
if (existingCurrent) {
|
||||
return existingCurrent;
|
||||
}
|
||||
|
||||
const firstCluster = first(clusters);
|
||||
const firstCluster: any = first(clusters);
|
||||
if (firstCluster && firstCluster.cluster_uuid) {
|
||||
return firstCluster;
|
||||
}
|
||||
|
@ -25,7 +30,9 @@ export function getClusterFromClusters(clusters, globalState, unsetGlobalState =
|
|||
if (cluster && cluster.license) {
|
||||
globalState.cluster_uuid = unsetGlobalState ? undefined : cluster.cluster_uuid;
|
||||
globalState.ccs = unsetGlobalState ? undefined : cluster.ccs;
|
||||
globalState.save();
|
||||
if (globalState.save) {
|
||||
globalState.save();
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
Loading…
Reference in a new issue