-
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
Move ui/indices into es_ui_shared plugin. #60186
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
// Note: we can't import from "ui/indices" as the TS Type definition don't exist | ||
// import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; | ||
// @ts-ignore | ||
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../indices'; |
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.
@sebelga AFAICT this file isn't consumed anywhere, so I wasn't sure how to test this. I don't want to spend time writing a test for it. I'm inclined to leave it with the expectation that a problem will be surfaced and fixed if/when we consume this file. What are your thoughts?
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.
OK, although I think it would have been nice to make use of this single validator in our apps instead of re-writing it multiple times as I've seen. Maybe as a second pass 😊
@elasticmachine merge upstream |
c15fd11
to
911640d
Compare
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.
Code owner changes are only whitespaces
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 making those changes @cjcenizal ! I am concerned about 3 things
- The folder structure of our
es_ui_shared
folder.
I am thinking of moving the forms
and validators
out of the static
folder and move the content to either public
either common
folders.
I think we should only have 3 top-level folders "public" "server" and "common", like all plugins. I was surprised to see the console_lang
as a top-level folder. It should be under a "console" folder in public
.
- Specific methods to validate indices
Now that we have generic validators, I think we should use them instead of adding the ones specific to indices. This means that from the "indices" folder we should probably only export the constants.
- We should export everything from the top-level "public" or "server" folder.
I am surprised the linting does not complain about importing from other folders but for us, maintainers of the es_ui_shared
folder, it makes our life much easier if we know that everything that other apps consume is exported from our 2 barrels files. This also means that we will probably need to namespace our exports
// es_ui_shared/public/index.ts
export const indices = {
INDEX_ILLEGAL_CHARACTERS_VISIBLE,
};
Let me know what you think! 👍
@@ -0,0 +1,26 @@ | |||
/* |
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 think it would be better to rename the .js
files to .ts
instead of using a declaration file.
Also, I don't think we need those functions anymore as we have generic validator for each of them:
indexNameBeginsWithPeriod(value)
-->startsWith('.')(value)
findIllegalCharactersInIndexName(value)
-->containsChars(INDEX_ILLEGAL_CHARACTERS_VISIBLE)(value)
indexNameContainsSpaces(value)
-->containsChars(' ')(value as string)
Can we use those instead?
// Note: we can't import from "ui/indices" as the TS Type definition don't exist | ||
// import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; | ||
// @ts-ignore | ||
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../indices'; |
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.
OK, although I think it would have been nice to make use of this single validator in our apps instead of re-writing it multiple times as I've seen. Maybe as a second pass 😊
@@ -29,7 +29,8 @@ import { | |||
EuiTitle, | |||
} from '@elastic/eui'; | |||
|
|||
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from 'ui/indices'; | |||
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../../src/plugins/es_ui_shared/indices'; |
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.
Shouldn't we expose our static code from the public
folder?
@elasticmachine merge upstream |
Thanks for the review @sebelga! Great points. I moved the indices directory into public as you suggested and also converted everything to TS. I believe refactoring the code to use the generic validator is out of scope for this PR, as it would introduce unnecessary risk of regression, so I'd like to defer that to another PR. Could you take another look please? |
@@ -30,6 +29,7 @@ import { | |||
EuiTitle, | |||
} from '@elastic/eui'; | |||
|
|||
import { INDEX_ILLEGAL_CHARACTERS_VISIBLE } from '../../../../../../../../src/plugins/es_ui_shared/public'; |
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.
It would be better to namespace our export.
import { indices } from '../../../../../../../../src/plugins/es_ui_shared/public;
const { INDEX_ILLEGAL_CHARACTERS_VISIBLE } = indices;
This will avoid naming collisions and better organization of all our exports.
@@ -12,8 +12,7 @@ import { | |||
indexNameBeginsWithPeriod, | |||
findIllegalCharactersInIndexName, | |||
indexNameContainsSpaces, | |||
} from 'ui/indices'; | |||
|
|||
} from '../../../../../../../src/plugins/es_ui_shared/public'; |
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.
Same here, it would be better to namespace under indices
@sebelga Done. Could you re-re-review please? |
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.
LGTM! Thanks for making the changes!
c33debd
to
6bc97b3
Compare
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Convert js files to ts. * Add indices namespace.
* master: (35 commits) [Alerting] Adds navigation by consumer and alert type to alerting (elastic#58997) Introduce search interceptor (elastic#60523) [ML] Add functional tests for file data visualizer (elastic#60413) [APM] Optimize service map query (elastic#60412) [SIEM][Detection Engine] Adds lists feature flag and list values to the REST interfaces Enhancement/update esdocs datasource (elastic#59512) [junit] only include stdout in report for failures (elastic#60530) Update dependency nock to v12 (elastic#60422) upgrade execa to get stdout/stderr in error messages (elastic#60537) skip flaky suite (elastic#60471) [Ingest] Agent Config Details - Data sources list ui (elastic#60429) [SIEM] Create ML Rules (elastic#58053) skip flaky suite (elastic#60559) fix agent type (elastic#60554) Fixed default message for index threshold includes both threshold values (elastic#60545) [Ingest] Add support for `yaml` field types (elastic#60440) Solved the issue for a GROUP BY expression validation (elastic#60558) [Maps] Mark instance state as readonly (elastic#60557) Move ui/indices into es_ui_shared plugin. (elastic#60186) ServiceNow action improvements (elastic#60052) ...
* master: (64 commits) [Alerting] Adds navigation by consumer and alert type to alerting (elastic#58997) Introduce search interceptor (elastic#60523) [ML] Add functional tests for file data visualizer (elastic#60413) [APM] Optimize service map query (elastic#60412) [SIEM][Detection Engine] Adds lists feature flag and list values to the REST interfaces Enhancement/update esdocs datasource (elastic#59512) [junit] only include stdout in report for failures (elastic#60530) Update dependency nock to v12 (elastic#60422) upgrade execa to get stdout/stderr in error messages (elastic#60537) skip flaky suite (elastic#60471) [Ingest] Agent Config Details - Data sources list ui (elastic#60429) [SIEM] Create ML Rules (elastic#58053) skip flaky suite (elastic#60559) fix agent type (elastic#60554) Fixed default message for index threshold includes both threshold values (elastic#60545) [Ingest] Add support for `yaml` field types (elastic#60440) Solved the issue for a GROUP BY expression validation (elastic#60558) [Maps] Mark instance state as readonly (elastic#60557) Move ui/indices into es_ui_shared plugin. (elastic#60186) ServiceNow action improvements (elastic#60052) ...
Fixes #52804
To test, ensure index name validation works in CCR auto-follow pattern and follower index creation forms, and the rollup job wizard. Ensure that help text still renders the disallowed characters
\ / ? , " < > | *
.