-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Console] Improve UX around handling multiple requests #132494
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
Changes from 21 commits
32db185
df0b1e2
a63deb5
0bf0c1a
215eb44
ad63eaf
ed198f8
962da8f
5a0d907
574bf1d
f56ec79
da63f46
d352a85
0e72f31
15d683e
3aa0043
c7b4f64
eaaee4b
371ce42
18e0e7e
30cce66
ad57319
2f9b9bc
0f33fd6
4996043
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * 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 { mapStatusCodeToBadge } from './output_highlight_rules'; | ||
|
|
||
| describe('mapStatusCodeToBadge', () => { | ||
| const testCases = [ | ||
| { | ||
| description: 'treats 100 as as default', | ||
| value: '# PUT test-index 100 Continue', | ||
| badge: 'badge.badge--default', | ||
| }, | ||
| { | ||
| description: 'treats 200 as success', | ||
| value: '# PUT test-index 200 OK', | ||
| badge: 'badge.badge--success', | ||
| }, | ||
| { | ||
| description: 'treats 301 as primary', | ||
| value: '# PUT test-index 301 Moved Permanently', | ||
| badge: 'badge.badge--primary', | ||
| }, | ||
| { | ||
| description: 'treats 400 as warning', | ||
| value: '# PUT test-index 404 Not Found', | ||
| badge: 'badge.badge--warning', | ||
| }, | ||
| { | ||
| description: 'treats 502 as danger', | ||
| value: '# PUT test-index 502 Bad Gateway', | ||
| badge: 'badge.badge--danger', | ||
| }, | ||
| { | ||
| description: 'treats unexpected numbers as danger', | ||
| value: '# PUT test-index 666 Demonic Invasion', | ||
| badge: 'badge.badge--danger', | ||
| }, | ||
| { | ||
| description: 'treats no numbers as undefined', | ||
| value: '# PUT test-index', | ||
| badge: undefined, | ||
| }, | ||
| ]; | ||
|
|
||
| testCases.forEach(({ description, value, badge }) => { | ||
| test(description, () => { | ||
| expect(mapStatusCodeToBadge(value)).toBe(badge); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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 ace from 'brace'; | ||
| import 'brace/mode/json'; | ||
| import { addXJsonToRules } from '@kbn/ace'; | ||
|
|
||
| const JsonHighlightRules = ace.acequire('ace/mode/json_highlight_rules').JsonHighlightRules; | ||
|
|
||
| export const mapStatusCodeToBadge = (value: string) => { | ||
| const regExpMatchArray = value.match(/\d+/); | ||
| if (regExpMatchArray) { | ||
| const status = parseInt(regExpMatchArray[0], 10); | ||
| if (status <= 199) { | ||
| return 'badge.badge--default'; | ||
| } | ||
| if (status <= 299) { | ||
| return 'badge.badge--success'; | ||
| } | ||
| if (status <= 399) { | ||
| return 'badge.badge--primary'; | ||
| } | ||
| if (status <= 499) { | ||
| return 'badge.badge--warning'; | ||
| } | ||
| return 'badge.badge--danger'; | ||
| } | ||
| }; | ||
|
|
||
| export class OutputJsonHighlightRules extends JsonHighlightRules { | ||
| constructor() { | ||
| super(); | ||
| this.$rules = {}; | ||
| addXJsonToRules(this, 'start'); | ||
| this.$rules.start.unshift( | ||
| { | ||
| token: 'warning', | ||
| regex: '#!.*$', | ||
| }, | ||
| { | ||
| token: 'comment', | ||
| regex: /#(.*?)(?=\d+\s(?:[\sA-Za-z]+)|$)/, | ||
| }, | ||
| { | ||
| token: mapStatusCodeToBadge, | ||
| regex: /(\d+\s[\sA-Za-z]+$)/, | ||
| } | ||
| ); | ||
|
|
||
| if (this instanceof OutputJsonHighlightRules) { | ||
| this.normalizeRules(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,47 @@ | |||||||||
| .conApp__output { | ||||||||||
| display: flex; | ||||||||||
| flex: 1 1 1px; | ||||||||||
|
|
||||||||||
| .ace_badge { | ||||||||||
| font-size: 12px; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| font-weight: 500; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| line-height: 18px; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| padding: 0 8px; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| display: inline-block; | ||||||||||
| text-decoration: none; | ||||||||||
| border-radius: 3px; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| border: solid 1px transparent; | ||||||||||
|
||||||||||
| white-space: nowrap; | ||||||||||
| vertical-align: middle; | ||||||||||
| cursor: default; | ||||||||||
| max-width: 100%; | ||||||||||
| text-align: left; | ||||||||||
mibragimov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| text-align: left; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting change to the correct badge background colors here.
| background-color: $euiColorSuccess; | |
| color: chooseLightOrDarkText($euiColorSuccess); | |
| background-color: $euiColorVis0_behindText; | |
| color: chooseLightOrDarkText($euiColorVis0_behindText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelMarcialis For our own edification, can you teach us about the role of $euiColorVis0_behindText and similar colors, and what makes it better than $euiColorSuccess here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, @cjcenizal! For the purposes of this PR, my reason for the suggested color changes were purely to make these ace badges consistent with the colors that our EuiBadge components use.
That said, I imagine the reason the EUI team ultimately chose to use the behind-text visualization colors for the EuiBadge component has to do with accessibility and the contrast ratio, as this component houses fairly small sized text. The contrast with the behind-text visualization colors appears to be higher and receives a better WCAG rating. Unlike EuiBadge, I assume that components with larger text sizes (such as EuiButton) can afford be a bit less strict with the color contrast, which is why they can use colors like $euiColorSuccess.
CCing @cchaos here to keep me honest and double-check my assumptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For full context on why we used visualization colors for badges, you can read through this PR: elastic/eui#2455
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you both! This helps me out a ton.
Uh oh!
There was an error while loading. Please reload this page.