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

[Fleet] Support for showing an Integration Detail Custom (UI Extension) tab #83805

Merged

Conversation

paul-tavares
Copy link
Contributor

@paul-tavares paul-tavares commented Nov 19, 2020

Summary

  • Changes the Integration Details view to show a Custom tab if a UI Extension for the given Integration (Package) is registered
  • Refactor Public Plugin component in support of a UT testing rendering tool

Checklist

@paul-tavares paul-tavares added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 Team:Defend Workflows “EDR Workflows” sub-team of Security Solution labels Nov 19, 2020
@paul-tavares paul-tavares self-assigned this Nov 19, 2020
Comment on lines 72 to 78
return (
(CustomView && (
<ExtensionWrapper>
<CustomView />
</ExtensionWrapper>
)) || <Redirect to={getPath('integration_details', { pkgkey: pkgkey ?? '' })} />
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind breaking this up multiple statements? It took me a bit to unpack this at first, and I still got it wrong :)

Also, at least by reading, "get url for integrations_details with key empty string" seems odd. e.g. /app/fleet#/integrations/detail/. I think it works in the app, but let's explicitly send the user to named/working view like 'integrations_all`

Perhaps something like:

Suggested change
return (
(CustomView && (
<ExtensionWrapper>
<CustomView />
</ExtensionWrapper>
)) || <Redirect to={getPath('integration_details', { pkgkey: pkgkey ?? '' })} />
);
const redirectUrl = pkgkey
? getPath("integration_details", { pkgkey })
: getPath("integration_all");
return CustomView ? (
<ExtensionWrapper>
<CustomView />
</ExtensionWrapper>
) : (
<Redirect to={redirectUrl} />
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, Agreed. This is condition check because I'm trying to grab the value from the current URL. I'm actually going to change to build it manually based on Component's input props (we have what we need). I will also look to see if there is a utility function that does that from a centralized location (I seem remember such utility, but maybe it was server side).

<UIExtensionsContext.Provider value={extensions}>
<FleetStatusProvider>
<IntraAppStateProvider kibanaScopedHistory={history}>
<PackageInstallProvider notifications={coreStart.notifications}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you note why PackageInstallProvider was moved outside Router? I realize this is still Draft and don't ask because I'm against it. Just add a note to highlight and explain the goal when it's ready for review.

I haven't thought about Router & Context recently enough to know what might be affected or potential consequences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually - now that I look at this again (the refactored version), I don't think it matters. In order to avoid any potential issues, I will move it back inside of <Router>. Thanks @jfsiii

import { AppMountParameters } from 'kibana/public';
import { EuiCode, EuiEmptyPrompt, EuiErrorBoundary, EuiPanel } from '@elastic/eui';
import { createHashHistory, History } from 'history';
import { Router, Redirect, Route, Switch } from 'react-router-dom';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the subtle change from using HashRouter to using Router along with History's createHashHistory. This is so that it can support testing.

}),
render: (ui, options) => {
let renderResponse: RenderResult;
act(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was having some errors on the test runs output about react state updates being done outside of act() - I think they are coming from useRequest, but even after I added this they did not go away.

Copy link
Member

Choose a reason for hiding this comment

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

Did you try to trigger the timers after the render I know jest offer a way to do that maybe it will fix the warnings?

}
});

it('should not show a custom tab', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I plan to complete these, but might not be part of this PR. I would like to get this due to the major surgery done the Plugin refactoring due to continued master merge conflicts.

}

// Don't show `custom` tab if a custom component is not registered
if (panelId === 'custom' && !showCustomTab) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Q. Should the custom tab be visible to packages that are not installed?

I think thats ok, since the custom tab is meant to show integration specific links/info.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, I don't think we should show the tab unless the integration is installed

@paul-tavares paul-tavares marked this pull request as ready for review November 25, 2020 15:46
@paul-tavares paul-tavares requested a review from a team as a code owner November 25, 2020 15:46
@paul-tavares paul-tavares requested a review from a team November 25, 2020 15:46
@paul-tavares paul-tavares requested a review from a team as a code owner November 25, 2020 15:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)


http.get.mockImplementation(async (path) => {
if (typeof path === 'string') {
if (path === '/api/fleet/epm/packages/nginx-0.3.7') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI - as I continue to work on this test file, I think I will eventually suggest that we break out these API request test "handlers" into another test utility so that they can be used with other tests.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 440 446 +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.1MB 1.1MB +15.0KB

History

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

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

A few comments nothing blocking, really cool to have a base for UI tests 🚀

@@ -265,7 +65,7 @@ export function renderApp(
extensions: UIExtensionsStorage
) {
ReactDOM.render(
<IngestManagerApp
<FleetApp
Copy link
Member

Choose a reason for hiding this comment

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

👍 of renaming rest of IngestManager plugin

}),
render: (ui, options) => {
let renderResponse: RenderResult;
act(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Did you try to trigger the timers after the render I know jest offer a way to do that maybe it will fix the warnings?

case 'custom':
return CustomView ? (
<ExtensionWrapper>
<CustomView />
Copy link
Member

Choose a reason for hiding this comment

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

Should we pass some props to that custom view, like the name, version, ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point @nchaulet . I can see that information being useful to Integrations (maybe even the lastestVersion as well).

I will change the signature for the Component's props and add those in in a subsequent PR. Thanks for the feedback.

Copy link
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 from a functionality standpoint

@paul-tavares paul-tavares merged commit 707dbcd into elastic:master Nov 30, 2020
@paul-tavares paul-tavares deleted the task/fleet-82492-integration-custom-tab branch November 30, 2020 16:12
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 30, 2020
* master: (25 commits)
  [Alerting] fixes buggy default message behaviour (elastic#84202)
  [Graph] Use new ES client and change license API (elastic#84398)
  [DOCS] Adds redirect to known plugins page (elastic#84001)
  Update IndexPatternSelect to get fields from indexPatternService instead of savedObject attributes (elastic#84376)
  Adding timestamps to created events so the sorting is stable (elastic#84515)
  [DOCS] Redirects for drilldown links (elastic#83846)
  [Fleet] Support for showing an Integration Detail Custom (UI Extension) tab (elastic#83805)
  [Enterprise Search] Migrate shared Schema components (elastic#84381)
  [Discover] Unskip date_nanos and shard links functional tests (elastic#82878)
  [APM] ML anomaly detection integration: Displaying anomaly job results in the Transaction duration chart is not as intended  (elastic#84415)
  Support for painless language autocomplete within monaco (elastic#80577)
  [Lens] Time scale ui (elastic#83904)
  removing beta callouts (elastic#84510)
  [Lens] (Accessibility) add aria-label to chart type icon (elastic#84493)
  Trusted Apps signer API. (elastic#83661)
  increase stdout max listeners for legacy logging (elastic#84497)
  [APM] Service overview: Add throughput chart (elastic#84439)
  [Discover] Unskip main functional tests (elastic#84300)
  Uptime overview overhaul (elastic#83406)
  [APM] Adjust time formats based on the difference between start and end (elastic#84470)
  ...
paul-tavares added a commit that referenced this pull request Nov 30, 2020
…n) tab (#83805) (#84539)

* Support for rendering a custom component in Integration Details
* Refactor Fleet app initialization contexts in order to support testing setup
* New test rendering helper tool
* refactor Endpoint to use mock builder from Fleet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants