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

[Monaco Editor] Add Search functionality #188337

Merged

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Jul 15, 2024

Fixes #186635

Summary

This PR adds the find action to the Monaco code editor, which enables the search bar functionality as it is needed for Console with Monaco. The functionality is disabled by default.

Screenshot 2024-07-15 at 18 08 14

How to test:

  1. Open Console and verify that Command/Ctrl + f opens the search bar (should work for both the editor and the output panel).
  2. Open any other code editor in Kibana and verify that the search functionality is disabled.

@ElenaStoeva ElenaStoeva added 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 Jul 15, 2024
@ElenaStoeva ElenaStoeva self-assigned this Jul 15, 2024
@ElenaStoeva
Copy link
Contributor Author

/ci

@ElenaStoeva ElenaStoeva marked this pull request as ready for review July 16, 2024 09:03
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner July 16, 2024 09:03
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

I think we should make the find functionality opt-in as oppose to making it available by default to all consumers. For instance this change would show up in discover for ES|QL like so;

Screenshot 2024-07-16 at 15 45 32

There's a monaco API to modify key bindings that we can use to disable the find action if a user doesn't opt in.

addendum
See microsoft/monaco-editor#3784 for the usage of this API

@ElenaStoeva ElenaStoeva requested a review from a team as a code owner July 16, 2024 15:38
@ElenaStoeva
Copy link
Contributor Author

Thanks for the review and for the suggestion @eokoneyo! I addressed your feedback in 3504ed1.

@@ -188,6 +193,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
}),
fitToContent,
accessibilityOverlayEnabled = true,
enableFindAction = false,
Copy link
Contributor

@eokoneyo eokoneyo Jul 17, 2024

Choose a reason for hiding this comment

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

nit: we don't actually need to specify false, undefined is also a falsy value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that makes sense. Changed with bab9b40.

Copy link
Contributor

@eokoneyo eokoneyo left a comment

Choose a reason for hiding this comment

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

@ElenaStoeva tested this, it works perfectly well. Thanks for making the change

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
console 457.1KB 457.1KB +40.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-css 206.6KB 211.9KB +5.3KB
kbnUiSharedDeps-srcJs 3.2MB 3.3MB +72.3KB
total +77.6KB
Unknown metric groups

API count

id before after diff
@kbn/code-editor 40 41 +1

ESLint disabled line counts

id before after diff
@kbn/code-editor 2 3 +1

Total ESLint disabled count

id before after diff
@kbn/code-editor 2 3 +1

History

cc @ElenaStoeva

@yuliacech yuliacech self-requested a review July 23, 2024 10:08
monaco.editor.addKeybindingRule({
// eslint-disable-next-line no-bitwise
keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyF,
command: enableFindAction ? 'actions.find' : null,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: instead of registering the keybindings with a null action, I think we could only register the key binding if the find action is enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we added the find action import in packages/kbn-monaco/src/monaco_imports.ts, this action is now enabled by default in every Monaco editor, unless we disable it. Therefore, we need to specify explicitly that the key binding should run no action; otherwise it would run the find action by default.

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Thanks a lot for adding the search bar, @ElenaStoeva!
Tested locally and all works as expected 👍

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

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

id before after diff
console 457.2KB 457.2KB +40.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-css 206.6KB 211.9KB +5.3KB
kbnUiSharedDeps-srcJs 3.2MB 3.3MB +72.3KB
total +77.6KB
Unknown metric groups

API count

id before after diff
@kbn/code-editor 40 41 +1

ESLint disabled line counts

id before after diff
@kbn/code-editor 2 3 +1

Total ESLint disabled count

id before after diff
@kbn/code-editor 2 3 +1

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

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva merged commit 3c97fba into elastic:main Jul 23, 2024
21 checks passed
@kibanamachine kibanamachine added v8.16.0 backport:skip This commit does not require backporting labels Jul 23, 2024
TinLe added a commit to TinLe/kibana that referenced this pull request Jul 30, 2024
* master: (3487 commits)
  `BedrockChat` & `GeminiChat` (elastic#186809)
  [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332)
  skip flaky suite (elastic#188997)
  [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580)
  [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608)
  [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943)
  Improve SearchSource SearchRequest type (elastic#186862)
  Deprecate Search Sessions config (elastic#188037)
  [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824)
  [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746)
  [Data Forge] Add `service.logs` dataset as a  data stream (elastic#188786)
  [Console] Fix failing bulk requests (elastic#188552)
  Update dependency terser to ^5.31.2 (main) (elastic#188528)
  [APM][ECO] Telemetry (elastic#188627)
  [Fleet] Fix uninstall package validation accross space (elastic#188749)
  Update warning on `xpack.fleet.enableExperimental` (elastic#188917)
  [DOCS][Cases] Automate more screenshots for cases (elastic#188697)
  [Fleet] Fix get one agent when feature flag disabled (elastic#188953)
  chore(investigate): Add investigate-app plugin from poc (elastic#188122)
  [Monaco Editor] Add Search functionality (elastic#188337)
  ...
TinLe added a commit to TinLe/kibana that referenced this pull request Jul 30, 2024
* master: (2400 commits)
  `BedrockChat` & `GeminiChat` (elastic#186809)
  [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332)
  skip flaky suite (elastic#188997)
  [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580)
  [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608)
  [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943)
  Improve SearchSource SearchRequest type (elastic#186862)
  Deprecate Search Sessions config (elastic#188037)
  [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824)
  [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746)
  [Data Forge] Add `service.logs` dataset as a  data stream (elastic#188786)
  [Console] Fix failing bulk requests (elastic#188552)
  Update dependency terser to ^5.31.2 (main) (elastic#188528)
  [APM][ECO] Telemetry (elastic#188627)
  [Fleet] Fix uninstall package validation accross space (elastic#188749)
  Update warning on `xpack.fleet.enableExperimental` (elastic#188917)
  [DOCS][Cases] Automate more screenshots for cases (elastic#188697)
  [Fleet] Fix get one agent when feature flag disabled (elastic#188953)
  chore(investigate): Add investigate-app plugin from poc (elastic#188122)
  [Monaco Editor] Add Search functionality (elastic#188337)
  ...
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 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.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Console Monaco migration] Search bar is not displayed
6 participants