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

Spaces - Client NP Migration, Phase 1 #40856

Merged
merged 66 commits into from
Dec 16, 2019

Conversation

legrego
Copy link
Member

@legrego legrego commented Jul 11, 2019

Summary

This introduces a shim in the client-side spaces plugin to start migrating to the new platform.

This PR uses the following NP core/plugin services:

  • Chrome Nav Control
  • Feature Catalogue Registry

This PR also performs some ancillary cleanup/prep work for when the rest of the plugin is able to migrate:

  • Introduce NP "Plugin" in legacy world
  • Migrate Chrome Nav Control to NP
  • Remove SpacesNavState, an unnecessary angular service
  • Update SpacesManager to use NP dependencies (http and notifications)
  • Initialize SpacesManager once within NP, consume single instance everywhere
  • Remove almost all injected variables, replace with private API calls
  • Replace usages of ui/capabilities with the NP equivalent
  • Migrate Feature Catalogue Registration to NP

Resolves #46255

Out of scope

  • Management screens - ⛔️ blocked: relies on legacy Kibana plugin/uiExports
  • Space selector screen door - ⛔️ blocked: relies on legacy Kibana for rendering hidden apps

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

const telemetryOptInProvider = Private(TelemetryOptInProvider);

const spaceProps = {
spacesEnabled,
};

if (spacesEnabled) {
Copy link
Member Author

Choose a reason for hiding this comment

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

stray code, was not being used in TememetryForm component

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -25,7 +26,6 @@ import { Space } from '../../../common/model/space';
import { SpaceCards } from '../components/space_cards';

interface Props {
spaces?: Space[];
Copy link
Member Author

Choose a reason for hiding this comment

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

If this.props.spaces was provided, it was via injected variables, which have been removed as part of this PR. Now, the selector screen must request the list of spaces on mount.

@@ -175,6 +187,14 @@ class SpacesMenuUI extends Component<Props, State> {
</EuiContextMenuItem>
);
};

private rendePlaceholderMenuItem = (key: string | number): JSX.Element => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not strictly required as part of this migration, but it makes for a better user experience when loading the list of available spaces. We often take the near-immediate responses for granted when running locally, and forget that these things can take a noticeable amount of time when hosted in the real world.

Copy link
Member

Choose a reason for hiding this comment

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

++, it actually looks very nice (testing with throttled network connection) 👍

Suggested change
private rendePlaceholderMenuItem = (key: string | number): JSX.Element => {
private rendePlaceholderMenuItem = (key: string | number) => {

@legrego legrego added Feature:New Platform Feature:Security/Spaces Platform Security - Spaces feature release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels Jul 12, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security

@elasticmachine
Copy link
Contributor

💔 Build Failed

@legrego
Copy link
Member Author

legrego commented Jul 12, 2019

retest

Copy link
Contributor

@afgomez afgomez left a comment

Choose a reason for hiding this comment

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

👋! I pulled the branch locally to test the infra changes and I found a thing.

I have two spaces: default and afgomez. I'm normally in the second space.

The changes in the useKibanaSpaceId hook cause the log analysis page to misbehave (in the "Logs" app, the second tab).

This is what I got on master

Screenshot 2019-12-10 at 14 25 44

This is what I got on this branch

Screenshot 2019-12-10 at 16 11 20

As you can see the content of the page changes, showing the wrong results when using this branch. I added a console.log after this line to see the value of spaceId before each render.

I think the issue is that useKibanaSpaceId is now asynchronous. We either need to make sure that it's synchronous again or allow it to return undefined if the space is not loaded yet. Then the components can decide how to render their respective trees in the absense of a spaceId.

I hope the description of the issue is clear. Please reach out to me if you have any questions <3

@legrego
Copy link
Member Author

legrego commented Dec 10, 2019

@afgomez thanks so much for testing and leaving feedback!

I updated the hook locally to return string | undefined, but the fallout from that cascades throughout the app, to the point where I'm not comfortable making the changes on my own (or as part of this PR)

I'll give this some more thought, but I'm learning towards re-introducing the activeSpace injected var to the legacy platform so that you can continue to consume this as-is, but then your migration to the NP will potentially require you to handle the space id arriving in an async manner.

@afgomez
Copy link
Contributor

afgomez commented Dec 11, 2019

your migration to the NP will potentially require you to handle the space id arriving in an async manner.

@legrego that should be OK. We will take it into account :)

Thanks!

@legrego
Copy link
Member Author

legrego commented Dec 11, 2019

@afgomez I restored the original functionality, and the log analysis UI appears to function correctly for me now. Would you mind double-checking for me when you get a chance?

Copy link
Contributor

@afgomez afgomez left a comment

Choose a reason for hiding this comment

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

@legrego thanks for this! I tried again and it works like a charm.

Infra changes LGTM

@legrego
Copy link
Member Author

legrego commented Dec 13, 2019

@elasticmachine merge upstream

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for doing this! I've played with a number of basic Spaces related operations - everything worked as expected.

@legrego
Copy link
Member Author

legrego commented Dec 16, 2019

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

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

@legrego legrego added the v7.6.0 label Dec 16, 2019
@legrego legrego merged commit fcdaed9 into elastic:master Dec 16, 2019
@legrego legrego deleted the np/spaces-nav-control branch December 16, 2019 13:31
legrego added a commit that referenced this pull request Dec 16, 2019
* Spaces - Client NP Migration, Phase 1 (#40856)

* shimming NP for spaces client-side plugin

* refresh active space in nav control when updated

* fix advanced settings screen

* allow npStart from unauthed routes

* use NP for deriving space management url

* remove security's usage of SpacesManager

* remove usages of ui/capabilities

* fix tests

* implement NP plugin interface

* remove hack in favor of convention in migration guide

* shim feature catalogue registration

* streamline nav control, and handle async loading more gracefully

* adding opaqueId

* fixes from merge

* fix merge from master

* fixing merge from master

* move _active_space route to NP

* moving to the NP feature catalogue registry

* moving setup to setup phase

* optimizing active space retrieval

* reverting test isolation change

* Apply suggestions from code review

Co-Authored-By: Aleh Zasypkin <[email protected]>

* removing unnecessary PluginInitializerContext

* updating advanced settings subtitle

* using NP anonymousPaths service

* additional nav_control_popover cleanup

* additional cleanup

* testing out onActiveSpaceChange$ property

* make the linter happy

* make the type checker happy

* fixing types

* fix merge from master

* spaces LP init should run on all pages, not just the kibana app

* address nits

* fix infra/logs, and the spaces disabled scenario

* fix typescript errors

* revert changes to infra plugin

* reintroducing activeSpace injected var for legacy plugins

* fixing react deprecation warning and unhandled promise rejection

* restore activeSpace default var

* spaces does not need to check its own enabled status

* fix from merge

Co-authored-by: Elastic Machine <[email protected]>

* fix backport merge
brianseeders added a commit to brianseeders/kibana that referenced this pull request Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration Feature:Security/Spaces Platform Security - Spaces feature release_note:skip Skip the PR/issue when compiling release notes Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors with nav control when spaces are disabled
8 participants