-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ES UI Shared] Added README #72034
[ES UI Shared] Added README #72034
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing these guidelines @jloleysens ! overall looks great, I added a few comments, let me know your thoughts 👍
src/plugins/es_ui_shared/README.md
Outdated
modules. | ||
|
||
If it does not, you should create a module and expose it | ||
to public or server code following the conventions described above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...to public or server code (or both) ..."?
src/plugins/es_ui_shared/README.md
Outdated
|
||
If I wanted to add functionality for calculating a Fibonacci sequence browser-side one would find or create a `Math` module by: | ||
|
||
1. Creating a folder `./__packages_do_not_import__/math`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add that the name of the folder should match the name of the package that will be exported. So math
will be Math
and index_managemnt
will be IndexManagement
?
src/plugins/es_ui_shared/README.md
Outdated
If I wanted to add functionality for calculating a Fibonacci sequence browser-side one would find or create a `Math` module by: | ||
|
||
1. Creating a folder `./__packages_do_not_import__/math`. | ||
2. Write your function (with accompanying tests) in `./__packages_do_not_import__/math`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe give the example with the filename too?
Write your function (with accompanying tests) in ./__packages_do_not_import__/math/calculate_fibonacci.ts
.
src/plugins/es_ui_shared/README.md
Outdated
4. Create a folder `./public/math`. | ||
5. Export all functionality from `./__packages_do_not_import__/math` in `./public/math/index.ts`. | ||
6. In `./public/index.ts` import `./public/math` using `import * as Math from './public/math;`. The name given here is really important and will be what consumers depend on. | ||
7. Export `Math` from `./public/index.ts`, `export { ..., Math }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe here be more specific as we already export multiple modules?
Add the Math
module to the list of exported modules in ./public/index.ts
, e.g. export { <...other modules>, Math }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the intention behind requiring the use of namespaces, but I don't think naming collisions will be a problem for us. In my experience naming collisions are rare and usually occur when two separate codebases are managed by separate teams that are unaware of one another. In our case, we're maintaining the entire codebase so I think we'll be able to anticipate and avoid any naming collisions that arise.
There are existing examples of large module surface areas that don't have naming collisions, e.g. the 65 service functions/variables exported by EUI. So I think there's some reassuring precedent.
That said, I'm comfortable moving forward with the structure we currently have if everyone likes it (disagree and commit for the win!).
I'm approving the PR to unblock progress, but I would really like @yuliacech to review this when she gets back next week. As the freshest member of the team, I think she's in the best position to suggest ways to improve these kinds of docs.
@cjcenizal The problem is not that we won't be able to solve collisions issues. As you say, we are maintaining the entire code base. The problem is that a package has to be independent and be able to give names in its context without having to tweak and prepend/append suffixes to its name to distinguish from other packages. ( The example you give from EUI is slightly different. In our case, we have a much broader scope (Forms, Monaco, Http Request, reusable UI components, utils services...) that will keep on growing. |
@cjcenizal Thanks for the feedback! I tend to agree that avoiding name collisions is a more theoretical bonus in some cases. I can see its usefulness quite directly for functionality in domains like Ace and Monaco. For the example of the 65 shared services and values from EUI I see namespacing is being used for At this point my vote is to create namespaces for functionality exported from A different benefit of namespacing I was thinking of recently, is colocating origin/domain with functionality (specifically function names). I find it is helpful to see This point 👆🏻 goes against a common practice in our JS/TS code to destructure. If we avoid destructuring in this case, I think we have another benefit to readability with namespaces. |
+++
I agree. And I also think that if we do deconstruct right on top of the component for example we still have the context right there in the file. |
To clarify, I'm against the requirement of namespaces. If someone thinks a module's design benefits from a namespace, then I think they should feel free to use one. FWIW, |
|
||
### Example | ||
|
||
If I wanted to add functionality for calculating a Fibonacci sequence browser-side one would do the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor grammar note: "If one wanted to ... one would do the following ..."
## Files and folders overview | ||
|
||
- `./public` | `./server`. Folders for grouping server or public code according to the Kibana plugin pattern. | ||
- `./__packages_do_not_import__` is where actual functionality is kept. This enables modules more control over what functionality is directly exported and prevents parts of modules to be depended on externally in unintended ways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor grammar note: "to be dependent" or "to depend".
Also I feel like a word is missing here? "to be dependent on externally <missing_word> in unintended ways"
Hi @jloleysens , thanks a lot for the detailed write up for
|
In regard to the example of Aside, they are already at 368L, I don't think this file is very "scanable". @yuliacech The "static" folder will be removed and its content will go to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this readme @jloleysens! I’m happy with this direction.
I agree with this, although I also think it might be worth reaching out to the platform to learn about their experience as CJ pointed out. |
From a conversation I had this morning with @kobelb re #71566, I gleaned that our code organization could be heading in a direction akin to Java packages or Go packages. If our code organization evolves in this direction then our use of namespaces here might make it easier to align with that direction. |
I had a chat with @stacey-gammon today about the future of code-sharing in Kibana, based off #71566 (comment). She'd like generalized code for building plugins and apps to be shared only through the App Arch or Platform team and not through domain-specific teams (like ES UI), out of concerns for stability and maintenance. I think we can support this by making it clear that the |
I can understand the concerns. At the same time, I think we might want to have some guidance on how to promote reusable solutions we build. We have many packages that could be useful to other teams that might not fall in the "for all teams" category (like we saw for the form lib). If we look at the last reusable component I added, the GlobalFlyout, it would be a waste of resources to have other teams build their own solution for the same problem. Or simply not know about it.
What does this mean for the siem team consuming the form lib? [EDIT] To make my question clearer: what would be the protocol to move some "es_ui_shared" code out of that folder and to some other (?) folder and say: "hey, we've built this reusable solution, the API is stable and it is fully tested and documented. It helps us solving X, you might want to try it out if you have the same problem!". [EDIT 2]: @cjcenizal I just read #71566 (comment), If we can define a formal path for sharing code more broadly to test its generalizability we can get rid of es_ui_shared.. I think we are aligned! 😊 |
My understanding is that Stacey is defining and documenting this process for sharing generalized code, so we don't have it yet but we will at some point. In the meantime, I think we're sort of in a holding pattern when it comes to sharing code. So I suggest that we:
|
Thanks all for the feedback! This was really good information for us all to see :). I will update the README with a note that we are still developing a pattern for sharing code across Kibana and that this is intended primarily for use within the ES UI team. |
Looks like the outdated check is ignoring PRs which it thinks are just docs changes... no good |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
4 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
Per title.
Additional Context
See comment on file changes: https://github.com/elastic/kibana/pull/70903/files#r455637115