-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[inspector] clusters tab MVP #166025
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
Merged
Merged
[inspector] clusters tab MVP #166025
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 ee221cd
extract clusters from response
nreese 0ee10fb
clusters table
nreese 8142aa4
expand column row
nreese 8898f3a
shards details
nreese 2b89e62
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 948e6e4
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 44e8fe0
failures
nreese b0b0f43
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 94ef2e9
only show shard section when its provided
nreese 1c5164c
timed out section
nreese 6ab002c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine b641688
clusters health
nreese afc687a
add missing FlexItem
nreese f4314ee
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 59384d9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine a3c5026
health hex codes
nreese f6eb7f0
health bar
nreese 0c387e2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine d1b9bc9
shard details flyout
nreese da607e7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine b340c05
show details
nreese 6038477
rename
nreese fe00cae
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 4f99eca
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 68bc6dc
cleanup table
nreese 29ac57f
do not show clusters tab if _shards or _clusters not provided
nreese 5edafbd
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 2b16d35
Merge branch 'main' into clusters_tab
kibanamachine 3da9458
show local cluster name as 'Local cluster'
nreese 85d4cbc
move all shard failure details to flyout
nreese d1b1473
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine a253acb
ShardFailuresTable
nreese 5eb100a
rename components
nreese 7e3138a
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 4cc1f99
rename
nreese 941939f
show shard failures
nreese ff3bf7d
tslint
nreese de91e9c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 906fca2
standardize i18n ids
nreese 7e204de
rename index.ts to clusters_view.ts
nreese 601748f
add jest test for ClustersView
nreese b3c2797
remove extra describe block
nreese c9f725b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 27fafef
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 5f7c751
reorganize all the things
nreese 088fbf3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 50bed3a
shard_view tests
nreese 28ac811
clean up
nreese d1c0744
local_cluster unit tests
nreese 028172c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine c5f5ad2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 2f74fd5
Merge branch 'main' into clusters_tab
kibanamachine 8a5c3d7
jest tests for ClusterView
nreese febfd19
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 6df9322
tslint
nreese 5998eaa
Merge branch 'main' into clusters_tab
kibanamachine 237cbd0
handle skipped clusters
nreese 6babc6f
clean up
nreese e7a37cf
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 5d25be9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine e9a0b7a
tslint
nreese 82f1c8b
clean up search failed callout
nreese 51f784b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 9d596ac
use unique id for shard table
nreese 8f7d8d3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine a18922f
break OpenShardFailureFlyoutButton into its own component
nreese 65a6e4f
move view failed shards button to failed cluster callout
nreese 1a0a2e3
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 830ed94
Merge branch 'main' into clusters_tab
kibanamachine ec6805c
Merge branch 'main' into clusters_tab
kibanamachine ef30299
Merge branch 'main' into clusters_tab
kibanamachine 3f7572c
change style prop to emotion
nreese 41fcd86
switch to eui theme colors
nreese 49249e3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 57400e1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine f47a321
update test expects
nreese 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
115 changes: 115 additions & 0 deletions
115
...views/requests/components/details/clusters_view/__snapshots__/clusters_view.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...public/views/requests/components/details/clusters_view/clusters_health/cluster_health.tsx
This file contains hidden or 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,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> | ||
| ); | ||
| } |
87 changes: 87 additions & 0 deletions
87
...ublic/views/requests/components/details/clusters_view/clusters_health/clusters_health.tsx
This file contains hidden or 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,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}; | ||
| `} | ||
| /> | ||
| </> | ||
| ); | ||
| } |
23 changes: 23 additions & 0 deletions
23
...r/public/views/requests/components/details/clusters_view/clusters_health/gradient.test.ts
This file contains hidden or 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,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%)` | ||
| ); | ||
| }); | ||
| }); |
51 changes: 51 additions & 0 deletions
51
...pector/public/views/requests/components/details/clusters_view/clusters_health/gradient.ts
This file contains hidden or 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,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 = { | ||
| 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})`; | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
...inspector/public/views/requests/components/details/clusters_view/clusters_health/index.ts
This file contains hidden or 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,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'; |
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.
Uh oh!
There was an error while loading. Please reload this page.