Skip to content

make IndexPattern class static #69379

@ppisljar

Description

@ppisljar

In order to be able to use index patterns inside other plugins without dependency on index patterns runtime contract we should make the IndexPatterns class static. (for example using them inside expressions). We want to use the logic to help working with index patterns field list but we will not be loading, saving or updating the index pattern.

that is possible if all the stateful logic is extracted to the index patterns service:

  • index pattern creation (fetching fields, talking to kibana api)
  • saving (talking to kibana api_
  • loading
  • refreshing field list

[ ] these methods should be removed from index pattern class and moved to index patterns service:

  • init: move to indexPatternsService.get(indexPatternId: string)
  • popularizeField: remove, only used by discover, move it to use save, as save will be refactored not to show toasts but rather throw in case of errors, discover can decide to handle that as it wants
  • create: move to indexPatternsService.save(indexPattern: IndexPattern)
  • save: move to indexPatternsService.save(indexPattern: IndexPattern)
  • fetchFields: move to indexPatternsService.updateFields(indexPattern: IndexPattern)
  • refreshFields: remove, move the logic of showing the error message to management app (if updateFields failed)
  • destroy: move to indexPatternService.delete(indexPatternId: string)

[x] remove all toast notifications or passing in error handlers but rather throw when something goes wrong

  • inside index_pattern.ts
  • inside field.ts
  • inside index_patterns.ts

at this point IndexPattern class should not need any dependencies passed in and can be exported statically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:Data ViewsData Views code and UI - index patterns before 8.0Meta

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions