Skip to content

[NP] Migrate uiSettings owned by Kibana app#64321

Merged
kertal merged 25 commits intoelastic:masterfrom
maryia-lapata:ui_settings
May 15, 2020
Merged

[NP] Migrate uiSettings owned by Kibana app#64321
kertal merged 25 commits intoelastic:masterfrom
maryia-lapata:ui_settings

Conversation

@maryia-lapata
Copy link
Copy Markdown
Contributor

@maryia-lapata maryia-lapata commented Apr 23, 2020

Summary

Fixes #63597.

This PR migrates the following ui settings to the new platform:

  • to discover:
    • defaultColumns
    • discover:sampleSize
    • discover:aggs:terms:size
    • discover:sort:defaultOrder
    • discover:searchOnPageLoad
    • doc_table:hideTimeColumn
    • fields:popularLimit
    • context:defaultSize
    • context:step
    • context:tieBreakerFields
  • to data:
    • metaFields
    • doc_table:highlight
  • to charts:
    • visualization:colorMapping
  • to vis_type_vislib:
    • visualization:dimmingOpacity
    • visualization:heatmap:maxBuckets
  • to saved_objects:
    • savedObjects:perPage
    • savedObjects:listingLimit
  • to vis_type_timeseries:
    • metrics:max_buckets
  • remove visualization:loadingDelay since it's unused.

i18n IDs were updated respectively.

@maryia-lapata maryia-lapata added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:NP Migration v7.8.0 labels Apr 23, 2020
@maryia-lapata
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@kertal
Copy link
Copy Markdown
Member

kertal commented Apr 27, 2020

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@kertal kertal self-assigned this Apr 28, 2020
@kertal
Copy link
Copy Markdown
Member

kertal commented Apr 28, 2020

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@kertal kertal marked this pull request as ready for review April 28, 2020 13:27
@kertal kertal requested a review from a team April 28, 2020 13:27
@kertal kertal requested review from a team as code owners April 28, 2020 13:27
@kertal kertal requested a review from flash1293 April 28, 2020 13:28
Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

Maps changes LGTM
code review

Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

I'm +1 with @restrry's comment here:

I wonder if moving the uiSettings name constants to their respective new owners and exposing these constants to other plugins is really the correct approach here.

Main issue with this is that you can import / use settings declared from plugins you don't have a declared dependency with (see first review comment)

I think exposing accessors to the settings via their owners contracts is probably more compliant with KP way of doing things, and will also ensure that you cannot use/access settings from plugins you don't depend on.

Accessing a setting from within the owner plugin's code would remain unchanged

import { MAX_BUCKETS_SETTING } from '../common/constants';
 const maxBuckets = config.get(MAX_BUCKETS_SETTING);

But accessing a setting owned by another plugin would be something like

const externalSetting = startDeps.dependencyPlugin.settings.getMaxBuckets()

I'm aware these are way more impactful changes than this PR's implementation, but I really think that's the way to go.

@restrry / @joshdover are we on the same page?

@joshdover
Copy link
Copy Markdown
Contributor

I agree with that plugins should only have access to the settings that either (1) Core exposes (2) plugins they depend on expose (3) they own themselves.

I also think that to accomplish that we need a much larger change to how this service works in order to enforce those boundaries. Same goes for saved object types. We probably shouldn't allow arbitrary access to any SO type.

So maybe for now we try to follow the pattern @pgayvallet laid out above where it's easy & feasible, but if there are some cases that don't fit nicely into that pattern we can solve that separately later?

@kertal
Copy link
Copy Markdown
Member

kertal commented May 11, 2020

So maybe for now we try to follow the pattern @pgayvallet laid out above where it's easy & feasible, but if there are some cases that don't fit nicely into that pattern we can solve that separately later?

I do agree and I'm currently adapting the PR to the pattern @pgayvallet suggested, where possible

Comment on lines +36 to +37
schema: schema.arrayOf(schema.string()),
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: I'm wondering whether we know all of them to declare validation as a union of well-known strings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

here are mapping fields. but not all e.g. _score of the query context is missing, think it should stay flexible, just in case
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-fields.html

@kertal kertal requested a review from mattkime May 14, 2020 15:43
Copy link
Copy Markdown
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested against current master and all settings are still there. LGTM.

While looking through the code I noticed we need to do the same thing for a bunch of timelion settings, I will create a separate issue for that.

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

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

import { fieldWildcardMatcher } from '../../../../../../../../../plugins/kibana_utils/public';
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public';
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public';
import { META_FIELDS_SETTING } from '../../../../../../../../../plugins/data/common';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I'm not wrong we are trying to avoid imports from /common folder.

Also I think that this approach introduce a lot of fields in our static contract which also not good.

Maybe we can move all into one variable:

const UI_SETTINGS = {
  META_FIELDS_SETTING: 'meta_field',
  DEFAULT_QUERY_LANGUAGE: 'kuery',
  META_FIELDS_SETTING: `'metaFields',`
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sorry, seems we had a comment/merge race condition. seen this comment after the merge. since this part of Kibana was in the legacy world, and it's currently migrated, this could be done in or after #65026

@kertal kertal merged commit 7c8eea1 into elastic:master May 15, 2020
@kertal kertal added v7.9.0 and removed v7.8.0 labels May 15, 2020
kertal pushed a commit to kertal/kibana that referenced this pull request May 15, 2020
* Move META_FIELDS_SETTING, DOC_HIGHLIGHT_SETTING to data plugin.ts

* Refactor table_list_view.tsx to no longer get PER_PAGE_SETTING by uiSettings

* Migrate graph, visualize, dashboard usage of saved_objects module constants to accessor functions

* Remove redundant logging in plugins start and setup methods

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>

# Conflicts:
#	src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts
kertal added a commit that referenced this pull request May 15, 2020
* Move META_FIELDS_SETTING, DOC_HIGHLIGHT_SETTING to data plugin.ts

* Refactor table_list_view.tsx to no longer get PER_PAGE_SETTING by uiSettings

* Migrate graph, visualize, dashboard usage of saved_objects module constants to accessor functions

* Remove redundant logging in plugins start and setup methods

Co-authored-by: Maryia Lapata <mary.lopato@gmail.com>
Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
gmmorris added a commit to gmmorris/kibana that referenced this pull request May 15, 2020
* master: (191 commits)
  [Maps] Get number of categories from palette (elastic#66454)
  move oss features registration to KP (elastic#66524)
  [kbn/plugin-helpers] typescript-ify (elastic#66513)
  Add kibana-operations as codeowners for .ci/es-snapshots and vars/ (elastic#66746)
  FTR: move basic services under common folder (elastic#66563)
  Migrate Beats Management UI to KP (elastic#65791)
  [CI] Add 20 minutes to overall build timeout
  lint import from restricted zones for export exressions (elastic#66588)
  [SIEM][Detection Engine] Add validation for Rule Actions (elastic#63332)
  KP plugins shouldn't need package.json (elastic#66654)
  Replace agent metrics link with the new one (elastic#66632)
  [CI] Add one retry to setup step (elastic#66638)
  [CI] Add slack alerts to tracked branch jobs, change default channel, change formatting (elastic#66580)
  [docLinks] Add docLinks to CoreSetup. (elastic#66631)
  [DOCS] Rename monitoring collection from internal to legacy (elastic#65781)
  unskip newsfeed tests (elastic#66562)
  [NP] Migrate uiSettings owned by Kibana app (elastic#64321)
  [ML] Functional tests - stabilize typing in DFA mml input (elastic#66706)
  [Map] return bounding box for static feature collection without joins (elastic#66607)
  remove trailing slash in graph sample data links (elastic#66358)
  ...
@kertal kertal added the Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// label May 25, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:NP Migration release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v7.9.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[uiSettings]: Migrate items owned by Kibana app to new platform