Skip to content
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

[inspector] clusters tab MVP #166025

Merged
merged 77 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
66c3f08
[inspector] show cluster details tab in inspector
nreese Sep 7, 2023
ee221cd
extract clusters from response
nreese Sep 7, 2023
0ee10fb
clusters table
nreese Sep 7, 2023
8142aa4
expand column row
nreese Sep 7, 2023
8898f3a
shards details
nreese Sep 8, 2023
2b89e62
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 8, 2023
948e6e4
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 8, 2023
44e8fe0
failures
nreese Sep 8, 2023
b0b0f43
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 8, 2023
94ef2e9
only show shard section when its provided
nreese Sep 8, 2023
1c5164c
timed out section
nreese Sep 8, 2023
6ab002c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 8, 2023
b641688
clusters health
nreese Sep 8, 2023
afc687a
add missing FlexItem
nreese Sep 8, 2023
f4314ee
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 8, 2023
59384d9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 8, 2023
a3c5026
health hex codes
nreese Sep 11, 2023
f6eb7f0
health bar
nreese Sep 11, 2023
0c387e2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 11, 2023
d1b9bc9
shard details flyout
nreese Sep 11, 2023
da607e7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 11, 2023
b340c05
show details
nreese Sep 11, 2023
6038477
rename
nreese Sep 11, 2023
fe00cae
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 11, 2023
4f99eca
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 11, 2023
68bc6dc
cleanup table
nreese Sep 11, 2023
29ac57f
do not show clusters tab if _shards or _clusters not provided
nreese Sep 11, 2023
5edafbd
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 11, 2023
2b16d35
Merge branch 'main' into clusters_tab
kibanamachine Sep 20, 2023
3da9458
show local cluster name as 'Local cluster'
nreese Sep 20, 2023
85d4cbc
move all shard failure details to flyout
nreese Sep 20, 2023
d1b1473
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 20, 2023
a253acb
ShardFailuresTable
nreese Sep 20, 2023
5eb100a
rename components
nreese Sep 20, 2023
7e3138a
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 20, 2023
4cc1f99
rename
nreese Sep 20, 2023
941939f
show shard failures
nreese Sep 20, 2023
ff3bf7d
tslint
nreese Sep 20, 2023
de91e9c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 20, 2023
906fca2
standardize i18n ids
nreese Sep 20, 2023
7e204de
rename index.ts to clusters_view.ts
nreese Sep 20, 2023
601748f
add jest test for ClustersView
nreese Sep 20, 2023
b3c2797
remove extra describe block
nreese Sep 20, 2023
c9f725b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 20, 2023
27fafef
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 20, 2023
5f7c751
reorganize all the things
nreese Sep 20, 2023
088fbf3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 20, 2023
50bed3a
shard_view tests
nreese Sep 21, 2023
28ac811
clean up
nreese Sep 21, 2023
d1c0744
local_cluster unit tests
nreese Sep 21, 2023
028172c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 21, 2023
c5f5ad2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 21, 2023
2f74fd5
Merge branch 'main' into clusters_tab
kibanamachine Sep 21, 2023
8a5c3d7
jest tests for ClusterView
nreese Sep 21, 2023
febfd19
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 21, 2023
6df9322
tslint
nreese Sep 21, 2023
5998eaa
Merge branch 'main' into clusters_tab
kibanamachine Sep 21, 2023
237cbd0
handle skipped clusters
nreese Sep 21, 2023
6babc6f
clean up
nreese Sep 21, 2023
e7a37cf
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 21, 2023
5d25be9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 21, 2023
e9a0b7a
tslint
nreese Sep 22, 2023
82f1c8b
clean up search failed callout
nreese Sep 22, 2023
51f784b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 22, 2023
9d596ac
use unique id for shard table
nreese Sep 22, 2023
8f7d8d3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 22, 2023
a18922f
break OpenShardFailureFlyoutButton into its own component
nreese Sep 22, 2023
65a6e4f
move view failed shards button to failed cluster callout
nreese Sep 22, 2023
1a0a2e3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 22, 2023
830ed94
Merge branch 'main' into clusters_tab
kibanamachine Sep 22, 2023
ec6805c
Merge branch 'main' into clusters_tab
kibanamachine Sep 25, 2023
ef30299
Merge branch 'main' into clusters_tab
kibanamachine Sep 25, 2023
3f7572c
change style prop to emotion
nreese Sep 26, 2023
41fcd86
switch to eui theme colors
nreese Sep 26, 2023
49249e3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 26, 2023
57400e1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 26, 2023
f47a321
update test expects
nreese Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiHealth, EuiText } from '@elastic/eui';
import { HEALTH_HEX_CODES } from './gradient';

interface Props {
count?: number;
status: string;
}

export function ClusterHealth({ count, status }: Props) {
if (typeof count === 'number' && count === 0) {
return null;
}

let color = 'subdued';
let statusLabel = status;
if (status === 'successful') {
color = HEALTH_HEX_CODES.successful;
statusLabel = i18n.translate('inspector.requests.clusters.successfulLabel', {
defaultMessage: 'successful',
});
} else if (status === 'partial') {
color = HEALTH_HEX_CODES.partial;
statusLabel = i18n.translate('inspector.requests.clusters.partialLabel', {
defaultMessage: 'partial',
});
} else if (status === 'skipped') {
color = HEALTH_HEX_CODES.skipped;
statusLabel = i18n.translate('inspector.requests.clusters.skippedLabel', {
defaultMessage: 'skipped',
});
} else if (status === 'failed') {
color = HEALTH_HEX_CODES.failed;
statusLabel = i18n.translate('inspector.requests.clusters.failedLabel', {
defaultMessage: 'failed',
});
}

const label = typeof count === 'number' ? `${count} ${statusLabel}` : statusLabel;
return (
<EuiHealth color={color}>
<EuiText size="xs" color="subdued">
{label}
</EuiText>
</EuiHealth>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import { css } from '@emotion/react';
import { euiThemeVars } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import type { ClusterDetails } from '@kbn/es-types';
import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { ClusterHealth } from './cluster_health';
import { getHeathBarLinearGradient } from './gradient';

interface Props {
clusters: Record<string, ClusterDetails>;
}

export function ClustersHealth({ clusters }: Props) {
let successful = 0;
let partial = 0;
let skipped = 0;
let failed = 0;
Object.values(clusters).forEach((clusterDetails) => {
if (clusterDetails.status === 'successful') {
successful++;
} else if (clusterDetails.status === 'partial') {
partial++;
} else if (clusterDetails.status === 'skipped') {
skipped++;
} else if (clusterDetails.status === 'failed') {
failed++;
}
});

return (
<>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiText size="xs" color="subdued">
{i18n.translate('inspector.requests.clusters.totalClustersLabel', {
defaultMessage: '{total} {total, plural, one {cluster} other {clusters}}',
values: { total: Object.keys(clusters).length },
})}
</EuiText>
</EuiFlexItem>

{successful > 0 ? (
<EuiFlexItem grow={false}>
<ClusterHealth count={successful} status="successful" />
</EuiFlexItem>
) : null}

{partial > 0 ? (
<EuiFlexItem grow={false}>
<ClusterHealth count={partial} status="partial" />
</EuiFlexItem>
) : null}

{skipped > 0 ? (
<EuiFlexItem grow={false}>
<ClusterHealth count={skipped} status="skipped" />
</EuiFlexItem>
) : null}

{failed > 0 ? (
<EuiFlexItem grow={false}>
<ClusterHealth count={failed} status="failed" />
</EuiFlexItem>
) : null}
</EuiFlexGroup>

<div
css={css`
background: ${getHeathBarLinearGradient(successful, partial, skipped, failed)};
border-radius: ${euiThemeVars.euiBorderRadiusSmall};
height: ${euiThemeVars.euiSizeS};
margin-top: ${euiThemeVars.euiSizeXS};
margin-bottom: ${euiThemeVars.euiSizeS};
`}
/>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { getHeathBarLinearGradient, HEALTH_HEX_CODES } from './gradient';

describe('getHeathBarLinearGradient', () => {
test('should return linear-gradient with percentages for each status', () => {
expect(getHeathBarLinearGradient(5, 1, 1, 2)).toBe(
`linear-gradient(to right, ${HEALTH_HEX_CODES.successful} 0% 56%, ${HEALTH_HEX_CODES.partial} 56% 67%, ${HEALTH_HEX_CODES.skipped} 67% 78%, ${HEALTH_HEX_CODES.failed} 78% 100%)`
);
});

test('should return linear-gradient with percentages for each status with count above zero', () => {
expect(getHeathBarLinearGradient(5, 0, 0, 2)).toBe(
`linear-gradient(to right, ${HEALTH_HEX_CODES.successful} 0% 71%, ${HEALTH_HEX_CODES.failed} 71% 100%)`
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { euiThemeVars } from '@kbn/ui-theme';

export const HEALTH_HEX_CODES = {
nreese marked this conversation as resolved.
Show resolved Hide resolved
successful: euiThemeVars.euiColorSuccess,
partial: euiThemeVars.euiColorWarning,
skipped: '#DA8B45',
failed: euiThemeVars.euiColorDanger,
};

export function getHeathBarLinearGradient(
successful: number,
partial: number,
skipped: number,
failed: number
) {
const total = successful + partial + skipped + failed;
const stops: string[] = [];
let startPercent: number = 0;

function addStop(value: number, color: string) {
if (value <= 0) {
return;
}

const percent = Math.round((value / total) * 100);
const endPercent = startPercent + percent;
stops.push(`${color} ${startPercent}% ${endPercent}%`);
startPercent = endPercent;
}

addStop(successful, HEALTH_HEX_CODES.successful);
addStop(partial, HEALTH_HEX_CODES.partial);
addStop(skipped, HEALTH_HEX_CODES.skipped);
addStop(failed, HEALTH_HEX_CODES.failed);

const printedStops = stops
.map((stop, index) => {
return index === stops.length - 1 ? stop : stop + ', ';
})
.join('');

return `linear-gradient(to right, ${printedStops})`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { ClustersHealth } from './clusters_health';
export { ClusterHealth } from './cluster_health';
Loading