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 Storage ⇒ NP #49448

Merged
merged 10 commits into from
Oct 29, 2019
Merged

Move Storage ⇒ NP #49448

merged 10 commits into from
Oct 29, 2019

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Oct 27, 2019

Summary

Resolves #47160

Storage is a wrapper around the browser's localStorage or sessionStorage, adding JSON handling for stored items.

It now resides in NP under kibana_utils.

Dev Docs

Move Storage to kibana_utils.

  • Move Storage class to NP, and introduce the interface IStorageWrapper for when we only pass storage around.
  • Rename places where storage was called store
  • Load the Storage directives only where applicable (not in autoload)

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@lizozom lizozom added release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v8.0.0 Team:AppArch Feature:NP Migration v7.6.0 labels Oct 27, 2019
@lizozom lizozom requested a review from a team October 27, 2019 14:09
@lizozom lizozom requested review from a team as code owners October 27, 2019 14:09
@lizozom lizozom self-assigned this Oct 27, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
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.

KibanaApp changes LGTM if build gets green

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lizozom lizozom requested a review from ppisljar October 28, 2019 09:22
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@streamich streamich mentioned this pull request Oct 28, 2019
9 tasks
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Storage } from 'ui/storage';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you have to have a path like this... I seem to recall Kibana paths aliased in Webpack so you can just do src/plugins/kibana_utils/public...?

For example: https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/browser/location.ts#L7

Copy link
Contributor

Choose a reason for hiding this comment

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

Asked and answered: #40446

Approving for Canvas... thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@clintandrewhall I'm familiar with that issue, but as far as I know it works for TS types but not for classes \ functions. Are you aware of any changes there?

@ppisljar ppisljar requested a review from a team October 29, 2019 06:46
Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

this is something that should be owned by platform team ideally @joshdover

@pgayvallet
Copy link
Contributor

@ppisljar we've got #41982 in the backlog regarding storages.

However the PR implementation still provides a global-exposed constructor for Storage that can be instantiated from anywhere and that have direct access to the whole local/session storages, so I'm not really sure this will ease migration when #41982 is implemented, as we plan to provide per-plugin isolated storage accessors accessible somewhere from CoreSetup/Start

@lizozom
Copy link
Contributor Author

lizozom commented Oct 29, 2019

@pgayvallet Could we still go ahead with that PR, as it cleared up a lot of unclear code, and migrate to your service once available?

@pgayvallet
Copy link
Contributor

pgayvallet commented Oct 29, 2019

Yes of course, it's still an improvement compared to before. It's just that platform should not gain ownership of the feature until #41982 is done.

Will properly review today


public setup(core: CoreSetup, { __LEGACY }: DataPluginSetupDependencies): DataSetup {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little scared about the changes on the way the storage is now accessed. What I mean is that before, the storage access was provided by a setup dependency (DataPluginSetupDependencies), and now the storage can be accessed basically from anywhere in the code base with a simple new Storage(window.localStorage), which may makes the migration more difficult when we'll implement #41982, as more calls may be added in places where there is no proper access to core APIs.

@joshdover WDYT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pgayvallet I agree that the way that storage was and is handled right now is not great. Even before this PR, apps would randomly create their own storage representation and pass it around. And this PR doesn't change the way this is handled (checkout x-pack/legacy/plugins/graph/public/app.js or x-pack/legacy/plugins/lens/public/app_plugin/plugin.tsx for example).

The __LEGACY wrapper was there only to mark the fact that Storage was imported from ui/public and not from NP. Now that it's moved to NP, we don't need that any more.

What we should do is, once platform team offers a core storage access service, is replace every occurrence of new Storage with that service.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lizozom lizozom merged commit a6d0b60 into elastic:master Oct 29, 2019
lizozom pushed a commit to lizozom/kibana that referenced this pull request Oct 29, 2019
* Move storage to kibana_utils

* Updated all references to Storage and replace places where it was referenced to as "store" to avoid confusion.

* fixed tests

* Delete data legacy dependencies plugin

* Imports fix

* update snapshots
lizozom pushed a commit that referenced this pull request Oct 29, 2019
* Move storage to kibana_utils

* Updated all references to Storage and replace places where it was referenced to as "store" to avoid confusion.

* fixed tests

* Delete data legacy dependencies plugin

* Imports fix

* update snapshots
@elasticmachine
Copy link
Contributor

💔 Build Failed

@lizozom lizozom changed the title Move Storage ⇒ NP kibana_utils Move Storage ⇒ NP Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui/storage 👉 kibana_utils/storage
6 participants