-
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
Merged
mibragimov
merged 25 commits into
elastic:main
from
mibragimov:console/multiple-requests-ux
Jun 6, 2022
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
32db185
[wip] show status code/text in editor output for multiple requests
df0b1e2
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine a63deb5
Render status badges in the output panel
0bf0c1a
Add missing dependancy for useEffect hook
215eb44
Lint
ad63eaf
Address comments
ed198f8
Add functional tests
962da8f
Update tests
5a0d907
Fix tests
574bf1d
Update selectAll command key for firefox
f56ec79
Merge branch 'main' into console/multiple-requests-ux
kibanamachine da63f46
Fix selecting all requests in tests
d352a85
Merge branch 'main' into console/multiple-requests-ux
kibanamachine 0e72f31
Convert output modes to TS
15d683e
Fix checks
3aa0043
Address comments
c7b4f64
Merge branch 'main' into console/multiple-requests-ux
kibanamachine eaaee4b
Fix types for editor session.update method
371ce42
Add tests for mapStatusCodeToBadge function
18e0e7e
Merge branch 'main' into console/multiple-requests-ux
kibanamachine 30cce66
Merge branch 'main' into console/multiple-requests-ux
kibanamachine ad57319
Address comments
2f9b9bc
Merge branch 'main' into console/multiple-requests-ux
kibanamachine 0f33fd6
Merge branch 'main' into console/multiple-requests-ux
kibanamachine 4996043
Change .ace-badge font family to $euiFontFamily
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
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
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
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
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
37 changes: 0 additions & 37 deletions
37
...ugins/console/public/application/models/legacy_core_editor/mode/output_highlight_rules.js
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
.../console/public/application/models/legacy_core_editor/mode/output_highlight_rules.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,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); | ||
| }); | ||
| }); | ||
| }); |
59 changes: 59 additions & 0 deletions
59
...ugins/console/public/application/models/legacy_core_editor/mode/output_highlight_rules.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,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(); | ||
| } | ||
| } | ||
| } | ||
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
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
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.