Skip to content

[Endpoint] Common PageView and LinkToApp components#60819

Merged
paul-tavares merged 21 commits intoelastic:masterfrom
paul-tavares:task/EMT-FE-common-components
Mar 26, 2020
Merged

[Endpoint] Common PageView and LinkToApp components#60819
paul-tavares merged 21 commits intoelastic:masterfrom
paul-tavares:task/EMT-FE-common-components

Conversation

@paul-tavares
Copy link
Copy Markdown
Contributor

@paul-tavares paul-tavares commented Mar 20, 2020

Summary

This PR contains the following:

  • A common PageView layout component.
    Ensure that all endpoint views are using a consistent layout. Currently, only the Policy List and Policy Details are using it.
  • A common LinkToApp component
    Its a EuiLink that utilizes services.application.navigateTo() to send a user to another app's URL without triggering a full page refresh. Policy List refactored to use it.
  • A common useNavigateToAppEventHandler() hook. Returns back an event handler callback that can be used with onClick events when wanting to create a Link or button that navigates to another app. Currently in use by the LinkToApp component.
  • Removes use of NP appBasePath (deprecated) in favor or using history to initialize react router (see Add ScopedHistory to AppMountParams #56705 for details)
  • Fixes bug in HeaderNav where section sub-routes would not show nav item as selected (seen currently when navigating to the Policy details)
  • Removed hello-world API that was initially part of the first NP plugin commit
  • Add the Endpoint Security app icon to the plugin registration so that it is used on Kibana's side navigation.

Checklist

Delete any items that are not applicable to this PR.

@paul-tavares paul-tavares added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.7.0 Team:Endpoint Management Feature:Endpoint Elastic Endpoint feature labels Mar 20, 2020
@paul-tavares paul-tavares requested a review from a team as a code owner March 20, 2020 21:11
@paul-tavares paul-tavares self-assigned this Mar 20, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/endpoint-management (Team:Endpoint Management)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

@paul-tavares
Copy link
Copy Markdown
Contributor Author

Once I get some feedback on this PR, I will add test cases on to this PR :)

defaultMessage: 'Policies',
})}
bodyHeader={
<EuiText color="subdued" data-test-subj="policyTotalCount">
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.

I think you need to adjust tests for checking for another data-test-subj, it checks for policyViewTitle now. We need to readjust

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, agreed. They are actually currently failing, but I wanted to hold off on fixing them until I got feedback that these changes look good to go in. :)

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.

the PageView component certainly lgtm, might have questions about the router and hook changes still

<KibanaContextProvider services={{ http, notifications, application, data }}>
<EuiThemeProvider darkMode={isDarkMode}>
<BrowserRouter basename={basename}>
<Router history={history}>
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.

why did we stop using <BrowserRouter> ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was a change request pushed down from the Kibana Platform - see #56705

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.

from the ticket, looks like they still use <BrowserRouter> in the after:

core.application.register({
  id: 'myApp',
  mount({ element, history }) {
    ReactDOM.render(
      <BrowserRouter history={history}>
        <App />
      </BrowserRouter>,
      element
    );
    return () => ReactDOM.unmountComponentAtNode(element);
  }
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kevinlog Thats a mistake. BrowserRouter does not accept the history prop 😃

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.

got it, sounds good

@aisantos
Copy link
Copy Markdown

aisantos commented Mar 24, 2020

@paul-tavares - Is there a link to the main issue this PR is related to or is this the issue? It looks like this is the issue and the PR. If so, could we add the AC? So I can help with adding test cases for our team :)

@paul-tavares
Copy link
Copy Markdown
Contributor Author

Hi @aisantos . I did not open an issue specifically for this, but I think I did have one on our backlog for misc. items. I'll find it and let you know.

Copy link
Copy Markdown
Contributor

@kevinlog kevinlog left a comment

Choose a reason for hiding this comment

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

LGTM based on past conversations surrounding unifying some of these navigation actions in the links. Would want another 👍 from another dev on another team - @kqualters-elastic @oatkiller etc

Copy link
Copy Markdown
Contributor

@kqualters-elastic kqualters-elastic left a comment

Choose a reason for hiding this comment

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

component stuff lgtm, and can't think of any problems off the top of my head with the nav hook. 👍 lgtm

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

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

@paul-tavares paul-tavares merged commit af316c5 into elastic:master Mar 26, 2020
@paul-tavares paul-tavares deleted the task/EMT-FE-common-components branch March 26, 2020 12:01
paul-tavares added a commit that referenced this pull request Mar 27, 2020
* a common PageView component
* Policy List cleanup + improvements to PageView
* Policy details refactored to use PageView layout
* Fix bug: header nav - ensure section sub-routes set nav to `isSelected`
* Added useNavigateToAppEventHandler hook
* Remove use of `appBasePath` and use `history` for initializing router
  - For details - see #56705
* Removed `hello-world` API
* Added `LinkToApp` component + refactor policy list to use it
* Add icon to plugin registration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants