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

Move ui/indices into es_ui_shared plugin. #60186

Merged
merged 6 commits into from
Mar 18, 2020

Conversation

cjcenizal
Copy link
Contributor

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 \ / ? , " < > | * .

@cjcenizal cjcenizal added chore Feature:CCR and Remote Clusters v8.0.0 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 Feature:Rollups v7.7.0 labels Mar 14, 2020
@cjcenizal cjcenizal requested a review from sebelga March 14, 2020 01:18
@cjcenizal cjcenizal requested a review from a team as a code owner March 14, 2020 01:18
@elasticmachine
Copy link
Contributor

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';
Copy link
Contributor Author

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?

Copy link
Contributor

@sebelga sebelga Mar 16, 2020

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 😊

@cjcenizal
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a 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

Copy link
Contributor

@sebelga sebelga left a 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 @@
/*
Copy link
Contributor

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';
Copy link
Contributor

@sebelga sebelga Mar 16, 2020

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';
Copy link
Contributor

@sebelga sebelga Mar 16, 2020

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?

@cjcenizal
Copy link
Contributor Author

@elasticmachine merge upstream

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Mar 17, 2020

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';
Copy link
Contributor

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';
Copy link
Contributor

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

@cjcenizal
Copy link
Contributor Author

@sebelga Done. Could you re-re-review please?

@sebelga sebelga self-requested a review March 17, 2020 17:18
Copy link
Contributor

@sebelga sebelga left a 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!

@cjcenizal
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@cjcenizal cjcenizal merged commit 9aad898 into elastic:master Mar 18, 2020
@cjcenizal cjcenizal deleted the chore/np-indices branch March 18, 2020 20:07
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Mar 19, 2020
* Convert js files to ts.
* Add indices namespace.
cjcenizal added a commit that referenced this pull request Mar 19, 2020
* Convert js files to ts.
* Add indices namespace.
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 19, 2020
* 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)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 19, 2020
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:CCR and Remote Clusters Feature:Rollups 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 v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate ui/indices to es_ui_shared for New Platform
5 participants