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

[Console] Add theme and more lexer rules #178757

Merged
merged 14 commits into from
Mar 27, 2024

Conversation

yuliacech
Copy link
Contributor

@yuliacech yuliacech commented Mar 14, 2024

Summary

This PR adds a theme for the Console language in Monaco editor and adds more lexer rules to bring the highlighting of the input closed to the original in Ace editor.

Screenshots

Monaco editor
Screenshot 2024-03-19 at 12 38 07

Ace editor
Screenshot 2024-03-19 at 12 37 52

How to test

  1. Add console.dev.enableMonaco: true to `kibana.dev.yml``
  2. Type different requests into Console and check that the highlighting works the same as in Ace. For example, use the following requests
GET ${pathVariable}/_search
{
 "query": {
   "match": {
     "${bodyNameVariable}": "${bodyValueVariable}",
     "number_property": 1234,
     "array_property": ["test1", 1234, false], 
     "boolean_property": true,
     "text_property": "text_value",
     "triple_quote": """
     inside triple quote
     """
     // line comment
     /* 
      block comment
    */
   }
 }
}

// line comment
/* 
block comment
*/

GET _sql
{
  "query": """
  SELECT "field" FROM "index-*" WHERE "column" = "value"
  """
}
  1. To check that xjson highlighting still works
    a. Navigate to Ingest pipelines and click the "create from csv" button
    b. Load a valid csv file, for example this one

Known issues that will be addressed in follow up PRs

@yuliacech yuliacech added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes labels Mar 14, 2024
@yuliacech
Copy link
Contributor Author

/ci

1 similar comment
@yuliacech
Copy link
Contributor Author

/ci

@yuliacech yuliacech marked this pull request as ready for review March 19, 2024 16:59
@yuliacech yuliacech requested review from a team as code owners March 19, 2024 16:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vis changes look good to me!

@ElenaStoeva ElenaStoeva self-requested a review March 20, 2024 09:37
Copy link
Contributor

@ElenaStoeva ElenaStoeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @yuliacech! I tested locally and the highlighting works as expected. Code changes also LGTM.

I left a small comment about the colors but it's not that important IMO - just something to think about.

const stringTextColor = '#009926';
const commentTextColor = '#4C886B';
const variableTextColor = '#0079A5';
const booleanTextColor = '#585CF6';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering whether we could use the already defined euiTheme colors for consistency, like it is done for the code editor theme (which I think is used in Painless lab). For example, the method color could be euiTheme.euiColorAccentText. But this decision depends on whether we want to keep the theme as close to the ace editor theme as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the hard coded values are not great, but we can't currently map them one-to-one without changing the colors. I think there are 2 ways to improve this code: either re-use the already existing json code editor theme, but that changes the look of console. Or alternatively, we try to keep the original look but re-use the built-in colors from EUI as much as possible.
I added a section to #176926 with follow up work once the initial language definition is implemented.

@yuliacech yuliacech force-pushed the console/add_more_lexer_rules branch from 3d1b6a6 to f58da35 Compare March 22, 2024 14:06
@yuliacech yuliacech enabled auto-merge (squash) March 22, 2024 14:58
@yuliacech yuliacech requested a review from a team as a code owner March 26, 2024 17:02
@yuliacech yuliacech requested a review from a team as a code owner March 26, 2024 17:02
@yuliacech yuliacech requested a review from a team as a code owner March 27, 2024 08:07
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/monaco 106 107 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
console 430.7KB 430.8KB +26.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-srcJs 2.9MB 2.9MB +2.3KB
Unknown metric groups

API count

id before after diff
@kbn/monaco 106 107 +1

References to deprecated APIs

id before after diff
@kbn/monaco 2 4 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@yuliacech yuliacech merged commit c59016e into elastic:main Mar 27, 2024
36 checks passed
@kibanamachine kibanamachine added v8.14.0 backport:skip This commit does not require backporting labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants