opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.67k stars 875 forks source link

[Research] [Console] Investigate what's required to remove `legacy_core_editor` from the dev tools console #3823

Open joshuarrrr opened 1 year ago

joshuarrrr commented 1 year ago

As part of our efforts to clean up and remove legacy code, we're interested to figure out where and how any of the code in https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/plugins/console/public/application/models/legacy_core_editor is still used in the developer tools console today. Additionally, what's the role of https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/plugins/console/public/application/containers/editor/legacy ?

Note that we'd also like to better understand the relationship of legacy_code_editor and the https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/src/plugins/console/public/application/models/sense_editor.

curq commented 1 year ago

@joshuarrrr, can I please be assigned to this issue? I'm currently working on two other issues from the same track, and they require a better understanding of this plugin, including the legacy_core_editor. So I might as well take on this issue too.

curq commented 1 year ago

@joshuarrrr I did some investigation and these are my current findings. If you need more in-depth look at some parts please let me know.

legacy_core_editor

  1. Core Editor used in the SenseEditor constructor and is a property of SenseEditor (this.coreEditor)
  2. Methods of Core Editor are extensively used in a SenseEditor itself, in fact most of the methods of SenseEditor call CoreEditor methods.
  3. Other files like create.ts and create_readonly.ts from /legacy_core_editor are also used in several places. smart_resize.ts is only used within legacy_core_editor itself.
  4. There are several other places where functions from the legacy_core_editor were used.
  5. /legacy_core_editor/mode is responsible for Ace Editor rules.

containers/legacy/editor

Similarily to CoreEditor, there are several places where the legacy files are used. For example current Editor (containers/editor/editor.tsx) component imports EditorUI and EditorOutput from the /editor/legacy/, so clearly some of the legacy components (also methods) are directly used in non-legacy components and containers.


Conclusion

Overall, it seems that the SenseEditor extends the functionality of CoreEditor. My guess is that previously the migration to SenseEditor was performed by moving more of the CoreEditor functionality to SenseEditor step by step. The current legacy code is used in quite a lot of places and it doesn't seem there is an easy way to remove it.

However, it looks like the legacy_core_editor contains large chunk of the ace editor logic, so if we decide to move to another code editor decent part of the legacy_core_editor might become irrelevant. So it might be better to first decide whether we will replace ace editor.