elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.38k stars 8k forks source link

[ES|QL] [Monaco] Investigate if we can render a different UI component for the from command #181031

Closed stratoula closed 1 week ago

stratoula commented 1 month ago

Describe the feature:

At the moment when we are suggesting indices we use the suggestions UI of the monaco api.

image

We want to make this component a bit more complicated. We don't want to suggest only indices but also integrations, datastreams etc.

We need somehow to make this distinction in the UI which means that the current UI of the monaco api needs to change.

Below is an idea:

image

The ideal scenario would be to be able to render our own UI component for the from command suggestions.

If this is not possible we could possibly define different icons to the different options and possibly different styling (?)

The purpose of this issue is to investigate the various options in order to make a decision forward.

Next steps:

elasticmachine commented 1 month ago

Pinging @elastic/kibana-esql (Team:ESQL)

drewdaemon commented 1 month ago

I understand the need but not why Monaco's default doesn't cover it.

We can already label each option on the right and change the icon on the left...

Screenshot 2024-04-17 at 7 34 37 AM
stratoula commented 1 month ago

@drewdaemon yes, but what if we want a different more compolicated UI? This is the investigation we want to do. What capabilities do we have? Can I have something fancier?

drewdaemon commented 1 month ago

@stratoula sounds good. I just read

We don't want to suggest only indices but also integrations, datastreams etc.

and looked at the wireframe and I think the default can cover these cases.

Still, I see value in this investigation as a way to stake out the boundaries of the possible 👍

stratoula commented 1 month ago

One quite hacky PoC from Joe https://github.com/elastic/kibana/pull/181112

dej611 commented 4 weeks ago

Another hack could be to combine the suggestion api with the commands API:

stratoula commented 2 weeks ago

So I investigated the different options we have with the monaco editor:

  1. Use the commands API and create a new option in the sources suggestions. This option can then open a modal or a flyout. This option is not hacky at all, we have used something similar in the enrich command. One demonstration below:

meow

  1. Use the commands api and create a new option in the sources suggestion. This options can open a new popover:

This is using on one hand the commands api to create naturally a new option in the autocomplete but unfortunately the popover should be created by hand. Also:

meow

  1. Do what Joe proposes above. This is not very different from the previous example implementation wise but it has an extra hack / drawback. We need to detect when the from command has been typed and open the popover.

Kapture 2024-04-18 at 08 24 07

Note: I also investigated the overlay widget idea from Marco but widgets are not what we want. They don't act as popovers, they are overlays inside the editor so I could not make them work as we want.

  1. Another idea we had with @timductive is to have a special character or a combination of special chacters (which is not going to be used by ES|QL - might be tricky) that the user can type and this is going to display a menu:

meow

The 1 and 2 and 4 ideas can be seen here. They are not working prototypes, they are just the result of my research. The second approach will need additional work to make it work smoothly and bug free. The 4th is a bit cleaner and I personally like it as an idea. I also like 1 too. The 2nd and 3rd are very dirty and we need to interfere with monaco events so they are def more prune to bugs and need a lot of love.

flash1293 commented 2 weeks ago

The options above are mostly exploring how to open the custom popover. This is part of the problem, the other part is how the users is interacting with the popover, which is probably also worth some thinking.

Some considerations:

Another angle to the whole problem - can we enumerate all the features we want/need? As @drewdaemon is mentioning, you can do things like custom icons, maybe we can get by with that already?

drewdaemon commented 2 weeks ago

Great discussion and research going on here.

As @drewdaemon is mentioning, you can do things like custom icons, maybe we can get by with that already?

Unfortunately, I have to throw a bit of water on my own party. I took a second look, and I don't think Monaco facilitates custom icons. Instead, it chooses from a set a predefined icons based on the kind property (doc). Not sure if it could be hacked... (doesn't look like they're going to change this: https://github.com/microsoft/monaco-editor/issues/2654).

However, we can definitely write custom labels and descriptions for each entry which could associate datasets with integrations for example.

https://github.com/elastic/kibana/assets/315764/f8d43b2d-ddc0-484b-990b-ef500e269ede

The little documentation popover accepts markdown, so we can put a lot of formatted information in there.

Screenshot 2024-05-14 at 2 27 53 PM
stratoula commented 2 weeks ago

Thanx Drew, it is ok. It doesnt seem we are going that way so this limitation is not so important atm

stratoula commented 1 week ago

I am closing this as we investigated the things we wanted to work on with @ryankeairns and now we can move forward to the design and actual implementation. Here is the PR which all the experiments https://github.com/elastic/kibana/pull/183377